import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as Parse from 'parse';
import { ModalController } from '@ionic/angular';
import { PageChatPanelComponent } from '../page-chat-panel/page-chat-panel.component'; // 引入PageChatPanelComponent

@Component({
  selector: 'app-chat-info',
  templateUrl: './chat-info.component.html',
  styleUrls: ['./chat-info.component.scss']
})
export class ChatInfoComponent {

  chatPanelOpen: boolean = false; // 添加一个标记来跟踪聊天面板的打开状态


  constructor(private router: Router,private modalController: ModalController) {}

  async openChatPanel() {
    if (this.chatPanelOpen) {
      const modal = await this.modalController.getTop();
      if (modal) {
        modal.dismiss();
      }
      this.chatPanelOpen = false;
    } else {
      const modal = await this.modalController.create({
        component: PageChatPanelComponent,
        cssClass: 'chat-panel-modal',
        componentProps: {}
      });
      modal.style.height = '40vh'; // 设置弹框高度为50%
      modal.style.margin = '40vh 0 0 40vw'; // 设置弹框高度为50%

      await modal.present();
      this.chatPanelOpen = true;

    }

  }

}
