import { Component } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { CommonModule, DatePipe } from '@angular/common';
import { Router } from '@angular/router';

@Component({
  selector: 'app-tab1',
  templateUrl: './tab1.page.html',
  styleUrls: ['./tab1.page.scss'],
  standalone: true,
  imports: [IonicModule, CommonModule, DatePipe],
})
export class Tab1Page {
  recentDreams = [
    {
      title: '飞翔的城市',
      date: new Date('2023-10-20'),
      emotion: '愉悦',
    },
    {
      title: '迷失的森林',
      date: new Date('2023-10-18'),
      emotion: '恐惧',
    },
    // 更多示例梦境
  ];

  constructor(private router: Router) {}

  // 导航到指定页面
  navigateTo(page: string) {
    this.router.navigate([`/tabs/${page}`]);
  }

  // 打开设置页面
  openSettings() {
    this.router.navigate(['/settings']);
  }

  // 打开梦境详情页
  openDreamDetail(dream: any) {
    this.router.navigate(['/dream-detail'], { state: { dream } });
  }

  // 根据情感获取对应的图标名称
  getEmotionIcon(emotion: string): string {
    switch (emotion) {
      case '愉悦':
        return 'happy-outline';
      case '悲伤':
        return 'sad-outline';
      case '恐惧':
        return 'alert-circle-outline';
      case '平静':
        return 'leaf-outline';
      default:
        return 'help-outline';
    }
  }
}