import { Component, OnInit } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonButtons, IonButton, IonIcon, IonDatetime } from '@ionic/angular/standalone';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
import { addIcons } from 'ionicons';
import { calendar, todayOutline } from 'ionicons/icons';
import { FormsModule } from '@angular/forms';
import { CommonModule } from '@angular/common';
import { Router } from '@angular/router';
import { CloudObject ,CloudQuery} from 'src/lib/ncloud';
@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone: true,
  imports: [FormsModule, CommonModule, IonHeader, IonToolbar, IonTitle, IonContent, IonButtons, IonButton, IonDatetime, IonIcon, ExploreContainerComponent],
})
export class Tab1Page implements OnInit {

  contentItems: any[] = [];
  loading: boolean = true; // 添加加载状态
  error: string | null = null; // 添加错误状态

  constructor(private router: Router) {
    addIcons({ calendar, todayOutline });
  }

  ngOnInit() {
    // 生命周期
    this.loadPLContentsList();
  }

  // 创建用于数据列表存储的属性
  PLContentsList:Array<CloudObject> = []

  async loadPLContentsList(){
    let query = new CloudQuery("PL_Contents");
    this.PLContentsList = await query.find()
  }

  navigateToDiary() {
    this.router.navigateByUrl('/daily-content');
    // 导航到日历页面的逻辑
  }

  navigateToToday() {
    // 返回到今天内容的逻辑
  }

  onDateChange(event: any) {
    // 处理日期改变的逻辑
  }

  viewItemDetails(card: any) {
    this.router.navigate(['/card-detail'], { queryParams: { id: card.id } }); // 传递卡片ID
  }
}
