From 0adf9521df57f0526ef4641676b8e36edf0e6282 Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 7 Jul 2025 15:03:27 +0800 Subject: [PATCH 01/11] =?UTF-8?q?fp=E9=A1=B9=E7=9B=AE=E9=80=82=E9=85=8D?= =?UTF-8?q?=E9=B8=BF=E8=92=99=E4=B8=96=E7=95=8Cux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rekirt --- .../ets/common/constants/CommonConstants.ets | 6 - .../main/ets/pages/BindContentCoverDemo.ets | 24 ++-- .../src/main/ets/pages/BindSheet.ets | 34 +++-- .../src/main/ets/pages/CustomCalendar.ets | 15 +- .../ets/pages/CustomDialogGathersPage.ets | 13 +- .../src/main/ets/pages/Details.ets | 25 ++-- .../src/main/ets/pages/FullScreen.ets | 30 ++-- .../src/main/ets/pages/Privacy.ets | 135 +++++++++--------- .../src/main/ets/pages/ScrollOption.ets | 33 +++-- .../src/main/ets/pages/Toast.ets | 28 ++-- .../src/main/ets/pages/TwoLevelPageSheet.ets | 36 +++-- .../src/main/ets/utils/BreakpointSystem.ets | 8 +- .../src/main/ets/utils/WindowUtil.ets | 18 ++- .../src/main/ets/view/AddPassengers.ets | 26 ++-- .../ets/view/CustomCalendarPickerDialog.ets | 15 +- .../src/main/ets/view/DefaultList.ets | 24 +++- .../src/main/ets/viewmodel/DataManager.ets | 1 - 17 files changed, 274 insertions(+), 197 deletions(-) diff --git a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets index 688004c..d81869a 100644 --- a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets +++ b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets @@ -119,12 +119,6 @@ export class CommonConstants { */ public static readonly GRID_FIVE: string = '1fr 1fr 1fr 1fr 1fr'; - /** - * Breakpoint sm. - */ - public static readonly BREAK_POINT_SM: string = 'sm'; - - /** * MD and LG width. */ diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets index 52b46de..05b0d8e 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets @@ -14,6 +14,7 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function BindContentCoverDemoBuilder() { @@ -25,7 +26,7 @@ export function BindContentCoverDemoBuilder() { struct BindContentCoverDemo { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); build() { @@ -132,17 +133,22 @@ struct BindContentCoverDemo { .mode(this.curBp === 'lg' ? NavigationMode.Split : NavigationMode.Stack) .navBarWidth($r('app.integer.nav_bar_width')) .titleMode(NavigationTitleMode.Mini) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8')} + ).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets index bde530d..5d7d9da 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets @@ -14,7 +14,7 @@ */ import { ConfigurationConstant } from '@kit.AbilityKit'; -import { BreakpointType } from '../utils/BreakpointSystem'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -29,7 +29,7 @@ struct BindSheetDemo { ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State isShowSheet: boolean = false; private menuList: ResourceStr[] = [ $r('app.string.spicy'), $r('app.string.spicy1'), $r('app.string.spicy2'), $r('app.string.spicy3'), @@ -113,7 +113,7 @@ struct BindSheetDemo { .bindSheet(this.isShowSheet, this.mySheet(), { title: { title: $r('app.string.select') }, scrollSizeMode: ScrollSizeMode.FOLLOW_DETENT, - height: new BreakpointType({sm:320,md: 560,lg: 560}).getValue(this.curBp), + height: new BreakpointType({ sm: 320, md: 120, lg: 140 }).getValue(this.curBp), width: this.curBp === 'sm' ? '100%' : $r('app.integer.bind_sheet_width'), preferType: SheetType.CENTER, backgroundColor: this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? @@ -131,24 +131,32 @@ struct BindSheetDemo { .width(CommonConstants.FULL_PERCENT) .backgroundColor($r('sys.color.background_secondary')) .padding({ - right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : - this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), - left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : - this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16') + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), + md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.curBp), + left: new BreakpointType({ + sm: $r('sys.float.padding_level8'), + md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.curBp) }) } .title($r('app.string.bind_sheet_dialog')) .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets index c673b2e..cca8370 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets @@ -17,6 +17,7 @@ import { CustomCalendarPickerDialog } from '../view/CustomCalendarPickerDialog'; import { CommonConstants } from '../common/constants/CommonConstants'; import { getRealTimeDate } from '../viewmodel/GetDate'; import { DateModel } from '../viewmodel/DateModel'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function CalendarViewBuilder() { @@ -28,7 +29,7 @@ export function CalendarViewBuilder() { export struct CalendarView { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); private week: ResourceStr[] = [$r('app.string.sunday'), $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), @@ -65,7 +66,10 @@ export struct CalendarView { getResourceString(resource: Resource): string { let resourceString: string = ''; - resourceString = getContext(this).resourceManager.getStringSync(resource.id); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + resourceString = hostContext.resourceManager.getStringSync(resource.id); + } return resourceString; } @@ -132,13 +136,12 @@ export struct CalendarView { .title($r('app.string.calendar_dialog')) .titleMode(NavigationTitleMode.Mini) .navBarWidth($r('app.integer.nav_bar_width')) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - bottom: px2vp(this.bottomRectHeight) + top: this.getUIContext().px2vp(this.topRectHeight), + bottom: this.getUIContext().px2vp(this.bottomRectHeight) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets index c113764..2920f19 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets @@ -14,13 +14,14 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { TitleModel } from '../viewmodel/DateModel'; @Component export struct CustomDialogGathersPage { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; scroller: Scroller = new Scroller(); pathStack: NavPathStack = new NavPathStack(); titleList: Array = [ @@ -76,7 +77,7 @@ export struct CustomDialogGathersPage { left: $r('sys.float.padding_level6') }) .onClick(() => { - this.pathStack.pushPathByName(url,null) + this.pathStack.pushPathByName(url, null); }) } @@ -104,13 +105,5 @@ export struct CustomDialogGathersPage { .titleMode(NavigationTitleMode.Full) .mode(NavigationMode.Stack) .backgroundColor($r('sys.color.background_secondary')) - .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') - }) } } diff --git a/customdialoggatherslibrary/src/main/ets/pages/Details.ets b/customdialoggatherslibrary/src/main/ets/pages/Details.ets index d290cc8..5528bfb 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Details.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Details.ets @@ -14,6 +14,7 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function DetailsBuilder() { @@ -25,7 +26,7 @@ export function DetailsBuilder() { struct Details { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); build() { @@ -41,7 +42,7 @@ struct Details { }) .backgroundColor($r('sys.color.brand')) .onClick(() => { - this.pathStack.pop() + this.pathStack.pop(); }) } .width(CommonConstants.FULL_PERCENT) @@ -60,15 +61,21 @@ struct Details { .hideBackButton(true) .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .padding({ top: this.getUIContext().px2vp(this.topRectHeight) }) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets index 0aa3120..1f9dee8 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets @@ -15,6 +15,7 @@ import { curves } from '@kit.ArkUI'; import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function FullScreenBuilder() { @@ -28,7 +29,7 @@ struct FullScreen { @State translateY: string | number = '110%'; @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; build() { NavDestination() { @@ -42,7 +43,7 @@ struct FullScreen { .margin({ bottom: $r('sys.float.padding_level6') }) .backgroundColor($r('sys.color.brand')) .onClick(() => { - animateTo({ + this.getUIContext().animateTo({ duration: CommonConstants.DURATION, curve: Curve.Sharp }, () => { @@ -64,12 +65,8 @@ struct FullScreen { .mode(NavigationMode.Stack) .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), }) RelativeContainer() { @@ -101,9 +98,12 @@ struct FullScreen { .height($r('app.integer.button_height_small')) .aspectRatio(1) .margin({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : - this.curBp === 'md' ? $r('sys.float.padding_level12') : $r('sys.float.padding_level16'), + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level8'), + md: $r('sys.float.padding_level12'), + lg: $r('sys.float.padding_level16') + }).getValue(this.curBp), }) .alignRules({ top: { anchor: '__container__', align: VerticalAlign.Top }, @@ -130,11 +130,11 @@ struct FullScreen { } } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } private closeSelf() { - animateTo({ + this.getUIContext().animateTo({ duration: CommonConstants.GRID_HEIGHT_M, curve: Curve.Sharp, }, () => { @@ -143,7 +143,7 @@ struct FullScreen { } private reset() { - animateTo({ + this.getUIContext().animateTo({ curve: curves.responsiveSpringMotion() }, () => { this.translateY = '0%'; @@ -155,7 +155,7 @@ struct FullScreen { if (!offsetY || offsetY < 0) { return; } - animateTo({ + this.getUIContext().animateTo({ curve: curves.responsiveSpringMotion() }, () => { this.translateY = this.positionY + offsetY; diff --git a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets index 01db877..c46fd57 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets @@ -15,6 +15,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function PrivacyBuilder() { @@ -26,7 +27,7 @@ export function PrivacyBuilder() { struct Privacy { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); dialogController: CustomDialogController | null = new CustomDialogController({ builder: PrivacyDialog({ @@ -46,7 +47,7 @@ struct Privacy { dismissDialogAction.dismiss(); } } - }) + }); onCancel() { hilog.info(0x0000, 'Privacy', '%{public}s', 'Callback when the first button is clicked'); @@ -89,18 +90,23 @@ struct Privacy { .title($r('app.string.toast_private_dialog')) .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } @@ -108,7 +114,7 @@ struct Privacy { struct PrivacyDialog { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; dialogController?: CustomDialogController; cancel: () => void = () => { } @@ -117,71 +123,68 @@ struct PrivacyDialog { pathStack: NavPathStack = new NavPathStack(); build() { - Navigation(this.pathStack) { + Column() { + Text($r('app.string.button_name2')) + .fontSize($r('sys.float.Subtitle_M')) + .fontWeight(FontWeight.Bold) + .padding({ + bottom: $r('sys.float.corner_radius_level8') + }) Column() { - Text($r('app.string.button_name2')) - .fontSize($r('sys.float.Subtitle_M')) - .fontWeight(FontWeight.Bold) - .padding({ - bottom: $r('sys.float.corner_radius_level8') - }) - Column() { - Text() { - Span($r('app.string.word1')) - Span($r('app.string.toast_text')) - .fontColor($r('sys.color.font_emphasize')) - .fontWeight(FontWeight.Bold) - .decoration({ - type: TextDecorationType.Underline, - color: $r('sys.color.font_emphasize') - }) - .onClick(() => { - if (this.dialogController != undefined) { - this.dialogController.close() - } - this.pathStack.pushPathByName('Details',null) - }) - Span($r('app.string.word2')) - } - .fontSize($r('sys.float.Body_L')) - } - - Row({ space: CommonConstants.SPACE_ONE }) { - Button($r('app.string.disagree'), { - stateEffect: true, - buttonStyle: ButtonStyleMode.TEXTUAL - }) - .width(CommonConstants.FORTY_PERCENT) + Text() { + Span($r('app.string.word1')) + Span($r('app.string.toast_text')) + .fontColor($r('sys.color.font_emphasize')) + .fontWeight(FontWeight.Bold) + .decoration({ + type: TextDecorationType.Underline, + color: $r('sys.color.font_emphasize') + }) .onClick(() => { if (this.dialogController != undefined) { - this.dialogController.close() + this.dialogController.close(); } }) + Span($r('app.string.word2')) + } + .fontSize($r('sys.float.Body_L')) + } - Divider() - .vertical(true) - .height($r('sys.float.Title_S')) - .color($r('sys.color.icon_fourth')) + Row({ space: CommonConstants.SPACE_ONE }) { + Button($r('app.string.disagree'), { + stateEffect: true, + buttonStyle: ButtonStyleMode.TEXTUAL + }) + .width(CommonConstants.FORTY_PERCENT) + .onClick(() => { + if (this.dialogController != undefined) { + this.dialogController.close(); + } + }) + + Divider() + .vertical(true) + .height($r('sys.float.Title_S')) + .color($r('sys.color.icon_fourth')) - Button($r('app.string.agreed'), { - stateEffect: true, - buttonStyle: ButtonStyleMode.TEXTUAL + Button($r('app.string.agreed'), { + stateEffect: true, + buttonStyle: ButtonStyleMode.TEXTUAL + }) + .onClick(() => { + if (this.dialogController != undefined) { + this.dialogController.close(); + } }) - .onClick(() => { - if (this.dialogController != undefined) { - this.dialogController.close() - } - }) - .width(CommonConstants.FORTY_PERCENT) - } - .justifyContent(FlexAlign.SpaceBetween) - .width(CommonConstants.FULL_PERCENT) - .margin({ top: $r('sys.float.corner_radius_level8') }) - .height($r('app.integer.button_height_small')) + .width(CommonConstants.FORTY_PERCENT) } + .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.FULL_PERCENT) - .backgroundColor($r('sys.color.comp_background_primary')) - .padding(this.curBp === 'sm' ? $r('sys.float.corner_radius_level8') : $r('sys.float.padding_level12')) + .margin({ top: $r('sys.float.corner_radius_level8') }) + .height($r('app.integer.button_height_small')) } + .width(CommonConstants.FULL_PERCENT) + .backgroundColor($r('sys.color.comp_background_primary')) + .padding(this.curBp === 'sm' ? $r('sys.float.corner_radius_level8') : $r('sys.float.padding_level12')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets index 1948c90..d1d1db6 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets @@ -14,6 +14,7 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function ScrollOptionBuilder() { @@ -25,7 +26,7 @@ export function ScrollOptionBuilder() { struct ScrollOption { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private selectTime: Date = new Date('2024-4-17T18:30:00'); @State select: number = 2; private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']; @@ -43,13 +44,13 @@ struct ScrollOption { bottom: $r('sys.float.padding_level6') }) .onClick(() => { - TimePickerDialog.show({ + this.getUIContext().showTimePickerDialog({ selected: this.selectTime, backgroundColor: $r('sys.color.background_primary'), onAccept: (value: TimePickerResult) => { this.selectTime.setHours(value.hour, value.minute); } - }) + }); }) Button($r('app.string.button_scroll_option2')) .width(this.curBp === 'sm' ? CommonConstants.FULL_PERCENT : CommonConstants.WIDTH_MD_LG) @@ -60,14 +61,14 @@ struct ScrollOption { bottom: $r('sys.float.padding_level6') }) .onClick(() => { - TextPickerDialog.show({ + this.getUIContext().showTextPickerDialog({ range: this.fruits, selected: this.select, backgroundColor: $r('sys.color.background_primary'), onAccept: (value: TextPickerResult) => { this.select = value.index as number; } - }) + }); }) } .justifyContent(FlexAlign.End) @@ -81,17 +82,23 @@ struct ScrollOption { .title($r('app.string.scroll_option')) .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) - .backgroundColor($r('sys.color.background_secondary')) + .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets index 1dd4a28..e4027d0 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets @@ -14,6 +14,7 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function CustomDialogUserBuilder() { @@ -45,7 +46,7 @@ struct CustomDialogExample { struct CustomDialogUser { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State inputValue: ResourceStr = $r('app.string.click'); dialogController: CustomDialogController | null = new CustomDialogController({ builder: CustomDialogExample(), @@ -66,7 +67,7 @@ struct CustomDialogUser { customStyle: true, cornerRadius: $r('sys.float.corner_radius_level12'), isModal: false - }) + }); aboutToDisappear() { this.dialogController = null; @@ -89,7 +90,7 @@ struct CustomDialogUser { this.dialogController.open(); setTimeout(() => { this.dialogController?.close(); - }, 3000) + }, 3000); } }) } @@ -104,17 +105,22 @@ struct CustomDialogUser { .title($r('app.string.toast_dialog')) .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets index ab9f7c9..b9d58bc 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets @@ -14,6 +14,7 @@ */ import { CommonConstants } from '../common/constants/CommonConstants'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; @Builder export function TwoLevelPageSheetBuilder() { @@ -25,7 +26,7 @@ export function TwoLevelPageSheetBuilder() { struct TwoLevelPageSheet { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State isShow: boolean = false @State isShow2: boolean = false @State sheetHeight: string = '50%'; @@ -70,6 +71,10 @@ struct TwoLevelPageSheet { this.isShow = false; }) } + .margin({ + bottom: this.curBp === BreakpointTypeEnum.LG && this.getUIContext().px2vp(this.bottomRectHeight) === 0 ? + $r('sys.float.padding_level12') : $r('sys.float.padding_level6') + }) } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.FULL_PERCENT) @@ -77,7 +82,7 @@ struct TwoLevelPageSheet { .padding({ top: $r('app.integer.padding_max'), right: $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), left: $r('sys.float.padding_level8') }) } @@ -99,6 +104,10 @@ struct TwoLevelPageSheet { .width(this.curBp === 'sm' ? CommonConstants.FULL_PERCENT : CommonConstants.WIDTH_MD_LG) .height($r('app.integer.button_height_small')) .backgroundColor($r('sys.color.brand')) + .margin({ + bottom: this.curBp === BreakpointTypeEnum.LG && this.getUIContext().px2vp(this.bottomRectHeight) === 0 ? + $r('sys.float.padding_level12') : $r('sys.float.padding_level6') + }) .onClick(() => { this.isShow = false; this.isShow2 = false; @@ -110,7 +119,7 @@ struct TwoLevelPageSheet { .padding({ top: $r('app.integer.padding_max'), right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level0'), - bottom: px2vp(this.bottomRectHeight), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level0') }) } @@ -149,17 +158,22 @@ struct TwoLevelPageSheet { .title($r('app.string.two_level_dialog')) .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) - .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: px2vp(this.topRectHeight), - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level4') : $r('sys.float.padding_level8') + top: this.getUIContext().px2vp(this.topRectHeight), + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level4'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } .hideTitleBar(true) - .padding({top: px2vp(this.topRectHeight)}) + .backgroundColor($r('sys.color.background_secondary')) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets index aa7581b..6b20282 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { window } from '@kit.ArkUI'; +import { display, window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; @@ -69,7 +69,7 @@ export class BreakpointType { export class BreakpointSystem { private static instance: BreakpointSystem; - private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.MD; + private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.SM; private constructor() { } @@ -96,8 +96,8 @@ export class BreakpointSystem { try { const mainWindow: window.WindowProperties = window.getWindowProperties(); const windowWidth: number = mainWindow.windowRect.width; - const windowWidthVp = px2vp(windowWidth); - let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.MD; + const windowWidthVp = windowWidth / display.getDefaultDisplaySync().densityPixels; + let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.SM; if (windowWidthVp < 320) { widthBp = BreakpointTypeEnum.XS; } else if (windowWidthVp >= 320 && windowWidthVp < 600) { diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 615138a..90b843a 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import { window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; -import { BreakpointSystem } from './BreakpointSystem'; +import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { ConfigurationConstant ,Configuration} from '@kit.AbilityKit'; +import { BreakpointSystem } from './BreakpointSystem'; const TAG: string = '[WindowUtil]'; @@ -50,6 +50,7 @@ export class WindowUtil { return; } BreakpointSystem.getInstance().updateWidthBp(data); + WindowUtil.updateAvoidArea(data); data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); data.on('avoidAreaChange', (avoidAreaOption) => { if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || @@ -60,12 +61,21 @@ export class WindowUtil { }) } + public static updateAvoidArea(windowObj: window.Window) { + let type = window.AvoidAreaType.TYPE_SYSTEM; + let avoidArea = windowObj.getWindowAvoidArea(type); + WindowUtil.setAvoidArea(type, avoidArea); + type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; + avoidArea = windowObj.getWindowAvoidArea(type); + WindowUtil.setAvoidArea(type, avoidArea); + } + // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate('topRectHeight', px2vp(area.topRect.height)); + AppStorage.setOrCreate('topRectHeight', area.topRect.height); } else { - AppStorage.setOrCreate('bottomRectHeight', px2vp(area.bottomRect.height)); + AppStorage.setOrCreate('bottomRectHeight', area.bottomRect.height); } } diff --git a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets index aa72c5f..912ae73 100644 --- a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets +++ b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets @@ -17,6 +17,7 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { PersonList, personList } from '../viewmodel/BindContentModel'; import { CommonConstants } from '../common/constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; const TAG = '[getResourceString]'; @@ -29,13 +30,16 @@ export function AddPassengersBuilder() { export struct AddPassengers { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private personList: Array = personList; getResourceString(resource: Resource): string { let resourceString: string = ''; try { - resourceString = getContext(this).resourceManager.getStringSync(resource.id); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + resourceString = hostContext.resourceManager.getStringSync(resource.id); + } } catch (error) { const err = error as BusinessError; hilog.error(0x0000, TAG, `getResourceString catch error, code: ${err.code}, message: ${err.message}`); @@ -161,16 +165,22 @@ export struct AddPassengers { build() { NavDestination() { - this.MyBuilder(); + this.MyBuilder() } .title(this.getResourceString($r('app.string.select_person'))) .backgroundColor($r('sys.color.background_secondary')) .padding({ - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level0') : $r('sys.float.padding_level2'), - bottom: px2vp(this.bottomRectHeight), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level0') : $r('sys.float.padding_level8') + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level0'), + lg: $r('sys.float.padding_level2') + }).getValue(this.curBp), + bottom: this.getUIContext().px2vp(this.bottomRectHeight), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level0'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index 0b2019b..4e66921 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -19,6 +19,7 @@ import { CommonConstants } from '../common/constants/CommonConstants'; import { DataManager } from '../viewmodel/DataManager'; import { getMonthDate } from '../viewmodel/GetDate'; import { DateModel } from '../viewmodel/DateModel'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @CustomDialog export struct CustomCalendarPickerDialog { @@ -26,7 +27,7 @@ export struct CustomCalendarPickerDialog { currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State contentData: MonthDataSource = new MonthDataSource(); @State nextMonth: number = 1; @State nextYear: number = 1; @@ -46,7 +47,10 @@ export struct CustomCalendarPickerDialog { getResourceString(resource: Resource): string { let resourceString: string = ''; - resourceString = getContext(this).resourceManager.getStringSync(resource.id); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + resourceString = hostContext.resourceManager.getStringSync(resource.id); + } return resourceString; } @@ -156,8 +160,11 @@ export struct CustomCalendarPickerDialog { this.dateModel.day = day; this.dateModel.week = weekIndex; this.dateModel.month = monthItem.num; - DataManager.setDate(getContext(this), this.dateModel, () => { - }); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + DataManager.setDate(hostContext, this.dateModel, () => { + }); + } this.controller.close(); } }) diff --git a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets index b046b74..a76853c 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets @@ -16,8 +16,9 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; + import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; -const TAG = '[getResourceString]'; + const TAG = '[getResourceString]'; @Builder export function DefaultListBuilder() { @@ -28,13 +29,16 @@ export function DefaultListBuilder() { export struct DefaultList { @StorageLink('topRectHeight') topRectHeight: number = 0; @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private defaultListData: Array = [1, 2, 3, 4, 5]; getResourceString(resource: Resource): string { let resourceString: string = ''; try { - resourceString = getContext(this).resourceManager.getStringSync(resource.id); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + resourceString = hostContext.resourceManager.getStringSync(resource.id); + } } catch (error) { const err = error as BusinessError; hilog.error(0x0000, TAG, `getResourceString catch error, code: ${err.code}, message: ${err.message}`); @@ -72,10 +76,16 @@ export struct DefaultList { .title(this.getResourceString($r('app.string.ticket_list'))) .backgroundColor($r('sys.color.background_secondary')) .padding({ - right: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level0') : $r('sys.float.padding_level2'), - left: this.curBp === 'sm' ? $r('sys.float.padding_level0') : - this.curBp === 'md' ? $r('sys.float.padding_level0') : $r('sys.float.padding_level8') + right: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level0'), + lg: $r('sys.float.padding_level2') + }).getValue(this.curBp), + left: new BreakpointType({ + sm: $r('sys.float.padding_level0'), + md: $r('sys.float.padding_level0'), + lg: $r('sys.float.padding_level8') + }).getValue(this.curBp) }) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets b/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets index e212d4c..e6c9167 100644 --- a/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets +++ b/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets @@ -15,7 +15,6 @@ import { preferences } from '@kit.ArkData'; import { DateModel } from './DateModel'; -import { getRealTimeDate } from './GetDate'; export class DataManager { static setDate(context: Context, dateModel: DateModel, callback: () => void) { -- Gitee From cb8ca4fa54da122228a55d6e385be7b8921f3a32 Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 7 Jul 2025 16:46:30 +0800 Subject: [PATCH 02/11] =?UTF-8?q?fp=E9=A1=B9=E7=9B=AE=E9=80=82=E9=85=8D?= =?UTF-8?q?=E9=B8=BF=E8=92=99=E4=B8=96=E7=95=8Cux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: rekirt --- .../src/main/ets/pages/BindContentCoverDemo.ets | 6 +++--- .../src/main/ets/pages/BindSheet.ets | 8 ++++---- .../src/main/ets/pages/CustomCalendar.ets | 8 ++++---- .../src/main/ets/pages/CustomDialogGathersPage.ets | 6 +++--- .../src/main/ets/pages/Details.ets | 6 +++--- .../src/main/ets/pages/FullScreen.ets | 6 +++--- .../src/main/ets/pages/Privacy.ets | 12 ++++++------ .../src/main/ets/pages/ScrollOption.ets | 6 +++--- .../src/main/ets/pages/Toast.ets | 6 +++--- .../src/main/ets/pages/TwoLevelPageSheet.ets | 6 +++--- .../src/main/ets/utils/BreakpointSystem.ets | 2 +- .../src/main/ets/utils/WindowUtil.ets | 8 ++++---- .../src/main/ets/view/AddPassengers.ets | 6 +++--- .../src/main/ets/view/CustomCalendarPickerDialog.ets | 10 +++++----- .../src/main/ets/view/DefaultList.ets | 6 +++--- .../src/main/ets/entryability/EntryAbility.ets | 2 +- 16 files changed, 52 insertions(+), 52 deletions(-) diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets index 05b0d8e..0f00bb1 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets @@ -24,9 +24,9 @@ export function BindContentCoverDemoBuilder() { @Entry @Component struct BindContentCoverDemo { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); build() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets index 5d7d9da..dfac57f 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets @@ -25,11 +25,11 @@ export function BindSheetDemoBuilder() { @Entry @Component struct BindSheetDemo { - @StorageProp('systemColorMode') currentMode: ConfigurationConstant.ColorMode = + @StorageProp('custom_dialog_gathers_systemColorMode') currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State isShowSheet: boolean = false; private menuList: ResourceStr[] = [ $r('app.string.spicy'), $r('app.string.spicy1'), $r('app.string.spicy2'), $r('app.string.spicy3'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets index cca8370..a3e5b03 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets @@ -27,9 +27,9 @@ export function CalendarViewBuilder() { @Entry @Component export struct CalendarView { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); private week: ResourceStr[] = [$r('app.string.sunday'), $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), @@ -37,7 +37,7 @@ export struct CalendarView { @State currentMonth: number = 1; @State currentDay: number = 1; @State currentYear: number = 1; - @StorageLink('selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); + @StorageLink('custom_dialog_gathers_selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); aboutToAppear(): void { this.dateModel = getRealTimeDate(); diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets index 2920f19..49a2717 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets @@ -19,9 +19,9 @@ import { TitleModel } from '../viewmodel/DateModel'; @Component export struct CustomDialogGathersPage { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; scroller: Scroller = new Scroller(); pathStack: NavPathStack = new NavPathStack(); titleList: Array = [ diff --git a/customdialoggatherslibrary/src/main/ets/pages/Details.ets b/customdialoggatherslibrary/src/main/ets/pages/Details.ets index 5528bfb..4cba486 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Details.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Details.ets @@ -24,9 +24,9 @@ export function DetailsBuilder() { @Entry @Component struct Details { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); build() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets index 1f9dee8..b6303d7 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets @@ -27,9 +27,9 @@ export function FullScreenBuilder() { struct FullScreen { private positionY: number = 0; @State translateY: string | number = '110%'; - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; build() { NavDestination() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets index c46fd57..edf065b 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets @@ -25,9 +25,9 @@ export function PrivacyBuilder() { @Entry @Component struct Privacy { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); dialogController: CustomDialogController | null = new CustomDialogController({ builder: PrivacyDialog({ @@ -112,9 +112,9 @@ struct Privacy { @CustomDialog struct PrivacyDialog { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; dialogController?: CustomDialogController; cancel: () => void = () => { } diff --git a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets index d1d1db6..fe71635 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets @@ -24,9 +24,9 @@ export function ScrollOptionBuilder() { @Entry @Component struct ScrollOption { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private selectTime: Date = new Date('2024-4-17T18:30:00'); @State select: number = 2; private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']; diff --git a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets index e4027d0..1f71a94 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets @@ -44,9 +44,9 @@ struct CustomDialogExample { @Entry @Component struct CustomDialogUser { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State inputValue: ResourceStr = $r('app.string.click'); dialogController: CustomDialogController | null = new CustomDialogController({ builder: CustomDialogExample(), diff --git a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets index b9d58bc..12a4aa5 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets @@ -24,9 +24,9 @@ export function TwoLevelPageSheetBuilder() { @Entry @Component struct TwoLevelPageSheet { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State isShow: boolean = false @State isShow2: boolean = false @State sheetHeight: string = '50%'; diff --git a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets index 6b20282..4669eed 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets @@ -84,7 +84,7 @@ export class BreakpointSystem { public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { if (this.currentBreakpoint !== breakpoint) { this.currentBreakpoint = breakpoint; - AppStorage.setOrCreate('currentBreakpoint', this.currentBreakpoint); + AppStorage.setOrCreate('custom_dialog_gathers_currentBreakpoint', this.currentBreakpoint); } } diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 90b843a..7b48483 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -73,18 +73,18 @@ export class WindowUtil { // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate('topRectHeight', area.topRect.height); + AppStorage.setOrCreate('custom_dialog_gathers_topRectHeight', area.topRect.height); } else { - AppStorage.setOrCreate('bottomRectHeight', area.bottomRect.height); + AppStorage.setOrCreate('custom_dialog_gathers_bottomRectHeight', area.bottomRect.height); } } public static updatedColorMode(newConfig: Configuration): void { let newColorMode: ConfigurationConstant.ColorMode = newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get('systemColorMode'); + let currentColorMode = AppStorage.get('custom_dialog_gathers_systemColorMode'); if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate('systemColorMode', newColorMode); + AppStorage.setOrCreate('custom_dialog_gathers_systemColorMode', newColorMode); } } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets index 912ae73..e87e640 100644 --- a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets +++ b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets @@ -28,9 +28,9 @@ export function AddPassengersBuilder() { @Component export struct AddPassengers { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private personList: Array = personList; getResourceString(resource: Resource): string { diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index 4e66921..4053ebd 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -23,11 +23,11 @@ import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @CustomDialog export struct CustomCalendarPickerDialog { - @StorageProp('systemColorMode') + @StorageProp('custom_dialog_gathers_systemColorMode') currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State contentData: MonthDataSource = new MonthDataSource(); @State nextMonth: number = 1; @State nextYear: number = 1; @@ -37,7 +37,7 @@ export struct CustomCalendarPickerDialog { @Link currentMonth: number; @Link currentDay: number; @Link currentYear: number; - @StorageLink('selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); + @StorageLink('custom_dialog_gathers_selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); controller: CustomDialogController; cancel: () => void = () => { }; diff --git a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets index a76853c..d1d7b29 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets @@ -27,9 +27,9 @@ export function DefaultListBuilder() { @Component export struct DefaultList { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; + @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; private defaultListData: Array = [1, 2, 3, 4, 5]; getResourceString(resource: Resource): string { diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index 96b4490..886272e 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -23,7 +23,7 @@ import { WindowUtil } from 'customdialoggatherslibrary/src/main/ets/utils/Window export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); + AppStorage.setOrCreate('custom_dialog_gathers_systemColorMode', this.context.config.colorMode); this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } -- Gitee From 11613a82ea78e8dacb9f14d9ef64b6c1d390b9b9 Mon Sep 17 00:00:00 2001 From: rekirt Date: Tue, 8 Jul 2025 16:13:52 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ets/common/constants/CommonConstants.ets | 21 ------------ .../main/ets/pages/BindContentCoverDemo.ets | 3 +- .../src/main/ets/pages/BindSheet.ets | 4 +-- .../src/main/ets/utils/WindowUtil.ets | 2 +- .../ets/view/CustomCalendarPickerDialog.ets | 5 ++- .../src/main/ets/view/DefaultList.ets | 32 +++++++++---------- .../main/ets/entryability/EntryAbility.ets | 7 ++-- .../src/main/ets/pages/Index.ets | 2 +- 8 files changed, 27 insertions(+), 49 deletions(-) diff --git a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets index d81869a..2a05507 100644 --- a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets +++ b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets @@ -18,107 +18,86 @@ export class CommonConstants { * Month. */ public static readonly MONTHS = 12; - /** * January. */ public static readonly JANUARY = 1; - /** * A week. */ public static readonly WEEK_NUMBER = 7; - /** * Month number. */ public static readonly MONTH_NUMBER = 35; - /** * Small grid height. */ public static readonly GRID_HEIGHT_L = 360; - /** * Large grid height. */ public static readonly GRID_HEIGHT_M = 300; - /** * Outside margin. */ public static readonly ELEMENTS_MARGIN = 12; - /** * The hundred percent of the components */ public static readonly FULL_PERCENT: string = '100%'; - /** * Forty percent. */ public static readonly FORTY_PERCENT: string = '40%'; - /** * Seventy-five percent. */ public static readonly SEVENTY_FIVE_PERCENT: string = '75%'; - /** * Duration. */ public static readonly DURATION: number = 1200; - /** * Delay. */ public static readonly DELAY: number = 500; - /** * Zero. */ public static readonly ZERO: number = 0; - /** * Space. */ public static readonly SPACE_ONE: number = 20; - /** * Element margin large. */ public static readonly ELEMENTS_MARGIN_L: number = 16; - /** * Element margin small. */ public static readonly ELEMENTS_MARGIN_M: number = 8; - /** * Saturday. */ public static readonly SATURDAY: string = '六'; - /** * Sunday. */ public static readonly SUNDAY: string = '日'; - /** * Seven grid. */ public static readonly GRID_SEVEN: string = '1fr 1fr 1fr 1fr 1fr 1fr 1fr'; - /** * Six grid. */ public static readonly GRID_SIX: string = '1fr 1fr 1fr 1fr 1fr 1fr'; - /** * Five grid. */ public static readonly GRID_FIVE: string = '1fr 1fr 1fr 1fr 1fr'; - /** * MD and LG width. */ diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets index 0f00bb1..0187f26 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets @@ -138,7 +138,8 @@ struct BindContentCoverDemo { right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), - lg: $r('sys.float.padding_level8')} + lg: $r('sys.float.padding_level8') + } ).getValue(this.curBp), bottom: this.getUIContext().px2vp(this.bottomRectHeight), left: new BreakpointType({ diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets index dfac57f..0bb6b33 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets @@ -60,7 +60,7 @@ struct BindSheetDemo { } .borderRadius($r('sys.float.corner_radius_level8')) .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth')) + $r('sys.color.background_primary') : $r('sys.color.background_fourth')) .margin({ top: $r('sys.float.corner_radius_level4'), right: $r('sys.float.corner_radius_level8'), @@ -76,7 +76,7 @@ struct BindSheetDemo { .width(CommonConstants.FULL_PERCENT) .height(CommonConstants.FULL_PERCENT) .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_secondary') : $r('sys.color.background_tertiary')) + $r('sys.color.background_secondary') : $r('sys.color.background_tertiary')) } build() { diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 7b48483..9825800 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -16,7 +16,7 @@ import type { BusinessError } from '@kit.BasicServicesKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { ConfigurationConstant ,Configuration} from '@kit.AbilityKit'; +import { ConfigurationConstant, Configuration } from '@kit.AbilityKit'; import { BreakpointSystem } from './BreakpointSystem'; const TAG: string = '[WindowUtil]'; diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index 4053ebd..a1a5b85 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -24,14 +24,13 @@ import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @CustomDialog export struct CustomCalendarPickerDialog { @StorageProp('custom_dialog_gathers_systemColorMode') - currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; + currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; @State contentData: MonthDataSource = new MonthDataSource(); @State nextMonth: number = 1; @State nextYear: number = 1; - @State currentMonthDay: number[] = []; @State initialIndex: number = 0; @Link currentMonth: number; @@ -233,7 +232,7 @@ export struct CustomCalendarPickerDialog { .height($r('app.integer.bind_sheet_width')) .borderRadius($r('sys.float.corner_radius_level12')) .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth')) + $r('sys.color.background_primary') : $r('sys.color.background_fourth')) .alignItems(HorizontalAlign.Center) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets index d1d7b29..73dadce 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets @@ -1,24 +1,24 @@ - /* - * Copyright (c) 2024 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +/* +* Copyright (c) 2024 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; - import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; - const TAG = '[getResourceString]'; +const TAG = '[getResourceString]'; @Builder export function DefaultListBuilder() { diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index 886272e..abc9b28 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -19,7 +19,6 @@ import { hilog } from '@kit.PerformanceAnalysisKit'; import { resourceManager } from '@kit.LocalizationKit'; import { WindowUtil } from 'customdialoggatherslibrary/src/main/ets/utils/WindowUtil' - export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); @@ -28,7 +27,7 @@ export default class EntryAbility extends UIAbility { } onConfigurationUpdate(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig) + WindowUtil.updatedColorMode(newConfig); } onDestroy(): void { @@ -36,8 +35,8 @@ export default class EntryAbility extends UIAbility { } onWindowStageCreate(windowStage: window.WindowStage): void { - WindowUtil.requestFullScreen(windowStage) - WindowUtil.registerBreakPoint(windowStage) + WindowUtil.requestFullScreen(windowStage); + WindowUtil.registerBreakPoint(windowStage); // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); let context = this.context; diff --git a/customdialoggatherssample/src/main/ets/pages/Index.ets b/customdialoggatherssample/src/main/ets/pages/Index.ets index 71f36b3..1036481 100644 --- a/customdialoggatherssample/src/main/ets/pages/Index.ets +++ b/customdialoggatherssample/src/main/ets/pages/Index.ets @@ -19,7 +19,7 @@ import { CustomDialogGathersPage } from 'customdialoggatherslibrary' @Component struct Index { build() { - Stack(){ + Stack() { CustomDialogGathersPage() } } -- Gitee From a4f388b5e421f44caca0c7c5ab2bfcee02b2246a Mon Sep 17 00:00:00 2001 From: rekirt Date: Thu, 10 Jul 2025 19:54:41 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E9=80=82=E9=85=8Dhar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 14 ++++ customdialoggatherslibrary/CHANGELOG.md | 14 ++++ customdialoggatherslibrary/Index.ets | 4 +- customdialoggatherslibrary/LICENSE | 78 +++++++++++++++++++ customdialoggatherslibrary/README.md | 57 ++++++++++++++ customdialoggatherslibrary/oh-package.json5 | 7 +- .../ets/CustomDialogGathersController.ets | 34 ++++++++ .../ets/common/constants/CommonConstants.ets | 20 +++++ .../main/ets/pages/BindContentCoverDemo.ets | 7 +- .../src/main/ets/pages/BindSheet.ets | 9 +-- .../src/main/ets/pages/CustomCalendar.ets | 7 +- ...e.ets => CustomDialogGathersComponent.ets} | 8 +- .../src/main/ets/pages/Details.ets | 6 +- .../src/main/ets/pages/FullScreen.ets | 7 +- .../src/main/ets/pages/Privacy.ets | 13 ++-- .../src/main/ets/pages/ScrollOption.ets | 7 +- .../src/main/ets/pages/Toast.ets | 7 +- .../src/main/ets/pages/TwoLevelPageSheet.ets | 7 +- .../src/main/ets/utils/BreakpointSystem.ets | 3 +- .../src/main/ets/utils/WindowUtil.ets | 15 +++- .../src/main/ets/view/AddPassengers.ets | 6 +- .../ets/view/CustomCalendarPickerDialog.ets | 8 +- .../src/main/ets/view/DefaultList.ets | 6 +- .../main/ets/entryability/EntryAbility.ets | 16 ++-- .../src/main/ets/pages/Index.ets | 4 +- 25 files changed, 288 insertions(+), 76 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 customdialoggatherslibrary/CHANGELOG.md create mode 100644 customdialoggatherslibrary/LICENSE create mode 100644 customdialoggatherslibrary/README.md create mode 100644 customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets rename customdialoggatherslibrary/src/main/ets/pages/{CustomDialogGathersPage.ets => CustomDialogGathersComponent.ets} (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..71fad7b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# 版本记录 +## 1.0.0(2025.07.10) + +--- +### Initial +- 初始版本 + +## 1.0.0(2025.07.10) + +--- +### Bugfix +- 适配鸿蒙世界UX +- 规范化导出类 +- 修复已知bug \ No newline at end of file diff --git a/customdialoggatherslibrary/CHANGELOG.md b/customdialoggatherslibrary/CHANGELOG.md new file mode 100644 index 0000000..71fad7b --- /dev/null +++ b/customdialoggatherslibrary/CHANGELOG.md @@ -0,0 +1,14 @@ +# 版本记录 +## 1.0.0(2025.07.10) + +--- +### Initial +- 初始版本 + +## 1.0.0(2025.07.10) + +--- +### Bugfix +- 适配鸿蒙世界UX +- 规范化导出类 +- 修复已知bug \ No newline at end of file diff --git a/customdialoggatherslibrary/Index.ets b/customdialoggatherslibrary/Index.ets index 0151ff7..1f1c335 100644 --- a/customdialoggatherslibrary/Index.ets +++ b/customdialoggatherslibrary/Index.ets @@ -1,2 +1,2 @@ -export { CustomDialogGathersPage} from './src/main/ets/pages/CustomDialogGathersPage' -export { WindowUtil } from './src/main/ets/utils/WindowUtil'; \ No newline at end of file +export { CustomDialogGathersComponent } from './src/main/ets/pages/CustomDialogGathersComponent' +export { CustomDialogGathersController } from './src/main/ets/CustomDialogGathersController'; \ No newline at end of file diff --git a/customdialoggatherslibrary/LICENSE b/customdialoggatherslibrary/LICENSE new file mode 100644 index 0000000..daeafe2 --- /dev/null +++ b/customdialoggatherslibrary/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/customdialoggatherslibrary/README.md b/customdialoggatherslibrary/README.md new file mode 100644 index 0000000..a041fdf --- /dev/null +++ b/customdialoggatherslibrary/README.md @@ -0,0 +1,57 @@ +## 实现多种自定义弹窗的效果 + +### 介绍 + +本示例通过CustomDialog、bindContentCover、bindSheet等接口,实现多种样式的弹窗。帮助开发者掌握自定义弹窗开发的步骤,灵活的实现自己业务需要用到的弹窗场景。 + +### 下载安装 + +使用ohpm安装依赖 + +``` +ohpm install @ohos_samples/customdialoggatherslibrary +``` + +或者按需在模块中修改oh-package.json5 + +``` +{ + "dependencies": { + "@ohos_samples/customdialoggatherslibrary": "^1.0.0" + } +} +``` + +### 使用说明 + +``` +import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary'; +``` +按需在文件中使用导出模块即可,其中CustomDialogGathersComponent是整个sample的入口页面。示例如下: +``` +// Page.ets +import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary'; +Stack() { + CustomDialogGathersComponent() +} + +// EntryAbility.ets +import { CustomDialogGathersController } from '@ohos_samples/multitravelaccommodationlibrary'; + onCreate(): void { + CustomDialogGathersController.initColorMode(this.context); + } + + onConfigurationUpdate(newConfig: Configuration): void { + CustomDialogGathersController.updateColorMode(newConfig); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.error(0x0000, 'testTag', `Failed to load the content, err code: ${err.code}, message: ${err.message}`); + return; + } + CustomDialogGathersController.initWindowConfig(windowStage); + }); + } +``` \ No newline at end of file diff --git a/customdialoggatherslibrary/oh-package.json5 b/customdialoggatherslibrary/oh-package.json5 index 3545cea..35946a5 100644 --- a/customdialoggatherslibrary/oh-package.json5 +++ b/customdialoggatherslibrary/oh-package.json5 @@ -1,9 +1,10 @@ { - "name": "customdialoggatherslibrary", + "name": "@ohos_samples/customdialoggatherslibrary", "version": "1.0.0", - "description": "Please describe the basic information.", + "description": "This sample uses CustomDialog, bindContentCover, and bindSheet to implement multiple custom dialog pop-ups.", "main": "Index.ets", - "author": "", + "author": "@ohos_samples", "license": "Apache-2.0", + "repository": "https://gitee.com/harmonyos_samples/custom-dialog-gathers/tree/br_release_hmos/", "dependencies": {} } diff --git a/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets new file mode 100644 index 0000000..0c29d67 --- /dev/null +++ b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { common } from '@kit.AbilityKit'; +import { Configuration } from '@kit.AbilityKit'; +import { WindowUtil } from "./utils/WindowUtil"; +import { window } from "@kit.ArkUI"; + +export class CustomDialogGathersController { + public static initWindowConfig(windowStage: window.WindowStage): void { + WindowUtil.requestFullScreen(windowStage); + WindowUtil.registerBreakPoint(windowStage); + } + + public static initColorMode(context: common.UIAbilityContext): void { + WindowUtil.initColorMode(context); + } + + public static updateColorMode(newConfig: Configuration): void { + WindowUtil.updatedColorMode(newConfig); + } +} \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets index 2a05507..81ce567 100644 --- a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets +++ b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets @@ -102,4 +102,24 @@ export class CommonConstants { * MD and LG width. */ public static readonly WIDTH_MD_LG: number = 448; + /** + * The prefix of app store key. + */ + public static readonly PREFIX: string = 'custom_dialog_gathers_'; + /** + * The key of color mode. + */ + public static readonly AS_KEY_COLOR_MODE: string = `${CommonConstants.PREFIX}systemColorMode`; + /** + * The key of break point. + */ + public static readonly AS_KEY_BREAK_POINT: string = `${CommonConstants.PREFIX}currentBreakpoint`; + /** + * The key of top height. + */ + public static readonly AS_KEY_TOP_HEIGHT: string = `${CommonConstants.PREFIX}topRectHeight`; + /** + * The key of top height. + */ + public static readonly AS_KEY_BOTTOM_HEIGHT: string = `${CommonConstants.PREFIX}bottomRectHeight`; } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets index 0187f26..e452ecc 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets @@ -21,12 +21,11 @@ export function BindContentCoverDemoBuilder() { BindContentCoverDemo(); } -@Entry @Component struct BindContentCoverDemo { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); build() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets index 0bb6b33..03ddcae 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets @@ -22,14 +22,13 @@ export function BindSheetDemoBuilder() { BindSheetDemo(); } -@Entry @Component struct BindSheetDemo { - @StorageProp('custom_dialog_gathers_systemColorMode') currentMode: ConfigurationConstant.ColorMode = + @StorageProp(CommonConstants.AS_KEY_COLOR_MODE) currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State isShowSheet: boolean = false; private menuList: ResourceStr[] = [ $r('app.string.spicy'), $r('app.string.spicy1'), $r('app.string.spicy2'), $r('app.string.spicy3'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets index a3e5b03..0a5ae53 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets @@ -24,12 +24,11 @@ export function CalendarViewBuilder() { CalendarView(); } -@Entry @Component export struct CalendarView { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pageInfos: NavPathStack = new NavPathStack(); private week: ResourceStr[] = [$r('app.string.sunday'), $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets similarity index 93% rename from customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets rename to customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets index 49a2717..1d93f41 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets @@ -18,10 +18,10 @@ import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { TitleModel } from '../viewmodel/DateModel'; @Component -export struct CustomDialogGathersPage { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; +export struct CustomDialogGathersComponent { + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; scroller: Scroller = new Scroller(); pathStack: NavPathStack = new NavPathStack(); titleList: Array = [ diff --git a/customdialoggatherslibrary/src/main/ets/pages/Details.ets b/customdialoggatherslibrary/src/main/ets/pages/Details.ets index 4cba486..9750952 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Details.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Details.ets @@ -24,9 +24,9 @@ export function DetailsBuilder() { @Entry @Component struct Details { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); build() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets index b6303d7..dbef694 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets @@ -22,14 +22,13 @@ export function FullScreenBuilder() { FullScreen(); } -@Entry @Component struct FullScreen { private positionY: number = 0; @State translateY: string | number = '110%'; - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; build() { NavDestination() { diff --git a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets index edf065b..d144ed6 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets @@ -22,12 +22,11 @@ export function PrivacyBuilder() { Privacy(); } -@Entry @Component struct Privacy { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); dialogController: CustomDialogController | null = new CustomDialogController({ builder: PrivacyDialog({ @@ -112,9 +111,9 @@ struct Privacy { @CustomDialog struct PrivacyDialog { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; dialogController?: CustomDialogController; cancel: () => void = () => { } diff --git a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets index fe71635..f2710e8 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets @@ -21,12 +21,11 @@ export function ScrollOptionBuilder() { ScrollOption(); } -@Entry @Component struct ScrollOption { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private selectTime: Date = new Date('2024-4-17T18:30:00'); @State select: number = 2; private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']; diff --git a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets index 1f71a94..d556f47 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/Toast.ets @@ -41,12 +41,11 @@ struct CustomDialogExample { } } -@Entry @Component struct CustomDialogUser { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State inputValue: ResourceStr = $r('app.string.click'); dialogController: CustomDialogController | null = new CustomDialogController({ builder: CustomDialogExample(), diff --git a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets index 12a4aa5..dec4d71 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets @@ -21,12 +21,11 @@ export function TwoLevelPageSheetBuilder() { TwoLevelPageSheet(); } -@Entry @Component struct TwoLevelPageSheet { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State isShow: boolean = false @State isShow2: boolean = false @State sheetHeight: string = '50%'; diff --git a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets index 4669eed..2665185 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets @@ -16,6 +16,7 @@ import { display, window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { CommonConstants } from '../common/constants/CommonConstants'; const TAG: string = '[BreakpointSystem]'; @@ -84,7 +85,7 @@ export class BreakpointSystem { public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { if (this.currentBreakpoint !== breakpoint) { this.currentBreakpoint = breakpoint; - AppStorage.setOrCreate('custom_dialog_gathers_currentBreakpoint', this.currentBreakpoint); + AppStorage.setOrCreate(CommonConstants.AS_KEY_BREAK_POINT, this.currentBreakpoint); } } diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 9825800..3840e6d 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -13,11 +13,13 @@ * limitations under the License. */ +import { common } from '@kit.AbilityKit'; import type { BusinessError } from '@kit.BasicServicesKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { ConfigurationConstant, Configuration } from '@kit.AbilityKit'; import { BreakpointSystem } from './BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; const TAG: string = '[WindowUtil]'; @@ -73,18 +75,23 @@ export class WindowUtil { // Get status bar height and indicator height. public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate('custom_dialog_gathers_topRectHeight', area.topRect.height); + AppStorage.setOrCreate(CommonConstants.AS_KEY_TOP_HEIGHT, area.topRect.height); } else { - AppStorage.setOrCreate('custom_dialog_gathers_bottomRectHeight', area.bottomRect.height); + AppStorage.setOrCreate(CommonConstants.AS_KEY_BOTTOM_HEIGHT, area.bottomRect.height); } } + public static initColorMode(context: common.UIAbilityContext): void { + AppStorage.setOrCreate(CommonConstants.AS_KEY_COLOR_MODE, context.config.colorMode); + context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + } + public static updatedColorMode(newConfig: Configuration): void { let newColorMode: ConfigurationConstant.ColorMode = newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get('custom_dialog_gathers_systemColorMode'); + let currentColorMode = AppStorage.get(CommonConstants.AS_KEY_COLOR_MODE); if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate('custom_dialog_gathers_systemColorMode', newColorMode); + AppStorage.setOrCreate(CommonConstants.AS_KEY_COLOR_MODE, newColorMode); } } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets index e87e640..25e0fa9 100644 --- a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets +++ b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets @@ -28,9 +28,9 @@ export function AddPassengersBuilder() { @Component export struct AddPassengers { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private personList: Array = personList; getResourceString(resource: Resource): string { diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index a1a5b85..7ae14ba 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -23,11 +23,11 @@ import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; @CustomDialog export struct CustomCalendarPickerDialog { - @StorageProp('custom_dialog_gathers_systemColorMode') + @StorageProp(CommonConstants.AS_KEY_COLOR_MODE) currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State contentData: MonthDataSource = new MonthDataSource(); @State nextMonth: number = 1; @State nextYear: number = 1; diff --git a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets index 73dadce..1073907 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets @@ -27,9 +27,9 @@ export function DefaultListBuilder() { @Component export struct DefaultList { - @StorageLink('custom_dialog_gathers_topRectHeight') topRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('custom_dialog_gathers_currentBreakpoint') curBp: string = BreakpointTypeEnum.SM; + @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private defaultListData: Array = [1, 2, 3, 4, 5]; getResourceString(resource: Resource): string { diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index abc9b28..8fb0e9d 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -13,21 +13,19 @@ * limitations under the License. */ -import { Configuration, ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; +import { Configuration, UIAbility } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { resourceManager } from '@kit.LocalizationKit'; -import { WindowUtil } from 'customdialoggatherslibrary/src/main/ets/utils/WindowUtil' +import { CustomDialogGathersController } from 'customdialoggatherslibrary' export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - AppStorage.setOrCreate('custom_dialog_gathers_systemColorMode', this.context.config.colorMode); - this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + CustomDialogGathersController.initColorMode(this.context); } onConfigurationUpdate(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig); + CustomDialogGathersController.updateColorMode(newConfig); } onDestroy(): void { @@ -35,18 +33,14 @@ export default class EntryAbility extends UIAbility { } onWindowStageCreate(windowStage: window.WindowStage): void { - WindowUtil.requestFullScreen(windowStage); - WindowUtil.registerBreakPoint(windowStage); // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - let context = this.context; - let resourceManager: resourceManager.ResourceManager = context.resourceManager; - AppStorage.setOrCreate('resourceManager', resourceManager); windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', `Failed to load the content, err code: ${err.code}, message: ${err.message}`); return; } + CustomDialogGathersController.initWindowConfig(windowStage); hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); }); } diff --git a/customdialoggatherssample/src/main/ets/pages/Index.ets b/customdialoggatherssample/src/main/ets/pages/Index.ets index 1036481..b56b680 100644 --- a/customdialoggatherssample/src/main/ets/pages/Index.ets +++ b/customdialoggatherssample/src/main/ets/pages/Index.ets @@ -13,14 +13,14 @@ * limitations under the License. */ -import { CustomDialogGathersPage } from 'customdialoggatherslibrary' +import { CustomDialogGathersComponent } from 'customdialoggatherslibrary' @Entry @Component struct Index { build() { Stack() { - CustomDialogGathersPage() + CustomDialogGathersComponent() } } } \ No newline at end of file -- Gitee From 418c5af802435b54c3d35c50ca7a1438acccaaed Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 14 Jul 2025 10:39:46 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9E=B6=E6=9E=84?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AppScope/app.json5 | 4 +- README.en.md | 34 ++-- README.md | 34 ++-- customdialoggatherslibrary/.gitignore | 6 - customdialoggatherslibrary/CHANGELOG.md | 4 +- customdialoggatherslibrary/Index.ets | 2 +- customdialoggatherslibrary/README.md | 14 +- customdialoggatherslibrary/oh-package.json5 | 2 +- .../ets/CustomDialogGathersController.ets | 15 +- .../ets/common/constants/CommonConstants.ets | 20 ++- .../BindContentCoverDemo.ets | 18 +- .../BindSheetDemo.ets} | 20 +-- .../CalendarView.ets} | 47 +++--- .../CustomDialogGathersComponent.ets | 16 +- .../CustomDialogUser.ets} | 20 +-- .../ets/{pages => component}/FullScreen.ets | 12 +- .../main/ets/{pages => component}/Privacy.ets | 27 +-- .../ets/{pages => component}/ScrollOption.ets | 10 +- .../TwoLevelPageSheet.ets | 18 +- .../src/main/ets/utils/BreakpointSystem.ets | 3 +- .../src/main/ets/utils/WindowUtil.ets | 108 +++++------- .../src/main/ets/view/AddPassengers.ets | 14 +- .../ets/view/CustomCalendarPickerDialog.ets | 30 ++-- .../src/main/ets/{pages => view}/Details.ets | 13 +- .../{DefaultList.ets => QueryTicketList.ets} | 14 +- .../src/main/ets/viewmodel/DataManager.ets | 29 +--- .../main/resources/base/element/color.json | 10 +- .../main/resources/base/element/string.json | 158 ++++++++---------- .../resources/base/profile/router_map.json | 40 ++--- .../main/resources/dark/element/color.json | 20 +++ .../main/resources/en_US/element/string.json | 46 ++--- .../main/resources/zh_CN/element/string.json | 46 ++--- .../obfuscation-rules.txt | 2 +- customdialoggatherssample/oh-package.json5 | 2 +- .../main/ets/entryability/EntryAbility.ets | 11 +- .../src/main/ets/pages/Index.ets | 2 +- .../main/resources/base/element/color.json | 8 + .../main/resources/base/element/string.json | 16 ++ .../main/resources/base/media/background.png | Bin .../main/resources/base/media/foreground.png | Bin .../resources/base/media/layered_image.json | 0 .../main/resources/base/media/startIcon.png | Bin .../main/resources/en_US/element/string.json | 16 ++ .../main/resources/zh_CN/element/string.json | 16 ++ 44 files changed, 472 insertions(+), 455 deletions(-) delete mode 100644 customdialoggatherslibrary/.gitignore rename customdialoggatherslibrary/src/main/ets/{pages => component}/BindContentCoverDemo.ets (92%) rename customdialoggatherslibrary/src/main/ets/{pages/BindSheet.ets => component/BindSheetDemo.ets} (84%) rename customdialoggatherslibrary/src/main/ets/{pages/CustomCalendar.ets => component/CalendarView.ets} (90%) rename customdialoggatherslibrary/src/main/ets/{pages => component}/CustomDialogGathersComponent.ets (91%) rename customdialoggatherslibrary/src/main/ets/{pages/Toast.ets => component/CustomDialogUser.ets} (88%) rename customdialoggatherslibrary/src/main/ets/{pages => component}/FullScreen.ets (94%) rename customdialoggatherslibrary/src/main/ets/{pages => component}/Privacy.ets (87%) rename customdialoggatherslibrary/src/main/ets/{pages => component}/ScrollOption.ets (93%) rename customdialoggatherslibrary/src/main/ets/{pages => component}/TwoLevelPageSheet.ets (90%) rename customdialoggatherslibrary/src/main/ets/{pages => view}/Details.ets (88%) rename customdialoggatherslibrary/src/main/ets/view/{DefaultList.ets => QueryTicketList.ets} (91%) create mode 100644 customdialoggatherslibrary/src/main/resources/dark/element/color.json create mode 100644 customdialoggatherssample/src/main/resources/base/element/color.json create mode 100644 customdialoggatherssample/src/main/resources/base/element/string.json rename {customdialoggatherslibrary => customdialoggatherssample}/src/main/resources/base/media/background.png (100%) rename {customdialoggatherslibrary => customdialoggatherssample}/src/main/resources/base/media/foreground.png (100%) rename {customdialoggatherslibrary => customdialoggatherssample}/src/main/resources/base/media/layered_image.json (100%) rename {customdialoggatherslibrary => customdialoggatherssample}/src/main/resources/base/media/startIcon.png (100%) create mode 100644 customdialoggatherssample/src/main/resources/en_US/element/string.json create mode 100644 customdialoggatherssample/src/main/resources/zh_CN/element/string.json diff --git a/AppScope/app.json5 b/AppScope/app.json5 index e2387db..0bd2912 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -2,8 +2,8 @@ "app": { "bundleName": "com.example.customdialoggathers", "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", + "versionCode": 1000001, + "versionName": "1.0.1", "icon": "$media:app_icon", "label": "$string:app_name" } diff --git a/README.en.md b/README.en.md index 0766205..c65a993 100644 --- a/README.en.md +++ b/README.en.md @@ -24,31 +24,37 @@ After the loading is complete, eight customized dialog pop-up types are displaye 7. Custom calendar selector dialog pop-up: Tap a date on the page. A date selector dialog pop-up is displayed. Only dates after the current date can be selected. After the selection is complete, the dialog pop-up is closed and the date is changed to the selected date. 8. Semi-modal + full-screen dialog pop-up: Tap **open sheet1** to display the first semi-modal dialog pop-up. Tap the text box. Tap **close sheet1** to close the first dialog pop-up. Taping the **open sheets2** button opens the second semi-modal dialog pop-up that has two buttons. Taping the **close sheets2** button closes only the second semi-modal dialog pop-up. Taping the **close sheets1 sheet2** button closes the first and second semi-modal dialog pop-ups. -### Project Directory +### Library Directory ``` ├──entry/src/main/ets/ │ ├──common/constant │ │ └──CommonConstants.ets // Common constant class -│ ├──entryability -│ │ └──EntryAbility.ets // Entry ability -│ ├──pages -│ │ ├──Index.ets // Homepage +│ ├──component │ │ ├──BindContentCoverDemo.ets // Modal dialog pop-up -│ │ ├──BindSheet.ets // Semi-modal dialog pop-up -│ │ ├──CustomCalendar.ets // Custom calendar selector dialog pop-up +│ │ ├──BindSheetDemo.ets // Semi-modal dialog pop-up +│ │ ├──CalendarView.ets // Custom calendar dialog pop-up +│ │ ├──CustomDialogGathersComponent.ets // Homepage +│ │ ├──CustomDialogUser.ets // Custom toast dialog pop-up │ │ ├──FullScreen.ets // Full-screen dialog pop-up │ │ ├──Privacy.ets // Privacy agreement dialog pop-up │ │ ├──ScrollOption.ets // Scroll-to-select dialog pop-up │ │ └──TwoLevelPageSheet.ets // Semi-modal + full-screen dialog pop-up +│ ├──utils +│ │ ├──BreakpointSystem.ets // Break point utils +│ │ └──WindowUtil.ets // Window utils │ ├──view -│ │ └──CustomCalendarPickerDialog.ets // Custom calendar dialog pop-up -│ └──viewmodel -│ ├──BindContentModel.ets // Modal dialog pop-up API and data -│ ├──DataManager.ets // Data storage class -│ ├──DateModel.ets // Date class -│ ├──GetDate.ets // Function for obtaining dates -│ └──MonthDataSource.ets // Month data class +│ │ ├──AddPassengers.ets // Add passenger +│ │ ├──CustomCalendarPickerDialog.ets // Custom calendar dialog pop-up +│ │ ├──QueryTicketList.ets // Query ticket list +│ │ └──Details.ets // Privacy Detail +│ ├──viewmodel +│ │ ├──BindContentModel.ets // Modal dialog pop-up API and data +│ │ ├──DataManager.ets // Data storage class +│ │ ├──DateModel.ets // Date class +│ │ ├──GetDate.ets // Function for obtaining dates +│ │ └──MonthDataSource.ets // Month data class +│ └────CustomDialogGathersController.ets // Export utils └──entry/src/main/resources // App resource directory ``` diff --git a/README.md b/README.md index d24df33..fc5c938 100644 --- a/README.md +++ b/README.md @@ -24,31 +24,37 @@ 7. 自定义日历选择器弹窗:点击页面中的日期会弹出日期选择器弹窗,当前日期之前的日期不可选,之后的日期可选,选择完成后弹窗关闭,日期更改为选中的日期。 8. 两级半模态+全屏弹窗:点击open sheet1按钮弹出第一个半模态弹窗,点击里面的输入框,弹出的键盘不避让,点击close sheets1按钮会关闭第一个弹窗;点击open sheets2按钮会打开第二个半模态弹窗,第二个半模态弹窗中有两个按钮,点击close sheets2按钮只会关闭第二个半模态弹窗,点击close sheet1 sheet2按钮会关闭第一个和第二个半模态弹窗。 -### 工程目录 +### 库目录 ``` ├──entry/src/main/ets/ │ ├──common/constant │ │ └──CommonConstants.ets // 公共常量类 -│ ├──entryability -│ │ └──EntryAbility.ets // 程序入口类 -│ ├──pages -│ │ ├──Index.ets // 首页 +│ ├──component │ │ ├──BindContentCoverDemo.ets // 模态弹窗页面 -│ │ ├──BindSheet.ets // 半模态弹窗页面 -│ │ ├──CustomCalendar.ets // 自定义日历选择器弹窗页面 +│ │ ├──BindSheetDemo.ets // 半模态弹窗页面 +│ │ ├──CalendarView.ets // 自定义日历选择器弹窗页面 +│ │ ├──CustomDialogGathersComponent.ets // 首页 +│ │ ├──CustomDialogUser.ets // 自定义Toast弹窗页面 │ │ ├──FullScreen.ets // 全屏弹窗页面 │ │ ├──Privacy.ets // 隐私协议弹窗页面 │ │ ├──ScrollOption.ets // 滑动选择弹窗页面 │ │ └──TwoLevelPageSheet.ets // 两级半模态+全屏弹窗页面 +│ ├──utils +│ │ ├──BreakpointSystem.ets // 断点工具类 +│ │ └──WindowUtil.ets // 窗口工具类 │ ├──view -│ │ └──CustomCalendarPickerDialog.ets // 自定义日历弹窗组件 -│ └──viewmodel -│ ├──BindContentModel.ets // 模态弹窗接口和数据 -│ ├──DataManager.ets // 数据存储类 -│ ├──DateModel.ets // 日期类 -│ ├──GetDate.ets // 获取日期函数 -│ └──MonthDataSource.ets // 月份数据类 +│ │ ├──AddPassengers.ets // 添加乘客页面 +│ │ ├──CustomCalendarPickerDialog.ets // 自定义日历弹窗组件 +│ │ ├──QueryTicketList.ets // 查询车票列表 +│ │ └──Details.ets // 隐私详情 +│ ├──viewmodel +│ │ ├──BindContentModel.ets // 模态弹窗接口和数据 +│ │ ├──DataManager.ets // 数据存储类 +│ │ ├──DateModel.ets // 日期类 +│ │ ├──GetDate.ets // 获取日期函数 +│ │ └──MonthDataSource.ets // 月份数据类 +│ └────CustomDialogGathersController.ets // 导出工具类 └──entry/src/main/resources // 应用资源目录 ``` diff --git a/customdialoggatherslibrary/.gitignore b/customdialoggatherslibrary/.gitignore deleted file mode 100644 index e2713a2..0000000 --- a/customdialoggatherslibrary/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/customdialoggatherslibrary/CHANGELOG.md b/customdialoggatherslibrary/CHANGELOG.md index 71fad7b..81aa6c4 100644 --- a/customdialoggatherslibrary/CHANGELOG.md +++ b/customdialoggatherslibrary/CHANGELOG.md @@ -1,11 +1,11 @@ # 版本记录 -## 1.0.0(2025.07.10) +## 1.0.1(2025.07.10) --- ### Initial - 初始版本 -## 1.0.0(2025.07.10) +## 1.0.1(2025.07.10) --- ### Bugfix diff --git a/customdialoggatherslibrary/Index.ets b/customdialoggatherslibrary/Index.ets index 1f1c335..1bfdb76 100644 --- a/customdialoggatherslibrary/Index.ets +++ b/customdialoggatherslibrary/Index.ets @@ -1,2 +1,2 @@ -export { CustomDialogGathersComponent } from './src/main/ets/pages/CustomDialogGathersComponent' +export { CustomDialogGathersComponent } from './src/main/ets/component/CustomDialogGathersComponent' export { CustomDialogGathersController } from './src/main/ets/CustomDialogGathersController'; \ No newline at end of file diff --git a/customdialoggatherslibrary/README.md b/customdialoggatherslibrary/README.md index a041fdf..1410751 100644 --- a/customdialoggatherslibrary/README.md +++ b/customdialoggatherslibrary/README.md @@ -32,20 +32,12 @@ import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggathersl // Page.ets import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary'; Stack() { - CustomDialogGathersComponent() + CustomDialogGathersComponent() } // EntryAbility.ets import { CustomDialogGathersController } from '@ohos_samples/multitravelaccommodationlibrary'; - onCreate(): void { - CustomDialogGathersController.initColorMode(this.context); - } - - onConfigurationUpdate(newConfig: Configuration): void { - CustomDialogGathersController.updateColorMode(newConfig); - } - - onWindowStageCreate(windowStage: window.WindowStage): void { +onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { hilog.error(0x0000, 'testTag', `Failed to load the content, err code: ${err.code}, message: ${err.message}`); @@ -53,5 +45,5 @@ import { CustomDialogGathersController } from '@ohos_samples/multitravelaccommod } CustomDialogGathersController.initWindowConfig(windowStage); }); - } +} ``` \ No newline at end of file diff --git a/customdialoggatherslibrary/oh-package.json5 b/customdialoggatherslibrary/oh-package.json5 index 35946a5..cf2be24 100644 --- a/customdialoggatherslibrary/oh-package.json5 +++ b/customdialoggatherslibrary/oh-package.json5 @@ -1,6 +1,6 @@ { "name": "@ohos_samples/customdialoggatherslibrary", - "version": "1.0.0", + "version": "1.0.1", "description": "This sample uses CustomDialog, bindContentCover, and bindSheet to implement multiple custom dialog pop-ups.", "main": "Index.ets", "author": "@ohos_samples", diff --git a/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets index 0c29d67..7d4ff28 100644 --- a/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets +++ b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets @@ -13,22 +13,11 @@ * limitations under the License. */ -import { common } from '@kit.AbilityKit'; -import { Configuration } from '@kit.AbilityKit'; -import { WindowUtil } from "./utils/WindowUtil"; import { window } from "@kit.ArkUI"; +import { WindowUtil } from "./utils/WindowUtil"; export class CustomDialogGathersController { public static initWindowConfig(windowStage: window.WindowStage): void { - WindowUtil.requestFullScreen(windowStage); - WindowUtil.registerBreakPoint(windowStage); - } - - public static initColorMode(context: common.UIAbilityContext): void { - WindowUtil.initColorMode(context); - } - - public static updateColorMode(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig); + WindowUtil.initialize(windowStage); } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets index 81ce567..deb897f 100644 --- a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets +++ b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets @@ -106,20 +106,24 @@ export class CommonConstants { * The prefix of app store key. */ public static readonly PREFIX: string = 'custom_dialog_gathers_'; - /** - * The key of color mode. - */ - public static readonly AS_KEY_COLOR_MODE: string = `${CommonConstants.PREFIX}systemColorMode`; /** * The key of break point. */ public static readonly AS_KEY_BREAK_POINT: string = `${CommonConstants.PREFIX}currentBreakpoint`; /** - * The key of top height. + * The key of status bar height. + */ + public static readonly AS_KEY_STATUS_BAR_HEIGHT: string = `${CommonConstants.PREFIX}statusBarHeight`; + /** + * The key of navigator bar height. + */ + public static readonly AS_KEY_NAVIGATOR_BAR_HEIGHT: string = `${CommonConstants.PREFIX}navigatorBarHeight`; + /** + * The key of path stack. */ - public static readonly AS_KEY_TOP_HEIGHT: string = `${CommonConstants.PREFIX}topRectHeight`; + public static readonly AS_KEY_PATH_STACK: string = `${CommonConstants.PREFIX}pathStack`; /** - * The key of top height. + * The key of selected date. */ - public static readonly AS_KEY_BOTTOM_HEIGHT: string = `${CommonConstants.PREFIX}bottomRectHeight`; + public static readonly AS_KEY_SELECTED_DATE: string = `${CommonConstants.PREFIX}selectedDate`; } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets b/customdialoggatherslibrary/src/main/ets/component/BindContentCoverDemo.ets similarity index 92% rename from customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets rename to customdialoggatherslibrary/src/main/ets/component/BindContentCoverDemo.ets index e452ecc..6148437 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/component/BindContentCoverDemo.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function BindContentCoverDemoBuilder() { @@ -23,14 +23,14 @@ export function BindContentCoverDemoBuilder() { @Component struct BindContentCoverDemo { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; - pageInfos: NavPathStack = new NavPathStack(); + pathStack: NavPathStack = new NavPathStack(); build() { NavDestination() { - Navigation(this.pageInfos) { + Navigation(this.pathStack) { Column() { Row() { Text($r('app.string.confirm_order')) @@ -95,7 +95,6 @@ struct BindContentCoverDemo { bottom: $r('sys.float.padding_level6') }) - Row() { Button({ type: ButtonType.Circle }) { SymbolGlyph($r('sys.symbol.plus')) @@ -113,7 +112,7 @@ struct BindContentCoverDemo { .fontWeight(FontWeight.Medium) } .onClick(() => { - this.pageInfos.replacePath({ name: 'addPassengers' }); + this.pathStack.replacePath({ name: 'AddPassengers' }); }) .width(CommonConstants.FULL_PERCENT) .height($r('app.integer.button_height')) @@ -121,7 +120,6 @@ struct BindContentCoverDemo { .justifyContent(FlexAlign.Center) .backgroundColor($r('sys.color.comp_background_primary')) .borderRadius($r('sys.float.corner_radius_level6')) - } .padding({ right: this.curBp === 'lg' ? $r('sys.float.padding_level16') : $r('sys.float.padding_level8'), @@ -133,14 +131,14 @@ struct BindContentCoverDemo { .navBarWidth($r('app.integer.nav_bar_width')) .titleMode(NavigationTitleMode.Mini) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') } ).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets b/customdialoggatherslibrary/src/main/ets/component/BindSheetDemo.ets similarity index 84% rename from customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets rename to customdialoggatherslibrary/src/main/ets/component/BindSheetDemo.ets index 03ddcae..8737dc8 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/component/BindSheetDemo.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import { ConfigurationConstant } from '@kit.AbilityKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @@ -24,10 +23,8 @@ export function BindSheetDemoBuilder() { @Component struct BindSheetDemo { - @StorageProp(CommonConstants.AS_KEY_COLOR_MODE) currentMode: ConfigurationConstant.ColorMode = - ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State isShowSheet: boolean = false; private menuList: ResourceStr[] = [ @@ -58,8 +55,7 @@ struct BindSheetDemo { }, (item: string, index: number) => (item + index).toString()) } .borderRadius($r('sys.float.corner_radius_level8')) - .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth')) + .backgroundColor($r('app.color.month_day_background')) .margin({ top: $r('sys.float.corner_radius_level4'), right: $r('sys.float.corner_radius_level8'), @@ -74,8 +70,7 @@ struct BindSheetDemo { } .width(CommonConstants.FULL_PERCENT) .height(CommonConstants.FULL_PERCENT) - .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_secondary') : $r('sys.color.background_tertiary')) + .backgroundColor($r('app.color.bottom_bind_sheet_background')) } build() { @@ -115,8 +110,7 @@ struct BindSheetDemo { height: new BreakpointType({ sm: 320, md: 120, lg: 140 }).getValue(this.curBp), width: this.curBp === 'sm' ? '100%' : $r('app.integer.bind_sheet_width'), preferType: SheetType.CENTER, - backgroundColor: this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_secondary') : $r('sys.color.background_tertiary'), + backgroundColor: $r('app.color.bind_sheet_background'), onWillDisappear: () => { this.isShowSheet = !this.isShowSheet; } @@ -146,8 +140,8 @@ struct BindSheetDemo { .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + top: this.statusBarHeight, + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets b/customdialoggatherslibrary/src/main/ets/component/CalendarView.ets similarity index 90% rename from customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets rename to customdialoggatherslibrary/src/main/ets/component/CalendarView.ets index 0a5ae53..efdcc0e 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CalendarView.ets @@ -13,11 +13,11 @@ * limitations under the License. */ -import { CustomCalendarPickerDialog } from '../view/CustomCalendarPickerDialog'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; -import { getRealTimeDate } from '../viewmodel/GetDate'; +import { CustomCalendarPickerDialog } from '../view/CustomCalendarPickerDialog'; import { DateModel } from '../viewmodel/DateModel'; -import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { getRealTimeDate } from '../viewmodel/GetDate'; @Builder export function CalendarViewBuilder() { @@ -26,25 +26,17 @@ export function CalendarViewBuilder() { @Component export struct CalendarView { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; + @State currentMonth: number = 1; + @State currentDay: number = 1; + @State currentYear: number = 1; + @StorageLink(CommonConstants.AS_KEY_SELECTED_DATE) dateModel: DateModel = new DateModel(0, 0, 0, 0); pageInfos: NavPathStack = new NavPathStack(); private week: ResourceStr[] = [$r('app.string.sunday'), $r('app.string.monday'), $r('app.string.tuesday'), $r('app.string.wednesday'), $r('app.string.thursday'), $r('app.string.friday'), $r('app.string.saturday')]; - @State currentMonth: number = 1; - @State currentDay: number = 1; - @State currentYear: number = 1; - @StorageLink('custom_dialog_gathers_selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); - - aboutToAppear(): void { - this.dateModel = getRealTimeDate(); - this.currentMonth = this.dateModel.month; - this.currentDay = this.dateModel.day; - this.currentYear = this.dateModel.year; - } - dialogController: CustomDialogController = new CustomDialogController({ builder: CustomCalendarPickerDialog({ currentMonth: this.currentMonth, @@ -55,12 +47,17 @@ export struct CalendarView { alignment: this.curBp === 'sm' ? DialogAlignment.Bottom : DialogAlignment.Center, customStyle: true, maskColor: $r('sys.color.mask_fourth') - }) + }); + + aboutToAppear(): void { + this.dateModel = getRealTimeDate(); + this.currentMonth = this.dateModel.month; + this.currentDay = this.dateModel.day; + this.currentYear = this.dateModel.year; + } onCancel(): void { - if (this.dialogController != undefined) { - this.dialogController.close(); - } + this.dialogController?.close(); } getResourceString(resource: Resource): string { @@ -104,7 +101,7 @@ export struct CalendarView { .justifyContent(FlexAlign.Center) .width(CommonConstants.FULL_PERCENT) .onClick(() => { - this.dialogController.open(); + this.dialogController?.open(); }) Button($r('app.string.ticket_inquiry')) @@ -113,7 +110,7 @@ export struct CalendarView { .fontSize($r('sys.float.Subtitle_M')) .backgroundColor($r('sys.color.brand')) .onClick(() => { - this.pageInfos.replacePath({ name: 'defaultList' }); + this.pageInfos.replacePath({ name: 'QueryTicketList' }); }) } .width(CommonConstants.FULL_PERCENT) @@ -136,8 +133,8 @@ export struct CalendarView { .titleMode(NavigationTitleMode.Mini) .navBarWidth($r('app.integer.nav_bar_width')) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), - bottom: this.getUIContext().px2vp(this.bottomRectHeight) + top: this.statusBarHeight, + bottom: this.navigatorBarHeight }) } .hideTitleBar(true) diff --git a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets b/customdialoggatherslibrary/src/main/ets/component/CustomDialogGathersComponent.ets similarity index 91% rename from customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets rename to customdialoggatherslibrary/src/main/ets/component/CustomDialogGathersComponent.ets index 1d93f41..5231908 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersComponent.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CustomDialogGathersComponent.ets @@ -13,25 +13,25 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; import { TitleModel } from '../viewmodel/DateModel'; @Component export struct CustomDialogGathersComponent { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; + @Provide(CommonConstants.AS_KEY_PATH_STACK) pathStack: NavPathStack = new NavPathStack(); scroller: Scroller = new Scroller(); - pathStack: NavPathStack = new NavPathStack(); titleList: Array = [ new TitleModel($r('app.string.scroll_option'), 'ScrollOption'), new TitleModel($r('app.string.dialog_name'), 'BindContentCoverDemo'), - new TitleModel($r('app.string.bind_sheet_dialog'), 'BindSheet'), - new TitleModel($r('app.string.toast_dialog'), 'Toast'), + new TitleModel($r('app.string.bind_sheet_dialog'), 'BindSheetDemo'), + new TitleModel($r('app.string.toast_dialog'), 'CustomDialogUser'), new TitleModel($r('app.string.toast_private_dialog'), 'Privacy'), new TitleModel($r('app.string.full_screen'), 'FullScreen'), - new TitleModel($r('app.string.calendar_dialog'), 'CustomCalendar'), + new TitleModel($r('app.string.calendar_dialog'), 'CalendarView'), new TitleModel($r('app.string.two_level_dialog'), 'TwoLevelPageSheet') ]; @@ -106,4 +106,4 @@ export struct CustomDialogGathersComponent { .mode(NavigationMode.Stack) .backgroundColor($r('sys.color.background_secondary')) } -} +} \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets b/customdialoggatherslibrary/src/main/ets/component/CustomDialogUser.ets similarity index 88% rename from customdialoggatherslibrary/src/main/ets/pages/Toast.ets rename to customdialoggatherslibrary/src/main/ets/component/CustomDialogUser.ets index d556f47..19f43a5 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CustomDialogUser.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function CustomDialogUserBuilder() { @@ -43,8 +43,8 @@ struct CustomDialogExample { @Component struct CustomDialogUser { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State inputValue: ResourceStr = $r('app.string.click'); dialogController: CustomDialogController | null = new CustomDialogController({ @@ -85,12 +85,10 @@ struct CustomDialogUser { bottom: $r('sys.float.padding_level6') }) .onClick(() => { - if (this.dialogController != null) { - this.dialogController.open(); - setTimeout(() => { - this.dialogController?.close(); - }, 3000); - } + this.dialogController?.open(); + setTimeout(() => { + this.dialogController?.close(); + }, 3000); }) } .height(CommonConstants.FULL_PERCENT) @@ -105,13 +103,13 @@ struct CustomDialogUser { .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets b/customdialoggatherslibrary/src/main/ets/component/FullScreen.ets similarity index 94% rename from customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets rename to customdialoggatherslibrary/src/main/ets/component/FullScreen.ets index dbef694..363a618 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets +++ b/customdialoggatherslibrary/src/main/ets/component/FullScreen.ets @@ -14,8 +14,8 @@ */ import { curves } from '@kit.ArkUI'; -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function FullScreenBuilder() { @@ -26,8 +26,8 @@ export function FullScreenBuilder() { struct FullScreen { private positionY: number = 0; @State translateY: string | number = '110%'; - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; build() { @@ -64,8 +64,8 @@ struct FullScreen { .mode(NavigationMode.Stack) .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + top: this.statusBarHeight, + bottom: this.navigatorBarHeight, }) RelativeContainer() { @@ -97,7 +97,7 @@ struct FullScreen { .height($r('app.integer.button_height_small')) .aspectRatio(1) .margin({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level8'), md: $r('sys.float.padding_level12'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets b/customdialoggatherslibrary/src/main/ets/component/Privacy.ets similarity index 87% rename from customdialoggatherslibrary/src/main/ets/pages/Privacy.ets rename to customdialoggatherslibrary/src/main/ets/component/Privacy.ets index d144ed6..109e4a4 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets +++ b/customdialoggatherslibrary/src/main/ets/component/Privacy.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function PrivacyBuilder() { @@ -24,8 +24,8 @@ export function PrivacyBuilder() { @Component struct Privacy { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); dialogController: CustomDialogController | null = new CustomDialogController({ @@ -90,13 +90,13 @@ struct Privacy { .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), @@ -111,8 +111,8 @@ struct Privacy { @CustomDialog struct PrivacyDialog { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) topRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) bottomRectHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; dialogController?: CustomDialogController; cancel: () => void = () => { @@ -139,11 +139,6 @@ struct PrivacyDialog { type: TextDecorationType.Underline, color: $r('sys.color.font_emphasize') }) - .onClick(() => { - if (this.dialogController != undefined) { - this.dialogController.close(); - } - }) Span($r('app.string.word2')) } .fontSize($r('sys.float.Body_L')) @@ -156,9 +151,7 @@ struct PrivacyDialog { }) .width(CommonConstants.FORTY_PERCENT) .onClick(() => { - if (this.dialogController != undefined) { - this.dialogController.close(); - } + this.dialogController?.close(); }) Divider() @@ -171,9 +164,7 @@ struct PrivacyDialog { buttonStyle: ButtonStyleMode.TEXTUAL }) .onClick(() => { - if (this.dialogController != undefined) { - this.dialogController.close(); - } + this.dialogController?.close(); }) .width(CommonConstants.FORTY_PERCENT) } diff --git a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets b/customdialoggatherslibrary/src/main/ets/component/ScrollOption.ets similarity index 93% rename from customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets rename to customdialoggatherslibrary/src/main/ets/component/ScrollOption.ets index f2710e8..19249c8 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets +++ b/customdialoggatherslibrary/src/main/ets/component/ScrollOption.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function ScrollOptionBuilder() { @@ -23,8 +23,8 @@ export function ScrollOptionBuilder() { @Component struct ScrollOption { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private selectTime: Date = new Date('2024-4-17T18:30:00'); @State select: number = 2; @@ -83,13 +83,13 @@ struct ScrollOption { .mode(NavigationMode.Stack) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), diff --git a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets b/customdialoggatherslibrary/src/main/ets/component/TwoLevelPageSheet.ets similarity index 90% rename from customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets rename to customdialoggatherslibrary/src/main/ets/component/TwoLevelPageSheet.ets index dec4d71..a3d4ac6 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/component/TwoLevelPageSheet.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function TwoLevelPageSheetBuilder() { @@ -23,8 +23,8 @@ export function TwoLevelPageSheetBuilder() { @Component struct TwoLevelPageSheet { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State isShow: boolean = false @State isShow2: boolean = false @@ -71,7 +71,7 @@ struct TwoLevelPageSheet { }) } .margin({ - bottom: this.curBp === BreakpointTypeEnum.LG && this.getUIContext().px2vp(this.bottomRectHeight) === 0 ? + bottom: this.curBp === BreakpointTypeEnum.LG && this.navigatorBarHeight === 0 ? $r('sys.float.padding_level12') : $r('sys.float.padding_level6') }) } @@ -81,7 +81,7 @@ struct TwoLevelPageSheet { .padding({ top: $r('app.integer.padding_max'), right: $r('sys.float.padding_level8'), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: $r('sys.float.padding_level8') }) } @@ -104,7 +104,7 @@ struct TwoLevelPageSheet { .height($r('app.integer.button_height_small')) .backgroundColor($r('sys.color.brand')) .margin({ - bottom: this.curBp === BreakpointTypeEnum.LG && this.getUIContext().px2vp(this.bottomRectHeight) === 0 ? + bottom: this.curBp === BreakpointTypeEnum.LG && this.navigatorBarHeight === 0 ? $r('sys.float.padding_level12') : $r('sys.float.padding_level6') }) .onClick(() => { @@ -118,7 +118,7 @@ struct TwoLevelPageSheet { .padding({ top: $r('app.integer.padding_max'), right: this.curBp === 'sm' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level0'), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level0') }) } @@ -158,13 +158,13 @@ struct TwoLevelPageSheet { .titleMode(NavigationTitleMode.Mini) .mode(NavigationMode.Stack) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), diff --git a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets index 2665185..52ea92d 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { display, window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; +import { display, window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { CommonConstants } from '../common/constants/CommonConstants'; @@ -73,6 +73,7 @@ export class BreakpointSystem { private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.SM; private constructor() { + AppStorage.setOrCreate(CommonConstants.AS_KEY_BREAK_POINT, this.currentBreakpoint); } public static getInstance(): BreakpointSystem { diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 3840e6d..56775cf 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -13,85 +13,69 @@ * limitations under the License. */ -import { common } from '@kit.AbilityKit'; import type { BusinessError } from '@kit.BasicServicesKit'; -import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { ConfigurationConstant, Configuration } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; import { BreakpointSystem } from './BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; const TAG: string = '[WindowUtil]'; export class WindowUtil { - public static requestFullScreen(windowStage: window.WindowStage): void { - windowStage.getMainWindow((err: BusinessError, data: window.Window) => { - if (err.code) { - return; - } - const windowClass: window.Window = data; - // Realize the immersive effect. - try { - const promise: Promise = windowClass.setWindowLayoutFullScreen(true); - promise.then(() => { - hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); - }).catch((err: BusinessError) => { - hilog.info(0x0000, TAG, - `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); - }); - } catch { - hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. '); - } - }); - } + private static windowClass: window.Window; - public static registerBreakPoint(windowStage: window.WindowStage) { - windowStage.getMainWindow((err: BusinessError, data: window.Window) => { - if (err.code) { - hilog.error(0x0000, TAG, `Failed to get main window: ${err.message}`); - return; - } - BreakpointSystem.getInstance().updateWidthBp(data); - WindowUtil.updateAvoidArea(data); - data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data)); - data.on('avoidAreaChange', (avoidAreaOption) => { - if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || - avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { - WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); - } - }); - }) + public static initialize(windowStage: window.WindowStage): void { + try { + WindowUtil.windowClass = windowStage.getMainWindowSync(); + WindowUtil.requestFullScreen(); + WindowUtil.registerBreakPoint(); + } catch (err) { + hilog.error(0x0000, TAG, `WindowUtil initialize Failed. Cause: ${err.message}`); + } } - public static updateAvoidArea(windowObj: window.Window) { - let type = window.AvoidAreaType.TYPE_SYSTEM; - let avoidArea = windowObj.getWindowAvoidArea(type); - WindowUtil.setAvoidArea(type, avoidArea); - type = window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR; - avoidArea = windowObj.getWindowAvoidArea(type); - WindowUtil.setAvoidArea(type, avoidArea); + private static requestFullScreen(): void { + // Realize the immersive effect. + try { + const promise: Promise = WindowUtil.windowClass.setWindowLayoutFullScreen(true); + promise.then(() => { + hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); + }).catch((err: BusinessError) => { + hilog.info(0x0000, TAG, + `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); + }); + } catch { + hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. '); + } } - // Get status bar height and indicator height. - public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { - if (type === window.AvoidAreaType.TYPE_SYSTEM) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_TOP_HEIGHT, area.topRect.height); - } else { - AppStorage.setOrCreate(CommonConstants.AS_KEY_BOTTOM_HEIGHT, area.bottomRect.height); - } + private static registerBreakPoint() { + BreakpointSystem.getInstance().updateWidthBp(WindowUtil.windowClass); + WindowUtil.updateAvoidArea(WindowUtil.windowClass); + WindowUtil.windowClass.on('windowSizeChange', + () => BreakpointSystem.getInstance().onWindowSizeChange(WindowUtil.windowClass)); + WindowUtil.windowClass.on('avoidAreaChange', (avoidAreaOption) => { + if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || + avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); + } + }); } - public static initColorMode(context: common.UIAbilityContext): void { - AppStorage.setOrCreate(CommonConstants.AS_KEY_COLOR_MODE, context.config.colorMode); - context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + private static updateAvoidArea(windowObj: window.Window) { + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_SYSTEM, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM)); + WindowUtil.setAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, + windowObj.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)); } - public static updatedColorMode(newConfig: Configuration): void { - let newColorMode: ConfigurationConstant.ColorMode = - newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get(CommonConstants.AS_KEY_COLOR_MODE); - if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate(CommonConstants.AS_KEY_COLOR_MODE, newColorMode); + // Get status bar height and indicator height. + private static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) { + let uiContext = WindowUtil.windowClass.getUIContext(); + if (type === window.AvoidAreaType.TYPE_SYSTEM) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT, uiContext.px2vp(area.topRect.height)); + } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { + AppStorage.setOrCreate(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT, uiContext.px2vp(area.bottomRect.height)); } } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets index 25e0fa9..7ec8858 100644 --- a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets +++ b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets @@ -13,13 +13,13 @@ * limitations under the License. */ -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { PersonList, personList } from '../viewmodel/BindContentModel'; -import { CommonConstants } from '../common/constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; +import { PersonList, personList } from '../viewmodel/BindContentModel'; -const TAG = '[getResourceString]'; +const TAG = '[AddPassengers]'; @Builder export function AddPassengersBuilder() { @@ -28,8 +28,8 @@ export function AddPassengersBuilder() { @Component export struct AddPassengers { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private personList: Array = personList; @@ -175,7 +175,7 @@ export struct AddPassengers { md: $r('sys.float.padding_level0'), lg: $r('sys.float.padding_level2') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level0'), diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index 7ae14ba..2a52b51 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -13,20 +13,17 @@ * limitations under the License. */ -import { ConfigurationConstant } from '@kit.AbilityKit'; -import { MonthDataSource, Month } from '../viewmodel/MonthDataSource'; +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; import { DataManager } from '../viewmodel/DataManager'; -import { getMonthDate } from '../viewmodel/GetDate'; import { DateModel } from '../viewmodel/DateModel'; -import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { getMonthDate } from '../viewmodel/GetDate'; +import { MonthDataSource, Month } from '../viewmodel/MonthDataSource'; @CustomDialog export struct CustomCalendarPickerDialog { - @StorageProp(CommonConstants.AS_KEY_COLOR_MODE) - currentMode: ConfigurationConstant.ColorMode = ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT; - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; @State contentData: MonthDataSource = new MonthDataSource(); @State nextMonth: number = 1; @@ -36,13 +33,13 @@ export struct CustomCalendarPickerDialog { @Link currentMonth: number; @Link currentDay: number; @Link currentYear: number; - @StorageLink('custom_dialog_gathers_selectedDate') dateModel: DateModel = new DateModel(0, 0, 0, 0); + @StorageLink(CommonConstants.AS_KEY_SELECTED_DATE) dateModel: DateModel = new DateModel(0, 0, 0, 0); controller: CustomDialogController; cancel: () => void = () => { }; private week: ResourceStr[] = - [$r('app.string.ri'), $r('app.string.yi'), $r('app.string.er'), $r('app.string.san'), $r('app.string.si'), - $r('app.string.wu'), $r('app.string.liu')]; + [$r("app.string.sun"), $r("app.string.mon"), $r("app.string.tue"), $r("app.string.wed"), $r("app.string.thu"), + $r("app.string.fri"), $r("app.string.sat")]; getResourceString(resource: Resource): string { let resourceString: string = ''; @@ -71,6 +68,8 @@ export struct CustomCalendarPickerDialog { ] this.contentData.pushData(months); this.initialIndex = this.dateModel.month > this.currentMonth ? 1 : 0; + console.log('month:' + this.dateModel.month + ' day:' + this.dateModel.day + ' ==== ' + + JSON.stringify(this.contentData.getData(0))) } @Builder @@ -149,9 +148,7 @@ export struct CustomCalendarPickerDialog { .width($r('app.float.calendar_height')) .borderRadius($r('sys.float.corner_radius_level2')) .backgroundColor(day === this.dateModel.day && monthItem.num === - this.dateModel.month ? $r('sys.color.font_emphasize') : - (this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth'))) + this.dateModel.month ? $r('sys.color.font_emphasize') : $r('app.color.month_day_background')) .opacity(day === CommonConstants.ZERO ? CommonConstants.ZERO : CommonConstants.JANUARY) .onClick(() => { if (day >= this.currentDay || monthItem.num > this.currentMonth) { @@ -167,7 +164,7 @@ export struct CustomCalendarPickerDialog { this.controller.close(); } }) - }, (day: number) => day.toString()) + }, (day: number, index: number) => (day + index).toString()) } .columnsTemplate(CommonConstants.GRID_SEVEN) .rowsTemplate(monthItem.days.length > CommonConstants.MONTH_NUMBER ? @@ -231,8 +228,7 @@ export struct CustomCalendarPickerDialog { .width(this.curBp === 'sm' ? '100%' : $r('app.integer.bind_sheet_width')) .height($r('app.integer.bind_sheet_width')) .borderRadius($r('sys.float.corner_radius_level12')) - .backgroundColor(this.currentMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT ? - $r('sys.color.background_primary') : $r('sys.color.background_fourth')) + .backgroundColor($r('app.color.month_day_background')) .alignItems(HorizontalAlign.Center) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/pages/Details.ets b/customdialoggatherslibrary/src/main/ets/view/Details.ets similarity index 88% rename from customdialoggatherslibrary/src/main/ets/pages/Details.ets rename to customdialoggatherslibrary/src/main/ets/view/Details.ets index 9750952..4ceb4d2 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Details.ets +++ b/customdialoggatherslibrary/src/main/ets/view/Details.ets @@ -13,19 +13,18 @@ * limitations under the License. */ -import { CommonConstants } from '../common/constants/CommonConstants'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; @Builder export function DetailsBuilder() { Details(); } -@Entry @Component struct Details { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; pathStack: NavPathStack = new NavPathStack(); @@ -61,13 +60,13 @@ struct Details { .hideBackButton(true) .backgroundColor($r('sys.color.background_secondary')) .padding({ - top: this.getUIContext().px2vp(this.topRectHeight), + top: this.statusBarHeight, right: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), lg: $r('sys.float.padding_level8') }).getValue(this.curBp), - bottom: this.getUIContext().px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: new BreakpointType({ sm: $r('sys.float.padding_level0'), md: $r('sys.float.padding_level4'), @@ -76,6 +75,6 @@ struct Details { }) } .hideTitleBar(true) - .padding({ top: this.getUIContext().px2vp(this.topRectHeight) }) + .padding({ top: this.statusBarHeight }) } } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets b/customdialoggatherslibrary/src/main/ets/view/QueryTicketList.ets similarity index 91% rename from customdialoggatherslibrary/src/main/ets/view/DefaultList.ets rename to customdialoggatherslibrary/src/main/ets/view/QueryTicketList.ets index 1073907..1655549 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/QueryTicketList.ets @@ -13,22 +13,22 @@ * limitations under the License. */ -import { hilog } from '@kit.PerformanceAnalysisKit'; -import { CommonConstants } from '../common/constants/CommonConstants'; import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; +import { CommonConstants } from '../common/constants/CommonConstants'; -const TAG = '[getResourceString]'; +const TAG = '[QueryTicketList]'; @Builder export function DefaultListBuilder() { - DefaultList() + QueryTicketList() } @Component -export struct DefaultList { - @StorageLink(CommonConstants.AS_KEY_TOP_HEIGHT) topRectHeight: number = 0; - @StorageLink(CommonConstants.AS_KEY_BOTTOM_HEIGHT) bottomRectHeight: number = 0; +export struct QueryTicketList { + @StorageLink(CommonConstants.AS_KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0; + @StorageLink(CommonConstants.AS_KEY_NAVIGATOR_BAR_HEIGHT) navigatorBarHeight: number = 0; @StorageLink(CommonConstants.AS_KEY_BREAK_POINT) curBp: string = BreakpointTypeEnum.SM; private defaultListData: Array = [1, 2, 3, 4, 5]; diff --git a/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets b/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets index e6c9167..ba2b996 100644 --- a/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets +++ b/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets @@ -14,32 +14,17 @@ */ import { preferences } from '@kit.ArkData'; +import { CommonConstants } from '../common/constants/CommonConstants'; import { DateModel } from './DateModel'; export class DataManager { - static setDate(context: Context, dateModel: DateModel, callback: () => void) { + static setDate(context: Context, dateModel: DateModel, callback: () => void): void { try { - let promise = preferences.getPreferences(context, 'date'); - promise.then((object: preferences.Preferences) => { - try { - let setPromise = object.put('selectedDate', JSON.stringify(dateModel)); - setPromise.then(() => { - let flushPromise = object.flush(); - flushPromise.then(() => { - AppStorage.setOrCreate('selectedDate', dateModel); - callback(); - }).catch(() => { - callback(); - }) - }).catch(() => { - callback(); - }) - } catch (err) { - callback(); - } - }).catch(() => { - callback(); - }) + let preferObj = preferences.getPreferencesSync(context, { name: 'date' }); + preferObj.putSync(CommonConstants.AS_KEY_SELECTED_DATE, JSON.stringify(dateModel)); + preferObj.flush(); + AppStorage.setOrCreate(CommonConstants.AS_KEY_SELECTED_DATE, dateModel); + callback(); } catch (err) { callback(); } diff --git a/customdialoggatherslibrary/src/main/resources/base/element/color.json b/customdialoggatherslibrary/src/main/resources/base/element/color.json index 3c71296..438ec33 100644 --- a/customdialoggatherslibrary/src/main/resources/base/element/color.json +++ b/customdialoggatherslibrary/src/main/resources/base/element/color.json @@ -1,8 +1,16 @@ { "color": [ { - "name": "start_window_background", + "name": "month_day_background", "value": "#FFFFFF" + }, + { + "name": "bind_sheet_background", + "value": "#F1F3F5" + }, + { + "name": "bottom_bind_sheet_background", + "value": "#F1F3F5" } ] } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/resources/base/element/string.json b/customdialoggatherslibrary/src/main/resources/base/element/string.json index 767984c..b156309 100644 --- a/customdialoggatherslibrary/src/main/resources/base/element/string.json +++ b/customdialoggatherslibrary/src/main/resources/base/element/string.json @@ -1,32 +1,20 @@ { "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "自定义弹窗集合" - }, { "name": "departure", - "value": "北京" + "value": "beijing" }, { "name": "destination", - "value": "上海" + "value": "shanghai" }, { "name": "ticket_inquiry", - "value": "查询车票" + "value": "Ticket Inquiry" }, { "name": "departure_date", - "value": "出发日期" + "value": "Departure date" }, { "name": "week_width", @@ -34,7 +22,7 @@ }, { "name": "button_scroll_option1", - "value": "TimePickerDialog 12小时制" + "value": "TimePickerDialog 12 hour clock" }, { "name": "button_scroll_option2", @@ -42,27 +30,27 @@ }, { "name": "index_name", - "value": "自定义弹窗合集" + "value": "Custom pop-up window collection" }, { "name": "scroll_option", - "value": "滑动选择弹窗" + "value": "Sliding selection popup" }, { "name": "select_person", - "value": "选择乘车人" + "value": "Choose a rider" }, { "name": "add_person", - "value": "添加乘车人" + "value": "Add passengers" }, { "name": "confirmed", - "value": "确认" + "value": "Confirm" }, { "name": "confirm_order", - "value": "确认订单" + "value": "Confirm Order" }, { "name": "start_time", @@ -70,7 +58,7 @@ }, { "name": "start_string", - "value": "始发站" + "value": "Departure" }, { "name": "car_name", @@ -78,7 +66,7 @@ }, { "name": "car_time", - "value": "8时1分" + "value": "8:01" }, { "name": "end_time", @@ -86,71 +74,71 @@ }, { "name": "end_name", - "value": "终点站" + "value": "Terminal" }, { "name": "button_select", - "value": "选择乘车人" + "value": "Choose a rider" }, { "name": "dialog_name", - "value": "模态弹窗" + "value": "Modal pop-up window" }, { "name": "tastes", - "value": "口味与餐具" + "value": "Taste and tableware" }, { "name": "choose_flavors", - "value": "选择点餐口味和餐具" + "value": "Choose flavors and cutlery" }, { "name": "bind_sheet_dialog", - "value": "半模态弹窗" + "value": "Semi-modal pop-up window" }, { "name": "login", - "value": "登录成功 !" + "value": "Login successfully !" }, { "name": "toast_dialog", - "value": "Toast弹窗" + "value": "Toast pop-up window" }, { "name": "button_name1", - "value": "隐私弹窗" + "value": "Privacy popup" }, { "name": "button_name2", - "value": "温馨提示(示例)" + "value": "Kind Tips(Example)" }, { "name": "two_level_dialog", - "value": "两级半模态+全屏弹窗" + "value": "Two semi-modal + full-screen window" }, { "name": "toast_text", - "value": "《隐私政策》" + "value": "Privacy Policy" }, { "name": "disagree", - "value": "不同意" + "value": "Disagree" }, { "name": "agreed", - "value": "同意" + "value": "Agree" }, { "name": "toast_private_dialog", - "value": "隐私协议弹窗(示例)" + "value": "Privacy Agreement pop-up window(Example)" }, { "name": "full_screen", - "value": "全屏弹窗" + "value": "Full screen pop-up window" }, { "name": "calendar_dialog", - "value": "自定义日历选择器弹窗" + "value": "Custom calendar picker popup" }, { "name": "button_one", @@ -174,147 +162,147 @@ }, { "name": "wang", - "value": "王**" + "value": "wang**" }, { "name": "song", - "value": "宋*" + "value": "song*" }, { "name": "xu", - "value": "许**" + "value": "xu**" }, { "name": "tang", - "value": "唐*" + "value": "tang*" }, { "name": "spicy", - "value": "少放辣" + "value": "Less spicy" }, { "name": "spicy1", - "value": "不需要辣" + "value": "No need for spicy" }, { "name": "spicy2", - "value": "需要一次性餐具" + "value": "Need disposable cutlery" }, { "name": "spicy3", - "value": "多放辣" + "value": "Extra spicy" }, { "name": "spicy4", - "value": "不要香菜" + "value": "No cilantro" }, { "name": "spicy5", - "value": "不要一次性餐具" + "value": "No disposable utensils" }, { "name": "click", - "value": "点击Toast" + "value": "Click Toast" }, { "name": "back", - "value": "返回" + "value": "Back" }, { "name": "word1", - "value": "根据《常见类型移动互联网应用程序必要个人信息范围规定》,主要功能为购买商品,必要个人信息为:注册用户电话号码;收货人姓名、地址、联系电话;支付时间、支付金额、支付渠道等。请您在使用我们的服务前仔细阅读" + "value": "According to the Provisions on the Scope of Necessary Personal Information for Common Types of Mobile Internet Applications, the main function is to purchase goods, and the necessary personal information is: telephone number of registered users; Name, address and telephone number of the consignee; Payment time, payment amount, payment channel, etc. Please read carefully before using our services" }, { "name": "word2", - "value": "。请您知悉,同意隐私政策仅代表您已了解应用提供功能,以及功能运行所需的必要个人信息。基于您的授权我们可能会获取您的位置等信息,您有权拒绝或取消授权;我们会采取业界先进的安全措施保护您的信息安全;未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;您可以查询、更正、删除您的个人信息" + "value": ". Please note that agreeing to the Privacy policy only means that you have understood the functions provided by the App and the necessary personal information required for the function to operate. Based on your authorization, we may obtain your location and other information, and you have the right to refuse or cancel the authorization; We will take the industry's advanced security measures to protect your information security; We will not obtain, share or provide your information from third parties without your consent; You can query, correct and delete your personal information" }, { - "name": "ri", - "value": "日" + "name": "sun", + "value": "Sun" }, { - "name": "yi", - "value": "一" + "name": "mon", + "value": "Mon" }, { - "name": "er", - "value": "二" + "name": "tue", + "value": "Tue" }, { - "name": "san", - "value": "三" + "name": "wed", + "value": "Wed" }, { - "name": "si", - "value": "四" + "name": "thu", + "value": "Thu" }, { - "name": "wu", - "value": "五" + "name": "fri", + "value": "Fri" }, { - "name": "liu", - "value": "六" + "name": "sat", + "value": "Sat" }, { "name": "year", - "value": "年" + "value": "year" }, { "name": "month", - "value": "月" + "value": "month" }, { "name": "day", - "value": "日" + "value": "day" }, { "name": "sunday", - "value": "星期日" + "value": "Sunday" }, { "name": "monday", - "value": "星期一" + "value": "Monday" }, { "name": "tuesday", - "value": "星期二" + "value": "Tuesday" }, { "name": "wednesday", - "value": "星期三" + "value": "Wednesday" }, { "name": "thursday", - "value": "星期四" + "value": "Thursday" }, { "name": "friday", - "value": "星期五" + "value": "Friday" }, { "name": "saturday", - "value": "星期六" + "value": "Saturday" }, { "name": "privacy_details", - "value": "隐私详情" + "value": "Privacy Details" }, { "name": "please_enter", - "value": "请输入......" + "value": "Please enter......" }, { "name": "passenger", - "value": "乘车人" + "value": "Passenger" }, { "name": "select", - "value": "选择" + "value": "Select" }, { "name": "ticket_list", - "value": "车票列表" + "value": "Ticket List" } ] } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/resources/base/profile/router_map.json b/customdialoggatherslibrary/src/main/resources/base/profile/router_map.json index 2e0ce77..d0b1bf2 100644 --- a/customdialoggatherslibrary/src/main/resources/base/profile/router_map.json +++ b/customdialoggatherslibrary/src/main/resources/base/profile/router_map.json @@ -2,58 +2,58 @@ "routerMap": [ { "name": "BindContentCoverDemo", - "pageSourceFile": "src/main/ets/pages/BindContentCoverDemo.ets", + "pageSourceFile": "src/main/ets/component/BindContentCoverDemo.ets", "buildFunction": "BindContentCoverDemoBuilder" }, { - "name": "BindSheet", - "pageSourceFile": "src/main/ets/pages/BindSheet.ets", + "name": "BindSheetDemo", + "pageSourceFile": "src/main/ets/component/BindSheetDemo.ets", "buildFunction": "BindSheetDemoBuilder" }, { - "name": "CustomCalendar", - "pageSourceFile": "src/main/ets/pages/CustomCalendar.ets", + "name": "CalendarView", + "pageSourceFile": "src/main/ets/component/CalendarView.ets", "buildFunction": "CalendarViewBuilder" }, { - "name": "Details", - "pageSourceFile": "src/main/ets/pages/Details.ets", - "buildFunction": "DetailsBuilder" + "name": "CustomDialogUser", + "pageSourceFile": "src/main/ets/component/CustomDialogUser.ets", + "buildFunction": "CustomDialogUserBuilder" }, { "name": "FullScreen", - "pageSourceFile": "src/main/ets/pages/FullScreen.ets", + "pageSourceFile": "src/main/ets/component/FullScreen.ets", "buildFunction": "FullScreenBuilder" }, { "name": "Privacy", - "pageSourceFile": "src/main/ets/pages/Privacy.ets", + "pageSourceFile": "src/main/ets/component/Privacy.ets", "buildFunction": "PrivacyBuilder" }, { "name": "ScrollOption", - "pageSourceFile": "src/main/ets/pages/ScrollOption.ets", + "pageSourceFile": "src/main/ets/component/ScrollOption.ets", "buildFunction": "ScrollOptionBuilder" }, - { - "name": "Toast", - "pageSourceFile": "src/main/ets/pages/Toast.ets", - "buildFunction": "CustomDialogUserBuilder" - }, { "name": "TwoLevelPageSheet", - "pageSourceFile": "src/main/ets/pages/TwoLevelPageSheet.ets", + "pageSourceFile": "src/main/ets/component/TwoLevelPageSheet.ets", "buildFunction": "TwoLevelPageSheetBuilder" }, { - "name": "addPassengers", + "name": "AddPassengers", "pageSourceFile": "src/main/ets/view/AddPassengers.ets", "buildFunction": "AddPassengersBuilder" }, { - "name": "defaultList", - "pageSourceFile": "src/main/ets/view/DefaultList.ets", + "name": "QueryTicketList", + "pageSourceFile": "src/main/ets/view/QueryTicketList.ets", "buildFunction": "DefaultListBuilder" + }, + { + "name": "Details", + "pageSourceFile": "src/main/ets/view/Details.ets", + "buildFunction": "DetailsBuilder" } ] } \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/resources/dark/element/color.json b/customdialoggatherslibrary/src/main/resources/dark/element/color.json new file mode 100644 index 0000000..ebeb4b5 --- /dev/null +++ b/customdialoggatherslibrary/src/main/resources/dark/element/color.json @@ -0,0 +1,20 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "month_day_background", + "value": "#2E3033" + }, + { + "name": "bind_sheet_background", + "value": "#000000" + }, + { + "name": "bottom_bind_sheet_background", + "value": "#202224" + } + ] +} \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/resources/en_US/element/string.json b/customdialoggatherslibrary/src/main/resources/en_US/element/string.json index 206c8ed..b156309 100644 --- a/customdialoggatherslibrary/src/main/resources/en_US/element/string.json +++ b/customdialoggatherslibrary/src/main/resources/en_US/element/string.json @@ -1,17 +1,5 @@ { "string": [ - { - "name": "module_desc", - "value": "module description" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "Customized pop-up window set" - }, { "name": "departure", "value": "beijing" @@ -152,6 +140,26 @@ "name": "calendar_dialog", "value": "Custom calendar picker popup" }, + { + "name": "button_one", + "value": "open sheet1" + }, + { + "name": "button_two", + "value": "close sheet1" + }, + { + "name": "button_three", + "value": "open sheet2" + }, + { + "name": "button_four", + "value": "close sheet2" + }, + { + "name": "button_five", + "value": "close sheet1 sheet2" + }, { "name": "wang", "value": "wang**" @@ -209,31 +217,31 @@ "value": ". Please note that agreeing to the Privacy policy only means that you have understood the functions provided by the App and the necessary personal information required for the function to operate. Based on your authorization, we may obtain your location and other information, and you have the right to refuse or cancel the authorization; We will take the industry's advanced security measures to protect your information security; We will not obtain, share or provide your information from third parties without your consent; You can query, correct and delete your personal information" }, { - "name": "ri", + "name": "sun", "value": "Sun" }, { - "name": "yi", + "name": "mon", "value": "Mon" }, { - "name": "er", + "name": "tue", "value": "Tue" }, { - "name": "san", + "name": "wed", "value": "Wed" }, { - "name": "si", + "name": "thu", "value": "Thu" }, { - "name": "wu", + "name": "fri", "value": "Fri" }, { - "name": "liu", + "name": "sat", "value": "Sat" }, { diff --git a/customdialoggatherslibrary/src/main/resources/zh_CN/element/string.json b/customdialoggatherslibrary/src/main/resources/zh_CN/element/string.json index 696ea65..2b66883 100644 --- a/customdialoggatherslibrary/src/main/resources/zh_CN/element/string.json +++ b/customdialoggatherslibrary/src/main/resources/zh_CN/element/string.json @@ -1,17 +1,5 @@ { "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "自定义弹窗集合" - }, { "name": "departure", "value": "北京" @@ -152,6 +140,26 @@ "name": "calendar_dialog", "value": "自定义日历选择器弹窗" }, + { + "name": "button_one", + "value": "打开sheet1" + }, + { + "name": "button_two", + "value": "关闭sheet1" + }, + { + "name": "button_three", + "value": "打开sheet2" + }, + { + "name": "button_four", + "value": "关闭sheet2" + }, + { + "name": "button_five", + "value": "关闭sheet1 sheet2" + }, { "name": "wang", "value": "王**" @@ -209,31 +217,31 @@ "value": "。请您知悉,同意隐私政策仅代表您已了解应用提供功能,以及功能运行所需的必要个人信息。基于您的授权我们可能会获取您的位置等信息,您有权拒绝或取消授权;我们会采取业界先进的安全措施保护您的信息安全;未经您同意,我们不会从第三方处获取、共享或向其提供您的信息;您可以查询、更正、删除您的个人信息" }, { - "name": "ri", + "name": "sun", "value": "日" }, { - "name": "yi", + "name": "mon", "value": "一" }, { - "name": "er", + "name": "tue", "value": "二" }, { - "name": "san", + "name": "wed", "value": "三" }, { - "name": "si", + "name": "thu", "value": "四" }, { - "name": "wu", + "name": "fri", "value": "五" }, { - "name": "liu", + "name": "sat", "value": "六" }, { diff --git a/customdialoggatherssample/obfuscation-rules.txt b/customdialoggatherssample/obfuscation-rules.txt index f8bf42a..e5df319 100644 --- a/customdialoggatherssample/obfuscation-rules.txt +++ b/customdialoggatherssample/obfuscation-rules.txt @@ -16,6 +16,6 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep # -keep-global-name: specifies names that you want to keep in the global scope --enable-property-obfuscation +# -enable-property-obfuscation -enable-toplevel-obfuscation -enable-export-obfuscation \ No newline at end of file diff --git a/customdialoggatherssample/oh-package.json5 b/customdialoggatherssample/oh-package.json5 index b2a3dc0..2d6d39a 100644 --- a/customdialoggatherssample/oh-package.json5 +++ b/customdialoggatherssample/oh-package.json5 @@ -6,6 +6,6 @@ "author": "", "license": "", "dependencies": { - "customdialoggatherslibrary": "file:../customdialoggatherslibrary" + "@ohos_samples/customdialoggatherslibrary": "file:../customdialoggatherslibrary" } } \ No newline at end of file diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index 8fb0e9d..6b7769c 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -13,19 +13,14 @@ * limitations under the License. */ -import { Configuration, UIAbility } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { CustomDialogGathersController } from 'customdialoggatherslibrary' +import { UIAbility } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary' export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - CustomDialogGathersController.initColorMode(this.context); - } - - onConfigurationUpdate(newConfig: Configuration): void { - CustomDialogGathersController.updateColorMode(newConfig); } onDestroy(): void { diff --git a/customdialoggatherssample/src/main/ets/pages/Index.ets b/customdialoggatherssample/src/main/ets/pages/Index.ets index b56b680..9f53726 100644 --- a/customdialoggatherssample/src/main/ets/pages/Index.ets +++ b/customdialoggatherssample/src/main/ets/pages/Index.ets @@ -13,7 +13,7 @@ * limitations under the License. */ -import { CustomDialogGathersComponent } from 'customdialoggatherslibrary' +import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary' @Entry @Component diff --git a/customdialoggatherssample/src/main/resources/base/element/color.json b/customdialoggatherssample/src/main/resources/base/element/color.json new file mode 100644 index 0000000..3c71296 --- /dev/null +++ b/customdialoggatherssample/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/customdialoggatherssample/src/main/resources/base/element/string.json b/customdialoggatherssample/src/main/resources/base/element/string.json new file mode 100644 index 0000000..8e0b54b --- /dev/null +++ b/customdialoggatherssample/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Customized pop-up window set" + } + ] +} \ No newline at end of file diff --git a/customdialoggatherslibrary/src/main/resources/base/media/background.png b/customdialoggatherssample/src/main/resources/base/media/background.png similarity index 100% rename from customdialoggatherslibrary/src/main/resources/base/media/background.png rename to customdialoggatherssample/src/main/resources/base/media/background.png diff --git a/customdialoggatherslibrary/src/main/resources/base/media/foreground.png b/customdialoggatherssample/src/main/resources/base/media/foreground.png similarity index 100% rename from customdialoggatherslibrary/src/main/resources/base/media/foreground.png rename to customdialoggatherssample/src/main/resources/base/media/foreground.png diff --git a/customdialoggatherslibrary/src/main/resources/base/media/layered_image.json b/customdialoggatherssample/src/main/resources/base/media/layered_image.json similarity index 100% rename from customdialoggatherslibrary/src/main/resources/base/media/layered_image.json rename to customdialoggatherssample/src/main/resources/base/media/layered_image.json diff --git a/customdialoggatherslibrary/src/main/resources/base/media/startIcon.png b/customdialoggatherssample/src/main/resources/base/media/startIcon.png similarity index 100% rename from customdialoggatherslibrary/src/main/resources/base/media/startIcon.png rename to customdialoggatherssample/src/main/resources/base/media/startIcon.png diff --git a/customdialoggatherssample/src/main/resources/en_US/element/string.json b/customdialoggatherssample/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..8e0b54b --- /dev/null +++ b/customdialoggatherssample/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Customized pop-up window set" + } + ] +} \ No newline at end of file diff --git a/customdialoggatherssample/src/main/resources/zh_CN/element/string.json b/customdialoggatherssample/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..10fff27 --- /dev/null +++ b/customdialoggatherssample/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "自定义弹窗集合" + } + ] +} \ No newline at end of file -- Gitee From 3953e652b9ba3b2e75c6052fda89df592f662813 Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 14 Jul 2025 14:14:14 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/CustomDialogGathersController.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets index 7d4ff28..7fe51d7 100644 --- a/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets +++ b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets @@ -13,8 +13,8 @@ * limitations under the License. */ -import { window } from "@kit.ArkUI"; -import { WindowUtil } from "./utils/WindowUtil"; +import { window } from '@kit.ArkUI'; +import { WindowUtil } from './utils/WindowUtil'; export class CustomDialogGathersController { public static initWindowConfig(windowStage: window.WindowStage): void { -- Gitee From 0642ecabce4465b8e8d1885bd29b54aff909291a Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 14 Jul 2025 16:00:34 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customdialoggatherslibrary/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customdialoggatherslibrary/README.md b/customdialoggatherslibrary/README.md index 1410751..837dc68 100644 --- a/customdialoggatherslibrary/README.md +++ b/customdialoggatherslibrary/README.md @@ -17,7 +17,7 @@ ohpm install @ohos_samples/customdialoggatherslibrary ``` { "dependencies": { - "@ohos_samples/customdialoggatherslibrary": "^1.0.0" + "@ohos_samples/customdialoggatherslibrary": "^1.0.1" } } ``` -- Gitee From b7a5ae19af8622e56e096d6c959564cc37fdb134 Mon Sep 17 00:00:00 2001 From: rekirt Date: Mon, 14 Jul 2025 17:27:40 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/view/CustomCalendarPickerDialog.ets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets index 2a52b51..777baaf 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -38,8 +38,8 @@ export struct CustomCalendarPickerDialog { cancel: () => void = () => { }; private week: ResourceStr[] = - [$r("app.string.sun"), $r("app.string.mon"), $r("app.string.tue"), $r("app.string.wed"), $r("app.string.thu"), - $r("app.string.fri"), $r("app.string.sat")]; + [$r('app.string.sun'), $r('app.string.mon'), $r('app.string.tue'), $r('app.string.wed'), $r('app.string.thu'), + $r('app.string.fri'), $r('app.string.sat')]; getResourceString(resource: Resource): string { let resourceString: string = ''; -- Gitee From d19b59295bbbccd54e8bbf29e0d764e81f99ac80 Mon Sep 17 00:00:00 2001 From: rekirt Date: Tue, 15 Jul 2025 17:32:14 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customdialoggatherslibrary/CHANGELOG.md | 12 ++---------- customdialoggatherslibrary/README.md | 4 ++-- customdialoggatherslibrary/oh-package.json5 | 2 +- .../src/main/ets/utils/WindowUtil.ets | 10 +++------- .../src/main/ets/entryability/EntryAbility.ets | 3 ++- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/customdialoggatherslibrary/CHANGELOG.md b/customdialoggatherslibrary/CHANGELOG.md index 81aa6c4..96c7a27 100644 --- a/customdialoggatherslibrary/CHANGELOG.md +++ b/customdialoggatherslibrary/CHANGELOG.md @@ -1,14 +1,6 @@ # 版本记录 -## 1.0.1(2025.07.10) +## 1.0.0(2025.07.10) --- ### Initial -- 初始版本 - -## 1.0.1(2025.07.10) - ---- -### Bugfix -- 适配鸿蒙世界UX -- 规范化导出类 -- 修复已知bug \ No newline at end of file +- 初始版本 \ No newline at end of file diff --git a/customdialoggatherslibrary/README.md b/customdialoggatherslibrary/README.md index 837dc68..fe679e9 100644 --- a/customdialoggatherslibrary/README.md +++ b/customdialoggatherslibrary/README.md @@ -17,7 +17,7 @@ ohpm install @ohos_samples/customdialoggatherslibrary ``` { "dependencies": { - "@ohos_samples/customdialoggatherslibrary": "^1.0.1" + "@ohos_samples/customdialoggatherslibrary": "^1.0.0" } } ``` @@ -29,7 +29,7 @@ import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggathersl ``` 按需在文件中使用导出模块即可,其中CustomDialogGathersComponent是整个sample的入口页面。示例如下: ``` -// Page.ets +// Index.ets import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary'; Stack() { CustomDialogGathersComponent() diff --git a/customdialoggatherslibrary/oh-package.json5 b/customdialoggatherslibrary/oh-package.json5 index cf2be24..35946a5 100644 --- a/customdialoggatherslibrary/oh-package.json5 +++ b/customdialoggatherslibrary/oh-package.json5 @@ -1,6 +1,6 @@ { "name": "@ohos_samples/customdialoggatherslibrary", - "version": "1.0.1", + "version": "1.0.0", "description": "This sample uses CustomDialog, bindContentCover, and bindSheet to implement multiple custom dialog pop-ups.", "main": "Index.ets", "author": "@ohos_samples", diff --git a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets index 56775cf..3be068b 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -41,7 +41,7 @@ export class WindowUtil { promise.then(() => { hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.'); }).catch((err: BusinessError) => { - hilog.info(0x0000, TAG, + hilog.error(0x0000, TAG, `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`); }); } catch { @@ -54,12 +54,8 @@ export class WindowUtil { WindowUtil.updateAvoidArea(WindowUtil.windowClass); WindowUtil.windowClass.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(WindowUtil.windowClass)); - WindowUtil.windowClass.on('avoidAreaChange', (avoidAreaOption) => { - if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM || - avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) { - WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area); - } - }); + WindowUtil.windowClass.on('avoidAreaChange', + (avoidAreaOption) => WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area)); } private static updateAvoidArea(windowObj: window.Window) { diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index 6b7769c..33230d7 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -13,14 +13,15 @@ * limitations under the License. */ +import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { UIAbility } from '@kit.AbilityKit'; import { window } from '@kit.ArkUI'; import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary' export default class EntryAbility extends UIAbility { onCreate(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } onDestroy(): void { -- Gitee From 13c6aec69cc7cff8c252f6f6a0e8c7f2d6efd96e Mon Sep 17 00:00:00 2001 From: rekirt Date: Wed, 16 Jul 2025 09:20:31 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9readme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- customdialoggatherslibrary/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customdialoggatherslibrary/README.md b/customdialoggatherslibrary/README.md index fe679e9..165acad 100644 --- a/customdialoggatherslibrary/README.md +++ b/customdialoggatherslibrary/README.md @@ -36,7 +36,7 @@ Stack() { } // EntryAbility.ets -import { CustomDialogGathersController } from '@ohos_samples/multitravelaccommodationlibrary'; +import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary'; onWindowStageCreate(windowStage: window.WindowStage): void { windowStage.loadContent('pages/Index', (err, data) => { if (err.code) { -- Gitee From acb09ff44f7d722aff589e869ea9f800180cc780 Mon Sep 17 00:00:00 2001 From: rekirt Date: Wed, 16 Jul 2025 09:58:34 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/ets/entryability/EntryAbility.ets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets index 33230d7..1f8cf80 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -16,7 +16,7 @@ import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; -import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary' +import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary'; export default class EntryAbility extends UIAbility { onCreate(): void { -- Gitee