import { Component } from '@angular/core';
import { ModalController } from '@ionic/angular';

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone:false
})
export class Tab1Page {
  healthScore: number = 87;
  isLoading: boolean = false;

  // 模拟数据
  userData = {
    name: '张先生',
    bodyFat: 18.5,
    muscleMass: 58.3,
    metabolism: 1650
  };

  todayPlan = {
    week: 3,
    focus: '肩部对称性训练',
    duration: 15
  };

  nutritionRecommendation = {
    items: [
      { name: '鸡胸肉', amount: 156, calories: 165, macro: '蛋白质' },
      { name: '西兰花', amount: 87, calories: 30, macro: '纤维' },
      { name: '糙米饭', amount: 120, calories: 140, macro: '碳水' }
    ]
  };

  aiRecommendations = [
    { 
      icon: 'barbell-outline',
      type: 'primary',
      message: '根据晨间体测，建议今日重点训练肩部平衡'
    },
    {
      icon: 'nutrition-outline',
      type: 'success',
      message: '增加Ω-3摄入以支持关节健康'
    },
    {
      icon: 'warning-outline',
      type: 'warning',
      message: '注意左膝代偿模式，建议调整深蹲姿势'
    }
  ];

  constructor(private modalCtrl: ModalController) {}

  async refreshData(event: any) {
    // 模拟数据刷新
    setTimeout(() => {
      this.healthScore = Math.floor(Math.random() * 20) + 80;
      event.target.complete();
    }, 1000);
  }

  getGreeting(): string {
    const hour = new Date().getHours();
    if (hour < 12) return '早上好';
    if (hour < 18) return '下午好';
    return '晚上好';
  }

  // 移除模拟打开体态扫描方法
  // async openBodyScan() {
  //   this.isLoading = true;
  //   setTimeout(() => {
  //     this.isLoading = false;
  //     // 实际项目中这里会打开模态框
  //     console.log('打开体态扫描');
  //   }, 500);
  // }
}