• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16import GlobalResourceManager from '@ohos/utils/src/main/ets/default/baseUtil/GlobalResourceManager'
17import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData'
18import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil'
19import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData'
20import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil'
21import {
22  circleColorArray,
23  fontColorArray,
24  SysDefFolderUuid,
25  DeleteFileType,
26  FolderType,
27  Delete,
28  LogUtil
29} from '@ohos/utils';
30import inputMethod from '@ohos.inputMethod'
31
32const TAG = "CusDialogComp"
33
34@CustomDialog
35export struct NewOrEditFolderDialog {
36  newOrEditFolderDialogCtl: CustomDialogController
37  confirm: (color: string, name: string) => void = (color: string, name: string) => {
38  };
39  @State inputName: string = ""
40  private oriInputName: string = ""
41  private oriSelectedColor: string = ""
42  private editFolderUuid: string = ""
43  private dialogType: number = 0 // 0表示新建文件夹  1表示修改文件夹
44  @State isExisted: boolean = false
45  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
46  @Consume('SelectedColor') selectedColor: string
47
48  build() {
49    Column() {
50      Text(this.dialogType == 0 ? $r("app.string.createFolder") : $r("app.string.editFolder"))
51        .fontSize(20)
52        .height(56)
53        .margin({ left: 24 })
54        .fontWeight(FontWeight.Medium)
55      // folder color choose
56      Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
57        ForEach(circleColorArray, (colorStr: string) => {
58          ColorCircleComp({ circleColor: colorStr })
59        }, (colorStr: string) => colorStr)
60      }.margin({ bottom: 12, left: 24, right: 24 })
61
62      // folder name input
63      Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
64        Image($r("app.media.folder"))
65          .objectFit(ImageFit.Fill)
66          .width(24)
67          .height(24)
68          .flexShrink(0)
69          .fillColor(this.selectedColor)
70        TextInput({ text: this.inputName, placeholder: $r("app.string.input_placeholder") })
71          .placeholderFont({ size: 18 })
72          .maxLength(20)
73          .borderRadius(15)
74          .backgroundColor($r("app.color.New_folder_input_box_color"))
75          .width('100%')
76          .padding({ left: 12, bottom: -12 })
77          .onChange((value: string) => {
78            this.inputName = value
79            FolderUtil.duplicateDetection(this.inputName, this.AllFolderArray).then(result => {
80              this.isExisted = result
81            })
82          })
83          .restoreId(1)
84      }.margin({ bottom: 4, left: 24, right: 24 })
85
86      Divider()
87        .height(1)
88        .margin({ left: 64, right: 24 })
89        .color((this.isExisted && this.inputName != this.oriInputName) ? $r("app.color.category_already_exist_divider_color") : $r("app.color.divider_color_182431"))
90      if (this.isExisted && this.inputName != this.oriInputName) {
91        Text($r("app.string.category_already_exist"))
92          .fontSize(10)
93          .margin({ left: 64, top: 4 })
94          .fontColor($r("app.color.category_already_exist_font_color"))
95          .visibility((this.isExisted && this.inputName != this.oriInputName) ? Visibility.Visible : Visibility.None)
96      } else {
97        Column() {
98        }
99        .height(16)
100        .width("100%")
101      }
102
103      // button group
104      Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
105        Text($r("app.string.cancel"))
106          .fontSize(18)
107          .textAlign(TextAlign.Center)
108          .fontColor($r("app.color.button_color_f86d05"))
109          .width('48%')
110          .onClick(() => {
111            this.newOrEditFolderDialogCtl.close()
112            inputMethod.getController().stopInputSession();
113          })
114        Divider()
115          .vertical(true)
116          .height(15)
117          .strokeWidth(1)
118          .color($r("app.color.divider_color_e4e4e4"))
119        Text($r("app.string.save"))
120          .opacity(this.inputName == "" || (this.oriSelectedColor == this.selectedColor &&
121            this.inputName == this.oriInputName && this.dialogType == 1) ||
122            (this.isExisted && this.dialogType == 0) ||
123            (this.isExisted && this.dialogType == 1 && this.inputName != this.oriInputName) ? 0.4 : 1)
124          .enabled(this.inputName == "" || (this.oriSelectedColor == this.selectedColor &&
125            this.inputName == this.oriInputName && this.dialogType == 1) ||
126            (this.isExisted && this.dialogType == 0) || (this.isExisted && this.dialogType == 1 &&
127            this.inputName != this.oriInputName) ? false : true)
128          .fontSize(18)
129          .textAlign(TextAlign.Center)
130          .fontColor($r("app.color.button_color_f86d05"))
131          .width('48%')
132          .onClick(() => {
133            this.newOrEditFolderDialogCtl.close()
134            if (this.inputName.replace(new RegExp('/\s+/g'), '') == '') {
135              return
136            } else {
137              this.confirm(this.selectedColor, this.inputName)
138            }
139            inputMethod.getController().stopInputSession();
140          })
141      }.width('100%')
142      .margin({ top: 21, bottom: 25 })
143    }
144    .width(336)
145    .borderRadius(36)
146    .backgroundColor($r("app.color.create_folder_bg_color"))
147    .alignItems(HorizontalAlign.Start)
148    .margin({ bottom: 16, left: 12, right: 12 })
149    .offset({ y: -50 })
150  }
151
152  aboutToAppear(): void {
153    let currentFolder: FolderData = FolderUtil.getFolderData(this.AllFolderArray, this.editFolderUuid); // 获取当前选中的文件夹
154    if (currentFolder == null) {
155      return
156    }
157    if (currentFolder.folder_type == FolderType.CusDef) {
158      this.inputName = currentFolder.name
159      this.oriInputName = this.inputName
160      this.oriSelectedColor = currentFolder.color
161    } else {
162      GlobalResourceManager.getStringByResource(FolderUtil.getFolderText(currentFolder) as Resource).then(result => {
163        this.inputName = result
164        this.oriInputName = this.inputName
165        this.oriSelectedColor = currentFolder.color
166      })
167    }
168  }
169}
170
171@Component
172struct ColorCircleComp {
173  private circleColor: string = '';
174  @Consume('SelectedColor') selectedColor: string
175
176  build() {
177    Stack({ alignContent: Alignment.Center }) {
178      Circle({ width: 24, height: 24 })
179        .fill(this.circleColor)
180      Circle({ width: 12, height: 12 })
181        .fill($r("app.color.color_ffffff"))
182        .visibility(this.circleColor == this.selectedColor ? Visibility.Visible : Visibility.None)
183    }.onClick(() => {
184      try {
185        this.selectedColor = this.circleColor
186      } catch (error) {
187        LogUtil.error(TAG, "selectedColor error: ", error.toString());
188      }
189    })
190  }
191}
192
193@CustomDialog
194export struct DeleteDialog {
195  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
196  @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray')
197  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray')
198  @Consume('SelectedNoteData') selectedNoteData: NoteData
199  @Consume('SelectedFolderData') selectedFolderData: FolderData
200  private multiSelect: boolean = false
201  private deleteFileType = DeleteFileType.NoteData
202  noteDataDeleteDialogCtl: CustomDialogController
203  onConfirm: () => void = () => {
204  };
205
206  build() {
207    Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) {
208      Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
209        if (this.deleteFileType == DeleteFileType.FolderData) {
210          Text($r("app.string.delete_tips"))
211            .fontSize(14)
212            .textAlign(TextAlign.Center)
213            .maxLines(1)
214        } else {
215          Text(this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ?
216          $r("app.string.deleteNoteComplete") : $r("app.string.deleteNote"))
217            .fontSize(14)
218            .textAlign(TextAlign.Center)
219            .maxLines(1)
220            .visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ?
221            Visibility.Visible : Visibility.None)
222          if (this.CheckedNoteArray.length ==
223          NoteUtil.getNoteDataArray(this.AllNoteArray, this.selectedFolderData.uuid).length) {
224            Text($r("app.string.deleteAllNote"))
225              .fontSize(14)
226              .textAlign(TextAlign.Center)
227              .maxLines(1)
228              .visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ?
229              Visibility.None : Visibility.Visible)
230          } else if (this.CheckedNoteArray.length > 1) {
231            Text($r("app.string.deletePartNote", this.CheckedNoteArray.length))
232              .fontSize(14)
233              .textAlign(TextAlign.Center)
234              .maxLines(1)
235              .visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ?
236              Visibility.None : Visibility.Visible)
237          } else {
238            Text($r("app.string.deleteNote"))
239              .fontSize(14)
240              .textAlign(TextAlign.Center)
241              .maxLines(1)
242              .visibility(this.multiSelect == false || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ?
243              Visibility.None : Visibility.Visible)
244          }
245        }
246      }
247      .width(288)
248      .height(28.5)
249
250      Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
251        Text($r("app.string.cancel"))
252          .fontSize(16)
253          .fontColor($r("app.color.button_color_f86d05"))
254          .textAlign(TextAlign.Center)
255          .maxLines(1)
256          .width('50%')
257          .height('100%')
258          .onClick(() => {
259            this.noteDataDeleteDialogCtl.close()
260          })
261        Divider()
262          .vertical(true)
263          .strokeWidth(1)
264          .color($r("app.color.divider_color_e4e4e4"))
265          .height(40)
266        Text($r("app.string.delete"))
267          .fontSize(16)
268          .fontColor($r("app.color.delete_color_fa2a2d"))
269          .textAlign(TextAlign.Center)
270          .maxLines(1)
271          .width('50%')
272          .height('100%')
273          .onClick(() => {
274            this.noteDataDeleteDialogCtl.close()
275            this.onConfirm()
276          })
277      }
278      .width('100%')
279      .height('50%')
280    }
281    .width(336)
282    .height(117)
283    .borderRadius(36)
284    .padding({ top: 24, bottom: 16, left: 16, right: 16 })
285    .backgroundColor($r("app.color.delete_note_bg_color"))
286    .margin({ bottom: 16, left: 12, right: 12 })
287    .offset({ y: -50 })
288  }
289}
290
291@Component
292struct NoteDataMoveItemComp {
293  @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = []
294  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
295  private folderItem: FolderData = new FolderData(0, '', new Date().getTime() + '', '', FolderType.CusDef, Delete.No,
296    new Date().getTime(), new Date().getTime());
297  dividerShow: boolean = true
298
299  build() {
300    Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap }) {
301      Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap }) {
302        Image(FolderUtil.getFolderIcon(this.folderItem.uuid!))
303          .objectFit(ImageFit.Fill)
304          .width(24)
305          .height(24)
306          .flexShrink(0)
307          .fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid!, false))
308      }
309      .width(24)
310
311      Column() {
312        Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
313          Text(FolderUtil.getFolderText(this.folderItem!))
314            .fontSize(16)
315            .textAlign(TextAlign.Center)
316            .maxLines(1)
317            .textOverflow({ overflow: TextOverflow.Ellipsis })
318            .flexShrink(1)
319            .fontWeight(FontWeight.Medium)
320          Image((FolderUtil.getCommonFolder(this.AllFolderArray, this.CheckedNoteArray) == null
321            || FolderUtil.getCommonFolder(this.AllFolderArray, this.CheckedNoteArray) != this.folderItem!) ?
322          $r("app.media.foldMove_unselect") : $r("app.media.foldMove_select"))
323            .objectFit(ImageFit.Fill)
324            .width(24)
325            .height(24)
326            .flexShrink(0)
327        }
328        .width(248)
329        .height(55)
330
331        if (this.dividerShow) {
332          Divider()
333            .color($r("app.color.divider_color_e4e4e4"))
334            .strokeWidth(1)
335        }
336
337      }
338      .padding({ left: 16 })
339    }
340    .width(288)
341    .height(56)
342    .visibility(FolderUtil.isFolderMoveIn(this.folderItem!) ? Visibility.Visible : Visibility.None)
343  }
344}
345
346@CustomDialog
347export struct NoteDataMoveDialog {
348  noteDataMoveDialogCtl: CustomDialogController
349  onConfirm: (folderUuid: string) => void = (folderUuid: string) => {
350  };
351  NoteDataMoveArray: FolderData[] = [];
352  @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = []
353
354  aboutToAppear() {
355    this.NoteDataMoveArray = this.AllFolderArray.slice(2, this.AllFolderArray.length);
356    if (this.AllFolderArray[1] === undefined || this.AllFolderArray[1] === null) {
357      LogUtil.info(TAG, 'this AllFolderArray[1] undefined');
358      return;
359    }
360    this.NoteDataMoveArray.push(this.AllFolderArray[1]);
361  }
362
363  build() {
364    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap }) {
365      Flex({ alignItems: ItemAlign.Center }) {
366        Text($r("app.string.chooseFolder"))
367          .fontSize(20)
368          .fontWeight(600)
369          .fontWeight(FontWeight.Medium)
370      }.height(56)
371      .width(288)
372
373      List() {
374        if (this.NoteDataMoveArray !== undefined && this.NoteDataMoveArray !== null &&
375          this.NoteDataMoveArray.length > 0) {
376          ForEach(this.NoteDataMoveArray.slice(0, this.NoteDataMoveArray.length - 1), (item: FolderData) => {
377            ListItem() {
378              NoteDataMoveItemComp({ folderItem: item })
379            }
380            .onClick(() => {
381              this.noteDataMoveDialogCtl.close()
382              this.onConfirm(item.uuid)
383            })
384          }, (noteItem: FolderData) => noteItem.uuid)
385        }
386        ListItem() {
387          NoteDataMoveItemComp({
388            folderItem: this.NoteDataMoveArray[this.NoteDataMoveArray.length - 1],
389            dividerShow: false
390          })
391        }
392        .onClick(() => {
393          this.noteDataMoveDialogCtl.close()
394          this.onConfirm(this.NoteDataMoveArray[this.NoteDataMoveArray.length - 1].uuid)
395        })
396      }.listDirection(Axis.Vertical)
397      .edgeEffect(EdgeEffect.Spring)
398      .height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56)
399
400      Flex({ alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
401        Text($r("app.string.cancel"))
402          .fontSize(16)
403          .fontColor($r("app.color.button_color_f86d05"))
404          .onClick(() => {
405            this.noteDataMoveDialogCtl.close()
406          })
407      }.height(56)
408      .width(288)
409    }
410    .width(336)
411    .borderRadius(36)
412    .height(this.AllFolderArray.length > 12 ? 616 : (this.AllFolderArray.length - 1) * 56)
413    .padding({ left: 24, right: 24 })
414    .backgroundColor($r("app.color.choose_folder_bg_color"))
415    .margin({ bottom: 16, left: 12, right: 12 })
416    .offset({ y: -50 })
417  }
418}
419
420let inSetValue: string = AppStorage.Link('inSetValue');
421
422@CustomDialog
423export struct EditContentDialog {
424  editContentDialogCtl: CustomDialogController
425  confirm: (excuteJs: string) => void = (excuteJs: string) => {
426  };
427  @State selectFontColor: string = fontColorArray[0]
428  @Consume('SelectedNoteData') selectedNoteData: NoteData
429  private circleColor: string = '';
430  private fontSize: number = 0;
431
432  aboutToAppear() {
433    this.confirm('javascript:RICH_EDITOR.getFontSizes()');
434  }
435
436  build() {
437    Row() {
438      Column() {
439        Row({ space: 70 }) {
440          Button({ type: ButtonType.Normal }) {
441            Image($r('app.media.action_bold'))
442              .height(24)
443              .width(24)
444              .onClick(() => {
445                this.confirm("javascript:RICH_EDITOR.setBold()")
446              })
447          }.width(42)
448          .height(42)
449          .borderRadius(8)
450          .backgroundColor($r('app.color.color_ffffff'))
451
452          Button({ type: ButtonType.Normal }) {
453            Image($r('app.media.format_italic'))
454              .height(24)
455              .width(24)
456              .onClick(() => {
457                this.confirm("javascript:RICH_EDITOR.setItalic()")
458              })
459          }.width(42)
460          .height(42)
461          .borderRadius(8)
462          .backgroundColor($r('app.color.color_ffffff'))
463
464          Button({ type: ButtonType.Normal }) {
465            Image($r('app.media.underline'))
466              .height(24)
467              .width(24)
468              .onClick(() => {
469                this.confirm("javascript:RICH_EDITOR.setUnderline()")
470              })
471          }.width(42)
472          .height(42)
473          .borderRadius(8)
474          .backgroundColor($r('app.color.color_ffffff'))
475
476          Button({ type: ButtonType.Normal }) {
477            Image($r('app.media.left_justify'))
478              .height(24)
479              .width(24)
480              .onClick(() => {
481                this.confirm("javascript:RICH_EDITOR.setJustifyLeft()")
482              })
483          }.width(42)
484          .height(42)
485          .borderRadius(8)
486          .backgroundColor($r('app.color.color_ffffff'))
487
488          Button({ type: ButtonType.Normal }) {
489            Image($r('app.media.mid_justify'))
490              .height(24)
491              .width(24)
492              .onClick(() => {
493                this.confirm("javascript:RICH_EDITOR.setJustifyCenter()")
494              })
495          }.width(42)
496          .height(42)
497          .borderRadius(8)
498          .backgroundColor($r('app.color.color_ffffff'))
499
500          Button({ type: ButtonType.Normal }) {
501            Image($r('app.media.right_justify'))
502              .height(24)
503              .width(24)
504              .onClick(() => {
505                this.confirm("javascript:RICH_EDITOR.setJustifyRight()")
506              })
507          }.width(42)
508          .height(42)
509          .borderRadius(8)
510          .backgroundColor($r('app.color.color_ffffff'))
511        }
512        .alignItems(VerticalAlign.Bottom)
513        .padding({ bottom: 2 })
514        .height(71)
515
516        Divider()
517          .vertical(false)
518          .color($r("app.color.divider_color_e4e4e4"))
519
520        Row({ space: 70 }) {
521          Button({ type: ButtonType.Normal }) {
522            Image($r('app.media.suojin'))
523              .height(24)
524              .width(24)
525              .onClick(() => {
526                this.confirm("javascript:RICH_EDITOR.setIndent()")
527              })
528          }.width(42)
529          .height(42)
530          .borderRadius(8)
531          .backgroundColor($r('app.color.color_ffffff'))
532
533          Button({ type: ButtonType.Normal }) {
534            Image($r('app.media.suojin_back'))
535              .height(24)
536              .width(24)
537              .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
538              .onClick(() => {
539                this.confirm("javascript:RICH_EDITOR.setOutdent()")
540              })
541          }.width(42)
542          .height(42)
543          .borderRadius(8)
544          .backgroundColor($r('app.color.color_ffffff'))
545
546          Button({ type: ButtonType.Normal }) {
547            Image($r("app.media.format_menulist_number"))
548              .height(24)
549              .width(24)
550              .onClick(() => {
551                this.confirm("javascript:RICH_EDITOR.setNumbers()")
552              })
553          }.width(42)
554          .height(42)
555          .borderRadius(8)
556          .backgroundColor($r('app.color.color_ffffff'))
557
558          Button({ type: ButtonType.Normal }) {
559            Image($r("app.media.format_menulist_alphabet"))
560              .height(24)
561              .width(24)
562              .onClick(() => {
563                this.confirm("javascript:RICH_EDITOR.setABC()")
564              })
565          }.width(42)
566          .height(42)
567          .borderRadius(8)
568          .backgroundColor($r('app.color.color_ffffff'))
569
570          Button({ type: ButtonType.Normal }) {
571            Image($r('app.media.format_menubullte2'))
572              .height(24)
573              .width(24)
574              .onClick(() => {
575                this.confirm("javascript:RICH_EDITOR.setBullets()")
576              })
577          }.width(42)
578          .height(42)
579          .borderRadius(8)
580          .backgroundColor($r('app.color.color_ffffff'))
581
582          Button({ type: ButtonType.Normal }) {
583            Image($r('app.media.format_menubullte1'))
584              .height(24)
585              .width(24)
586              .onClick(() => {
587                this.confirm("javascript:RICH_EDITOR.setSquare()")
588              })
589          }.width(42)
590          .height(42)
591          .borderRadius(8)
592          .backgroundColor($r('app.color.color_ffffff'))
593        }
594        .alignItems(VerticalAlign.Top)
595        .padding({ top: 2 })
596        .height(56)
597      }
598      .width('50%')
599      .padding({ left: 24, right: 24 })
600      .height(128)
601
602      Divider()
603        .vertical(true)
604        .height(128)
605        .color($r("app.color.divider_color_e4e4e4"))
606        .margin({ top: 4, bottom: 4 })
607
608      Column() {
609        Flex({ direction: FlexDirection.Row, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.End }) {
610          Image($r('app.media.cross'))
611            .height(16)
612            .width(16)
613            .margin({ top: 8 })
614            .opacity(0.6)
615            .fillColor('#99182431')
616            .onClick(() => {
617              this.editContentDialogCtl.close()
618            })
619        }
620        .height(36)
621
622        Row() {
623          Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
624            ForEach(fontColorArray, (colorStr: string) => {
625              Stack({ alignContent: Alignment.Center }) {
626                Circle({ width: 24, height: 24 })
627                  .fill(colorStr)
628                Circle({ width: 12, height: 12 })
629                  .fill($r("app.color.color_ffffff"))
630                  .visibility(colorStr == this.selectFontColor ? Visibility.Visible : Visibility.None)
631              }.onClick(() => {
632                this.selectFontColor = colorStr
633                this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectFontColor + "')")
634              })
635            }, (colorStr: string) => colorStr)
636          }.padding({ bottom: 11 })
637        }
638        .alignItems(VerticalAlign.Top)
639        .height(35)
640
641        Divider()
642          .vertical(false)
643          .color($r("app.color.divider_color_e4e4e4"))
644
645        Row({ space: 15 }) {
646          Image($r('app.media.font_small'))
647            .height(24)
648            .width(24)
649            .margin({ top: 8 })
650          Slider({
651            value: this.selectedNoteData.slider_value,
652            min: 0,
653            max: 16,
654            step: 4,
655            style: SliderStyle.InSet
656          })
657            .blockColor($r("app.color.color_ffffff"))
658            .trackColor($r("app.color.divider_color_e4e4e4"))
659            .selectedColor($r("app.color.text_color_f86d05"))
660            .showSteps(false)
661            .showTips(false)
662            .onChange((value: number, mode: SliderChangeMode) => {
663              this.selectedNoteData.slider_value = value
664              this.fontSize = value + 12
665              this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')")
666              LogUtil.info(TAG, 'value:' + value + 'mode:' + mode.toString())
667            })
668            .width('88%')
669          Image($r('app.media.font_large'))
670            .height(24)
671            .width(24)
672            .margin({ top: 7 })
673        }
674        .alignItems(VerticalAlign.Top)
675        .padding({ top: 5 })
676        .height(56)
677      }
678      .width('50%')
679      .height(128)
680      .padding({ left: 24, right: 24 })
681    }
682    .width('100%')
683    .height(128)
684    .backgroundColor($r("app.color.color_ffffff"))
685    .borderRadius(36)
686  }
687}
688
689@CustomDialog
690export struct EditTitleDialog {
691  editTitleDialog: CustomDialogController
692  confirm: (newTitle: string) => void = (newTitle: string) => {
693  };
694  @State inputName: string = ""
695  @State isEquivalentVal: boolean = true
696
697  build() {
698    Column() {
699      Text($r("app.string.editNoteTitle"))
700        .fontSize(20)
701        .height(56)
702        .margin({ left: 24 })
703
704      // title input
705      Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
706        TextInput({ text: this.inputName, placeholder: $r("app.string.input_placeholder") })
707          .placeholderFont({ size: 18 })
708          .maxLength(20)
709          .borderRadius(15)
710          .backgroundColor($r("app.color.title_input_bg_color"))
711          .width('90%')
712          .onChange((value: string) => {
713            if (this.inputName == value) {
714              this.isEquivalentVal = true
715            } else {
716              this.isEquivalentVal = false
717            }
718            this.inputName = value
719          })
720          .restoreId(2)
721      }.margin({ bottom: 4, left: 24, right: 24 })
722
723
724      // button group
725      Flex({ wrap: FlexWrap.Wrap, justifyContent: FlexAlign.SpaceBetween }) {
726        Text($r("app.string.cancel"))
727          .fontSize(18)
728          .textAlign(TextAlign.Center)
729          .fontColor($r("app.color.button_color_419fff"))
730          .width('48%')
731          .onClick(() => {
732            this.editTitleDialog.close()
733            inputMethod.getController().stopInputSession();
734          })
735        Divider()
736          .vertical(true)
737          .height(15)
738          .strokeWidth(1)
739          .color($r("app.color.divider_color_e4e4e4"))
740        Text($r("app.string.save"))
741          .opacity(this.isEquivalentVal ? 0.4 : 1)
742          .enabled(this.isEquivalentVal ? false : true)
743          .fontSize(18)
744          .textAlign(TextAlign.Center)
745          .fontColor($r("app.color.button_color_419fff"))
746          .width('48%')
747          .onClick(() => {
748            this.editTitleDialog.close()
749            inputMethod.getController().stopInputSession();
750            if (this.inputName.replace(new RegExp('/\s+/g'), '') == '') {
751              return
752            } else {
753              this.confirm(this.inputName)
754            }
755          })
756      }.width('100%')
757      .margin({ top: 21, bottom: 25 })
758    }
759    .width(336)
760    .borderRadius(36)
761    .backgroundColor($r("app.color.Edit_title_bg_color"))
762    .alignItems(HorizontalAlign.Start)
763    .margin({ bottom: 16, left: 12, right: 12 })
764  }
765}
766
767@CustomDialog
768export struct EditContentDialogPortrait {
769  editContentDialogCtl: CustomDialogController;
770  confirm: (excuteJs: string) => void = (excuteJs: string) => {
771  };
772  @State selectFontColor: string = fontColorArray[0]
773  @Consume('SelectedNoteData') selectedNoteData: NoteData
774  private circleColor: string = '';
775  private fontSize: number = 0;
776
777  aboutToAppear() {
778    try {
779      this.confirm('javascript:RICH_EDITOR.getFontSizes()');
780      LogUtil.info(TAG, `runJavaScript success.`);
781    } catch (error) {
782      LogUtil.error(TAG, `runJavaScript failed.code:${JSON.stringify(error.code)},message:${JSON.stringify(error.message)}`);
783    }
784  }
785
786  build() {
787    Column() {
788      Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap,
789        justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
790        Text($r("app.string.style")).margin({ top: 8 })
791          .fontSize(14).fontColor($r("app.color.font_stylecolor_AD182431"))
792
793        Image($r('app.media.cross'))
794          .height(16)
795          .width(16)
796          .margin({ top: 8 })
797          .fillColor($r("app.color.font_stylecolor_AD182431"))
798          .onClick(() => {
799            this.editContentDialogCtl.close()
800          })
801      }
802      .height(48)
803      .padding({ left: 24, right: 24 })
804
805
806      Row({ space: 16 }) {
807        Button({ type: ButtonType.Normal }) {
808          Image($r('app.media.action_bold'))
809            .height(24)
810            .width(24)
811            .onClick(() => {
812              this.confirm("javascript:RICH_EDITOR.setBold()")
813            })
814        }.width(42)
815        .height(42)
816        .borderRadius(8)
817        .backgroundColor($r('app.color.color_ffffff'))
818
819        Button({ type: ButtonType.Normal }) {
820          Image($r('app.media.format_italic'))
821            .height(24)
822            .width(24)
823            .onClick(() => {
824              this.confirm("javascript:RICH_EDITOR.setItalic()")
825            })
826        }.width(42)
827        .height(42)
828        .borderRadius(8)
829        .backgroundColor($r('app.color.color_ffffff'))
830
831        Button({ type: ButtonType.Normal }) {
832          Image($r('app.media.underline'))
833            .height(24)
834            .width(24)
835            .onClick(() => {
836              this.confirm("javascript:RICH_EDITOR.setUnderline()")
837            })
838        }.width(42)
839        .height(42)
840        .borderRadius(8)
841        .backgroundColor($r('app.color.color_ffffff'))
842
843        Button({ type: ButtonType.Normal }) {
844          Image($r('app.media.right_justify'))
845            .height(24)
846            .width(24)
847            .onClick(() => {
848              this.confirm("javascript:RICH_EDITOR.setJustifyRight()")
849            })
850        }.width(42)
851        .height(42)
852        .borderRadius(8)
853        .backgroundColor($r('app.color.color_ffffff'))
854
855        Button({ type: ButtonType.Normal }) {
856          Image($r('app.media.mid_justify'))
857            .height(24)
858            .width(24)
859            .onClick(() => {
860              this.confirm("javascript:RICH_EDITOR.setJustifyCenter()")
861            })
862        }.width(42)
863        .height(42)
864        .borderRadius(8)
865        .backgroundColor($r('app.color.color_ffffff'))
866
867        Button({ type: ButtonType.Normal }) {
868          Image($r('app.media.left_justify'))
869            .height(24)
870            .width(24)
871            .onClick(() => {
872              this.confirm("javascript:RICH_EDITOR.setJustifyLeft()")
873            })
874        }.width(42)
875        .height(42)
876        .borderRadius(8)
877        .backgroundColor($r('app.color.color_ffffff'))
878      }
879      .height(48)
880
881      Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
882
883      Row({ space: 16 }) {
884
885        Button({ type: ButtonType.Normal }) {
886          Image($r('app.media.suojin'))
887            .height(24)
888            .width(24)
889            .onClick(() => {
890              this.confirm("javascript:RICH_EDITOR.setIndent()")
891            })
892        }.width(42)
893        .height(42)
894        .borderRadius(8)
895        .backgroundColor($r('app.color.color_ffffff'))
896
897        Button({ type: ButtonType.Normal }) {
898          Image($r('app.media.suojin_back'))
899            .height(24)
900            .width(24)
901            .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 })
902            .onClick(() => {
903              this.confirm("javascript:RICH_EDITOR.setOutdent()")
904            })
905        }.width(42)
906        .height(42)
907        .borderRadius(8)
908        .backgroundColor($r('app.color.color_ffffff'))
909
910        Button({ type: ButtonType.Normal }) {
911          Image($r("app.media.format_menulist_number"))
912            .height(24)
913            .width(24)
914            .onClick(() => {
915              this.confirm("javascript:RICH_EDITOR.setNumbers()")
916            })
917        }.width(42)
918        .height(42)
919        .borderRadius(8)
920        .backgroundColor($r('app.color.color_ffffff'))
921
922        Button({ type: ButtonType.Normal }) {
923          Image($r("app.media.format_menulist_alphabet"))
924            .height(24)
925            .width(24)
926            .onClick(() => {
927              this.confirm("javascript:RICH_EDITOR.setABC()")
928            })
929        }.width(42)
930        .height(42)
931        .borderRadius(8)
932        .backgroundColor($r('app.color.color_ffffff'))
933
934        Button({ type: ButtonType.Normal }) {
935          Image($r('app.media.format_menubullte2'))
936            .height(24)
937            .width(24)
938            .onClick(() => {
939              this.confirm("javascript:RICH_EDITOR.setBullets()")
940            })
941        }.width(42)
942        .height(42)
943        .borderRadius(8)
944        .backgroundColor($r('app.color.color_ffffff'))
945
946        Button({ type: ButtonType.Normal }) {
947          Image($r('app.media.format_menubullte1'))
948            .height(24)
949            .width(24)
950            .onClick(() => {
951              this.confirm("javascript:RICH_EDITOR.setSquare()")
952            })
953        }.width(42)
954        .height(42)
955        .borderRadius(8)
956        .backgroundColor($r('app.color.color_ffffff'))
957      }
958      .height(48)
959
960      Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
961
962      Row() {
963        Flex({ wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) {
964          ForEach(fontColorArray, (colorStr: string) => {
965            Stack({ alignContent: Alignment.Center }) {
966              Circle({ width: 24, height: 24 }).fill(colorStr)
967              Circle({ width: 12, height: 12 }).fill($r("app.color.color_ffffff"))
968                .visibility(colorStr == this.selectFontColor ? Visibility.Visible : Visibility.None)
969            }.onClick(() => {
970              this.selectFontColor = colorStr
971              this.confirm("javascript:RICH_EDITOR.setTextColor('" + this.selectFontColor + "')")
972            })
973          }, (colorStr: string) => colorStr)
974        }
975      }
976      .height(48)
977      .padding({ left: 24, right: 24 })
978
979      Divider().vertical(false).color($r("app.color.divider_color_e4e4e4"))
980
981      Row({ space: 10 }) {
982        Image($r('app.media.font_small')).height(24).width(24).margin({ top: 8 })
983        Slider({
984          value: this.selectedNoteData.slider_value,
985          min: 0,
986          max: 16,
987          step: 4,
988          style: SliderStyle.InSet
989        })
990          .blockColor($r("app.color.color_ffffff"))
991          .trackColor($r("app.color.divider_color_e4e4e4"))
992          .selectedColor($r("app.color.text_color_f86d05"))
993          .showSteps(false)
994          .showTips(false)
995          .onChange((value: number, mode: SliderChangeMode) => {
996            this.selectedNoteData.slider_value = value
997            this.fontSize = value + 12
998            this.confirm("javascript:RICH_EDITOR.execFontSize('" + this.fontSize + "')")
999            LogUtil.info(TAG, 'value:' + value + 'mode:' + mode.toString())
1000          })
1001          .width('79%')
1002        Image($r('app.media.font_large')).height(24).width(24).margin({ top: 7 })
1003      }
1004      .alignItems(VerticalAlign.Top)
1005      .padding({ top: 5 })
1006      .height(72)
1007      .padding({ left: 24, right: 24 })
1008    }
1009    .width(360)
1010    .height(266)
1011    .backgroundColor($r("app.color.color_ffffff"))
1012    .borderRadius(36)
1013    .offset({ y: -35 })
1014  }
1015}