import { CommonConstants } from '../common/constants/CommonConstants'; import { ConflictResolution } from '../viewmodel/PlaylistBackup'; @CustomDialog export struct ImportConflictDialog { controller?: CustomDialogController; onResolve?: (resolution: ConflictResolution, applyToAll: boolean) => void; onCancel?: () => void; conflictName: string = ''; themeColor: string = CommonConstants.DEFAULT_THEME_COLOR; @State applyToAll: boolean = false; private handleResolve(resolution: ConflictResolution): void { this.onResolve?.(resolution, this.applyToAll); this.controller?.close(); } private handleCancel(): void { this.onCancel?.(); this.controller?.close(); } build() { Column() { Text('导入冲突') .fontSize(20) .fontWeight(FontWeight.Medium) .margin({ bottom: 8 }); Text(`歌单「${this.conflictName}」已存在,请选择处理方式:`) .fontSize(14) .fontColor(Color.Gray) .margin({ bottom: 16 }) .textAlign(TextAlign.Center); // 三个操作按钮 Button('覆盖现有歌单') .width('100%') .height(44) .backgroundColor(this.themeColor || CommonConstants.DEFAULT_THEME_COLOR) .fontColor(Color.White) .borderRadius(12) .margin({ bottom: 8 }) .onClick(() => this.handleResolve(ConflictResolution.OVERWRITE)); Button('重命名导入') .width('100%') .height(44) .backgroundColor(Color.Transparent) .fontColor(this.themeColor || CommonConstants.DEFAULT_THEME_COLOR) .border({ color: this.themeColor || CommonConstants.DEFAULT_THEME_COLOR, width: 1, radius: 12 }) .borderRadius(12) .margin({ bottom: 8 }) .onClick(() => this.handleResolve(ConflictResolution.RENAME)); Button('跳过') .width('100%') .height(44) .backgroundColor(Color.Transparent) .fontColor(Color.Gray) .border({ color: Color.Gray, width: 1, radius: 12 }) .borderRadius(12) .margin({ bottom: 12 }) .onClick(() => this.handleResolve(ConflictResolution.SKIP)); // 应用到全部复选框 Row() { Checkbox() .select(this.applyToAll) .selectedColor(this.themeColor || CommonConstants.DEFAULT_THEME_COLOR) .onChange((value: boolean) => { this.applyToAll = value; }); Text('应用到所有冲突') .fontSize(14) .fontColor(Color.Gray) .margin({ left: 8 }); } .margin({ bottom: 8 }); // 取消按钮 Text('取消导入') .fontSize(14) .fontColor(Color.Gray) .onClick(() => this.handleCancel()); } .padding(24) .width('100%') .backgroundColor($r('app.color.start_window_background')) .borderRadius(24); } }