diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e3fd01880df89ea6fcc9d64bdf093aff4236541b --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.componentencapsulation", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c0809cec621696e259b7931c2d203cd462b2e49e --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ComponentEncapsulation" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..0210352ae2ade0dd7b4c841cb6e8ba08b4780038 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2023 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/README.en.md b/README.en.md deleted file mode 100644 index 275ac38432d1a92f4def2aa62dd9f6526d3e3628..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# ComponentEncapsulation - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 35a590f6b6b88a412e67184ad1da6aa1b818949f..9214d39665f5d8481a8410813048afe4b40593ec 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,60 @@ -# ComponentEncapsulation +# ArkUI组件封装场景 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例介绍三种ArkUI组件封装复用的典型业务场景:公用组件封装场景、弹窗组件封装场景和组件工厂类封装场景。 +### 效果图预览 -#### 安装教程 +| 首页 | 公用组件封装场景 | 弹窗组件封装场景 | 组件工厂类封装场景 | +|----------------------------------------|-----------------------------------------|-----------------------------------------|------------------------------------------| +| ![image](screenshots/device/index.png) | ![image](screenshots/device/common.png) | ![image](screenshots/device/dialog.png) | ![image](screenshots/device/factory.png) | -1. xxxx -2. xxxx -3. xxxx +##### 使用说明 -#### 使用说明 +进入首面,会看到公用组件封装、弹窗组件封装和组件工厂类封装三个按钮,点击按钮会进入对应的封装场景实现的页面,查看效果。 -1. xxxx -2. xxxx -3. xxxx +### 工程目录 -#### 参与贡献 +``` +├──entry/src/main/ets/ +│ ├──common +│ │ └──CommonConstants.ets // 公共常量类 +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──model +│ │ ├──AttributeModifier.ets // AttributeModifier接口类 +│ │ ├──GetResourceString.ets // Resource转换String函数 +│ │ └──PopViewUtils.ets // 自定义弹窗类 +│ ├──pages +│ │ ├──CommonComponent.ets // 公共组件封装 +│ │ ├──ComponentFactory.ets // 组件工厂类封装 +│ │ ├──DialogComponent.ets // 弹窗组件封装 +│ │ └──Index.ets // 首页 +│ └──view +│ ├──CustomImageText.ets // 自定义图片加文本组件 +│ └──FactoryMap.ets // 组件工厂 +└──entry/src/main/resources // 应用静态资源目录 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 具体实现 +1. 公用组件封装:系统组件提供了attributeModifier属性方法,通过自定义Class类实现AttributeModifier接口对系统组件属性进行扩展。 -#### 特技 +2. 弹窗组件封装:通过使用UIContext中获取到的PromptAction对象来实现自定义弹窗封装,使用PromptAction对象中openCustomDialog接口打开弹窗,closeCustomDialog接口关闭弹窗。 -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +3. 组件工厂类封装:使用Map结构将封装的各个组件存入,提供方将需要工厂化的组件通过全局@Builder方法封装,将封装好的全局@Builder方法使用wrapBuilder函数包裹,并将返回值作为组件工厂Map的value值存入,使用时通过Map的key值获取相应组件。 + +### 相关权限 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 + +2. HarmonyOS系统:HarmonyOS NEXT Release及以上。 + +3. DevEco Studio版本:DevEco Studio NEXT Release及以上。 + +4. HarmonyOS SDK版本:HarmonyOS NEXT Release SDK及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c033ce4278fb0641d84107c3c134047ac487368e --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,35 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +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/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/common/CommonConstants.ets b/entry/src/main/ets/common/CommonConstants.ets new file mode 100644 index 0000000000000000000000000000000000000000..1272a4ad078601fa1edecca3342453adedacb7a1 --- /dev/null +++ b/entry/src/main/ets/common/CommonConstants.ets @@ -0,0 +1,36 @@ +/* + * 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. + */ + +export class CommonConstants { + /** + * One hundred percent. + */ + static readonly ONE_HUNDRED_PERCENT: string = '100%'; + + /** + * Button width. + */ + static readonly BUTTON_WIDTH: string = '42%'; + + /** + * Button spacing. + */ + static readonly BUTTON_SPACING: number = 12; + + /** + * Row spacing. + */ + static readonly ROW_SPACING: number = 16; +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..ba0058d8e601abe08f429b1637dc111484855e25 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,58 @@ +/* + * 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 { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class EntryAbility extends UIAbility { + 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'); + window.getLastWindow(this.context).then((data: window.Window) => { + let uiContext = data.getUIContext(); + AppStorage.setOrCreate('uiContext', uiContext); + }); + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + 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/model/AttributeModifier.ets b/entry/src/main/ets/model/AttributeModifier.ets new file mode 100644 index 0000000000000000000000000000000000000000..826b2a7c19bb49825cd52799c3fab6f3e4a569f1 --- /dev/null +++ b/entry/src/main/ets/model/AttributeModifier.ets @@ -0,0 +1,51 @@ +/* + * 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. + */ + +// The AttributeModifier interface implementation class for the Image component. +export class ImageModifier implements AttributeModifier { + private imageWidth: Length = 0; + private imageHeight: Length = 0; + + constructor(width: Length, height: Length) { + this.imageWidth = width; + this.imageHeight = height; + } + + width(width: Length) { + this.imageWidth = width; + return this; + } + + height(height: Length) { + this.imageHeight = height; + return this; + } + + applyNormalAttribute(instance: ImageAttribute): void { + instance.width(this.imageWidth); + instance.height(this.imageHeight); + instance.borderRadius($r('app.float.padding_l')) + } +} + +// Text component's AttributeModifier interface implementation class. +export class TextModifier implements AttributeModifier { + constructor() { + } + + applyNormalAttribute(instance: TextAttribute): void { + instance.fontSize($r('app.float.font_size_l')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/GetResourceString.ets b/entry/src/main/ets/model/GetResourceString.ets new file mode 100644 index 0000000000000000000000000000000000000000..45b7542cb2fff0824b5319703dbb594be829abad --- /dev/null +++ b/entry/src/main/ets/model/GetResourceString.ets @@ -0,0 +1,19 @@ +/* + * 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. + */ + +export function getResourceString(resource: Resource, __this: object): string { + let resourceString = getContext(__this).resourceManager.getStringSync(resource.id); + return resourceString; +} \ No newline at end of file diff --git a/entry/src/main/ets/model/PopViewUtils.ets b/entry/src/main/ets/model/PopViewUtils.ets new file mode 100644 index 0000000000000000000000000000000000000000..440760e006ed95420dd00224651b4e0f2ddc0db1 --- /dev/null +++ b/entry/src/main/ets/model/PopViewUtils.ets @@ -0,0 +1,86 @@ +/* + * 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 { ComponentContent, promptAction } from '@kit.ArkUI'; + +export enum PopViewShowType { + OPEN +} + +interface PopViewModel { + com: ComponentContent; + popType: PopViewShowType; +} + +export class PopViewUtils { + private static popShare: PopViewUtils; + private infoList: PopViewModel[] = new Array(); + + static shareInstance(): PopViewUtils { + if (!PopViewUtils.popShare) { + PopViewUtils.popShare = new PopViewUtils(); + } + return PopViewUtils.popShare; + } + + static showDialog(type: PopViewShowType, contentView: WrappedBuilder<[T]>, args: T, + options?: promptAction.BaseDialogOptions):void { + let uiContext = AppStorage.get('uiContext'); + if (uiContext) { + // The promptAction object was obtained. + let prompt = uiContext.getPromptAction(); + let componentContent = new ComponentContent(uiContext, contentView, args); + let customOptions: promptAction.BaseDialogOptions = { + alignment: options?.alignment || DialogAlignment.Bottom + }; + // Open pop-ups using openCustomDialog + prompt.openCustomDialog(componentContent, customOptions); + let infoList = PopViewUtils.shareInstance().infoList; + let info: PopViewModel = { + com: componentContent, + popType: type + }; + infoList[0] = info; + } + } + + static closeDialog(type: PopViewShowType):void { + let uiContext = AppStorage.get('uiContext'); + if (uiContext) { + // The promptAction object was obtained. + let prompt = uiContext.getPromptAction(); + let sameTypeList = PopViewUtils.shareInstance().infoList.filter((model) => { + return model.popType === type; + }) + let info = sameTypeList[sameTypeList.length - 1]; + if (info.com) { + PopViewUtils.shareInstance().infoList = PopViewUtils.shareInstance().infoList.filter((model) => { + return model.com !== info.com; + }) + // Close pop-ups using closeCustomDialog. + prompt.closeCustomDialog(info.com); + } + } + } + + static showPopView(contentView: WrappedBuilder<[T]>, args: T, + options?: promptAction.BaseDialogOptions):void { + PopViewUtils.showDialog(PopViewShowType.OPEN, contentView, args, options); + } + + static closePopView():void { + PopViewUtils.closeDialog(PopViewShowType.OPEN); + } +} diff --git a/entry/src/main/ets/pages/CommonComponent.ets b/entry/src/main/ets/pages/CommonComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..ed645fe8b4cd1c2534ff8bd8579926018ea5a9dd --- /dev/null +++ b/entry/src/main/ets/pages/CommonComponent.ets @@ -0,0 +1,49 @@ +/* + * 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 { CommonConstants } from '../common/CommonConstants'; +import { ImageModifier, TextModifier } from '../model/AttributeModifier'; +import { getResourceString } from '../model/GetResourceString'; +import { CustomImageText } from '../view/CustomImageText'; + +@Builder +export function CommonComponentBuilder() { + CommonComponent() +} + +@Entry +@Component +struct CommonComponent { + imageAttribute: ImageModifier = new ImageModifier(330, 330); + textAttribute: TextModifier = new TextModifier(); + + build() { + NavDestination() { + Column() { + CustomImageText({ + imageAttribute: this.imageAttribute, + textAttribute: this.textAttribute, + imageSrc: $r('app.media.image'), + text: 'Scenery' + }) + } + .margin({ top: $r('app.float.margin_top') }) + .justifyContent(FlexAlign.Start) + .alignItems(HorizontalAlign.Center) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .height(CommonConstants.ONE_HUNDRED_PERCENT) + } + .title(getResourceString($r('app.string.common'), this)) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/ComponentFactory.ets b/entry/src/main/ets/pages/ComponentFactory.ets new file mode 100644 index 0000000000000000000000000000000000000000..43049a0ce8b086c2330d24711907425fae72ccf7 --- /dev/null +++ b/entry/src/main/ets/pages/ComponentFactory.ets @@ -0,0 +1,45 @@ +/* + * 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 the component factory. The path must be based on the actual location. +import { factoryMap } from '../view/FactoryMap'; +import { getResourceString } from '../model/GetResourceString'; +import { CommonConstants } from '../common/CommonConstants'; + +// Get the corresponding WrappedBuilder object from the key value of the component factory Map. +let myRadio: WrappedBuilder<[]> = factoryMap.get('Radio') as WrappedBuilder<[]>; +let myCheckbox: WrappedBuilder<[]> = factoryMap.get('Checkbox') as WrappedBuilder<[]>; + +@Builder +export function ComponentFactoryBuilder() { + ComponentFactory() +} + +@Entry +@Component +struct ComponentFactory { + build() { + NavDestination() { + Column({ space: CommonConstants.BUTTON_SPACING }) { + // myRadio and myCheckbox are WrappedBuilder objects obtained from the component factory. + myRadio.builder(); + myCheckbox.builder(); + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .padding($r('app.float.padding')) + } + .title(getResourceString($r('app.string.factory'), this)) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/DialogComponent.ets b/entry/src/main/ets/pages/DialogComponent.ets new file mode 100644 index 0000000000000000000000000000000000000000..6971ff3c06b3f7e540a0505560f29f5881644792 --- /dev/null +++ b/entry/src/main/ets/pages/DialogComponent.ets @@ -0,0 +1,81 @@ +/* + * 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 { CommonConstants } from '../common/CommonConstants'; +import { getResourceString } from '../model/GetResourceString'; +import { PopViewUtils } from '../model/PopViewUtils'; + +@Builder +export function DialogComponentBuilder() { + DialogComponent() +} + +@Builder +export function buildText(_obj: Object) { + Column({ space: CommonConstants.ROW_SPACING }) { + Text($r('app.string.tips')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Bold) + Text($r('app.string.content')) + .fontSize($r('app.float.font_size_l')) + Row() { + Button($r('app.string.cancel')) + .fontColor($r('app.color.blue')) + .backgroundColor(Color.White) + .margin({ right: $r('app.float.margin_right') }) + .width(CommonConstants.BUTTON_WIDTH) + .onClick(() => { + PopViewUtils.closePopView(); + }) + Button($r('app.string.confirm')) + .width(CommonConstants.BUTTON_WIDTH) + .onClick(() => { + PopViewUtils.closePopView(); + }) + } + .justifyContent(FlexAlign.Center) + .width($r('app.float.dialog_width')) + } + .width($r('app.float.dialog_width')) + .padding($r('app.float.padding_l')) + .justifyContent(FlexAlign.Center) + .alignItems(HorizontalAlign.Center) + .backgroundColor(Color.White) + .borderRadius($r('app.float.border_radius')) +} + +@Entry +@Component +struct DialogComponent { + build() { + NavDestination() { + Column() { + Button('Click me') + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .onClick(() => { + PopViewUtils.showPopView(wrapBuilder(buildText), new Object(), { alignment: DialogAlignment.Center }); + }) + } + .justifyContent(FlexAlign.End) + .padding({ + left: $r('app.float.padding'), + right: $r('app.float.padding'), + bottom: $r('app.float.padding') + }) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .height(CommonConstants.ONE_HUNDRED_PERCENT) + } + .title(getResourceString($r('app.string.dialog'), this)) + } +} \ 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..bac07162d247bcfcc8cef073ef17757d7dca4582 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,49 @@ +/* + * 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 { CommonConstants } from '../common/CommonConstants'; + +@Entry +@Component +struct Index { + pageStack: NavPathStack = new NavPathStack(); + + build() { + Navigation(this.pageStack) { + Column({ space: CommonConstants.BUTTON_SPACING }) { + Button($r('app.string.common')) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .onClick(() => { + this.pageStack.pushPathByName('CommonComponent', null, true); + }) + Button($r('app.string.dialog')) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .onClick(() => { + this.pageStack.pushPathByName('DialogComponent', null, true); + }) + Button($r('app.string.factory')) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + .onClick(() => { + this.pageStack.pushPathByName('ComponentFactory', null, true); + }) + } + .padding($r('app.float.padding')) + .justifyContent(FlexAlign.End) + .alignItems(HorizontalAlign.Center) + .height(CommonConstants.ONE_HUNDRED_PERCENT) + .width(CommonConstants.ONE_HUNDRED_PERCENT) + } + .title($r('app.string.scenario')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/CustomImageText.ets b/entry/src/main/ets/view/CustomImageText.ets new file mode 100644 index 0000000000000000000000000000000000000000..0e138be951bce11438192503925489a1e1ffee86 --- /dev/null +++ b/entry/src/main/ets/view/CustomImageText.ets @@ -0,0 +1,32 @@ +/* + * 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 { CommonConstants } from '../common/CommonConstants'; + +@Component +export struct CustomImageText { + @Prop imageAttribute: AttributeModifier; + @Prop textAttribute: AttributeModifier; + @Prop imageSrc: PixelMap | ResourceStr | DrawableDescriptor; + @Prop text: string; + + build() { + Column({ space: CommonConstants.BUTTON_SPACING }) { + Image(this.imageSrc) + .attributeModifier(this.imageAttribute) + Text(this.text) + .attributeModifier(this.textAttribute) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/FactoryMap.ets b/entry/src/main/ets/view/FactoryMap.ets new file mode 100644 index 0000000000000000000000000000000000000000..7aac8867e86694db26b725b5e6d004afb6ef9d93 --- /dev/null +++ b/entry/src/main/ets/view/FactoryMap.ets @@ -0,0 +1,75 @@ +/* + * 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 { CommonConstants } from '../common/CommonConstants'; + +@Builder +function myRadio() { + Text($r('app.string.radio')) + .width('100%') + .fontColor($r('sys.color.mask_secondary')) + Row() { + Radio({ value: '1', group: 'radioGroup' }) + .margin({ right: $r('app.float.margin_right') }) + Text('man') + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) + + Row() { + Radio({ value: '0', group: 'radioGroup' }) + .margin({ right: $r('app.float.margin_right') }) + Text('woman') + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) +} + +@Builder +function myCheckBox() { + Text($r('app.string.checkbox')) + .width('100%') + .fontColor($r('sys.color.mask_secondary')) + Row() { + CheckboxGroup({ group: 'checkboxGroup' }) + .checkboxShape(CheckBoxShape.ROUNDED_SQUARE) + Text('all') + .margin({ left: $r('app.float.margin_right') }) + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) + + Row() { + Checkbox({ name: '1', group: 'checkboxGroup' }) + .shape(CheckBoxShape.ROUNDED_SQUARE) + .margin({ right: $r('app.float.margin_right') }) + Text('text1') + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) + + Row() { + Checkbox({ name: '0', group: 'checkboxGroup' }) + .shape(CheckBoxShape.ROUNDED_SQUARE) + .margin({ right: $r('app.float.margin_right') }) + Text('text2') + } + .width(CommonConstants.ONE_HUNDRED_PERCENT) +} + +// Define the component factory Map. +let factoryMap: Map = new Map(); + +// The components that need to be factory stored in the component factory. +factoryMap.set('Radio', wrapBuilder(myRadio)); +factoryMap.set('Checkbox', wrapBuilder(myCheckBox)); + +// Export assembly factory +export { factoryMap }; \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4a3b5e15e45e58c87a37daef0dffe4fb4cdd4fec --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,39 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "routerMap": "$profile:route_map", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..de3f4e25703a48c10caf23722c82373eccb45047 --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "blue", + "value": "#0a59f7" + }, + { + "name": "gray", + "value": "#f1f3f5" + } + ] +} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..aef0b511aed93d3e5ac4505555dd28d0572d1e6b --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,36 @@ +{ + "float": [ + { + "name": "padding", + "value": "16vp" + }, + { + "name": "font_size_l", + "value": "16fp" + }, + { + "name": "font_size_m", + "value": "14fp" + }, + { + "name": "padding_l", + "value": "18vp" + }, + { + "name": "border_radius", + "value": "24vp" + }, + { + "name": "margin_right", + "value": "12vp" + }, + { + "name": "dialog_width", + "value": "328vp" + }, + { + "name": "margin_top", + "value": "56vp" + } + ] +} \ 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 new file mode 100644 index 0000000000000000000000000000000000000000..8d61c21208448bd1a4ac7084d90329b01e4d3e94 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,56 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ArkUI component encapsulation scenario" + }, + { + "name": "scenario", + "value": "ArkUI component encapsulation scenario" + }, + { + "name": "common", + "value": "Common component encapsulation" + }, + { + "name": "dialog", + "value": "Popup component encapsulation" + }, + { + "name": "factory", + "value": "Component factory class encapsulation" + }, + { + "name": "tips", + "value": "tips" + }, + { + "name": "content", + "value": "Have read and agree to the content" + }, + { + "name": "confirm", + "value": "confirm" + }, + { + "name": "cancel", + "value": "cancel" + }, + { + "name": "radio", + "value": "Radio" + }, + { + "name": "checkbox", + "value": "CheckBox" + } + ] +} \ No newline at end of file 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/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/image.png b/entry/src/main/resources/base/media/image.png new file mode 100644 index 0000000000000000000000000000000000000000..a92c914bdafeb10087de9bb6edf8867a74418f22 Binary files /dev/null and b/entry/src/main/resources/base/media/image.png 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/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 new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/base/profile/route_map.json b/entry/src/main/resources/base/profile/route_map.json new file mode 100644 index 0000000000000000000000000000000000000000..7e8f26a009aeddb1fa857523ac071963af8fa6cd --- /dev/null +++ b/entry/src/main/resources/base/profile/route_map.json @@ -0,0 +1,28 @@ +{ + "routerMap": [ + { + "name": "CommonComponent", + "pageSourceFile": "src/main/ets/pages/CommonComponent.ets", + "buildFunction": "CommonComponentBuilder", + "data": { + "description" : "this is CommonComponent" + } + }, + { + "name": "DialogComponent", + "pageSourceFile": "src/main/ets/pages/DialogComponent.ets", + "buildFunction": "DialogComponentBuilder", + "data": { + "description" : "this is DialogComponent" + } + }, + { + "name": "ComponentFactory", + "pageSourceFile": "src/main/ets/pages/ComponentFactory.ets", + "buildFunction": "ComponentFactoryBuilder", + "data": { + "description" : "this is ComponentFactory" + } + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8d61c21208448bd1a4ac7084d90329b01e4d3e94 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,56 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ArkUI component encapsulation scenario" + }, + { + "name": "scenario", + "value": "ArkUI component encapsulation scenario" + }, + { + "name": "common", + "value": "Common component encapsulation" + }, + { + "name": "dialog", + "value": "Popup component encapsulation" + }, + { + "name": "factory", + "value": "Component factory class encapsulation" + }, + { + "name": "tips", + "value": "tips" + }, + { + "name": "content", + "value": "Have read and agree to the content" + }, + { + "name": "confirm", + "value": "confirm" + }, + { + "name": "cancel", + "value": "cancel" + }, + { + "name": "radio", + "value": "Radio" + }, + { + "name": "checkbox", + "value": "CheckBox" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..82248c13665c88dd60a4b283762bbed0608e7821 --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,56 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ArkUI组件封装场景" + }, + { + "name": "scenario", + "value": "ArkUI组件封装场景" + }, + { + "name": "common", + "value": "公用组件封装" + }, + { + "name": "dialog", + "value": "弹窗组件封装" + }, + { + "name": "factory", + "value": "组件工厂类封装" + }, + { + "name": "tips", + "value": "提示" + }, + { + "name": "content", + "value": "已阅读并同意相关内容" + }, + { + "name": "confirm", + "value": "确定" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "radio", + "value": "单选框" + }, + { + "name": "checkbox", + "value": "复选框" + } + ] +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +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*/ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +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 new file mode 100644 index 0000000000000000000000000000000000000000..bb12751b97530b9a3504e56e8ed09d8c9ba1fa52 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/screenshots/device/common.png b/screenshots/device/common.png new file mode 100644 index 0000000000000000000000000000000000000000..6ae8105cf1b646abb15dc7d546627ced6f6bec3b Binary files /dev/null and b/screenshots/device/common.png differ diff --git a/screenshots/device/dialog.png b/screenshots/device/dialog.png new file mode 100644 index 0000000000000000000000000000000000000000..c9edc233af291d4f7f82e83115f2bc5000fce499 Binary files /dev/null and b/screenshots/device/dialog.png differ diff --git a/screenshots/device/factory.png b/screenshots/device/factory.png new file mode 100644 index 0000000000000000000000000000000000000000..41bf46ff6066f7b8e32664ee1b6799cf48057980 Binary files /dev/null and b/screenshots/device/factory.png differ diff --git a/screenshots/device/index.png b/screenshots/device/index.png new file mode 100644 index 0000000000000000000000000000000000000000..06a5ab4189fb023c2335f00c0f7b3f6455cc654a Binary files /dev/null and b/screenshots/device/index.png differ