import { Component, OnInit } from '@angular/core';
import { IonicModule } from '@ionic/angular';
import { FormsModule } from '@angular/forms';
import { TagInputComponent } from '../tag-input/tag-input.component';
import { addIcons } from 'ionicons';
import { barbellOutline, personOutline, square, alarmOutline } from 'ionicons/icons';

@Component({
  selector: 'app-test-page',
  templateUrl: './test-page.component.html',
  styleUrls: ['./test-page.component.scss'],
  standalone: true,
  imports: [IonicModule, FormsModule, TagInputComponent]  // 导入必要的模块
})
export class TestPageComponent implements OnInit {
  selectedTags: string[] = [];  // 用来存储选择的标签
  exercisePreference: string = '';  // 锻炼方式偏好
  workoutFrequency: string = '';  // 每周锻炼频率
  height: number | null = null;  // 身高
  weight: number | null = null;  // 体重
  age: number | null = null;  // 年龄
  goalDescription: string = '';  // 目标描述，用来绑定文本域内容

  constructor() {
    addIcons({ personOutline, barbellOutline, alarmOutline, square });
  }

  ngOnInit() { }

  onTagsChanged(tags: string[]) {
    this.selectedTags = tags;
    console.log('当前标签:', this.selectedTags);
  }

  onGoalDescriptionChange(event: any) {
    this.goalDescription = event.detail.value;
  }

  onExercisePreferenceChange(event: any) {
    this.exercisePreference = event.detail.value;
  }

  onWorkoutFrequencyChange(event: any) {
    this.workoutFrequency = event.detail.value;
  }

  onHeightChange(event: any) {
    this.height = event.detail.value;
  }

  onWeightChange(event: any) {
    this.weight = event.detail.value;
  }

  onAgeChange(event: any) {
    this.age = event.detail.value;
  }

  generatePlan() {
    console.log('生成健身计划', {
      tags: this.selectedTags,
      exercisePreference: this.exercisePreference,
      workoutFrequency: this.workoutFrequency,
      height: this.height,
      weight: this.weight,
      age: this.age,
      goalDescription: this.goalDescription
    });
  }
}
