chendeben пре 7 месеци
родитељ
комит
45e06bf89e
1 измењених фајлова са 75 додато и 0 уклоњено
  1. 75 0
      entry/src/main/ets/dialog/CreateFolderDialog.ets

+ 75 - 0
entry/src/main/ets/dialog/CreateFolderDialog.ets

@@ -0,0 +1,75 @@
+import { CommonConstants } from '../common/constants/CommonConstants';
+
+@CustomDialog
+export struct CreateFolderDialog {
+  controller?: CustomDialogController;
+  onConfirm?: (folderName: string) => void;
+  onCancel?: () => void;
+  initialName: string = '';
+  themeColor: string = CommonConstants.DEFAULT_THEME_COLOR;
+
+  @State folderName: string = '';
+
+  aboutToAppear(): void {
+    this.folderName = this.initialName || '';
+  }
+
+  private handleConfirm(): void {
+    const name = this.folderName.trim();
+    if (name.length === 0) {
+      return;
+    }
+    this.onConfirm?.(name);
+    this.controller?.close();
+  }
+
+  private handleCancel(): void {
+    this.onCancel?.();
+    this.controller?.close();
+  }
+
+  build() {
+    Column() {
+      Text('新建文件夹')
+        .fontSize(20)
+        .fontWeight(FontWeight.Medium)
+        .margin({ bottom: 12 });
+
+      TextInput({ text: this.folderName, placeholder: '请输入文件夹名称' })
+        .width('100%')
+        .height(48)
+        .backgroundColor(Color.White)
+        .padding({ left: 12, right: 12 })
+        .borderRadius(12)
+        .onChange((value: string) => {
+          this.folderName = value;
+        });
+
+      Row() {
+        Button('取消')
+          .layoutWeight(1)
+          .height(44)
+          .backgroundColor(Color.Transparent)
+          .fontColor(Color.Gray)
+          .border({ color: Color.Gray, width: 1, radius: 12 })
+          .onClick(() => this.handleCancel())
+          .margin({ right: 8 });
+
+        Button('创建')
+          .layoutWeight(1)
+          .height(44)
+          .backgroundColor(this.themeColor || CommonConstants.DEFAULT_THEME_COLOR)
+          .fontColor(Color.White)
+          .borderRadius(12)
+          .onClick(() => this.handleConfirm())
+          .margin({ left: 8 });
+      }
+      .margin({ top: 16 })
+      .justifyContent(FlexAlign.SpaceBetween);
+    }
+    .padding(24)
+    .width('100%')
+    .backgroundColor($r('app.color.start_window_background'))
+    .borderRadius(24);
+  }
+}