import { Component } from '@angular/core';
import {
  IonHeader,
  IonToolbar,
  IonTitle,
  IonContent,
  IonApp,
  IonMenu,
  IonButtons,
  IonMenuButton,
  IonCardHeader,
  IonCardTitle,
  IonCardSubtitle,
  IonCardContent,
  IonList,
  IonItem,
  IonThumbnail,
  IonLabel,
  IonGrid,
  IonRow,
  IonCol,
  IonAlert,
  IonCard,
  IonCheckbox,
  IonInput,
  IonNavLink,
  IonButton,
} from '@ionic/angular/standalone';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
import { TodoEditComponent } from '../component/todo-edit/todo-edit.component';
import { TodolistPageComponent } from '../page/todolist-page/todolist-page.component';
import { Route, Router } from '@angular/router';
import { AiplanPageComponent } from '../page/aiplan-page/aiplan-page.component';

@Component({
  selector: 'app-tab1',
  templateUrl: 'tab1.page.html',
  styleUrls: ['tab1.page.scss'],
  standalone: true,
  imports: [
    IonHeader,
    IonToolbar,
    IonTitle,
    IonContent,
    ExploreContainerComponent,
    IonApp,
    IonMenu,
    IonButtons,
    IonButton,
    IonMenuButton,
    IonCard,
    IonCardHeader,
    IonCardTitle,
    IonCardSubtitle,
    IonCardContent,
    IonList,
    IonItem,
    IonThumbnail,
    IonLabel,
    IonGrid,
    IonRow,
    IonCol,
    IonAlert,
    TodoEditComponent,
    IonCheckbox,
    IonInput,
    IonNavLink,
    AiplanPageComponent,
  ],
})
export class Tab1Page {
  constructor(private router: Router) {}
  alertButtons = ['打卡'];
  duringday: number = 10;
  goodday: number = 20;
  badday: number = 5;
  todolist: Array<string> = ['have a good day'];
  sexChecked: boolean = false;

  navigateTo(path: string) {
    this.router.navigate([`/tabs/${path}`]);
  }
  goodbody() {
    let allChange = document.querySelector('#allChange');
    if (allChange) {
      allChange.setAttribute('color', 'success');
    }
    this.goodday++;
    this.duringday++;
    this.sexChecked = true;
  }
  badbody() {
    let allChange = document.querySelector('#allChange');
    if (allChange) {
      allChange.setAttribute('color', 'danger');
    }
    this.badday++;
    this.duringday = 0;
    this.sexChecked = true;
  }
  changeTodolist(ev: any) {
    this.todolist = ev;
  }
  deleteThisTodolist(todo: string) {
    let idx = this.todolist.findIndex((item) => item === todo);
    this.todolist.splice(idx, 1);
  }
}
