import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { IonHeader, IonToolbar, IonTitle, IonContent, IonList,IonItem,IonIcon,IonLabel,IonButton,IonAvatar,
  IonCard,IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle} from '@ionic/angular/standalone';
import { ExploreContainerComponent } from '../explore-container/explore-container.component';
import { CloudUser } from 'src/lib/ncloud';
import { openUserLoginModal } from 'src/lib/user/modal-user-login/modal-user-login.component';
import { ModalController } from '@ionic/angular/standalone';
import { openUserEditModal } from 'src/lib/user/modal-user-edit/modal-user-edit.component';

@Component({
  selector: 'app-tab3',
  templateUrl: 'tab3.page.html',
  styleUrls: ['tab3.page.scss'],
  standalone: true,
  imports: [IonHeader,IonToolbar,IonTitle,IonContent,IonList,IonItem,IonIcon,IonLabel,IonButton,IonAvatar,
    IonCard,IonCardContent,IonCardHeader,IonCardTitle,IonCardSubtitle,
    ExploreContainerComponent
  ],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class Tab3Page {

  currentUser:CloudUser|undefined
  constructor(private modalCtrl:ModalController) {
    this.currentUser = new CloudUser();
  }
  async login(){
    //弹出登录窗口
    let user = await openUserLoginModal(this.modalCtrl);
    if(user?.id){
      this.currentUser = user
    }
  }
  async signup(){
    //弹出注册窗口
    let user = await openUserLoginModal(this.modalCtrl,"signup");
    if(user?.id){
      this.currentUser = user
    }
  }
  logout(){
    this.currentUser?.logout();
  }
  editUser(){
    openUserEditModal(this.modalCtrl)
  }
}