From 2de4c3476ccc0172a135b9805deb95a9b4c1c006 Mon Sep 17 00:00:00 2001 From: kukixi Date: Thu, 28 Jul 2022 16:00:16 +0800 Subject: [PATCH] use tablet version for phone Signed-off-by: kukixi --- .../main/ets/components/FolderListComp.ets | 25 +----- .../src/main/ets/components/NoteListComp.ets | 23 +----- .../main/ets/default/model/NoteBaseData.ets | 2 +- .../tablet/src/main/ets/pages/NoteHome.ets | 82 ++++++++++--------- 4 files changed, 48 insertions(+), 84 deletions(-) diff --git a/common/component/src/main/ets/components/FolderListComp.ets b/common/component/src/main/ets/components/FolderListComp.ets index 76d7c62..957dcd4 100644 --- a/common/component/src/main/ets/components/FolderListComp.ets +++ b/common/component/src/main/ets/components/FolderListComp.ets @@ -36,28 +36,6 @@ export struct FolderListComp { build() { Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.SpaceBetween }) { Column() { - Column() { - Image($r("app.media.suojin")) - .height(24) - .width(24) - .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) - .onClick(() => { - if (this.sectionStatus == 1) { - this.expandStatus = !this.expandStatus - } else { - this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // save continue data - AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - LogUtil.info(this.TAG, "FolderListComp, set continue section success") - } - }) - } - .alignItems(HorizontalAlign.Start) - .width("100%") - .margin({ top: 28 }) - .padding({ left: 24 }) - .flexGrow(1) - NoteAndCreateComp() // center List() { @@ -73,7 +51,6 @@ export struct FolderListComp { .flexGrow(1) } - Column() { FolderItemComp({ folderItem: FolderUtil.getFolderData(AppStorage.Get('AllFolderArray'), SysDefFolderUuid.MyFavorites), @@ -148,7 +125,7 @@ export struct NoteAndCreateComp { }).padding({ right: 0 }) }.width(50) }.width("100%") - .margin({ top: 8 }) + .margin({ top: 56 }) .padding({ left: 24 }) .height(56) } diff --git a/common/component/src/main/ets/components/NoteListComp.ets b/common/component/src/main/ets/components/NoteListComp.ets index f2db4da..f57333c 100644 --- a/common/component/src/main/ets/components/NoteListComp.ets +++ b/common/component/src/main/ets/components/NoteListComp.ets @@ -96,25 +96,6 @@ struct NoteOverViewComp { build() { Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { - Column() { - Image($r("app.media.suojin_back")) - .height(24) - .width(24) - .responseRegion({ x: -15.0, y: -15.0, width: 54, height: 54 }) - .margin({ right: this.sectionStatus != 3 ? 24 : 0 }) // 两分栏时缩进图片与右边有个24的间距 - .visibility(this.sectionStatus != 3 ? Visibility.Visible : Visibility.None) - .onClick(() => { - if (this.sectionStatus == 1) { - this.expandStatus = !this.expandStatus - } else { - this.sectionStatus = (this.sectionStatus == 3 ? 2 : 3) - // save continue data - AppStorage.SetOrCreate('ContinueSection', this.sectionStatus) - LogUtil.info(TAG, "NoteOverViewComp, set continue section success") - } - }) - }.alignItems(HorizontalAlign.Center) - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, @@ -137,7 +118,9 @@ struct NoteOverViewComp { } .margin({ top: 5 }) .visibility((FolderUtil.getNoteCount(AppStorage.Get('AllNoteArray'), this.selectedFolderData.uuid) == 0) ? Visibility.None : Visibility.Visible) - }.visibility(this.longpress ? Visibility.None : Visibility.Visible) + } + .visibility(this.longpress ? Visibility.None : Visibility.Visible) + .margin({ left: 48}) Row() { Image($r("app.media.cross")) diff --git a/common/utils/src/main/ets/default/model/NoteBaseData.ets b/common/utils/src/main/ets/default/model/NoteBaseData.ets index 3c2de8f..67db6a3 100644 --- a/common/utils/src/main/ets/default/model/NoteBaseData.ets +++ b/common/utils/src/main/ets/default/model/NoteBaseData.ets @@ -97,7 +97,7 @@ export class WidthWeightMessage { } } -let widthWeightOneSection: WidthWeightMessage = new WidthWeightMessage("0%", 0, "0%", 0, "100%", 1) +let widthWeightOneSection: WidthWeightMessage = new WidthWeightMessage("0%", 0, "100%", 1, "0%", 0) let widthWeightTwoSection = new WidthWeightMessage("0%", 0, "34%", 1, "66%", 1) let widthWeightThreeSection = new WidthWeightMessage("16%", 1, "34%", 1, "50%", 1) diff --git a/product/tablet/src/main/ets/pages/NoteHome.ets b/product/tablet/src/main/ets/pages/NoteHome.ets index 1493527..a9a31bb 100644 --- a/product/tablet/src/main/ets/pages/NoteHome.ets +++ b/product/tablet/src/main/ets/pages/NoteHome.ets @@ -13,6 +13,8 @@ * limitations under the License. */ +import deviceInfo from '@ohos.deviceInfo' +import mediaquery from '@ohos.mediaquery' import { FolderListComp } from '@ohos/component/src/main/ets/components/FolderListComp' import { NoteListComp } from '@ohos/component/src/main/ets/components/NoteListComp' import { NoteContentComp } from '@ohos/component/src/main/ets/components/NoteContentComp' @@ -24,7 +26,6 @@ import NoteData from '@ohos/utils/src/main/ets/default/model/databaseModel/NoteD import { SysDefFolderUuid } from '@ohos/utils/src/main/ets/default/model/databaseModel/EnumData' import LayoutUtil from '@ohos/utils/src/main/ets/default/baseUtil/LayoutUtil' import NoteUtil from '@ohos/utils/src/main/ets/default/baseUtil/NoteUtil' -import mediaquery from '@ohos.mediaquery' @Entry @Component @@ -58,7 +59,7 @@ export struct NoteHomeComp { } build() { - Flex({ justifyContent: FlexAlign.Start }) { + SideBarContainer(deviceInfo.deviceType === 'phone' ? SideBarContainerType.Overlay : SideBarContainerType.Embed) { // Folder list display area Flex({ direction: FlexDirection.Column, wrap: FlexWrap.NoWrap, justifyContent: FlexAlign.Center }) { FolderListComp({ controllerShow: this.controllerShow }) @@ -67,52 +68,55 @@ export struct NoteHomeComp { .backgroundColor($r("app.color.folderlist_bgcolor_f1f3f5")) .width(200) .height(StyleConstants.PERCENTAGE_100) - .visibility( - LayoutUtil.getWidthWeightMessage(this.sectionStatus) - .folderListVisibility == 0 ? Visibility.None : Visibility.Visible) .enabled(this.search ? false : true) - - // Note list display area - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { - Divider() - .vertical(true) - .strokeWidth(1) - .color($r("app.color.divider_color_182431")) - .height("100%") - .opacity(StyleConstants.OPACITY_10) - NoteListComp({ controllerShow: this.controllerShow }) + Flex({ justifyContent: FlexAlign.Start }) { + // Note list display area + Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + Divider() + .vertical(true) + .strokeWidth(1) + .color($r("app.color.divider_color_182431")) + .height("100%") + .opacity(StyleConstants.OPACITY_10) + NoteListComp({ controllerShow: this.controllerShow }) + } + .flexShrink(1) + .backgroundColor($r("app.color.notelist_bgcolor_f1f3f5")) + .layoutWeight(2) + .height(StyleConstants.PERCENTAGE_100) + .visibility( + LayoutUtil.getWidthWeightMessage(this.sectionStatus) + .noteListVisibility == 0 ? Visibility.None : Visibility.Visible) + // Note content display area + Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { + Divider() + .vertical(true) + .strokeWidth(1) + .color($r("app.color.divider_color_182431")) + .height("100%") + .opacity(StyleConstants.OPACITY_10) + NoteContentComp({ controllerShow: this.controllerShow }) + } + .flexShrink(0) + .backgroundColor($r("app.color.notecontent_color_ffffff")) + .layoutWeight(this.sectionStatus != 1 ? 3 : null) + .height(StyleConstants.PERCENTAGE_100) + .enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true) } - .flexShrink(1) - .backgroundColor($r("app.color.notelist_bgcolor_f1f3f5")) - .layoutWeight(2) - .height(StyleConstants.PERCENTAGE_100) - .visibility( - LayoutUtil.getWidthWeightMessage(this.sectionStatus) - .noteListVisibility == 0 ? Visibility.None : Visibility.Visible) - // Note content display area - Flex({ direction: FlexDirection.Column, wrap: FlexWrap.Wrap, justifyContent: FlexAlign.Start }) { - Divider() - .vertical(true) - .strokeWidth(1) - .color($r("app.color.divider_color_182431")) - .height("100%") - .opacity(StyleConstants.OPACITY_10) - NoteContentComp({ controllerShow: this.controllerShow }) - } - .flexShrink(0) - .backgroundColor($r("app.color.notecontent_color_ffffff")) - .layoutWeight(this.sectionStatus != 1 ? 3 : null) + .width(StyleConstants.PERCENTAGE_100) .height(StyleConstants.PERCENTAGE_100) - .enabled(this.longpress || this.search && this.inputKeyword.length == 0 ? false : true) } - .width(StyleConstants.PERCENTAGE_100) - .height(StyleConstants.PERCENTAGE_100) + .showSideBar(this.sectionStatus === 3) + .controlButton( { top: 24, left: 24, width: 24, height: 24, icons: { + shown: $r('app.media.suojin'), + hidden: $r('app.media.suojin_back') + }}) } aboutToAppear(): void{ LogUtil.info(this.TAG, "aboutToAppear") this.narrowWinListener.on('change', this.onWinSizeChange.bind(this)) - this.sectionStatus = this.narrowWinListener.matches ? 2 : 3 + this.sectionStatus = deviceInfo.deviceType === 'phone' ? 1 : this.narrowWinListener.matches ? 2 : 3 let isContinue = AppStorage.Get('IsContinue') LogUtil.info(this.TAG, "aboutToAppear, isContinue : " + isContinue) if (isContinue) { -- Gitee