| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- 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);
- }
- }
|