diff --git a/LICENSE b/LICENSE index 0210352ae2ade0dd7b4c841cb6e8ba08b4780038..18795a48d6b12fcdc1aa7bac9a9cb99f83815267 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ - Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. + Copyright (c) 2025 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. diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 6cbe4e1beb25dcfdc1a55c2ff73ac9f51f21b944..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,32 +0,0 @@ -# Building Multiple Styles of Dialog Boxes - -### Overview - -This codelab introduces how to implement four types of dialog boxes, including the alert dialog box, custom dialog box, date picker dialog box, and text picker dialog box. - -![](screenshots/device/MultipeDialog.en.gif) - -### Concepts - -- Alert dialog box: an alert dialog box component, in which the text content and response callback can be set. -- Custom dialog box: a custom dialog box that is displayed by using the **CustomDialogController** class. -- Date picker dialog box: a date picker based on the specified date range, which is displayed in the dialog box. -- Text picker dialog box: a text picker based on the specified selection range, which is displayed in the dialog box. - -### Permissions - -N/A - -### How to Use - -1. Open the app home page. Tap the Back button in the upper left corner, and the alert dialog box is displayed. Tap OK to exit the page. -2. Open the app home page. Touch the Date of Birth option, and the date picker dialog box is displayed. Swipe up or down to pick a date, touch OK, and the picked date is displayed. -3. Open the app home page. Touch the Gender option, and the text picker dialog box is displayed. Swipe up or down to pick an option, touch OK, and the picked text is displayed. -4. Open the app home page. Touch the Hobby option, and the custom dialog box is displayed. Pick multiple hobbies, touch OK, and the picked hobbies are displayed. - -### Constraints - -1. The sample is only supported on Huawei phones with standard systems. -2. HarmonyOS: HarmonyOS NEXT Developer Beta1 or later. -3. DevEco Studio: DevEco Studio NEXT Developer Beta1 or later. -4. HarmonyOS SDK: HarmonyOS NEXT Developer Beta1 SDK or later. diff --git a/README.md b/README.md index 0ffb4c4a7cc83f9daf61f79ac64dda6228556cc5..e8891d4645d5ceda4d63083f881fa81efaa31d01 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,58 @@ -# 构建多种样式弹窗 +# 实现固定样式和自定义样式弹窗 -### 简介 - -本篇Codelab将介绍如何使用弹窗功能,实现四种类型弹窗。分别是:警告弹窗、自定义弹窗、日期滑动选择器弹窗、文本滑动选择器弹窗。 +## 简介 +本示例主要介绍如何给应用添加固定样式和自定义样式的弹窗,其中气泡提示(Popup)、即时反馈(Toast)、日期滑动选择器弹窗、文本滑动选择器弹窗、警告弹窗都属于固定样式弹窗,弹窗的样式固定,使用系统提供的API,传入相应的参数即可实现。 +而自定义弹窗的样式和交互方式都可以自定义,可以实现更加复杂的交互场景。 +## 预览效果 ![](screenshots/device/MultipeDialog.gif) -### 相关概念 +## 工程目录 +``` +├──entry/src/main/ets // 弹窗代码区 +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets +│ ├──pages +│ │ ├──index.ets // 首页 +│ │ └──PersonalInformation.ets // 个人信息页 +│ ├──utils +│ │ ├──CommonUtils.ets // 公共方法 +│ │ └──Logger.ets // 日志打印 +│ └──view +│ ├──Dialog.ets // 自定义弹窗 +│ ├──TextCommonComponent.ets // 文本展示组件 +│ └──TextInputComponent.ets // 文本输入组件 +└──entry/src/main/resources // 应用资源目录 +``` + +## 相关概念 - 警告弹窗:显示警告弹窗组件,可设置文本内容与响应回调。 -- 自定义弹窗: 通过CustomDialogController类显示自定义弹窗。 +- 自定义弹窗: 使用UIContext中获取到的PromptAction对象提供的openCustomDialog接口来实现自定义弹出框。 - 日期滑动选择器弹窗:根据指定范围的Date创建可以选择日期的滑动选择器,展示在弹窗上。 - 文本滑动选择器弹窗:根据指定的选择范围创建文本选择器,展示在弹窗上。 +- 气泡弹窗:可绑定在组件上显示气泡弹窗提示,设置弹窗内容、交互逻辑和显示状态。主要用于屏幕录制、信息弹出提醒等显示状态。 -### 相关权限 +## 相关权限 不涉及 -### 使用说明 +## 使用说明 1. 打开应用首页,点击主页左上角返回按钮,展示警告弹窗,点击确定按钮退出页面。 2. 打开应用首页,点击出生日期选项,展示日期滑动选择弹窗,上下滑动日期,点击确定按钮,显示选中日期。 3. 打开应用首页,点击性别选项,展示文本滑动选择弹窗,上下滑动文本,点击确定按钮,显示选中文本。 4. 打开应用首页,点击兴趣爱好选项,展示自定义弹窗,选中多个兴趣爱好,点击确定,显示选中兴趣爱好。 +5. 打开应用首页,点击主页右上角菜单按钮,展示气泡弹窗,点击保存,可保存信息,之后退出页面不再弹出警告弹窗。 + +## 约束与限制 + +* 本示例仅支持标准系统上运行,支持设备:华为手机。 + +* HarmonyOS系统:HarmonyOS 5.0.0 Release及以上。 -### 约束与限制 +* DevEco Studio版本:DevEco Studio 5.0.0 Release及以上。 -1. 本示例仅支持标准系统上运行,支持设备:华为手机。 -2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 -3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 -4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 +* HarmonyOS SDK版本:HarmonyOS 5.0.0 Release SDK及以上。 diff --git a/build-profile.json5 b/build-profile.json5 index 1d12140d202702d7c73d64f1b291fe5c45a660ce..1e69556b3411622cb2e87a87389653bb34f1b148 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -6,7 +6,21 @@ "name": "default", "signingConfig": "default", "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS" + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" } ] }, diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..77b31b517a3e5c2f34c3ae1bf44083c0c06cbd6d --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,20 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/entry/.gitignore b/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 index 13c5eda6e6a3dae913ec5c5c4d60ea3ac954f205..0311b505dbf43f0d22662c8d783c5f4464d15b15 100644 --- a/entry/build-profile.json5 +++ b/entry/build-profile.json5 @@ -1,11 +1,25 @@ { - "apiType": 'stageMode', + "apiType": "stageMode", "buildOption": { }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], "targets": [ { - "name": "default", - "runtimeOS": "HarmonyOS" + "name": "default" } ] } \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts index 80e4ec5b81689f238c34614b167a0b9e9c83e8d9..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 100644 --- a/entry/hvigorfile.ts +++ b/entry/hvigorfile.ts @@ -1,2 +1,6 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { hapTasks } from '@ohos/hvigor-ohos-plugin'; +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# 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-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 225946cb11a2c405c8dc81eea89c22f923556638..248c3b7541a589682a250f86a6d3ecf7414d2d6a 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -1,10 +1,10 @@ { - "license": "", - "devDependencies": {}, - "author": "", "name": "entry", + "version": "1.0.0", "description": "Please describe the basic information.", "main": "", - "version": "1.0.0", + "author": "", + "license": "", "dependencies": {} } + diff --git a/entry/src/main/ets/common/constants/CommonConstants.ets b/entry/src/main/ets/common/constants/CommonConstants.ets deleted file mode 100644 index 55e181dfa7efc3ee6b10c9544fd9be23e16e1215..0000000000000000000000000000000000000000 --- a/entry/src/main/ets/common/constants/CommonConstants.ets +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2023 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. - */ - -/** - * Common constants for all features. - */ -export default class CommonConstants { - /** - * The entry ability tag. - */ - static readonly TAG_ABILITY: string = 'EntryAbility'; - - /** - * The home page tag. - */ - static readonly TAG_HOME: string = 'HomePage'; - - /** - * The Common utils tag. - */ - static readonly TAG_COMMON_UTILS: string = 'CommonUtils'; - - /** - * Custom dialog widget tag. - */ - static readonly TAG_CUSTOM: string = 'CustomDialogWidget'; - - /** - * Width the percentage of the 100. - */ - static readonly FULL_WIDTH: string = '100%'; - - /** - * Height the percentage of the 100. - */ - static readonly FULL_HEIGHT: string = '100%'; - - /** - * Date year - */ - static readonly DATE_YEAR: Resource = $r('app.string.text_year'); - - /** - * Date month - */ - static readonly DATE_MONTH: Resource = $r('app.string.text_month'); - - /** - * Date day - */ - static readonly DATE_DAY: Resource = $r('app.string.text_day'); - - /** - * Date dialog start time. - */ - static readonly START_TIME: string = '1900-1-1'; - - /** - * Date dialog select time. - */ - static readonly SELECT_TIME: string = '1990-1-1'; - - /** - * Image back margin left of the 7.2. - */ - static readonly BACK_MARGIN_LEFT: string = '7.2%'; - - /** - * Image avatar margin top of the 5.5. - */ - static readonly AVATAR_MARGIN_TOP: string = '5.5%'; - - /** - * Text personal margin top of the 2.1. - */ - static readonly PERSONAL_MARGIN_TOP: string = '2.1%'; - - /** - * Common dialog width of the 93.3. - */ - static readonly COMMON_DIALOG_WIDTH: string = '93.3%'; - - /** - * Join comma - */ - static readonly COMMA: string = ','; - - /** - * Image back margin top of the 19. - */ - static readonly BACK_MARGIN_TOP: number = 19; - - /** - * Font weight of the 500. - */ - static readonly BIGGER: number = 500; - - /** - * Dialog y-axis offset distance of the 20. - */ - static readonly DY_OFFSET: number = -20; - - /** - * Current month plus one. - */ - static readonly PLUS_ONE: number = 1; - - /** - * Layout weight size of the 1. - */ - static readonly WEIGHT_ONE: number = 1; - - /** - * Text common max lines of the 1. - */ - static readonly ONE_LINES: number = 1; -} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/CommonUtils.ets b/entry/src/main/ets/common/utils/CommonUtils.ets deleted file mode 100644 index 227eba057c5e9080946eca0e86c6de2c868e7096..0000000000000000000000000000000000000000 --- a/entry/src/main/ets/common/utils/CommonUtils.ets +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { common } from '@kit.AbilityKit'; -import Logger from './Logger'; -import CommonConstants from '../constants/CommonConstants'; -import HobbyItem from '../../viewmodel/HobbyItem'; - -/** - * This is a pop-up window tool class, which is used to encapsulate dialog code. - * Developers can directly invoke the methods in. - */ -export class CommonUtils { - /** - * Alert dialog dialog - */ - alertDialog(context: common.UIAbilityContext) { - AlertDialog.show({ - message: $r('app.string.alert_dialog_message'), - alignment: DialogAlignment.Bottom, - offset: { - dx: 0, - dy: CommonConstants.DY_OFFSET - }, - primaryButton: { - value: $r('app.string.cancel_button'), - action: () => { - Logger.info(CommonConstants.TAG_COMMON_UTILS, 'Callback cancel button is clicked'); - } - }, - secondaryButton: { - value: $r('app.string.definite_button'), - action: () => { - // Exiting the app. - context.terminateSelf(); - Logger.info(CommonConstants.TAG_COMMON_UTILS, 'Callback definite button is clicked'); - } - } - }); - } - - - /** - * Date dialog dialog - */ - datePickerDialog(dateCallback: Function) { - DatePickerDialog.show({ - start: new Date(CommonConstants.START_TIME), - end: new Date(), - selected: new Date(CommonConstants.SELECT_TIME), - lunar: false, - onDateAccept: (value: Date) => { - let year: number = value.getFullYear(); - let month: number = value.getMonth() + CommonConstants.PLUS_ONE; - let day: number = value.getDate(); - let birthdate: string = this.getBirthDateValue(year, month, day); - dateCallback(birthdate); - } - }); - } - - /** - * Text dialog dialog - */ - textPickerDialog(sexArray: Resource, sexCallback: Function) { - if (this.isEmpty(sexArray)) { - Logger.error(CommonConstants.TAG_COMMON_UTILS, 'sex is null'); - return; - } - TextPickerDialog.show({ - range: sexArray, - canLoop:false, - selected: 0, - onAccept: (result: TextPickerResult) => { - sexCallback(result.value); - }, - onCancel: () => { - Logger.info(CommonConstants.TAG_COMMON_UTILS, 'TextPickerDialog onCancel'); - } - }); - } - - /** - * Get default birth date - * - * @param {number} year year - * @param {number} month month - * @param {number} day day - * @returns {string} return birth date - */ - getBirthDateValue(year: number, month: number, day: number): string { - let birthdate: string = `${year}${this.getResourceString(CommonConstants.DATE_YEAR)}${month}` + - `${this.getResourceString(CommonConstants.DATE_MONTH)}${day}${this.getResourceString(CommonConstants.DATE_DAY)}`; - return birthdate; - } - - /** - * Check obj is empty - * - * @param {object} obj - * @return {boolean} true(empty) - */ - isEmpty(obj: object | string): boolean { - return obj === undefined || obj === null || obj === ''; - } - - /** - * Check array is empty - * - * @param {Array}array - * @return {boolean} true(empty) - */ - isEmptyArr(array: Array): boolean { - return this.isEmpty(array) || array.length === 0; - } - - /** - * The Resource type is converted to a string type. - */ - getResourceString(resource: Resource): string { - let resourceString: string = ''; - try { - resourceString = getContext(this).resourceManager.getStringSync(resource.id); - } catch (error) { - Logger.error(`getResourceString err: ${JSON.stringify(error)}`); - } - return resourceString; - } -} - -export default new CommonUtils(); \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 26bd9781ab1717285edad4f04705777b86a274e8..0f2f8b94aa24b0a50e272270e4e18b6df93ac5fd 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,23 +13,44 @@ * limitations under the License. */ -import { UIAbility } from '@kit.AbilityKit'; +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; import { window } from '@kit.ArkUI'; -import Logger from '../common/utils/Logger'; -import CommonConstants from '../common/constants/CommonConstants'; -/** - * Lift cycle management of Ability. - */ export default class EntryAbility extends UIAbility { - onWindowStageCreate(windowStage: window.WindowStage) { - // Main window is created, set main page for this ability. - windowStage.loadContent('pages/HomePage', (err, data) => { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { if (err.code) { - Logger.error(CommonConstants.TAG_ABILITY, 'Failed to load the content. Cause:' + JSON.stringify(err)); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; } - Logger.info(CommonConstants.TAG_ABILITY, 'Succeeded to load the content. Data: ' + JSON.stringify(data)); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); }); } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } } diff --git a/entry/src/main/ets/viewmodel/HobbyItem.ets b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets similarity index 54% rename from entry/src/main/ets/viewmodel/HobbyItem.ets rename to entry/src/main/ets/entrybackupability/EntryBackupAbility.ets index 50a0f4b85da6bb6d7e3ac76377a0d0dd9ff7a753..b1e212947256c5533c7b06285a597c94f840a6e3 100644 --- a/entry/src/main/ets/viewmodel/HobbyItem.ets +++ b/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,17 +13,15 @@ * limitations under the License. */ -/** - * Hobby info item. - */ -export default class HobbyItem { - /** - * Hobby title - */ - label?: string; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } - /** - * Hobby check status - */ - isChecked?: boolean; + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/HomePage.ets b/entry/src/main/ets/pages/HomePage.ets deleted file mode 100644 index 88fa05d7fca60704b00066dfed4d6e30c97a67f6..0000000000000000000000000000000000000000 --- a/entry/src/main/ets/pages/HomePage.ets +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { common } from '@kit.AbilityKit'; -import CommonUtils from '../common/utils/CommonUtils'; -import CommonConstants from '../common/constants/CommonConstants'; -import TextInputWidget from '../view/TextInputWidget'; -import TextCommonWidget from '../view/TextCommonWidget'; -import CustomDialogWidget from '../view/CustomDialogWidget'; -import Logger from '../common/utils/Logger'; - -/** - * There are four dialog modes on the personal information page. - * Date pop-up window, text pop-up window, warning pop-up window, and custom pop-up window. - * Developers can modify the content displayed in the pop-up window. - */ -@Entry -@Component -struct HomePage { - @State birthdate: string = ''; - @State sex: string = ''; - @State hobbies: string = ''; - private sexArray: Resource = $r('app.strarray.sex_array'); - customDialogController: CustomDialogController = new CustomDialogController({ - builder: CustomDialogWidget({ - hobbies: $hobbies, - }), - alignment: DialogAlignment.Bottom, - customStyle: true, - offset: { - dx: 0, - dy: CommonConstants.DY_OFFSET - } - }); - - aboutToAppear() { - let date = new Date(); - let year = date.getFullYear(); - let month = date.getMonth() + CommonConstants.PLUS_ONE; - let day = date.getDate(); - this.birthdate = CommonUtils.getBirthDateValue(year, month, day); - let context = getContext(this); - if ((CommonUtils.isEmpty(context)) || (CommonUtils.isEmpty(context.resourceManager))) { - Logger.error(CommonConstants.TAG_HOME, 'context or resourceManager is null'); - return; - } - let manager = context.resourceManager; - manager.getStringValue($r('app.string.default_sex').id, (error, sexValue) => { - if (!CommonUtils.isEmpty(error)) { - Logger.error(CommonConstants.TAG_HOME, 'error = ' + JSON.stringify(error)); - } else { - this.sex = sexValue; - } - }); - } - - build() { - Column() { - Image($r('app.media.ic_back')) - .width($r('app.float.image_back_size')) - .height($r('app.float.image_back_size')) - .alignSelf(ItemAlign.Start) - .margin({ - left: CommonConstants.BACK_MARGIN_LEFT, - top: CommonConstants.BACK_MARGIN_TOP - }) - .onClick(() => { - let context = getContext(this) as common.UIAbilityContext; - CommonUtils.alertDialog(context); - }) - Image($r('app.media.ic_avatar')) - .width($r('app.float.avatar_size')) - .height($r('app.float.avatar_size')) - .alignSelf(ItemAlign.Center) - .margin({ top: CommonConstants.AVATAR_MARGIN_TOP }) - Text($r('app.string.text_personal_title')) - .fontColor(Color.Black) - .fontSize($r('app.float.personal_font_size')) - .margin({ top: CommonConstants.PERSONAL_MARGIN_TOP }) - .alignSelf(ItemAlign.Center) - TextInputWidget({ - inputImage: $r('app.media.ic_nickname'), - hintText: $r('app.string.text_input_hint') - }) - TextCommonWidget({ - textImage: $r('app.media.ic_birthdate'), - title: $r('app.string.title_birthdate'), - content: $birthdate, - onItemClick: () => { - CommonUtils.datePickerDialog((birthValue: string) => { - this.birthdate = birthValue; - }); - } - }) - TextCommonWidget({ - textImage: $r('app.media.ic_sex'), - title: $r('app.string.title_sex'), - content: $sex, - onItemClick: () => { - CommonUtils.textPickerDialog(this.sexArray, (sexValue: string) => { - this.sex = sexValue; - }); - } - }) - TextInputWidget({ - inputImage: $r('app.media.ic_signature'), - hintText: $r('app.string.text_input_signature') - }) - TextCommonWidget({ - textImage: $r('app.media.ic_hobbies'), - title: $r('app.string.title_hobbies'), - content: $hobbies, - onItemClick: () => { - this.customDialogController.open(); - } - }) - } - .backgroundColor($r('app.color.column_background_color')) - .width(CommonConstants.FULL_WIDTH) - .height(CommonConstants.FULL_HEIGHT) - } -} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b045615ba7ac9f7cbc595c93c752f5cb675619ed --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2025 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 { PersonalInformation } from './PersonalInformation'; + +@Entry +@Component +struct Index { + @Provide('NavPathStack') pathStack: NavPathStack = new NavPathStack(); + + @Builder + PagesMap(name: string) { + if (name === 'PersonalInformation') { + PersonalInformation() + } + } + + build() { + Navigation(this.pathStack) { + Column() { + Text($r('app.string.multi_popup_interaction')) + .fontSize(30) + .opacity(0.9) + .fontWeight(FontWeight.Bold) + .width('100%') + .height(56) + .margin({ top: 56 }) + Column({ space: 12 }) { + Button($r('app.string.personalInformation')) + .onClick(() => { + this.pathStack.pushPath({ name: 'PersonalInformation' }); + }) + .width('100%') + } + .height(248) + .width('100%') + .justifyContent(FlexAlign.End) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.SpaceBetween) + .padding({ + left: 16, + right: 16, + bottom: 16 + }) + } + .backgroundColor('#F1F3F5') + .navDestination(this.PagesMap) + .mode(NavigationMode.Stack) + .hideToolBar(true) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/PersonalInformation.ets b/entry/src/main/ets/pages/PersonalInformation.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8e4ff37674d0686a08ca5675312be0b42dbdc1d --- /dev/null +++ b/entry/src/main/ets/pages/PersonalInformation.ets @@ -0,0 +1,400 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { promptAction, ComponentContent } from '@kit.ArkUI'; +import TextInputComponent from '../view/TextInputComponent'; +import TextCommonComponent from '../view/TextCommonComponent'; +import CommonUtils from '../utils/CommonUtils'; +import PromptActionClass from '../view/Dialog'; + +class HobbyItem { + label?: string; + isChecked?: boolean; +} + +class Params { + hobbyItems: HobbyItem[] = []; + + constructor(hobbyItems: HobbyItem[]) { + this.hobbyItems = hobbyItems; + } +} + +@Extend(Button) +function dialogButtonStyle() { + .fontSize(16) + .fontColor('#0A59F7') + .layoutWeight(1) + .backgroundColor(Color.White) + .width('100%') + .height(40) +} + +function setHobbiesValue(hobbyItems: HobbyItem[]) { + if (CommonUtils.isEmptyArr(hobbyItems)) { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'hobbyItems length is 0'); + return; + } + let hobbiesText: string = ''; + hobbiesText = hobbyItems.filter((isCheckItem: HobbyItem) => isCheckItem?.isChecked) + .map((checkedItem: HobbyItem) => { + return checkedItem.label!; + }) + .join(','); + return hobbiesText; +} + +@Builder +function buildHobbyItems(params: Params) { + Column() { + Text($r('app.string.hobbies_and_interests')) + .fontSize(20) + .opacity(0.9) + .lineHeight(28) + .fontWeight(700) + .alignSelf(ItemAlign.Start) + .margin({ left: 24 }) + + List() { + ForEach(params.hobbyItems, (itemHobby: HobbyItem) => { + ListItem() { + Row() { + Text(itemHobby.label) + .fontSize(16) + .opacity(0.9) + .layoutWeight(1) + .textAlign(TextAlign.Start) + .fontWeight(500) + .margin({ left: 24 }) + Toggle({ type: ToggleType.Checkbox, isOn: false }) + .onChange((isCheck) => { + itemHobby.isChecked = isCheck; + }) + .width(20) + .height(20) + .margin({ right: 24 }) + } + .height(22) + .margin({ + top: 13, + bottom: 13 + }) + } + }, (itemHobby: HobbyItem) => JSON.stringify(itemHobby.label)) + } + .margin({ + top: 14, + bottom: 8 + }) + .divider({ + strokeWidth: 0.5, + color: '#0D182431' + }) + .listDirection(Axis.Vertical) + .edgeEffect(EdgeEffect.None) + .width('100%') + .height(242) + + Row() { + Button($r('app.string.cancel')) + .dialogButtonStyle() + .onClick(() => { + PromptActionClass.closeDialog() + }) + Blank() + .backgroundColor('#F2F2F2') + .width(1) + .opacity(1) + .height(25) + .margin({ left: 8, right: 8 }) + Button($r('app.string.confirm')) + .dialogButtonStyle() + .onClick(() => { + PromptActionClass.closeDialog(); + let text = setHobbiesValue(params.hobbyItems); + AppStorage.setOrCreate('Hobbies', text); + AppStorage.setOrCreate('isEdit', true); + }) + } + .padding({ + left: 16, + right: 16 + }) + } + .width('93.3%') + .padding({ + top: 14, + bottom: 16 + }) + .borderRadius(32) + .backgroundColor(Color.White) +} + +@Component +export struct PersonalInformation { + @StorageLink('nikeName') nikeName: string = ''; + @StorageLink('signature') signature: string = ''; + @StorageLink('birthDate') birthDate: string = ''; + @StorageLink('sex') sex: ResourceStr = $r('app.string.male'); + @StorageLink('Hobbies') hobbies: string = ''; + @StorageLink('selectTime') selectTime: Date = new Date('2000-12-25T08:30:00'); + @State hobbyItems: HobbyItem[] = []; + @StorageLink('select') select: number = 0; + @StorageLink('isEdit') isEdit: boolean = false; + @State customPopup: boolean = false + @State isSaved: boolean = false; + @Consume('NavPathStack') pathStack: NavPathStack; + private sexArray: Resource = $r('app.strarray.sex_array'); + private currentDate: string = ''; + private ctx: UIContext = this.getUIContext(); + private contentNode: ComponentContent = + new ComponentContent(this.ctx, wrapBuilder(buildHobbyItems), + new Params(this.hobbyItems)); + + // The popup constructor defines the contents of the pop-up + @Builder + PopupBuilder() { + Row({ space: 2 }) { + Text($r('app.string.save')) + .fontSize(16) + .opacity(0.9) + } + .onClick(() => { + this.isSaved = true; + this.customPopup = false; // Close popup dialog + AppStorage.setOrCreate('isEdit', false); + promptAction.showToast({ + message: $r('app.string.save_successfully'), + duration: 2000 + }) + AppStorage.setOrCreate('nikeName', this.nikeName); + AppStorage.setOrCreate('signature', this.signature); + AppStorage.setOrCreate('birthDate', this.birthDate); + AppStorage.setOrCreate('selectTime', this.selectTime); + AppStorage.setOrCreate('sex', this.sex); + AppStorage.setOrCreate('select', this.select); + AppStorage.setOrCreate('hobbies', this.hobbies); + AppStorage.setOrCreate('isEdit', false); + }) + .width(200) + .height(50) + .padding(16) + } + + aboutToAppear() { + PromptActionClass.setContext(this.ctx); + + PromptActionClass.setOptions({ alignment: DialogAlignment.Center }); + let date = new Date(); + let year = date.getFullYear(); + let month = date.getMonth() + 1; + let day = date.getDate(); + this.currentDate = year + '-' + month + '-' + day; + if (!this.birthDate) { + this.birthDate = CommonUtils.getBirthDateValue(year, month, day); + } + let context = getContext(this); + if ((CommonUtils.isEmpty(context)) || (CommonUtils.isEmpty(context.resourceManager))) { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'context or resourceManager is null'); + return; + } + } + + @Builder + NavDestinationTitle() { + Column() { + Row() { + Image($r('app.media.dot_grid')) + .width(24) + .height(24) + } + .width(40) + .height(40) + .borderRadius(36) + .backgroundColor('#E9E9E9') + .justifyContent(FlexAlign.Center) + .onClick(() => { + this.customPopup = !this.customPopup + }) + .bindPopup(this.customPopup, { + builder: this.PopupBuilder, // Bubble content + placement: Placement.Bottom, // The pop position of the bubble + onStateChange: (e) => { + if (!e.isVisible) { + this.customPopup = false; + } + } + }) + } + .alignItems(HorizontalAlign.End) + .padding({ top: 8, right: 16 }) + .width('calc(100% - 56vp)') + } + + build() { + NavDestination() { + Column() { + Column({ space: 12 }) { + Image($r('app.media.ic_avatar')) + .width(56) + .height(56) + .alignSelf(ItemAlign.Center) + Text($r('app.string.personalInformation')) + .fontSize(17) + .opacity(0.9) + } + .width('100%') + .alignItems(HorizontalAlign.Center) + + Column() { + TextInputComponent({ + inputImage: $r('app.media.person'), + text: this.nikeName, + hintText: $r('app.string.nickname') + }) + } + .margin({ top: 12 }) + + Column() { + TextCommonComponent({ + textImage: $r('app.media.calendar'), + title: $r('app.string.date_of_birth'), + content: this.birthDate, + onItemClick: () => { + this.getUIContext().showDatePickerDialog({ + start: new Date('1925-1-1'), + end: new Date(this.currentDate), + selected: this.selectTime, + lunarSwitch: true, + showTime: false, + onDateAccept: (value: Date) => { + this.selectTime = value; + let birthDateArray = JSON.stringify(value).slice(1, 11).split('-'); + let year = Number(birthDateArray[0]); + let month = Number(birthDateArray[1]); + let day = Number(birthDateArray[2]); + this.birthDate = CommonUtils.getBirthDateValue(year, month, day); + AppStorage.setOrCreate('isEdit', true); + } + }) + } + }) + } + + Column() { + TextCommonComponent({ + textImage: $r('app.media.person_2'), + title: $r('app.string.sex'), + content: this.sex, + onItemClick: () => { + this.getUIContext().showTextPickerDialog({ + range: this.sexArray, + selected: this.select, + canLoop: false, + onAccept: (value: TextPickerResult) => { + this.select = value.index as number; + this.sex = value.value as string; + AppStorage.setOrCreate('isEdit', true); + }, + onChange: (value: TextPickerResult) => { + this.select = value.index as number; + } + }) + } + }) + } + + Column() { + TextInputComponent({ + inputImage: $r('app.media.doc_plaintext_and_pencil'), + text: this.signature, + hintText: $r('app.string.personal_signature') + }) + } + + Column() { + TextCommonComponent({ + textImage: $r('app.media.heart'), + title: $r('app.string.Hobbies_multiple_choices'), + content: this.hobbies, + onItemClick: () => { + this.hobbyItems = []; + let context = getContext(this); + if ((CommonUtils.isEmpty(context)) || (CommonUtils.isEmpty(context.resourceManager))) { + return; + } + let manager = context.resourceManager; + manager.getStringArrayValue($r('app.strarray.hobbies_data').id, (error, hobbyArray) => { + if (!CommonUtils.isEmpty(error)) { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'error = ' + JSON.stringify(error)); + } else { + hobbyArray.forEach((hobbyItem: string) => { + let tmpHobbyItem = new HobbyItem(); + tmpHobbyItem.label = hobbyItem; + tmpHobbyItem.isChecked = false; + this.hobbyItems.push(tmpHobbyItem); + }); + this.contentNode = + new ComponentContent(this.ctx, wrapBuilder(buildHobbyItems), new Params(this.hobbyItems)); + PromptActionClass.setContentNode(this.contentNode); + PromptActionClass.openDialog(); + AppStorage.setOrCreate('isEdit', true); + } + }); + } + }) + } + } + .padding(16) + } + .onBackPressed(() => { + if (!this.isSaved && this.isEdit) { + this.getUIContext().showAlertDialog({ + message: $r('app.string.tips'), + autoCancel: true, + alignment: DialogAlignment.Center, + offset: { dx: 0, dy: -20 }, + gridCount: 4, + buttons: [ + { + value: $r('app.string.cancel'), + action: () => { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'Callback when the first button is clicked'); + } + }, + { + value: $r('app.string.confirm'), + action: () => { + this.nikeName = ''; + this.sex = $r('app.string.male'); + this.birthDate = ''; + this.signature = ''; + this.hobbies = ''; + AppStorage.setOrCreate('isEdit', false); + this.pathStack.pop(); + } + } + ] + }) + return true; + } + return false; + }) + .title(this.NavDestinationTitle()) + .backgroundColor('#F1F3F5') + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/Logger.ets b/entry/src/main/ets/utils/CommonUtils.ets similarity index 37% rename from entry/src/main/ets/common/utils/Logger.ets rename to entry/src/main/ets/utils/CommonUtils.ets index 9967b108a78ca7606d2da0ec611bea562741fd77..de4d8eac7eeb3c55239fc23bb71bd145eac58b76 100644 --- a/entry/src/main/ets/common/utils/Logger.ets +++ b/entry/src/main/ets/utils/CommonUtils.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,39 +13,27 @@ * limitations under the License. */ -import { hilog } from '@kit.PerformanceAnalysisKit'; - -class Logger { - private domain: number; - private prefix: string; - private format: string = '%{public}s, %{public}s'; - - /** - * constructor. - * - * @param Prefix Identifies the log tag. - * @param domain Domain Indicates the service domain, which is a hexadecimal integer ranging from 0x0 to 0xFFFFF. - */ - constructor(prefix: string = 'MyApp', domain: number = 0xFF00) { - this.prefix = prefix; - this.domain = domain; - } - - debug(...args: string[]): void { - hilog.debug(this.domain, this.prefix, this.format, args); - } +class HobbyItem { + label?: string; + isChecked?: boolean; +} - info(...args: string[]): void { - hilog.info(this.domain, this.prefix, this.format, args); +export class CommonUtils { + getBirthDateValue(year: number, month: number, day: number): string { + let resourceYear = getContext(this).resourceManager.getStringSync($r('app.string.year')); + let resourceMonth = getContext(this).resourceManager.getStringSync($r('app.string.month')); + let resourceDay = getContext(this).resourceManager.getStringSync($r('app.string.day')); + let birthdate: string = `${year}${resourceYear}${month}` + `${resourceMonth}${day}${resourceDay}`; + return birthdate; } - warn(...args: string[]): void { - hilog.warn(this.domain, this.prefix, this.format, args); + isEmpty(obj: object | string): boolean { + return obj === undefined || obj === null || obj === ''; } - error(...args: string[]): void { - hilog.error(this.domain, this.prefix, this.format, args); + isEmptyArr(array: Array): boolean { + return array.length === 0; } } -export default new Logger('MultipleDialog', 0xFF00) \ No newline at end of file +export default new CommonUtils(); \ No newline at end of file diff --git a/entry/src/main/ets/view/CustomDialogWidget.ets b/entry/src/main/ets/view/CustomDialogWidget.ets deleted file mode 100644 index 54f73a2157d737d03de742baf0a4e19f54650868..0000000000000000000000000000000000000000 --- a/entry/src/main/ets/view/CustomDialogWidget.ets +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2023 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 Logger from '../common/utils/Logger'; -import HobbyItem from '../viewmodel/HobbyItem'; -import CommonUtils from '../common/utils/CommonUtils'; -import CommonConstants from '../common/constants/CommonConstants'; - -@CustomDialog -export default struct CustomDialogWidget { - @State hobbyItems: HobbyItem[] = []; - @Link hobbies: string; - private controller?: CustomDialogController; - - aboutToAppear() { - let context: Context = getContext(this); - if (CommonUtils.isEmpty(context) || CommonUtils.isEmpty(context.resourceManager)) { - Logger.error(CommonConstants.TAG_CUSTOM, 'context or resourceManager is null'); - return; - } - let manager = context.resourceManager; - manager.getStringArrayValue($r('app.strarray.hobbies_data').id, (error, hobbyArray) => { - if (!CommonUtils.isEmpty(error)) { - Logger.error(CommonConstants.TAG_CUSTOM, 'error = ' + JSON.stringify(error)); - } else { - hobbyArray.forEach((hobbyItem: string) => { - let tmpHobbyItem = new HobbyItem(); - tmpHobbyItem.label = hobbyItem; - tmpHobbyItem.isChecked = false; - this.hobbyItems.push(tmpHobbyItem); - }); - } - }); - } - - /** - * Set hobbies value - * - * @param {HobbyItem[]} hobby item array - */ - setHobbiesValue(hobbyItems: HobbyItem[]) { - if (CommonUtils.isEmptyArr(hobbyItems)) { - Logger.error(CommonConstants.TAG_HOME, 'hobbyItems length is 0'); - return; - } - let hobbiesText: string = ''; - hobbiesText = hobbyItems.filter((isCheckItem: HobbyItem) => isCheckItem?.isChecked) - .map((checkedItem: HobbyItem) => { - return checkedItem.label!; - }) - .join(CommonConstants.COMMA); - if (hobbiesText.length > 0) { - this.hobbies = hobbiesText; - } - } - - build() { - Column() { - Text($r('app.string.text_title_hobbies')) - .fontColor($r('app.color.custom_color')) - .fontSize($r('app.float.title_hobbies_size')) - .lineHeight($r('app.float.title_line_height')) - .fontWeight(CommonConstants.BIGGER) - .alignSelf(ItemAlign.Start) - .margin({ left: $r('app.float.title_left_distance') }) - List() { - ForEach(this.hobbyItems, (itemHobby: HobbyItem) => { - ListItem() { - Row() { - Text(itemHobby.label) - .fontSize($r('app.float.label_size')) - .fontColor($r('app.color.custom_color')) - .layoutWeight(CommonConstants.WEIGHT_ONE) - .textAlign(TextAlign.Start) - .fontWeight(CommonConstants.BIGGER) - .margin({ left: $r('app.float.label_left_distance') }) - Toggle({ type: ToggleType.Checkbox, isOn: false }) - .onChange((isCheck) => { - itemHobby.isChecked = isCheck; - }) - .width($r('app.float.toggle_size')) - .height($r('app.float.toggle_size')) - .margin({ right: $r('app.float.toggle_right_distance') }) - } - .height($r('app.float.options_height')) - .margin({ - top: $r('app.float.options_top_distance'), - bottom: $r('app.float.options_bottom_distance') - }) - } - }, (itemHobby: HobbyItem) => JSON.stringify(itemHobby.label)) - } - .margin({ - top: $r('app.float.list_top_distance'), - bottom: $r('app.float.list_bottom_distance') - }) - .divider({ - strokeWidth: $r('app.float.divider_height'), - color: $r('app.color.divider_color') - }) - .listDirection(Axis.Vertical) - .edgeEffect(EdgeEffect.None) - .width(CommonConstants.FULL_WIDTH) - .height($r('app.float.options_list_height')) - - Row() { - Button($r('app.string.cancel_button')) - .dialogButtonStyle() - .onClick(() => { - this.controller?.close(); - }) - Blank() - .backgroundColor($r('app.color.custom_blank_color')) - .width($r('app.float.blank_width')) - .opacity($r('app.float.blank_opacity')) - .height($r('app.float.blank_height')) - Button($r('app.string.definite_button')) - .dialogButtonStyle() - .onClick(() => { - this.setHobbiesValue(this.hobbyItems); - this.controller?.close(); - }) - } - } - .width(CommonConstants.COMMON_DIALOG_WIDTH) - .padding({ - top: $r('app.float.dialog_top_distance'), - bottom: $r('app.float.dialog_bottom_distance') - }) - .borderRadius($r('app.float.dialog_radius')) - .backgroundColor(Color.White) - } -} - -@Extend(Button) function dialogButtonStyle() { - .fontSize($r('app.float.button_text_size')) - .fontColor($r('app.color.custom_button_color')) - .layoutWeight(CommonConstants.WEIGHT_ONE) - .backgroundColor(Color.White) - .width(CommonConstants.FULL_WIDTH) - .height($r('app.float.button_height')) -} \ No newline at end of file diff --git a/entry/src/main/ets/view/Dialog.ets b/entry/src/main/ets/view/Dialog.ets new file mode 100644 index 0000000000000000000000000000000000000000..28bfa2b43f38053cda0fac942d164f64122346c7 --- /dev/null +++ b/entry/src/main/ets/view/Dialog.ets @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2025 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 { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; +import { hilog } from '@kit.PerformanceAnalysisKit'; + +class PromptActionClass { + private ctx: UIContext | undefined = undefined; + private contentNode: ComponentContent | undefined = undefined; + private options: promptAction.BaseDialogOptions | undefined = undefined; + + setContext(context: UIContext) { + this.ctx = context; + } + + setContentNode(node: ComponentContent) { + this.contentNode = node; + } + + setOptions(options: promptAction.BaseDialogOptions) { + this.options = options; + } + + openDialog() { + if (this.contentNode !== null) { + this.ctx?.getPromptAction().openCustomDialog(this.contentNode, this.options) + .then(() => { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'OpenCustomDialog complete'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + hilog.error(0xFF00, 'PersonalInformation', '%{public}s', + `OpenCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + closeDialog() { + if (this.contentNode !== null) { + this.ctx?.getPromptAction().closeCustomDialog(this.contentNode) + .then(() => { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'CloseCustomDialog complete'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + hilog.error(0xFF00, 'PersonalInformation', '%{public}s', + `CloseCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + updateDialog(options: Object) { + if (this.contentNode !== null) { + this.ctx?.getPromptAction().updateCustomDialog(this.contentNode, options) + .then(() => { + hilog.info(0xFF00, 'PersonalInformation', '%{public}s', 'UpdateCustomDialog complete'); + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + hilog.error(0xFF00, 'PersonalInformation', '%{public}s', + `UpdateCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } +} + +export default new PromptActionClass(); \ No newline at end of file diff --git a/entry/src/main/ets/view/TextCommonWidget.ets b/entry/src/main/ets/view/TextCommonComponent.ets similarity index 41% rename from entry/src/main/ets/view/TextCommonWidget.ets rename to entry/src/main/ets/view/TextCommonComponent.ets index 040b902d807535fd5800b4fd33789db49adc6624..89f7dd02e6092da330f1e11588fc024984571c95 100644 --- a/entry/src/main/ets/view/TextCommonWidget.ets +++ b/entry/src/main/ets/view/TextCommonComponent.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,46 +13,47 @@ * limitations under the License. */ -import CommonConstants from '../common/constants/CommonConstants'; - @Component -export default struct TextCommonWidget { - @Link content: string; - private textImage?: Resource; - private title?: Resource; - onItemClick = () => {}; +export default struct TextCommonComponent { + @Link content: ResourceStr; + textImage?: Resource; + title?: ResourceStr; + onItemClick = (): void => {}; build() { Row() { Image(this.textImage !== undefined ? this.textImage : '') - .width($r('app.float.text_image_size')) - .height($r('app.float.text_image_size')) - .margin({ left: $r('app.float.image_left_distance') }) + .width(26) + .height(26) + .margin({ left: 12 }) Text(this.title) - .fontSize($r('app.float.text_size')) - .margin({ left: $r('app.float.image_left_distance') }) - .height(CommonConstants.FULL_HEIGHT) + .fontSize(17) + .margin({ left: 16 }) + .height('100%') + .opacity(0.9) Text(this.content) - .fontSize($r('app.float.text_size')) + .fontSize(17) + .opacity(0.9) .textAlign(TextAlign.End) .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(CommonConstants.ONE_LINES) + .maxLines(1) .margin({ - left: $r('app.float.content_left_distance'), - right: $r('app.float.content_right_distance') + left: 16, + right: 7 }) - .layoutWeight(CommonConstants.WEIGHT_ONE) - .width(CommonConstants.FULL_WIDTH) - Image($r('app.media.ic_arrow')) - .width($r('app.float.arrow_image_width')) - .height($r('app.float.arrow_image_height')) - .margin({ right: $r('app.float.arrow_right_distance') }) + .height('100%') + .layoutWeight(1) + .width('100%') + Image($r('app.media.chevron_right')) + .width(13) + .height(13) + .margin({ right: 14 }) } - .margin({ top: $r('app.float.row_top_distance') }) - .borderRadius($r('app.float.row_radius')) + .margin({ top: 12 }) + .borderRadius(24) .backgroundColor(Color.White) - .width(CommonConstants.COMMON_DIALOG_WIDTH) - .height($r('app.float.row_height')) + .width('100%') + .height(64) .onClick(this.onItemClick) } } \ No newline at end of file diff --git a/entry/src/main/ets/view/TextInputWidget.ets b/entry/src/main/ets/view/TextInputComponent.ets similarity index 48% rename from entry/src/main/ets/view/TextInputWidget.ets rename to entry/src/main/ets/view/TextInputComponent.ets index 1169e0f1a1326c4495692a0a3753e4237a520c46..1d586bac99f0b7ecbbf17819856bba60109afc9d 100644 --- a/entry/src/main/ets/view/TextInputWidget.ets +++ b/entry/src/main/ets/view/TextInputComponent.ets @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2025 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 @@ -13,36 +13,38 @@ * limitations under the License. */ -import CommonConstants from '../common/constants/CommonConstants'; - @Component -export default struct TextInputWidget { - private inputImage?: Resource; - private hintText?: Resource; +export default struct TextInputComponent { + @Link text: string; + inputImage?: Resource; + hintText?: ResourceStr; build() { Row() { Image(this.inputImage !== undefined ? this.inputImage : '') - .width($r('app.float.input_image_size')) - .height($r('app.float.input_image_size')) - .margin({ left: $r('app.float.input_image_left') }) - TextInput({ placeholder: this.hintText }) - .fontSize($r('app.float.input_text_size')) - .padding({ left: $r('app.float.input_left_inside') }) - .placeholderColor($r('app.color.place_color')) + .width(26) + .height(26) + .margin({ left: 12 }) + TextInput({ placeholder: this.hintText, text: this.text }) + .fontSize(17) + .padding({ left: 12 }) .backgroundColor(Color.White) .fontWeight(FontWeight.Normal) .fontStyle(FontStyle.Normal) .fontColor(Color.Black) - .margin({ right: $r('app.float.input_right_inside') }) - .layoutWeight(CommonConstants.WEIGHT_ONE) - .height($r('app.float.text_input_height')) + .opacity(0.9) + .margin({ right: 32 }) + .layoutWeight(1) + .height(48) .enableKeyboardOnFocus(false) + .onChange((value: string) => { + this.text = value; + }) } - .margin({ top: $r('app.float.input_row_top') }) - .borderRadius($r('app.float.input_row_radius')) + .margin({ top: 12 }) + .borderRadius(24) .backgroundColor(Color.White) - .width(CommonConstants.COMMON_DIALOG_WIDTH) - .height($r('app.float.input_row_height')) + .width('100%') + .height(64) } } \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 index 2f762b604df059cd02f0da055d19d779b4e5f876..ad219d733f6afa5ea07f85f580208b08cc3b9041 100644 --- a/entry/src/main/module.json5 +++ b/entry/src/main/module.json5 @@ -15,11 +15,10 @@ "name": "EntryAbility", "srcEntry": "./ets/entryability/EntryAbility.ets", "description": "$string:EntryAbility_desc", - "icon": "$media:icon", + "icon": "$media:layered_image", "label": "$string:EntryAbility_label", - "startWindowIcon": "$media:icon", + "startWindowIcon": "$media:startIcon", "startWindowBackground": "$color:start_window_background", - "orientation": "portrait", "exported": true, "skills": [ { @@ -32,6 +31,20 @@ } ] } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } ] } } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json index 8a31531e1fd375f3e9d854bdd65543c66e3f8dd2..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644 --- a/entry/src/main/resources/base/element/color.json +++ b/entry/src/main/resources/base/element/color.json @@ -3,30 +3,6 @@ { "name": "start_window_background", "value": "#FFFFFF" - }, - { - "name": "column_background_color", - "value": "#F5F5F5" - }, - { - "name": "custom_color", - "value": "#182431" - }, - { - "name": "custom_button_color", - "value": "#007DFF" - }, - { - "name": "custom_blank_color", - "value": "#F2F2F2" - }, - { - "name": "place_color", - "value": "#99000000" - }, - { - "name": "divider_color", - "value": "#0D182431" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json deleted file mode 100644 index e4140f7cac4a0f591364a6af618cfbea4acc6ed5..0000000000000000000000000000000000000000 --- a/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,188 +0,0 @@ -{ - "float": [ - { - "name": "image_back_size", - "value": "26vp" - }, - { - "name": "avatar_size", - "value": "56vp" - }, - { - "name": "personal_font_size", - "value": "16fp" - }, - { - "name": "title_hobbies_size", - "value": "20fp" - }, - { - "name": "title_line_height", - "value": "28vp" - }, - { - "name": "label_size", - "value": "16fp" - }, - { - "name": "options_height", - "value": "22vp" - }, - { - "name": "toggle_size", - "value": "20vp" - }, - { - "name": "options_top_distance", - "value": "13vp" - }, - { - "name": "options_bottom_distance", - "value": "13vp" - }, - { - "name": "divider_height", - "value": "0.5vp" - }, - { - "name": "list_top_distance", - "value": "14vp" - }, - { - "name": "list_bottom_distance", - "value": "8vp" - }, - { - "name": "options_list_height", - "value": "242vp" - }, - { - "name": "blank_width", - "value": "1vp" - }, - { - "name": "blank_opacity", - "value": "1vp" - }, - { - "name": "blank_height", - "value": "25vp" - }, - { - "name": "dialog_radius", - "value": "32vp" - }, - { - "name": "title_left_distance", - "value": "24vp" - }, - { - "name": "label_left_distance", - "value": "24vp" - }, - { - "name": "dialog_left_distance", - "value": "24vp" - }, - { - "name": "dialog_top_distance", - "value": "14vp" - }, - { - "name": "toggle_right_distance", - "value": "24vp" - }, - { - "name": "dialog_bottom_distance", - "value": "16vp" - }, - { - "name": "button_text_size", - "value": "16fp" - }, - { - "name": "button_height", - "value": "40vp" - }, - { - "name": "text_image_size", - "value": "24vp" - }, - { - "name": "image_left_distance", - "value": "12vp" - }, - { - "name": "text_size", - "value": "16vp" - }, - { - "name": "content_left_distance", - "value": "16vp" - }, - { - "name": "content_right_distance", - "value": "7vp" - }, - { - "name": "arrow_image_width", - "value": "12vp" - }, - { - "name": "arrow_image_height", - "value": "24vp" - }, - { - "name": "arrow_right_distance", - "value": "14vp" - }, - { - "name": "row_top_distance", - "value": "24vp" - }, - { - "name": "row_radius", - "value": "24vp" - }, - { - "name": "row_height", - "value": "64vp" - }, - { - "name": "input_image_size", - "value": "24vp" - }, - { - "name": "input_image_left", - "value": "12vp" - }, - { - "name": "input_text_size", - "value": "16fp" - }, - { - "name": "input_left_inside", - "value": "12vp" - }, - { - "name": "input_right_inside", - "value": "32vp" - }, - { - "name": "text_input_height", - "value": "48vp" - }, - { - "name": "input_row_top", - "value": "24vp" - }, - { - "name": "input_row_radius", - "value": "24vp" - }, - { - "name": "input_row_height", - "value": "64vp" - } - ] -} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 4ad68f22e8a7acb30af30041a8cb1dde671e4013..1dd486dca0155da24bad305fa3040c8ce371cfae 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -6,66 +6,82 @@ }, { "name": "EntryAbility_desc", - "value": "Main program entry" + "value": "description" }, { "name": "EntryAbility_label", - "value": "MultipleWindow" + "value": "MultipleDialog" }, { - "name": "text_input_hint", - "value": "Nickname" + "name": "multi_popup_interaction", + "value": "Add pop-ups to your app" }, { - "name": "text_input_signature", - "value": "Personalized signature" + "name": "personalInformation", + "value": "PersonalInformation" }, { - "name": "title_birthdate", - "value": "Date of birth" + "name": "hobbies_and_interests", + "value": "Hobbies and interests" }, { - "name": "title_sex", - "value": "Sex" + "name": "cancel", + "value": "Cancel" }, { - "name": "default_sex", + "name": "confirm", + "value": "Confirm" + }, + { + "name": "male", "value": "Male" }, { - "name": "title_hobbies", - "value": "Hobbies (multiple choices)" + "name": "female", + "value": "Female" }, { - "name": "alert_dialog_message", - "value": "The current data is not saved. Are you sure you want to leave?" + "name": "save", + "value": "Save" }, { - "name": "cancel_button", - "value": "Cancel" + "name": "save_successfully", + "value": "Save successfully" + }, + { + "name": "nickname", + "value": "Nickname" }, { - "name": "definite_button", - "value": "Definite" + "name": "date_of_birth", + "value": "Date of birth" }, { - "name": "text_personal_title", - "value": "Personal Information" + "name": "sex", + "value": "Sex" + }, + { + "name": "personal_signature", + "value": "Personal signature" + }, + { + "name": "Hobbies_multiple_choices", + "value": "Hobbies (multiple choices)" }, { - "name": "text_title_hobbies", - "value": "Hobbies" + "name": "tips", + "value": "Data on the current page is not saved. Determine whether to leave" }, { - "name": "text_year", - "value": "-" + "name": "year", + "value": "/" }, { - "name": "text_month", - "value": "-" + "name": "month", + "value": "/" }, { - "name": "text_day", + "name": "day", "value": "" } ] diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/calendar.png b/entry/src/main/resources/base/media/calendar.png new file mode 100644 index 0000000000000000000000000000000000000000..336d51109ea904c4f6f4876e9dbe36b4b784f14d Binary files /dev/null and b/entry/src/main/resources/base/media/calendar.png differ diff --git a/entry/src/main/resources/base/media/chevron_right.png b/entry/src/main/resources/base/media/chevron_right.png new file mode 100644 index 0000000000000000000000000000000000000000..2d10597347ebec40fdee1b81c8ea08f4a99bf1d7 Binary files /dev/null and b/entry/src/main/resources/base/media/chevron_right.png differ diff --git a/entry/src/main/resources/base/media/doc_plaintext_and_pencil.png b/entry/src/main/resources/base/media/doc_plaintext_and_pencil.png new file mode 100644 index 0000000000000000000000000000000000000000..6572f2fc0319188becfb8663d38ac90ceaed833d Binary files /dev/null and b/entry/src/main/resources/base/media/doc_plaintext_and_pencil.png differ diff --git a/entry/src/main/resources/base/media/dot_grid.png b/entry/src/main/resources/base/media/dot_grid.png new file mode 100644 index 0000000000000000000000000000000000000000..4ce1dd5f8da9bc0263e67baf5021afbaf8bccdb4 Binary files /dev/null and b/entry/src/main/resources/base/media/dot_grid.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/heart.png b/entry/src/main/resources/base/media/heart.png new file mode 100644 index 0000000000000000000000000000000000000000..0fc046ac322ff3bf5557b5df4070eed33fccc352 Binary files /dev/null and b/entry/src/main/resources/base/media/heart.png differ diff --git a/entry/src/main/resources/base/media/ic_back.png b/entry/src/main/resources/base/media/ic_back.png deleted file mode 100644 index 6cbe911b6b33e467fe20c4fbe305f2bc7022d29d..0000000000000000000000000000000000000000 Binary files a/entry/src/main/resources/base/media/ic_back.png and /dev/null differ diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/person.png b/entry/src/main/resources/base/media/person.png new file mode 100644 index 0000000000000000000000000000000000000000..ec3c202728fa88d860dc99e398a9ce1a51a83961 Binary files /dev/null and b/entry/src/main/resources/base/media/person.png differ diff --git a/entry/src/main/resources/base/media/person_2.png b/entry/src/main/resources/base/media/person_2.png new file mode 100644 index 0000000000000000000000000000000000000000..fd6013008a52c68427e247a048101fcf652afd3a Binary files /dev/null and b/entry/src/main/resources/base/media/person_2.png differ diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 8607be393726d65baba7d64deacc51ce1c8f143d..1898d94f58d6128ab712be2c68acc7c98e9ab9ce 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/HomePage" + "pages/Index" ] } diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json index b9e3d388e1726789190b15b6f1353051a583b5fd..1dd486dca0155da24bad305fa3040c8ce371cfae 100644 --- a/entry/src/main/resources/en_US/element/string.json +++ b/entry/src/main/resources/en_US/element/string.json @@ -6,66 +6,82 @@ }, { "name": "EntryAbility_desc", - "value": "Main program entry" + "value": "description" }, { "name": "EntryAbility_label", - "value": "MultipleWindow" + "value": "MultipleDialog" }, { - "name": "text_input_hint", - "value": "Nickname" + "name": "multi_popup_interaction", + "value": "Add pop-ups to your app" }, { - "name": "text_input_signature", - "value": "Personalized signature" + "name": "personalInformation", + "value": "PersonalInformation" }, { - "name": "title_birthdate", - "value": "Date of birth" + "name": "hobbies_and_interests", + "value": "Hobbies and interests" }, { - "name": "title_sex", - "value": "Sex" + "name": "cancel", + "value": "Cancel" }, { - "name": "default_sex", + "name": "confirm", + "value": "Confirm" + }, + { + "name": "male", "value": "Male" }, { - "name": "title_hobbies", - "value": "Hobbies (multiple choices)" + "name": "female", + "value": "Female" }, { - "name": "alert_dialog_message", - "value": "The current data is not saved. Are you sure you want to leave?" + "name": "save", + "value": "Save" }, { - "name": "cancel_button", - "value": "Cancel" + "name": "save_successfully", + "value": "Save successfully" + }, + { + "name": "nickname", + "value": "Nickname" }, { - "name": "definite_button", - "value": "Definite" + "name": "date_of_birth", + "value": "Date of birth" }, { - "name": "text_personal_title", - "value": "Personal Information" + "name": "sex", + "value": "Sex" + }, + { + "name": "personal_signature", + "value": "Personal signature" + }, + { + "name": "Hobbies_multiple_choices", + "value": "Hobbies (multiple choices)" }, { - "name": "text_title_hobbies", - "value": "Hobbies" + "name": "tips", + "value": "Data on the current page is not saved. Determine whether to leave" }, { - "name": "text_year", + "name": "year", "value": "/" }, { - "name": "text_month", + "name": "month", "value": "/" }, { - "name": "text_day", + "name": "day", "value": "" } ] diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 70833bd23b9b444b3ab3556e66602ddaddb10eee..a172e640939ef91616c644d405ec60e536e6f600 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -2,70 +2,86 @@ "string": [ { "name": "module_desc", - "value": "模块描述" + "value": "module description" }, { "name": "EntryAbility_desc", - "value": "主程序入口" + "value": "description" }, { "name": "EntryAbility_label", - "value": "构建多种样式弹窗" + "value": "MultipleDialog" }, { - "name": "text_input_hint", - "value": "昵称" + "name": "multi_popup_interaction", + "value": "给应用添加弹窗" }, { - "name": "text_input_signature", - "value": "个性签名" + "name": "personalInformation", + "value": "个人信息" }, { - "name": "title_birthdate", - "value": "出生日期" + "name": "hobbies_and_interests", + "value": "兴趣爱好" }, { - "name": "title_sex", - "value": "性别" + "name": "cancel", + "value": "取消" }, { - "name": "default_sex", + "name": "confirm", + "value": "确定" + }, + { + "name": "male", "value": "男" }, { - "name": "title_hobbies", - "value": "兴趣爱好(多选)" + "name": "female", + "value": "女" }, { - "name": "alert_dialog_message", - "value": "当前数据未保存,是否离开?" + "name": "save", + "value": "保存信息" }, { - "name": "cancel_button", - "value": "取消" + "name": "save_successfully", + "value": "保存成功" }, { - "name": "definite_button", - "value": "确定" + "name": "nickname", + "value": "昵称" }, { - "name": "text_personal_title", - "value": "个人信息" + "name": "date_of_birth", + "value": "出生日期" }, { - "name": "text_title_hobbies", - "value": "兴趣爱好" + "name": "sex", + "value": "性别" + }, + { + "name": "personal_signature", + "value": "个人签名" + }, + { + "name": "Hobbies_multiple_choices", + "value": "兴趣爱好(多选)" + }, + { + "name": "tips", + "value": "当前页面数据未保存,是否离开" }, { - "name": "text_year", + "name": "year", "value": "年" }, { - "name": "text_month", + "name": "month", "value": "月" }, { - "name": "text_day", + "name": "day", "value": "日" } ] diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index f70ecd4112d94f9aa555adf898d53f18bf58f3e9..06b2783670a348f95533b352c1ceda909a842bbc 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -1,5 +1,22 @@ { "modelVersion": "5.0.0", "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ } -} \ No newline at end of file +} diff --git a/hvigorfile.ts b/hvigorfile.ts index 6478186902c0c1ad7c966a929c7d6b7d8ae7a9f3..f3cb9f1a87a81687554a76283af8df27d8bda775 100644 --- a/hvigorfile.ts +++ b/hvigorfile.ts @@ -1,2 +1,6 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -export { appTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package.json5 b/oh-package.json5 index 466bf538ba2622c8344436389cae3a3e692709e6..0cec98259052cc175d04dbcf61780de4bc9785f4 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -1,13 +1,7 @@ { "modelVersion": "5.0.0", - "license": "", - "devDependencies": { - "@ohos/hypium": "1.0.15" - }, - "author": "", - "name": "multipledialog", "description": "Please describe the basic information.", - "main": "", - "version": "1.0.0", - "dependencies": {} + "dependencies": { + }, + "devDependencies": {} } diff --git a/screenshots/device/MultipeDialog.en.gif b/screenshots/device/MultipeDialog.en.gif deleted file mode 100644 index 41cd4b118c9b95cc9bbd57b3e2a25c95df3de3bd..0000000000000000000000000000000000000000 Binary files a/screenshots/device/MultipeDialog.en.gif and /dev/null differ diff --git a/screenshots/device/MultipeDialog.gif b/screenshots/device/MultipeDialog.gif index ec122d90ef64637388c43c364bd68de2651aab7f..427b1caaa5acf7784c89ae4f3133fbc03befc7d7 100644 Binary files a/screenshots/device/MultipeDialog.gif and b/screenshots/device/MultipeDialog.gif differ