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 DateUtil from '@ohos/utils/src/main/ets/default/baseUtil/DateUtil' 17import RdbStoreUtil from '@ohos/utils/src/main/ets/default/baseUtil/RdbStoreUtil' 18import FolderData from '@ohos/utils/src/main/ets/default/model/databaseModel/FolderData' 19import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteData' 20import util from '@ohos.util' 21import { 22 TableName, 23 NoteTableColumn, 24 SysDefFolderUuid, 25 Favorite, 26 Delete 27} from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData' 28import StyleConstants from '@ohos/utils/src/main/ets/default/constants/StyleConstants' 29import { EditContentDialog, EditTitleDialog } from './CusDialogComp' 30import FolderUtil from '@ohos/utils/src/main/ets/default/baseUtil/FolderUtil' 31import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil' 32import { LogUtil } from '@ohos/utils/src/main/ets/default/baseUtil/LogUtil' 33import OperationUtils from '@ohos/utils/src/main/ets/default/baseUtil/OperationUtils' 34import router from '@system.router'; 35import inputMethod from '@ohos.inputMethod'; 36import { folderTextMap } from '@ohos/utils/src/main/ets/default/model/NoteBaseData' 37import webview from '@ohos.web.webview'; 38 39const TAG = "NoteContent" 40 41var timeID: number 42 43@Component 44export struct NoteContent { 45 @Provide('SelectedNoteData') selectedNoteData: NoteData = AppStorage.Get('NewNote') 46 @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') 47 @Provide('Issave') issave: number = 0 48 @Provide('EditModel') editModel: boolean = false 49 @StorageLink('dpi') dpi: number = 240 50 controllerShow: webview.WebviewController = new webview.WebviewController(); 51 private editContentFlag = false 52 @StorageLink('ScrollTopPercent') scrollTopPercent: number = 0.0 53 54 storeScrollTop(scrollTop: number) { 55 if (scrollTop < 0) { 56 return 57 } 58 AppStorage.SetOrCreate<number>('ScrollTopPercent', scrollTop / this.controllerShow.getPageHeight()) 59 } 60 61 restoreScrollTop() { 62 if (!AppStorage.Has('remoteScrollTopPercent')) { 63 return 64 } 65 var scrollTopPercent = AppStorage.Get<number>('remoteScrollTopPercent') 66 if (scrollTopPercent < 0) { 67 return 68 } 69 this.controllerShow.runJavaScript( 70 'document.documentElement.scrollTop = ' + this.controllerShow.getPageHeight() * scrollTopPercent 71 ) 72 AppStorage.Delete('remoteScrollTopPercent') 73 } 74 75 restoreFocus() { 76 if (!AppStorage.Has('isRemoteFocusOnSearch')) { 77 return 78 } 79 let isRemoteFocusOnSearch = AppStorage.Get<boolean>('isRemoteFocusOnSearch') 80 if (isRemoteFocusOnSearch) { 81 focusControl.requestFocus('searchInput') 82 } 83 AppStorage.Delete('isRemoteFocusOnSearch') 84 } 85 86 noteContent = { 87 callbackhtml: (html) => { 88 LogUtil.info(TAG, 'note uuid is:' + this.selectedNoteData.uuid) 89 this.selectedNoteData.content_text = NoteUtil.contrastInitType(this.selectedNoteData.content_text); 90 if (this.selectedNoteData.content_text === html ) { 91 return; 92 }; 93 this.selectedNoteData.content_text = html 94 this.selectedNoteData.modified_time = new Date().getTime() 95 let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) 96 predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) 97 RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) 98 LogUtil.info(TAG, 'update note success:' + this.selectedNoteData.uuid) 99 AppStorage.SetOrCreate<NoteData>('NewNote', this.selectedNoteData) 100 AppStorage.SetOrCreate<boolean>('needRefresh', true) 101 // save continue data 102 let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) 103 AppStorage.SetOrCreate<string>('ContinueNote', continueNote) 104 LogUtil.info(TAG, "callbackhtml, set continue note success") 105 }, 106 callbackImagePath: (imgName) => { 107 // updata note image 108 LogUtil.info(TAG, 'note imgPath is:' + imgName) 109 this.selectedNoteData.content_img = imgName 110 }, 111 112 callbackScheduledSave: (html) => { 113 LogUtil.info(TAG, 'callbackScheduledSave') 114 if (this.selectedNoteData.content_text == html) { 115 LogUtil.info(TAG, 'callbackScheduledSave the same value return') 116 return; 117 } 118 this.selectedNoteData.content_text = html 119 this.selectedNoteData.modified_time = new Date().getTime() 120 let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) 121 predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) 122 RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) 123 LogUtil.info(TAG, 'callbackScheduledSave, update note success:' + this.selectedNoteData.uuid) 124 // save continue data 125 let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) 126 LogUtil.info(TAG, 'continueNote content', continueNote) 127 AppStorage.SetOrCreate<string>('ContinueNote', continueNote) 128 LogUtil.info(TAG, 'callbackScheduledSave, set continue note success') 129 }, 130 callbackPasteImage: (html) => { 131 if (html) { 132 LogUtil.info(TAG, 'paste info' + html) 133 let realHtml = "" 134 let base64regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/ 135 if (html && html.indexOf("base64") > 0) { 136 LogUtil.info(TAG, " getSrcFromHtml, src[1] : " + html) 137 let imgData = html.split(',')[1]; 138 let imgType = 'png' 139 if (html.indexOf("jpeg") > 0) { 140 imgType = 'jpg' 141 } else if (html.indexOf("gif") > 0) { 142 imgType = 'gif' 143 } 144 let filePath = "" 145 if (base64regex.test(imgData)) { 146 let base64 = new util.Base64() 147 let decodeArr = base64.decodeSync(imgData) 148 filePath = OperationUtils.saveImageData(decodeArr, imgType) 149 } else { 150 filePath = OperationUtils.saveImage(imgData, imgType) 151 } 152 realHtml = "file://" + filePath 153 } 154 LogUtil.info(TAG, 'paste info11' + realHtml) 155 this.controllerShow.runJavaScript("javascript:RICH_EDITOR.insertImageHtml('" + realHtml + "')") 156 } else { 157 LogUtil.info(TAG, 'paste info22223') 158 } 159 }, 160 callbackGetSize: (fontSize) => { 161 if (fontSize === 16) { 162 this.selectedNoteData.slider_value = 0 163 } else if (fontSize === 18) { 164 this.selectedNoteData.slider_value = 4 165 } else if (fontSize === 24) { 166 this.selectedNoteData.slider_value = 8 167 } else if (fontSize === 32) { 168 this.selectedNoteData.slider_value = 12 169 } else if (fontSize === 48) { 170 this.selectedNoteData.slider_value = 16 171 } 172 } 173 } 174 175 build() { 176 Stack({ alignContent: Alignment.Bottom }) { 177 Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, 178 alignItems: ItemAlign.Start, alignContent: FlexAlign.SpaceAround }) { 179 Column() { 180 ToolBarComp({ controllerShow: this.controllerShow }) 181 }.margin({ left: 24, right: 24 }) 182 183 Column() { 184 NoteContentOverViewComp() 185 186 Web({ src: $rawfile('editor.html'), controller: this.controllerShow }) 187 .javaScriptAccess(true) 188 .javaScriptProxy({ 189 object: this.noteContent, 190 name: "callBackToApp", // html--> name.method 191 methodList: ["callbackhtml", "callbackScheduledSave", "callbackPasteImage", "callbackImagePath", "callbackGetSize"], 192 controller: this.controllerShow 193 }) 194 .onPageEnd((e) => { 195 if (this.dpi <= 240) { 196 this.controllerShow.runJavaScript("changeSizeToRk()") 197 } else if (this.dpi <= 320 && this.dpi > 240) { 198 this.controllerShow.runJavaScript("changeSizeToPhone()") 199 } else { 200 this.controllerShow.runJavaScript("changeSizeToTablet()") 201 } 202 if (AppStorage.Get('breakPoint') !== 'sm') { 203 this.controllerShow.runJavaScript("hiddenButton()") 204 } 205 LogUtil.info(TAG, "finish loadurl") 206 if (this.selectedNoteData) { 207 let self = this 208 this.controllerShow.runJavaScript( 209 "RICH_EDITOR.setHtml('" + this.selectedNoteData.content_text + "')", 210 () => { 211 // wait for the image in the note to load 212 setTimeout(function () { 213 self.restoreScrollTop() 214 self.restoreFocus() 215 }, 100) 216 } 217 ) 218 } 219 }) 220 .zoomAccess(false) 221 .imageAccess(true) 222 .onlineImageAccess(true) 223 .fileAccess(true) 224 .domStorageAccess(true) 225 .height('88%') 226 .width('100%') 227 .onScroll((event) => { 228 this.storeScrollTop(event.yOffset) 229 }) 230 .onClick(() => { 231 // 添加定时器:3s自动保存 232 if (timeID) { 233 clearInterval(timeID) 234 } 235 timeID = setInterval(() => { 236 try { 237 this.controllerShow.runJavaScript("scheduledSaveContent()"); 238 LogUtil.info(TAG, `runJavaScript scheduledSaveContent success.`); 239 } catch (error) { 240 LogUtil.info(TAG, `runJavaScript scheduledSaveContent failed.code:${JSON.stringify(error.code)}, 241 message:${JSON.stringify(error.message)}`); 242 } 243 }, 3000) 244 LogUtil.info(TAG, "setInterval timeID : " + timeID) 245 this.issave = 0 246 this.editModel = true 247 }) 248 } 249 .margin({ left: 12, right: 24, top: 16 }) 250 } 251 .height(StyleConstants.PERCENTAGE_100) 252 } 253 .height(StyleConstants.PERCENTAGE_100) 254 .width(StyleConstants.PERCENTAGE_100) 255 } 256 257 aboutToAppear(): void { 258 LogUtil.info(TAG, "aboutToAppear") 259 } 260 261 aboutToDisappear(): void { 262 AppStorage.Set("refreshCurrentNote", true) 263 NoteUtil.refreshAll() 264 clearInterval(timeID) 265 LogUtil.info(TAG, "aboutToDisappear") 266 } 267} 268 269@Component 270export struct ToolBarComp { 271 @Consume('SelectedNoteData') selectedNoteData: NoteData 272 @StorageLink('AllNoteArray') AllNoteArray: NoteData[] = AppStorage.Link('AllNoteArray') 273 @Consume('Issave') issave: number 274 @Consume('EditModel') editModel: boolean 275 controllerShow: WebviewController 276 editContentDialogCtl: CustomDialogController = new CustomDialogController({ 277 builder: EditContentDialog({ confirm: this.confirm.bind(this) }), 278 alignment: DialogAlignment.Bottom, 279 autoCancel: true, 280 customStyle: true, 281 }) 282 283 aboutToDisappear() { 284 this.editContentDialogCtl = null 285 } 286 287 confirm(excuteJs: string) { 288 this.controllerShow.runJavaScript(excuteJs) 289 } 290 291 build() { 292 Flex({ direction: FlexDirection.Row, wrap: FlexWrap.NoWrap, 293 justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 294 Image($r('app.media.narrow')) 295 .height(24) 296 .width(24) 297 .onClick(() => { 298 try { 299 this.controllerShow.runJavaScript("RICH_EDITOR.setInputEnabled(false)"); 300 this.controllerShow.runJavaScript("getHtmlContent()"); 301 LogUtil.info(TAG, `runJavaScript setInputEnabled and getHtmlContent success.`); 302 } catch (error) { 303 LogUtil.info(TAG, `runJavaScript setInputEnabled and getHtmlContent fail.code:${JSON.stringify(error.code)}, 304 message:${JSON.stringify(error.message)}`); 305 } 306 307 // 清除定时器 308 if (timeID != undefined) { 309 LogUtil.info(TAG, "zoom, clearInterval timeID : " + timeID) 310 clearInterval(timeID) 311 } 312 AppStorage.Set("refreshCurrentNote", true) 313 router.back() 314 NoteUtil.refreshAll() 315 }) 316 .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) 317 318 if (this.editModel == false) { 319 Row({ space: StyleConstants.SPACE_24 }) { 320 Image(this.selectedNoteData.is_favorite == Favorite.Yes ? $r('app.media.favorite') : $r('app.media.favorite_cancel')) 321 .height(24).width(24) 322 .onClick(() => { 323 try { 324 this.selectedNoteData.is_favorite = (this.selectedNoteData.is_favorite == Favorite.Yes ? Favorite.No : Favorite.Yes) 325 // update note to db 326 let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) 327 predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) 328 RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) 329 // save continue data 330 let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) 331 AppStorage.SetOrCreate<string>('ContinueNote', continueNote) 332 LogUtil.info(TAG, 'ToolBarComp, set continue note success') 333 NoteUtil.refreshAll() 334 } catch (error) { 335 LogUtil.error(TAG, 'favorite error: ' + JSON.stringify(error)); 336 } 337 }) 338 }.width(36) 339 .visibility(this.selectedNoteData.is_deleted == Delete.Yes ? Visibility.None : Visibility.Visible) 340 } else { 341 Row({ space: StyleConstants.SPACE_6 }) { 342 Button({ type: ButtonType.Normal, stateEffect: true }) { 343 Image($r('app.media.circle_tick1')) 344 .height(24) 345 .width(24) 346 .onClick(() => { 347 // 退出键盘 348 // @ts-ignore 349 inputMethod.getController().stopInputSession(); 350 // 清单 351 this.controllerShow.runJavaScript("javascript:RICH_EDITOR.setTodo()") 352 }) 353 }.width(42) 354 .height(42) 355 .borderRadius(8) 356 .backgroundColor($r('app.color.color_fffffB')) 357 358 Button({ type: ButtonType.Normal, stateEffect: true }) { 359 Image($r('app.media.font_style')) 360 .height(24) 361 .width(24) 362 .onClick(() => { 363 // 退出键盘 364 // @ts-ignore 365 inputMethod.getController().stopInputSession(); 366 LogUtil.info(TAG, 'editContentDialogCtl start') 367 this.editContentDialogCtl.open() 368 }) 369 }.width(42) 370 .height(42) 371 .borderRadius(8) 372 .backgroundColor($r('app.color.color_fffffB')) 373 374 Button({ type: ButtonType.Normal, stateEffect: true }) { 375 Image($r('app.media.picture_white')).height(24).width(24) 376 .onClick(async () => { 377 // 退出键盘 378 // @ts-ignore 379 inputMethod.getController().stopInputSession(); 380 LogUtil.info(TAG, 'startAbility start') 381 await globalThis.noteContext.startAbilityForResult({ 382 parameters: { uri: "singleselect" }, 383 bundleName: "com.ohos.photos", 384 abilityName: "com.ohos.photos.MainAbility", 385 }) 386 .then(v => { 387 let want = v['want']; 388 if (want != null && want != undefined) { 389 let param = want['parameters']; 390 let imageUri = "" 391 if (param != null && param != undefined) { 392 let uri = param['select-item-list']; 393 imageUri = uri[0]; 394 } 395 // 拷贝 396 if (imageUri != null && imageUri != "") { 397 OperationUtils.copy(imageUri).then((uriPath) => { 398 var path = "file://" + uriPath 399 LogUtil.info(TAG, 'image uri is:' + path) 400 this.controllerShow.runJavaScript( 401 "javascript:RICH_EDITOR.insertImage('" + path + "')" 402 ) 403 this.issave = 1 404 // 保存笔记信息到数据库 405 this.controllerShow.runJavaScript("getHtmlContent()") 406 }) 407 } 408 } 409 }); 410 }) 411 }.width(42) 412 .height(42) 413 .borderRadius(8) 414 .backgroundColor($r('app.color.color_fffffB')) 415 416 Button({ type: ButtonType.Normal, stateEffect: true }) { 417 Image($r('app.media.undo')) 418 .height(24) 419 .width(24) 420 .onClick(() => { 421 // 退出键盘 422 // @ts-ignore 423 inputMethod.getController().stopInputSession(); 424 this.controllerShow.runJavaScript("RICH_EDITOR.undo()") 425 }) 426 }.width(42) 427 .height(42) 428 .borderRadius(8) 429 .backgroundColor($r('app.color.color_fffffB')) 430 431 Button({ type: ButtonType.Normal, stateEffect: true }) { 432 Image($r('app.media.todo')) 433 .height(24) 434 .width(24) 435 .onClick(() => { 436 // 退出键盘 437 // @ts-ignore 438 inputMethod.getController().stopInputSession(); 439 this.controllerShow.runJavaScript("RICH_EDITOR.redo()") 440 }) 441 }.width(42) 442 .height(42) 443 .borderRadius(8) 444 .backgroundColor($r('app.color.color_fffffB')) 445 446 447 Button({ type: ButtonType.Normal, stateEffect: true }) { 448 Image($r('app.media.tick_thick')) 449 .height(24) 450 .width(24) 451 .fillColor(this.issave == 0 ? Color.Black : Color.Grey) 452 .onClick(() => { 453 this.issave = 1 454 // 保存笔记信息到数据库 455 this.controllerShow.runJavaScript("getHtmlContent()") 456 }) 457 }.width(42) 458 .height(42) 459 .borderRadius(8) 460 .backgroundColor($r('app.color.color_fffffB')) 461 }.width(274) 462 } 463 } 464 .width(StyleConstants.PERCENTAGE_100) 465 .height(80) 466 } 467} 468 469@Component 470export struct NoteContentOverViewComp { 471 @Consume('SelectedNoteData') selectedNoteData: NoteData 472 @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = [] 473 @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] 474 @StorageLink('isUpdate') isUpdate: boolean = false 475 editTitleDialogCtl: CustomDialogController = new CustomDialogController({ 476 builder: EditTitleDialog({ confirm: this.confirm.bind(this) }), 477 alignment: DialogAlignment.Center, 478 autoCancel: false, 479 customStyle: true, 480 }) 481 482 aboutToDisappear() { 483 this.editTitleDialogCtl = null 484 } 485 486 confirm(newTitle: string) { 487 this.selectedNoteData.title = newTitle 488 this.selectedNoteData.modified_time = new Date().getTime() 489 let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) 490 predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) 491 RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) 492 // save continue data 493 let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) 494 AppStorage.SetOrCreate<string>('ContinueNote', continueNote) 495 LogUtil.info(TAG, "NoteContentOverViewComp confirm, set continue note success") 496 NoteUtil.refreshAll() 497 } 498 499 @Builder MenuBuilder() { 500 Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) { 501 List() { 502 ForEach(this.AllFolderArray, (item) => { 503 ListItem() { 504 NoteDataMoveItemComp({ folderItem: item }) 505 } 506 .onClick(() => { 507 this.selectedNoteData.folder_uuid = item.uuid 508 let predicates_note = RdbStoreUtil.getRdbPredicates(TableName.NoteTable) 509 predicates_note.equalTo(NoteTableColumn.Uuid, this.selectedNoteData.uuid) 510 RdbStoreUtil.update(this.selectedNoteData.toNoteObject(), predicates_note, null) 511 // save continue data 512 let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) 513 AppStorage.SetOrCreate<string>('ContinueNote', continueNote) 514 LogUtil.info(TAG, "NoteContentOverViewComp MenuBuilder, set continue note success") 515 NoteUtil.refreshAll() 516 }) 517 }, noteItem => JSON.stringify(noteItem)) 518 }.listDirection(Axis.Vertical) 519 .edgeEffect(EdgeEffect.Spring) 520 .height(this.AllFolderArray.length > 12 ? 504 : (this.AllFolderArray.length - 3) * 56) 521 } 522 .width(148) 523 .backgroundColor($r("app.color.color_fffffB")) 524 .padding({ left: 24, right: 24 }) 525 } 526 527 build() { 528 if (this.selectedNoteData) { 529 Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, 530 justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 531 Row() { 532 Text(this.selectedNoteData.title) 533 .id(this.isUpdate + '') 534 .fontSize(30) 535 .margin({ left: 12, right: 24 }) 536 .onClick(() => { 537 clearInterval(timeID) 538 this.editTitleDialogCtl.open() 539 }) 540 }.height(40) 541 .width(StyleConstants.PERCENTAGE_100) 542 543 Row() { 544 Text(DateUtil.formateDateForNoteContent(new Date(this.selectedNoteData.modified_time))) 545 .id(this.isUpdate + '') 546 .fontSize(12) 547 .padding({ top: 4, bottom: 4 }) 548 .fontColor($r("app.color.modified_time_font_color")) 549 .margin({ left: 12 }) 550 Row() { 551 Text(FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid)) == 552 folderTextMap["sys_def_myFavorites_uuid"] ? folderTextMap["sys_def_unClassified_uuid"] : 553 FolderUtil.getFolderText(FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid))) 554 .id(this.isUpdate + '') 555 .fontSize(12) 556 .fontColor($r("app.color.list_modified_time_font_color")) 557 Image($r('app.media.triangle')) 558 .width(6) 559 .height(12) 560 .margin({ left: 4 }) 561 } 562 .padding({ left: 8, right: 8, top: 4, bottom: 4 }) 563 .margin({ left: 8 }) 564 .borderRadius(16) 565 .backgroundColor(NoteUtil.getNoteBgColor(AppStorage.Get('AllFolderArray'), this.selectedNoteData.folder_uuid, SysDefFolderUuid.AllNotes, false)) 566 .bindMenu(this.MenuBuilder) 567 }.alignItems(VerticalAlign.Top).height(40).width(StyleConstants.PERCENTAGE_100) 568 } 569 .opacity(this.selectedNoteData.is_deleted == Delete.Yes ? 0.4 : 1) 570 .width(StyleConstants.PERCENTAGE_100) 571 .height(80) 572 } 573 } 574} 575 576@Component 577struct NoteDataMoveItemComp { 578 @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] 579 @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = [] 580 private folderItem: FolderData 581 582 build() { 583 Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.Center }) { 584 Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap }) { 585 Image(FolderUtil.getFolderIcon(this.folderItem.uuid)) 586 .objectFit(ImageFit.Fill) 587 .width(24) 588 .height(24) 589 .flexShrink(0) 590 .fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, false)) 591 } 592 .width(24) 593 594 Column() { 595 Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) { 596 Text(FolderUtil.getFolderText(this.folderItem)) 597 .fontSize(16) 598 .fontColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, false)) 599 .textAlign(TextAlign.Center) 600 .maxLines(1) 601 .textOverflow({ overflow: TextOverflow.Ellipsis }) 602 .flexShrink(1) 603 } 604 .width('100%') 605 .height(55) 606 607 Divider() 608 .color($r("app.color.divider_color_e4e4e4")) 609 .strokeWidth(1) 610 } 611 .padding({ left: 16 }) 612 } 613 .width('100%') 614 .height(56) 615 .visibility(FolderUtil.isFolderMoveIn(this.folderItem) ? Visibility.Visible : Visibility.None) 616 } 617}