diff --git a/AppScope/app.json5 b/AppScope/app.json5 index e2387db9456826b273aeeabadd605bd63f72d334..0bd29122242f5cc898d32063f6d8a85de4db1041 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/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..71fad7b5ad30c0afe3fb0f086fdc129a181762f5 --- /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/README.en.md b/README.en.md index 076620545936fb41edcf84985f254db8cca88db7..c65a9933c53b389fdf94800f49cc41f1a28184ca 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 d24df33acd8c5d2f25b64f6b69ccc31eeb88b07b..fc5c938dbbf67ef1dc4c5fbca1bf391f680a1010 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 e2713a2779c5a3e0eb879efe6115455592caeea5..0000000000000000000000000000000000000000 --- 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 new file mode 100644 index 0000000000000000000000000000000000000000..96c7a272dae3ba52795b7e66d1bc5b770ff51d45 --- /dev/null +++ b/customdialoggatherslibrary/CHANGELOG.md @@ -0,0 +1,6 @@ +# 版本记录 +## 1.0.0(2025.07.10) + +--- +### Initial +- 初始版本 \ No newline at end of file diff --git a/customdialoggatherslibrary/Index.ets b/customdialoggatherslibrary/Index.ets index 0151ff7c6087de301e16ef7a23cf1df14f525497..1bfdb762cd65487836637fec904795528a372f81 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/component/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 0000000000000000000000000000000000000000..daeafe2766b25138cf257ffb195f956a5b957e43 --- /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 0000000000000000000000000000000000000000..165acad1f9107615012b6d33a39364bb083eb9cd --- /dev/null +++ b/customdialoggatherslibrary/README.md @@ -0,0 +1,49 @@ +## 实现多种自定义弹窗的效果 + +### 介绍 + +本示例通过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的入口页面。示例如下: +``` +// Index.ets +import { CustomDialogGathersComponent } from '@ohos_samples/customdialoggatherslibrary'; +Stack() { + CustomDialogGathersComponent() +} + +// EntryAbility.ets +import { CustomDialogGathersController } from '@ohos_samples/customdialoggatherslibrary'; +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 3545ceaffe43c07c9166a0e94b713cc355d07a99..35946a51105ebebdefe701d9be6515b8800311b6 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 0000000000000000000000000000000000000000..7fe51d7383f8652fbe47db69121802714623fc16 --- /dev/null +++ b/customdialoggatherslibrary/src/main/ets/CustomDialogGathersController.ets @@ -0,0 +1,23 @@ +/* + * 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 { window } from '@kit.ArkUI'; +import { WindowUtil } from './utils/WindowUtil'; + +export class CustomDialogGathersController { + public static initWindowConfig(windowStage: window.WindowStage): void { + 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 688004c661459474a77d831e20507a208ca69344..deb897fb4ed325e5c8b62abfec9447f9bc7b3956 100644 --- a/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets +++ b/customdialoggatherslibrary/src/main/ets/common/constants/CommonConstants.ets @@ -18,115 +18,112 @@ 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'; - - /** - * Breakpoint sm. - */ - public static readonly BREAK_POINT_SM: string = 'sm'; - - /** * 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 break point. + */ + public static readonly AS_KEY_BREAK_POINT: string = `${CommonConstants.PREFIX}currentBreakpoint`; + /** + * 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_PATH_STACK: string = `${CommonConstants.PREFIX}pathStack`; + /** + * The key of selected date. + */ + 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 82% rename from customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets rename to customdialoggatherslibrary/src/main/ets/component/BindContentCoverDemo.ets index 52b46de157fa7a7df6f15759ab357f944289e2e8..614843726bf6e6d5c77416d4bd9ab1e48ce41d62 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindContentCoverDemo.ets +++ b/customdialoggatherslibrary/src/main/ets/component/BindContentCoverDemo.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -20,17 +21,16 @@ export function BindContentCoverDemoBuilder() { BindContentCoverDemo(); } -@Entry @Component struct BindContentCoverDemo { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; - pageInfos: NavPathStack = new NavPathStack(); + @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(); 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'), @@ -132,17 +130,23 @@ 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.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.navigatorBarHeight, + 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/component/BindSheetDemo.ets similarity index 72% rename from customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets rename to customdialoggatherslibrary/src/main/ets/component/BindSheetDemo.ets index bde530ddc9c68cc823dd7e59dd6675821cba88c9..8737dc81bf71a61afc1251a69377c49f13b10f16 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/BindSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/component/BindSheetDemo.ets @@ -13,8 +13,7 @@ * limitations under the License. */ -import { ConfigurationConstant } from '@kit.AbilityKit'; -import { BreakpointType } from '../utils/BreakpointSystem'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -22,14 +21,11 @@ export function BindSheetDemoBuilder() { BindSheetDemo(); } -@Entry @Component struct BindSheetDemo { - @StorageProp('systemColorMode') 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(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[] = [ $r('app.string.spicy'), $r('app.string.spicy1'), $r('app.string.spicy2'), $r('app.string.spicy3'), @@ -59,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'), @@ -75,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() { @@ -113,11 +107,10 @@ 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 ? - $r('sys.color.background_secondary') : $r('sys.color.background_tertiary'), + backgroundColor: $r('app.color.bind_sheet_background'), onWillDisappear: () => { this.isShowSheet = !this.isShowSheet; } @@ -131,24 +124,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.statusBarHeight, + bottom: this.navigatorBarHeight, + 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/component/CalendarView.ets similarity index 83% rename from customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets rename to customdialoggatherslibrary/src/main/ets/component/CalendarView.ets index c673b2e480141fa00c5442d6b60e5b2d658ac0c3..efdcc0e038d9788e0ccb630d2f46e71c1a2b18ea 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomCalendar.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CalendarView.ets @@ -13,38 +13,30 @@ * 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 { getRealTimeDate } from '../viewmodel/GetDate'; @Builder export function CalendarViewBuilder() { CalendarView(); } -@Entry @Component export struct CalendarView { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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('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,17 +47,25 @@ 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 { 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; } @@ -101,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')) @@ -110,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) @@ -132,13 +132,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.statusBarHeight, + bottom: this.navigatorBarHeight }) } .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/component/CustomDialogGathersComponent.ets similarity index 82% rename from customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets rename to customdialoggatherslibrary/src/main/ets/component/CustomDialogGathersComponent.ets index c1137643dc37959aa322eb1bb4e5324e2f37a90a..52319081827dd315fdf6f0625a209b59597b0182 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/CustomDialogGathersPage.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CustomDialogGathersComponent.ets @@ -13,24 +13,25 @@ * limitations under the License. */ +import { BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; 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; +export struct CustomDialogGathersComponent { + @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') ]; @@ -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') - }) } -} +} \ 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 75% rename from customdialoggatherslibrary/src/main/ets/pages/Toast.ets rename to customdialoggatherslibrary/src/main/ets/component/CustomDialogUser.ets index 1dd4a287b3cd5203646ba38d27f3dbfd31941a33..19f43a5df4cf6ef0c9412c47c4662de221f4696f 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Toast.ets +++ b/customdialoggatherslibrary/src/main/ets/component/CustomDialogUser.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -40,12 +41,11 @@ struct CustomDialogExample { } } -@Entry @Component struct CustomDialogUser { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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({ builder: CustomDialogExample(), @@ -66,7 +66,7 @@ struct CustomDialogUser { customStyle: true, cornerRadius: $r('sys.float.corner_radius_level12'), isModal: false - }) + }); aboutToDisappear() { this.dialogController = null; @@ -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) @@ -104,17 +102,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.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.navigatorBarHeight, + 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/FullScreen.ets b/customdialoggatherslibrary/src/main/ets/component/FullScreen.ets similarity index 83% rename from customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets rename to customdialoggatherslibrary/src/main/ets/component/FullScreen.ets index 0aa3120d67b6e0ef0fc990bd7797ae34180e1060..363a6186a901f6664fab958931211a8d18547446 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/FullScreen.ets +++ b/customdialoggatherslibrary/src/main/ets/component/FullScreen.ets @@ -14,6 +14,7 @@ */ import { curves } from '@kit.ArkUI'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -21,14 +22,13 @@ export function FullScreenBuilder() { FullScreen(); } -@Entry @Component 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 = CommonConstants.BREAK_POINT_SM; + @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() { NavDestination() { @@ -42,7 +42,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 +64,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.statusBarHeight, + bottom: this.navigatorBarHeight, }) RelativeContainer() { @@ -101,9 +97,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.statusBarHeight, + 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 +129,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 +142,7 @@ struct FullScreen { } private reset() { - animateTo({ + this.getUIContext().animateTo({ curve: curves.responsiveSpringMotion() }, () => { this.translateY = '0%'; @@ -155,7 +154,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/component/Privacy.ets similarity index 51% rename from customdialoggatherslibrary/src/main/ets/pages/Privacy.ets rename to customdialoggatherslibrary/src/main/ets/component/Privacy.ets index 01db877bb4b5f316110addc3d2b1aaff7ab00df1..109e4a42ab65fe7cf7d132fe2c8638ef6f1870ce 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Privacy.ets +++ b/customdialoggatherslibrary/src/main/ets/component/Privacy.ets @@ -13,20 +13,20 @@ * 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() { Privacy(); } -@Entry @Component struct Privacy { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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({ builder: PrivacyDialog({ @@ -46,7 +46,7 @@ struct Privacy { dismissDialogAction.dismiss(); } } - }) + }); onCancel() { hilog.info(0x0000, 'Privacy', '%{public}s', 'Callback when the first button is clicked'); @@ -89,26 +89,31 @@ 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.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.navigatorBarHeight, + 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')) } } @CustomDialog struct PrivacyDialog { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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 = () => { } @@ -117,71 +122,59 @@ 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')) + 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') + }) + 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 + Row({ space: CommonConstants.SPACE_ONE }) { + Button($r('app.string.disagree'), { + stateEffect: true, + buttonStyle: ButtonStyleMode.TEXTUAL + }) + .width(CommonConstants.FORTY_PERCENT) + .onClick(() => { + this.dialogController?.close(); }) - .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')) + 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(() => { + 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/component/ScrollOption.ets similarity index 74% rename from customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets rename to customdialoggatherslibrary/src/main/ets/component/ScrollOption.ets index 1948c90b691a32827f1764e91338a6cdc33c076d..19249c808ad3896ea0112b80b8adb7fd8b78815e 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/ScrollOption.ets +++ b/customdialoggatherslibrary/src/main/ets/component/ScrollOption.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -20,12 +21,11 @@ export function ScrollOptionBuilder() { ScrollOption(); } -@Entry @Component struct ScrollOption { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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; private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4', 'banana5']; @@ -43,13 +43,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 +60,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 +81,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.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.navigatorBarHeight, + 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/component/TwoLevelPageSheet.ets similarity index 79% rename from customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets rename to customdialoggatherslibrary/src/main/ets/component/TwoLevelPageSheet.ets index ab9f7c9ca9b1363efd7fd012b3eed9cc46c0835c..a3d4ac657d22d8000282b010b28b2c6601e28cc3 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/TwoLevelPageSheet.ets +++ b/customdialoggatherslibrary/src/main/ets/component/TwoLevelPageSheet.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -20,12 +21,11 @@ export function TwoLevelPageSheetBuilder() { TwoLevelPageSheet(); } -@Entry @Component struct TwoLevelPageSheet { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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 @State sheetHeight: string = '50%'; @@ -70,6 +70,10 @@ struct TwoLevelPageSheet { this.isShow = false; }) } + .margin({ + bottom: this.curBp === BreakpointTypeEnum.LG && this.navigatorBarHeight === 0 ? + $r('sys.float.padding_level12') : $r('sys.float.padding_level6') + }) } .justifyContent(FlexAlign.SpaceBetween) .width(CommonConstants.FULL_PERCENT) @@ -77,7 +81,7 @@ struct TwoLevelPageSheet { .padding({ top: $r('app.integer.padding_max'), right: $r('sys.float.padding_level8'), - bottom: px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: $r('sys.float.padding_level8') }) } @@ -99,6 +103,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.navigatorBarHeight === 0 ? + $r('sys.float.padding_level12') : $r('sys.float.padding_level6') + }) .onClick(() => { this.isShow = false; this.isShow2 = false; @@ -110,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: px2vp(this.bottomRectHeight), + bottom: this.navigatorBarHeight, left: this.curBp === 'sm' ? $r('sys.float.padding_level8') : $r('sys.float.padding_level0') }) } @@ -149,17 +157,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.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.navigatorBarHeight, + 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 aa7581b2047323eac83c8d9a031e21faabc55bd2..52ea92dcb32bbdfe1818356a88ae8131dfad1adc 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/BreakpointSystem.ets @@ -13,9 +13,10 @@ * limitations under the License. */ -import { 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'; const TAG: string = '[BreakpointSystem]'; @@ -69,9 +70,10 @@ export class BreakpointType { export class BreakpointSystem { private static instance: BreakpointSystem; - private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.MD; + private currentBreakpoint: BreakpointTypeEnum = BreakpointTypeEnum.SM; private constructor() { + AppStorage.setOrCreate(CommonConstants.AS_KEY_BREAK_POINT, this.currentBreakpoint); } public static getInstance(): BreakpointSystem { @@ -84,7 +86,7 @@ export class BreakpointSystem { public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void { if (this.currentBreakpoint !== breakpoint) { this.currentBreakpoint = breakpoint; - AppStorage.setOrCreate('currentBreakpoint', this.currentBreakpoint); + AppStorage.setOrCreate(CommonConstants.AS_KEY_BREAK_POINT, this.currentBreakpoint); } } @@ -96,8 +98,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 615138afbe0b504da5ebc7cce028a40294d6079b..3be068bbf549855138dbc915e97a62c64925487b 100644 --- a/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets +++ b/customdialoggatherslibrary/src/main/ets/utils/WindowUtil.ets @@ -13,68 +13,65 @@ * limitations under the License. */ -import { window } from '@kit.ArkUI'; import type { BusinessError } from '@kit.BasicServicesKit'; -import { BreakpointSystem } from './BreakpointSystem'; 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 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 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); - 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); - } + 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.error(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('topRectHeight', px2vp(area.topRect.height)); - } else { - AppStorage.setOrCreate('bottomRectHeight', px2vp(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) => WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area)); } - public static updatedColorMode(newConfig: Configuration): void { - let newColorMode: ConfigurationConstant.ColorMode = - newConfig.colorMode || ConfigurationConstant.ColorMode.COLOR_MODE_DARK; - let currentColorMode = AppStorage.get('systemColorMode'); - if (newColorMode !== currentColorMode) { - AppStorage.setOrCreate('systemColorMode', newColorMode); + 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)); + } + + // 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 aa72c5f7875373cd5428140931de7417e7e8ee81..7ec88584c450505e96a4cc2751b69bba3c0068f0 100644 --- a/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets +++ b/customdialoggatherslibrary/src/main/ets/view/AddPassengers.ets @@ -13,12 +13,13 @@ * limitations under the License. */ +import { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { PersonList, personList } from '../viewmodel/BindContentModel'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; -import { BusinessError } from '@kit.BasicServicesKit'; +import { PersonList, personList } from '../viewmodel/BindContentModel'; -const TAG = '[getResourceString]'; +const TAG = '[AddPassengers]'; @Builder export function AddPassengersBuilder() { @@ -27,15 +28,18 @@ export function AddPassengersBuilder() { @Component export struct AddPassengers { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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; 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.navigatorBarHeight, + 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 0b2019b7f0c9b213a7d95d99d2925ee15f41337d..777baaf98f427c8250cf31790debbb3089051498 100644 --- a/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets +++ b/customdialoggatherslibrary/src/main/ets/view/CustomCalendarPickerDialog.ets @@ -13,40 +13,40 @@ * 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 { getMonthDate } from '../viewmodel/GetDate'; +import { MonthDataSource, Month } from '../viewmodel/MonthDataSource'; @CustomDialog export struct CustomCalendarPickerDialog { - @StorageProp('systemColorMode') - 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(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; @State nextYear: number = 1; - @State currentMonthDay: number[] = []; @State initialIndex: number = 0; @Link currentMonth: number; @Link currentDay: number; @Link currentYear: number; - @StorageLink('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 = ''; - resourceString = getContext(this).resourceManager.getStringSync(resource.id); + let hostContext = this.getUIContext().getHostContext(); + if (hostContext) { + resourceString = hostContext.resourceManager.getStringSync(resource.id); + } return resourceString; } @@ -68,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 @@ -146,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) { @@ -156,12 +156,15 @@ 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(); } }) - }, (day: number) => day.toString()) + }, (day: number, index: number) => (day + index).toString()) } .columnsTemplate(CommonConstants.GRID_SEVEN) .rowsTemplate(monthItem.days.length > CommonConstants.MONTH_NUMBER ? @@ -225,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 69% rename from customdialoggatherslibrary/src/main/ets/pages/Details.ets rename to customdialoggatherslibrary/src/main/ets/view/Details.ets index d290cc8c7ed5359b94be11346d35b083078d3b71..4ceb4d2574c5b2f94f8e03ea951f62356666689c 100644 --- a/customdialoggatherslibrary/src/main/ets/pages/Details.ets +++ b/customdialoggatherslibrary/src/main/ets/view/Details.ets @@ -13,6 +13,7 @@ * limitations under the License. */ +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; @Builder @@ -20,12 +21,11 @@ export function DetailsBuilder() { Details(); } -@Entry @Component struct Details { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; + @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(); build() { @@ -41,7 +41,7 @@ struct Details { }) .backgroundColor($r('sys.color.brand')) .onClick(() => { - this.pathStack.pop() + this.pathStack.pop(); }) } .width(CommonConstants.FULL_PERCENT) @@ -60,15 +60,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.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.navigatorBarHeight, + 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.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 48% rename from customdialoggatherslibrary/src/main/ets/view/DefaultList.ets rename to customdialoggatherslibrary/src/main/ets/view/QueryTicketList.ets index b046b74639a9b09ded3ef8e844f01ef1edc60a2d..1655549fbd05ac61088bdeec880e8ea7f8c8fe11 100644 --- a/customdialoggatherslibrary/src/main/ets/view/DefaultList.ets +++ b/customdialoggatherslibrary/src/main/ets/view/QueryTicketList.ets @@ -1,40 +1,44 @@ - /* - * 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 { BusinessError } from '@kit.BasicServicesKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BreakpointType, BreakpointTypeEnum } from '../utils/BreakpointSystem'; import { CommonConstants } from '../common/constants/CommonConstants'; -import { BusinessError } from '@kit.BasicServicesKit'; -const TAG = '[getResourceString]'; +const TAG = '[QueryTicketList]'; @Builder export function DefaultListBuilder() { - DefaultList() + QueryTicketList() } @Component -export struct DefaultList { - @StorageLink('topRectHeight') topRectHeight: number = 0; - @StorageLink('bottomRectHeight') bottomRectHeight: number = 0; - @StorageLink('currentBreakpoint') curBp: string = CommonConstants.BREAK_POINT_SM; +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]; 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 e212d4c4de8ab286629fcdedbe3e196ae881c189..ba2b996db735dd0f43019a2787f18d3c25c6f5b3 100644 --- a/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets +++ b/customdialoggatherslibrary/src/main/ets/viewmodel/DataManager.ets @@ -14,33 +14,17 @@ */ import { preferences } from '@kit.ArkData'; +import { CommonConstants } from '../common/constants/CommonConstants'; import { DateModel } from './DateModel'; -import { getRealTimeDate } from './GetDate'; 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 3c712962da3c2751c2b9ddb53559afcbd2b54a02..438ec33ca2a9f8ed93d39d0fe554ae720e9f58b7 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 767984cc784da5b84d9f6077d4f9fda5529f8018..b156309bafbb3959b5210cd2002db69e7628dae7 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 2e0ce771edf2e572b0742ae694ce5f517141b315..d0b1bf210477b6919bbfbf423fc81de958d9152c 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 0000000000000000000000000000000000000000..ebeb4b5dbcae60ae3d006b7d72a644c1bbf841a5 --- /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 206c8ede40562d1af5dec885d58e95eb1b158ad4..b156309bafbb3959b5210cd2002db69e7628dae7 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 696ea652d8a31e09ea60b6cb36d435d4a1a3be86..2b668838edec19f82c814267f02f4a4671777ef6 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 f8bf42a6d9720ce24231dc0b736dcf310ff0efdf..e5df3191fbe004819edf818f74e3f505583a0301 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 b2a3dc0144ecfcda6a17028edf87d29708ed6e11..2d6d39a2bd795c61bbd9f0a208a0d6b0b3cccce5 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 96b4490225df68c59ec0b81e52e9a3ea985fa046..1f8cf807845a00f49dcfd54995e398773a0d4a6a 100644 --- a/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets +++ b/customdialoggatherssample/src/main/ets/entryability/EntryAbility.ets @@ -13,41 +13,30 @@ * limitations under the License. */ -import { Configuration, ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; -import { window } from '@kit.ArkUI'; +import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit'; import { hilog } from '@kit.PerformanceAnalysisKit'; -import { resourceManager } from '@kit.LocalizationKit'; -import { WindowUtil } from 'customdialoggatherslibrary/src/main/ets/utils/WindowUtil' - +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'); - AppStorage.setOrCreate('systemColorMode', this.context.config.colorMode); this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); } - onConfigurationUpdate(newConfig: Configuration): void { - WindowUtil.updatedColorMode(newConfig) - } - onDestroy(): void { hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); } 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 71f36b33ffef0962e7275d3ea2ea66870445dca0..9f537261efa681ba16450b31fc296750ee12fda2 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 '@ohos_samples/customdialoggatherslibrary' @Entry @Component struct Index { build() { - Stack(){ - CustomDialogGathersPage() + Stack() { + CustomDialogGathersComponent() } } } \ No newline at end of file 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 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /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 0000000000000000000000000000000000000000..8e0b54b3b57e8ed0a7a4a29ce32c13cd9fe8949c --- /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 0000000000000000000000000000000000000000..8e0b54b3b57e8ed0a7a4a29ce32c13cd9fe8949c --- /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 0000000000000000000000000000000000000000..10fff27bcf90f379dcf5cb0b45d8148687216782 --- /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