import { Component, OnInit } from '@angular/core';
import { NavController } from '@ionic/angular';

@Component({
  selector: 'app-tab4',
  templateUrl: './tab4.page.html',
  styleUrls: ['./tab4.page.scss'],
})
export class Tab4Page implements OnInit {

  constructor(private navCtrl: NavController) {}//this.selectedContent = '发布';
  selectedContent: string = '发布';

  publishedWorks: any[] = [
    {description: '这是发布作品1的描述' },
    {description: '这是发布作品2的描述' },
    // 其他发布作品信息
  ];

  collectedWorks: any[] = [
    {description: '这是收藏作品1的描述' },
    {description: '这是收藏作品2的描述' },
    // 其他收藏作品信息
  ];

  likedWorks: any[] = [
    {description: '这是点赞作品1的描述' },
    {description: '这是点赞作品2的描述' },
    // 其他点赞作品信息
  ];

  viewedWorks: any[] = [
    {description: '这是浏览作品1的描述' },
    {description: '这是浏览作品2的描述' },
    // 其他浏览作品信息
  ];

  selectedWorks: any[] = [];

  showContent(content: string) {
    this.selectedContent = content;
    switch(content) {
      case '发布':
        this.selectedWorks = this.publishedWorks;
        break;
      case '收藏':
        this.selectedWorks = this.collectedWorks;
        break;
      case '点赞':
        this.selectedWorks = this.likedWorks;
        break;
      case '浏览':
        this.selectedWorks = this.viewedWorks;
        break;
      default:
        this.selectedWorks = [];
    }
  }



  openFeedbackPage() {
    // 打开反馈页面
    this.navCtrl.navigateForward('/feedback');
  }
  

  openSettingsPage() {
    // 打开设置页面
  }

  openLoginPage() {
    this.navCtrl.navigateForward('/login');
  }

  ngOnInit() {
    this.showContent(this.selectedContent);
  }

}

