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