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