From 91b8494b43aaec134286fa4255350ce9a2c5d2ca Mon Sep 17 00:00:00 2001 From: wangzhiyusss Date: Wed, 23 Nov 2022 16:58:02 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=96=B0=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhiyusss --- .../main/ets/components/FolderListComp.ets | 21 +++--- .../main/ets/components/NoteContentComp.ets | 1 + .../components/NoteContentCompPortrait.ets | 2 + .../src/main/ets/components/NoteListComp.ets | 71 +++++++++++-------- product/default/package.json | 1 - .../default/src/main/ets/pages/MyNoteHome.ets | 2 +- 6 files changed, 60 insertions(+), 38 deletions(-) diff --git a/features/src/main/ets/components/FolderListComp.ets b/features/src/main/ets/components/FolderListComp.ets index aea80d9..b23b93c 100644 --- a/features/src/main/ets/components/FolderListComp.ets +++ b/features/src/main/ets/components/FolderListComp.ets @@ -132,6 +132,7 @@ export struct NoteAndCreateComp { this.AllFolderArray.push(folderData) // insert folder to db RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null) + AppStorage.SetOrCreate('isUpdate', true) } build() { @@ -177,6 +178,7 @@ struct FolderItemComp { controllerShow: WebController private isLongPress: boolean = false TAG = "FolderListComp" + @StorageLink('isUpdata') isUpdate: boolean = false // Folder Edit Dialog folderEditDialogCtl: CustomDialogController = new CustomDialogController({ builder: NewOrEditFolderDialog({ @@ -208,6 +210,7 @@ struct FolderItemComp { let predicates_folder = RdbStoreUtil.getRdbPredicates(TableName.FolderTable) predicates_folder.equalTo(FolderTableColumn.Uuid, this.folderItem.uuid) RdbStoreUtil.update(this.folderItem.toFolderObject(), predicates_folder, null) + this.isUpdate = true } // Folder Delete Dialog folderDeleteDialogCtl: CustomDialogController = new CustomDialogController({ @@ -275,6 +278,7 @@ struct FolderItemComp { AppStorage.SetOrCreate('ContinueNote', continueNote) LogUtil.info(this.TAG, "onDeleteConfirm, set continue note success") } + this.isUpdate = true } // Folder Create Dialog folderCreateDialogCtl: CustomDialogController = new CustomDialogController({ @@ -296,6 +300,7 @@ struct FolderItemComp { this.AllFolderArray.push(folderData) // insert folder to db RdbStoreUtil.insert(TableName.FolderTable, folderData.toFolderObject(), null) + this.isUpdate = true } @Builder menuBuilder() { @@ -363,13 +368,13 @@ struct FolderItemComp { if (this.folderItem.folder_type == FolderType.CusDef) { Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) { Row() { - Image(FolderUtil.getFolderIcon(this.folderItem.uuid)) + Image(this.isUpdate ? FolderUtil.getFolderIcon(this.folderItem.uuid) : FolderUtil.getFolderIcon(this.folderItem.uuid)) .objectFit(ImageFit.Fill) .width(24) .height(24) - .fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid)) + .fillColor(this.isUpdate ? FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid) : FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid)) .margin({ right: 16 }) - Text(FolderUtil.getFolderText(this.folderItem)) + Text(this.isUpdate ? FolderUtil.getFolderText(this.folderItem) : FolderUtil.getFolderText(this.folderItem)) .fontWeight(FontWeight.Medium) .fontSize(16) .textAlign(TextAlign.Center) @@ -381,7 +386,7 @@ struct FolderItemComp { .visibility(Visibility.None) // 用于强制刷新使用 }.width(118) - Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString()) + Text(this.isUpdate ? FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString() : FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString()) .fontWeight(FontWeight.Regular) .fontSize(14) .textAlign(TextAlign.Center) @@ -420,13 +425,13 @@ struct FolderItemComp { } else { Flex({ alignItems: ItemAlign.Center, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.SpaceBetween }) { Row() { - Image(FolderUtil.getFolderIcon(this.folderItem.uuid)) + Image(this.isUpdate ? FolderUtil.getFolderIcon(this.folderItem.uuid) : FolderUtil.getFolderIcon(this.folderItem.uuid)) .objectFit(ImageFit.Fill) .width(24) .height(24) - .fillColor(FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid)) + .fillColor(this.isUpdate ? FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid) : FolderUtil.getFolderIconColor(this.AllFolderArray, this.folderItem.uuid, this.selectedFolderData.uuid == this.folderItem.uuid)) .margin({ right: 16 }) - Text(FolderUtil.getFolderText(this.folderItem)) + Text(this.isUpdate ? FolderUtil.getFolderText(this.folderItem) : FolderUtil.getFolderText(this.folderItem)) .fontWeight(FontWeight.Medium) .fontSize(16) .textAlign(TextAlign.Center) @@ -438,7 +443,7 @@ struct FolderItemComp { .visibility(Visibility.None) // 用于强制刷新使用 }.width(118) - Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString()) + Text(this.isUpdate == true ? FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString() : FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.folderItem.uuid).toString()) .fontWeight(FontWeight.Regular) .fontSize(14) .textAlign(TextAlign.Center) diff --git a/features/src/main/ets/components/NoteContentComp.ets b/features/src/main/ets/components/NoteContentComp.ets index 12ca9bc..fcd58a9 100644 --- a/features/src/main/ets/components/NoteContentComp.ets +++ b/features/src/main/ets/components/NoteContentComp.ets @@ -459,6 +459,7 @@ export struct ToolBarComp { let continueNote: string = JSON.stringify(this.selectedNoteData.toNoteObject()) AppStorage.SetOrCreate('ContinueNote', continueNote) LogUtil.info(TAG, "NoteContentOverViewComp, set continue note success") + AppStorage.SetOrCreate('isUpdate', true) } editContentDialogCtl: CustomDialogController = new CustomDialogController({ diff --git a/features/src/main/ets/components/NoteContentCompPortrait.ets b/features/src/main/ets/components/NoteContentCompPortrait.ets index c0631b3..796b00c 100644 --- a/features/src/main/ets/components/NoteContentCompPortrait.ets +++ b/features/src/main/ets/components/NoteContentCompPortrait.ets @@ -362,6 +362,7 @@ export struct ToolBarComp { RdbStoreUtil.delete(predicates_note, null) routePage() } + AppStorage.SetOrCreate('isUpdate', true) } noteDataDeleteDialogCtl: CustomDialogController = new CustomDialogController({ @@ -491,6 +492,7 @@ export struct DeleteNoteComp { RdbStoreUtil.delete(predicates_note, null) routePage() } + AppStorage.SetOrCreate('isUpdate', false) } build() { diff --git a/features/src/main/ets/components/NoteListComp.ets b/features/src/main/ets/components/NoteListComp.ets index ad23b81..0514dca 100644 --- a/features/src/main/ets/components/NoteListComp.ets +++ b/features/src/main/ets/components/NoteListComp.ets @@ -81,6 +81,7 @@ export struct NoteListComp { } aboutToAppear(): void { + AppStorage.SetOrCreate('isUpdate', false) LogUtil.info(TAG, "aboutToAppear") } @@ -102,6 +103,8 @@ struct NoteOverViewComp { @Consume('Search') search: boolean @Consume('PortraitModel') portraitModel: boolean controllerShow: WebController + @State noteNumber: any = undefined + @StorageLink('isUpdate') isUpdate: boolean = false build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { @@ -143,7 +146,7 @@ struct NoteOverViewComp { .fontWeight(FontWeight.Medium) .textOverflow({ overflow: TextOverflow.Ellipsis }) Row() { - Text(FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString()) + Text(this.isUpdate? FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString():FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid).toString()) .maxLines(1) .fontSize(14) .fontColor($r("app.color.num_of_notes_font_color")) @@ -205,13 +208,18 @@ export struct NoteItemComp { @Consume('SelectedNoteData') selectedNoteData: NoteData @StorageLink('AllFolderArray') AllFolderArray: FolderData[] = AppStorage.Link('AllFolderArray') @StorageLink('CheckedNoteArray') CheckedNoteArray: NoteData[] = [] - @Consume('Longpress') longpress: boolean @Consume('ChooseNote') chooseNote: boolean @Consume('RefreshFlag') refreshFlag: number @Consume('Search') search: boolean @Consume('selectedAll') selectedAll: boolean @Consume('PortraitModel') portraitModel: boolean - + @State isChecked: boolean = undefined + @Consume('Longpress')@Watch('isLongPress') longpress: boolean + isLongPress(){ + if(this.longpress){ + this.isChecked = false + } + } build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { @@ -222,27 +230,9 @@ export struct NoteItemComp { .height(16) .width(4) .fillColor(NoteUtil.getVerticalBarBgColor(AppStorage.Get('AllFolderArray'), this.noteItem.folder_uuid)) - Text() { - ForEach(this.spans.map((item1, index1) => { - return { index: index1, data: item1 } - }), item => { - - if (item.data.type == 0) { - Span(item.data.text) - .fontColor($r("app.color.note_title_font_color")) - .fontSize(16) - .fontWeight(FontWeight.Medium) - } else if (item.data.type == 1) { - Span(item.data.text) - .fontColor($r("app.color.note_title_font_color_blue")) - .fontSize(16) - .fontWeight(FontWeight.Medium) - } - }, - item => item.index) - } - .maxLines(1) - .textOverflow({ overflow: TextOverflow.Ellipsis }) + Text(this.noteItem.title) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) } Row({ space: 4 }) { @@ -282,7 +272,7 @@ export struct NoteItemComp { Image($r("app.media.checked")) .width(24) .height(24) - .visibility(NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem) ? Visibility.Visible : Visibility.None) + .visibility(this.isChecked ? Visibility.Visible : Visibility.None) }.width(24) .height(24) .visibility(this.longpress ? Visibility.Visible : Visibility.None) @@ -313,9 +303,11 @@ export struct NoteItemComp { if (NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem)) { NoteUtil.unsetNoteChecked(this.CheckedNoteArray, this.noteItem) this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem) ? true : false } else { NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem) this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem) ? true : false } return; } else { @@ -346,8 +338,10 @@ export struct NoteItemComp { LongPressGesture() .onAction(() => { if (this.longpress == false) { + this.isChecked = false this.longpress = true NoteUtil.setNoteChecked(this.CheckedNoteArray, this.noteItem) + this.isChecked = NoteUtil.isNoteChecked(this.CheckedNoteArray, this.noteItem) ? true : false } }) ) @@ -367,7 +361,20 @@ export struct NoteItemListComp { @Consume('SearchResultList') searchResultList: NoteData[] @Consume('SelectedNoteData') selectedNoteData: NoteData @Consume('PortraitModel') portraitModel: boolean + @State dateList: NoteData[] = [] controllerShow: WebController + @StorageLink('isUpdate') @Watch('updateList') isUpdate: boolean = false + + updateList() { + if (this.isUpdate) { + this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) + } + this.isUpdate = false + } + + aboutToAppear() { + this.dateList = NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) + } doSearch() { SearchModel.search(NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid), this.inputKeyword) @@ -432,7 +439,7 @@ export struct NoteItemListComp { .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.Visible : Visibility.None) ForEach(this.inputKeyword.length == 0 ? - NoteUtil.getNoteDataArray(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) : this.searchResultList, (noteItem) => { + this.dateList : this.searchResultList, (noteItem) => { ListItem() { Column() { NoteItemComp({ @@ -443,9 +450,13 @@ export struct NoteItemListComp { } .padding({ left: 24, right: 24, bottom: 12 }) } - }, noteItem => noteItem.uuid.toString()) + }, noteItem => JSON.stringify(noteItem)) } - .margin((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? { bottom: 0 } : { bottom: 130 }) + .margin((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? { + bottom: 0 + } : { + bottom: 130 + }) .layoutWeight(1) .listDirection(Axis.Vertical) .edgeEffect(EdgeEffect.Spring) @@ -690,6 +701,7 @@ export struct AddNoteComp { AppStorage.SetOrCreate('ContinueNote', continueNote) LogUtil.info(TAG, "addNote, set continue note success") routePage() + AppStorage.SetOrCreate('isUpdate', true) }) .visibility(this.longpress || this.selectedFolderData.uuid == SysDefFolderUuid.RecentDeletes ? Visibility.None : Visibility.Visible) } @@ -886,6 +898,7 @@ export struct OperateNoteCompForPortrait { .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.noteDataDeleteDialogCtlBottom.open() + AppStorage.SetOrCreate('isUpdate', true) }) Text($r("app.string.delete")) .opacity(this.greyOpacity ? 0.4 : 1) @@ -909,6 +922,7 @@ export struct OperateNoteCompForPortrait { .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) .onClick(() => { this.noteDataMoveDialogCtlBottom.open() + AppStorage.SetOrCreate('isUpdate', true) }) Text($r("app.string.move")) .opacity(this.greyOpacity ? 0.4 : 1) @@ -956,6 +970,7 @@ export struct OperateNoteCompForPortrait { this.longpress = false NoteUtil.unsetAllNotesChecked(this.CheckedNoteArray) this.refreshFlag = (this.refreshFlag == 0 ? 1 : 0) + AppStorage.SetOrCreate('isUpdate', true) }) Text($r("app.string.recover")) .fontSize(10) diff --git a/product/default/package.json b/product/default/package.json index b13c8b1..654e795 100644 --- a/product/default/package.json +++ b/product/default/package.json @@ -1,4 +1,3 @@ - { "license": "ISC", "devDependencies": {}, diff --git a/product/default/src/main/ets/pages/MyNoteHome.ets b/product/default/src/main/ets/pages/MyNoteHome.ets index a61e3c3..8eefbbb 100644 --- a/product/default/src/main/ets/pages/MyNoteHome.ets +++ b/product/default/src/main/ets/pages/MyNoteHome.ets @@ -35,7 +35,7 @@ export struct MyNoteHomeComp { @StorageLink('breakPoint')@Watch('onBreakPointChange') breakPoints: string = 'lg' onBreakPointChange(){ - if(this.breakPoints == 'sm'){ + if(this.breakPoints == 'sm' || this.breakPoints == 'md'){ this.portraitModel = true }else{ this.portraitModel = false -- Gitee From 3ccb26e41c45f27a567e493bbde2fc6789087574 Mon Sep 17 00:00:00 2001 From: wangzhiyusss Date: Wed, 23 Nov 2022 17:14:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=80=E5=A4=9A=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wangzhiyusss --- common/utils/src/main/ets/default/baseUtil/NoteUtil.ets | 2 ++ product/default/src/main/ets/pages/MyNoteHome.ets | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets b/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets index 1e8a24a..e5d6644 100644 --- a/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets +++ b/common/utils/src/main/ets/default/baseUtil/NoteUtil.ets @@ -38,6 +38,7 @@ export class NoteUtil { setNoteChecked(checkedNoteArray: NoteData[], noteItem: NoteData) { LogUtil.info(TAG, "setNoteChecked") checkedNoteArray.push(noteItem) + AppStorage.Set('CheckedNoteArray',checkedNoteArray) } /** @@ -52,6 +53,7 @@ export class NoteUtil { }) LogUtil.info(TAG, "index " + index.toString() + noteItem.uuid) index == -1 ? null : checkedNoteArray.splice(index, 1) + AppStorage.Set('CheckedNoteArray',checkedNoteArray) } /** diff --git a/product/default/src/main/ets/pages/MyNoteHome.ets b/product/default/src/main/ets/pages/MyNoteHome.ets index 8eefbbb..8c252ae 100644 --- a/product/default/src/main/ets/pages/MyNoteHome.ets +++ b/product/default/src/main/ets/pages/MyNoteHome.ets @@ -60,6 +60,11 @@ export struct MyNoteHomeComp { aboutToAppear(): void { LogUtil.info(this.TAG, "aboutToAppear") this.breakPoints = AppStorage.Get('breakPoint') + if(this.breakPoints == 'sm' || this.breakPoints == 'md'){ + this.portraitModel = true + }else{ + this.portraitModel = false + } if (this.context == undefined || this.context == null) { LogUtil.warn(this.TAG, "context is error") return -- Gitee