<ion-header>
  <ion-toolbar>
    <ion-title>每日记录</ion-title>
  </ion-toolbar>
</ion-header>

<ion-content>
  <ion-segment [(ngModel)]="segment">
    <ion-segment-button value="memo">
      <ion-label>备忘录</ion-label>
    </ion-segment-button>
    <ion-segment-button value="chat">
      <ion-label>AI对话</ion-label>
    </ion-segment-button>
  </ion-segment>

  <div *ngIf="segment === 'memo'">
    <ion-list>
      <ion-item *ngFor="let memo of memos">
        {{ memo }}
        <ion-button slot="end" color="danger" (click)="confirmDeleteMemo(memo)">
          删除
        </ion-button>
      </ion-item>
    </ion-list>

    <ion-item>
      <ion-input placeholder="添加新备忘录" [(ngModel)]="newMemo"></ion-input>
      <ion-button (click)="addMemo()">添加</ion-button>
    </ion-item>
  </div>

  <div *ngIf="segment === 'chat'">
    <ion-list>
      <ion-item *ngFor="let message of messages">
        <ion-label [ngClass]="{'ai': message.sender === 'ai', 'user': message.sender === 'user'}">
          {{ message.text }}
        </ion-label>
      </ion-item>
    </ion-list>

    <ion-item>
      <ion-input placeholder="输入消息" [(ngModel)]="newMessage"></ion-input>
      <ion-button (click)="sendMessage()">发送</ion-button>
    </ion-item>
  </div>
</ion-content>
