// src/app/tab4/tab4.page.ts
import { Component } from '@angular/core';

type NutritionKey = 'protein' | 'carbs' | 'fat';

@Component({
  selector: 'app-tab4',
  templateUrl: 'tab4.page.html',
  styleUrls: ['tab4.page.scss'],
  standalone: false,
})
export class Tab4Page {
  currentPhase = '增肌期';
  phaseConfig = {
    color: '#FF6B35',
    tip: '建议每日热量盈余 300kcal'
  };

  trainingData = {
    calories: 875,
    sets: 5,
    accuracy: 92,
    exercise: '深蹲训练'
  };

  // 类型安全的数据结构
  nutritionKeys: NutritionKey[] = ['protein', 'carbs', 'fat'];
  nutritionGoals: Record<NutritionKey, { target: number; current: number }> = {
    protein: { target: 158, current: 120 },
    carbs: { target: 240, current: 180 },
    fat: { target: 62, current: 45 }
  };

  restaurants = [
    {
      name: '奥力给健身厨房',
      rating: 4.8,
      distance: 1.2,
      tags: ['蛋白质达标', '562kcal/套餐', '30分钟达'],
      dish: {
        name: '增肌冠军碗',
        protein: 42,
        carbs: '慢碳黑米',
        veggies: '双倍西兰花',
        price: 58,
        originalPrice: 78,
        image: 'assets/images/chicken-bowl.jpg'
      }
    }
  ];

  constructor() {}

  getProgress(goal: number, current: number): string {
    const percent = (current / goal) * 100;
    return `${percent}%`;
  }
}