import { Component, OnInit } from '@angular/core';
import { 
  IonHeader, 
  IonToolbar, 
  IonTitle, 
  IonContent, 
  IonBackButton, 
  IonButtons, 
  IonButton, 
  IonIcon, 
  IonCard, 
  IonCardHeader, 
  IonCardTitle, 
  IonCardContent,
  IonList,
  IonItem,
  IonLabel,
  IonChip,
  IonBadge,
  IonAvatar,
  IonFab,
  IonFabButton
} from '@ionic/angular/standalone';
import { ActivatedRoute } from '@angular/router';
import { addIcons } from 'ionicons';
import { 
  timeOutline, 
  flameOutline, 
  peopleOutline, 
  basketOutline, 
  restaurantOutline,
  star,
  starOutline,
  bookmark,
  bookmarkOutline,
  shareSocialOutline,
  pricetag,
  time,
  ellipse,
  ellipseOutline
} from 'ionicons/icons';
import { CloudObject, CloudQuery } from 'src/lib/ncloud';

@Component({
  selector: 'app-page-records-detail',
  templateUrl: './page-records-detail.page.html',
  styleUrls: ['./page-records-detail.page.scss'],
  standalone: false,
})
export class PageRecordsDetailPage implements OnInit {
  recipe: CloudObject | undefined | null;
  isBookmarked = false;

  constructor(private route: ActivatedRoute) {
    addIcons({ 
      timeOutline, 
      flameOutline, 
      peopleOutline, 
      basketOutline, 
      restaurantOutline,
      star,
      starOutline,
      bookmark,
      bookmarkOutline,
      shareSocialOutline,
      pricetag,
      time,
      ellipse,
      ellipseOutline
    });
    
    this.route.params.subscribe(params => {
      this.loadRecipe(params['recipeId']);
    });
  }

  async loadRecipe(recipeId: string) {
    let query = new CloudQuery("Recipe");
    this.recipe = await query.get(recipeId);
    console.log(this.recipe);
  }

  toggleBookmark() {
    this.isBookmarked = !this.isBookmarked;
    // 这里可以添加收藏/取消收藏的逻辑
  }

  shareRecipe() {
    // 这里可以添加分享逻辑
    console.log('分享菜谱');
  }

  rateRecipe() {
    // 这里可以添加评分逻辑
    console.log('评分菜谱');
  }

  ngOnInit() {}
}