diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..47274c13ef86cf1096cffef8365d703903dc694c --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.verificationcodescenario", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} \ No newline at end of file diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b79b02f4d019af0d09c86623289e22e7ae3b0dd1 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "VerificationCodeScenario" + } + ] +} \ No newline at end of file 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..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index b7c1e31df66f8ecc9ea81040711cc8d098700444..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# VerificationCodeScenario - -#### 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 0aad0a796a82bb2217306e51508aa5eabce0f84a..2103f880d6a2f852caf0cf06fd208c92e1f3c4e0 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,59 @@ -# VerificationCodeScenario +# 验证码场景实例 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例介绍了文本框显示光标、底部加横条、背景颜色改变、选择验证码、滑块验证码五种验证码实例。 +### 效果预览 -#### 安装教程 +![](screenshots/device/verification.gif) -1. xxxx -2. xxxx -3. xxxx +使用说明: -#### 使用说明 +加载完成后显示首页的5个验证码实例,点击对应按钮,进入相应的验证码页面: +1. 文本框显示光标:输入数字光标会移动到下一个文本框,同时下边框变色。 +2. 底部加横条:在输入框内输入6位数字。 +3. 背景颜色改变:输入数字后背景颜色改变。 +4. 选择验证码:按照提示文字的顺序点击图片上的文字,然后点击提交。 +5. 滑块验证码:点击滑块按钮向右滑动,直到将图片拼接完整时松手。 -1. xxxx -2. xxxx -3. xxxx +### 工程目录 -#### 参与贡献 +``` +├──entry/src/main/ets/ +│ ├──common +│ │ ├──Constants.ets // 公共常量类 +│ │ └──GlobalBuilderContext.ets // 全局页面信息 +│ ├──entryability +│ │ └──EntryAbility.ets // 程序入口类 +│ ├──pages +│ │ ├──BackgroundColorChange.ets // 背景颜色改变 +│ │ ├──BottomWithBar.ets // 底部加横条 +│ │ ├──Index.ets // 首页 +│ │ ├──SelectVerificationCode.ets // 选择验证码 +│ │ ├──SliderVerificationCode.ets // 滑块验证码 +│ │ └──TextBoxShowCursor.ets // 文本框显示光标 +│ └──viewmodel +│ └──NavDestinationItem.ets // 路由类型 +└──entry/src/main/resources // 应用资源目录 +``` -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request +### 具体实现 +1. 文本框显示光标:当前TextInput暂时无法监听到删除键,这里使用了Text组件,订阅输入法插入、删除事件,从而获取输入内容,当组件的可视面积变化的时候进行绑定与解绑,光标通过属性动画显隐效果实现。 +2. 底部加横条:通过TextInput实现,限制最大输入个数为6个数字,使用Divider在下面添加一条横线实现效果。 +3. 背景颜色改变:与文本框显示光标相同的原理,背景颜色改变是通过判断是否输入了数字,有数字的背景颜色改变。 +4. 选择验证码:通过Stack组件将数字覆盖到图片上,当点击数字时获取当前点击位置相对于页面的横纵坐标和点击的文字内容,并将文字添加到数组中,通过坐标移动代表点击顺序的数字,点击提交按钮判断数组中的文字内容和顺序是否正确。 +5. 滑块验证码:通过Slider组件的onChange方法获取互动的距离,从而移动图片上的滑块把图片拼接完整。 +### 相关权限 +不涉及。 -#### 特技 +### 约束与限制 -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/) +1.本示例仅支持标准系统上运行,支持设备:华为手机。 + +2.HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 + +3.DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 + +4.HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 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..808380f3b726e2036a3d6cf5fb9b0fd9513a8215 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,25 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + } + ] +} \ 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..803b25293388deda7b9a05a21b5aeadeb716b4d5 --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} \ No newline at end of file diff --git a/entry/src/main/ets/common/Constants.ets b/entry/src/main/ets/common/Constants.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc6ad96e962d87dfae3c7b2771a2ecdf5b477694 --- /dev/null +++ b/entry/src/main/ets/common/Constants.ets @@ -0,0 +1,303 @@ +/* + * 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 { NavDestinationItem } from '../viewmodel/NavDestinationItem'; + +export default class Constants { + /** + * One hundred percent. + */ + static readonly ONE_HUNDRED_PERCENT: string = '100%'; + + /** + * Ninety percent. + */ + static readonly NINETY_PERCENT: string = '90%'; + + /** + * Eighty percent. + */ + static readonly EIGHTY_PERCENT: string = '80%'; + + /** + * Eighty-five percent. + */ + static readonly EIGHTY_FIVE_PERCENT: string = '85%'; + + /** + * Rotate angle. + */ + static readonly ANGLE: number = 45; + + /** + * Change value. + */ + static readonly CHANGE_VALUE: number = 77; + + /** + * Zero. + */ + static readonly ZERO: number = 0; + + /** + * Eight hundred. + */ + static readonly EIGHT_HUNDRED: number = 800; + + /** + * Two thousand. + */ + static readonly TWO_THOUSAND: number = 2000; + + /** + * Three thousand. + */ + static readonly THREE_THOUSAND: number = 3000; + + /** + * One hundred. + */ + static readonly ONE_HUNDRED: number = 100; + + /** + * Iteration. + */ + static readonly ITERATION: number = -1; + + /** + * Negative two. + */ + static readonly NEGATIVE_TWO: number = -2; + + /** + * Negative one hundred ninety-seven. + */ + static readonly ONE_HUNDRED_NINETY_SEVEN: number = -197; + + /** + * Negative one hundred and fourteen. + */ + static readonly ONE_HUNDRED_FOURTEEN: number = -114; + + /** + * Negative one hundred twenty. + */ + static readonly NEGATIVE_ONE_HUNDRED_TWENTY: number = -120; + + /** + * Coefficient of movement. + */ + static readonly COEFFICIENT: number = 2.83; + + /** + * Twenty. + */ + static readonly TWENTY: number = 20; + + /** + * Negative twenty. + */ + static readonly NEGATIVE_TWENTY: number = -20; + + /** + * Thirty. + */ + static readonly THIRTY: number = 30; + + /** + * One hundred and twenty. + */ + static readonly ONE_HUNDRED_AND_TWENTY: number = 120; + + /** + * Three hundred and forty. + */ + static readonly THREE_HUNDRED_AND_FORTY: number = 340; + + /** + * Ninety. + */ + static readonly NINETY: number = 90; + + /** + * Ninety five. + */ + static readonly NINETY_FIVE: number = 95; + + /** + * Two. + */ + static readonly TWO: number = 2; + + /** + * Three. + */ + static readonly THREE: number = 3; + + /** + * Four. + */ + static readonly FOUR: number = 4; + + /** + * Line move. + */ + static readonly LINE_MOVE: number = 14; + + /** + * Line height. + */ + static readonly LINE_HEIGHT: number = 1; + + /** + * Line width. + */ + static readonly LINE_WIDTH: number = 48; + + /** + * Item divider. + */ + static readonly ITEM_DIVIDER: number = 5; + + /** + * Fifty-eight point five. + */ + static readonly FIFTY_EIGHT_POINT_FIVE: number = 58.5; + + /** + * Fifty-nine. + */ + static readonly FIFTY_NINE: number = 59; + + /** + * Sixty. + */ + static readonly SIXTY: number = 60; + + /** + * Negative sixty. + */ + static readonly NEGATIVE_SIXTY: number = -60; + + /** + * Forty. + */ + static readonly FORTY: number = 40; + + /** + * One hundred forty. + */ + static readonly ONE_HUNDRED_FORTY: number = 140; + + /** + * Negative one hundred. + */ + static readonly NEGATIVE_ONE_HUNDRED: number = -100; + + /** + * Negative one hundred ten. + */ + static readonly NEGATIVE_ONE_HUNDRED_TEN: number = -110; + + /** + * Negative thirty-five. + */ + static readonly NEGATIVE_THIRTY_FIVE: number = -35; + + /** + * Negative seventy-five. + */ + static readonly NEGATIVE_SEVENTY_FIVE: number = -75; + + /** + * Ten. + */ + static readonly TEN: number = 10; + + /** + * Negative twelve. + */ + static readonly NEGATIVE_TWELVE: number = -12; + + /** + * Negative twenty-five. + */ + static readonly NEGATIVE_TWENTY_FIVE: number = -25; + + /** + * Negative five. + */ + static readonly NEGATIVE_FIVE: number = -5; + + /** + * Minus thirty. + */ + static readonly MINUS_THIRTY: number = -30; + + /** + * Draw. + */ + static readonly DRAW: string = '画'; + + /** + * Therefore. + */ + static readonly THEREFORE: string = '故'; + + /** + * Weir. + */ + static readonly WEIR: string = '堰'; + + /** + * Communes. + */ + static readonly COMMUNES: string = '乡'; + + /** + * Hua. + */ + static readonly HUA: string = '华'; + + /** + * Ancients. + */ + static readonly ANCIENTS: string = '古'; + + /** + * Hunan. + */ + static readonly HUNAN: string = '湘'; + + /** + * Word. + */ + static readonly WORD: string = '古堰画乡'; + + /** + * Destination. + */ + static readonly NAV_DESTINATION_DATA: NavDestinationItem[] = [ + { + name: 'TextBoxShowCursor', detail: '文本框显示光标' + }, + { + name: 'BottomWithBar', detail: '底部加横条' + }, + { + name: 'BackgroundColorChange', detail: '背景颜色改变' + } + ]; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/GlobalBuilderContext.ets b/entry/src/main/ets/common/GlobalBuilderContext.ets new file mode 100644 index 0000000000000000000000000000000000000000..8674f1be1607390b6eb701bffa7b7dcbe305bc02 --- /dev/null +++ b/entry/src/main/ets/common/GlobalBuilderContext.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 { wrappedBuilderShowCursor } from '../pages/TextBoxShowCursor'; +import { wrappedBuilderBottomWithBar } from '../pages/BottomWithBar'; +import { wrappedBuilderColorChange } from '../pages/BackgroundColorChange'; +import { wrappedBuilderVerificationCode } from '../pages/SelectVerificationCode'; +import { wrappedBuilderSliderVerification } from '../pages/SliderVerificationCode'; + +export class GlobalBuilderContext { + private static instance: GlobalBuilderContext; + private _objects = new Map(); + + public static getContext(): GlobalBuilderContext { + if (!GlobalBuilderContext.instance) { + GlobalBuilderContext.instance = new GlobalBuilderContext(); + GlobalBuilderContext.instance.setObject('TextBoxShowCursor', wrappedBuilderShowCursor); + GlobalBuilderContext.instance.setObject('BottomWithBar', wrappedBuilderBottomWithBar); + GlobalBuilderContext.instance.setObject('BackgroundColorChange', wrappedBuilderColorChange); + GlobalBuilderContext.instance.setObject('VerificationCode', wrappedBuilderVerificationCode); + GlobalBuilderContext.instance.setObject('SliderVerification', wrappedBuilderSliderVerification); + } + return GlobalBuilderContext.instance; + } + + getObject(value: string): Object | undefined { + return this._objects.get(value); + } + + setObject(key: string, objectClass: Object): void { + this._objects.set(key, objectClass); + } +} \ 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..631333d05052079c193779de35b8a9b062e64f1c --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * 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'); + + 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'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/BackgroundColorChange.ets b/entry/src/main/ets/pages/BackgroundColorChange.ets new file mode 100644 index 0000000000000000000000000000000000000000..7863678db3275ac782e1da3c5c4a6e29f0f23deb --- /dev/null +++ b/entry/src/main/ets/pages/BackgroundColorChange.ets @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { inputMethod } from '@kit.IMEKit'; +import Constants from '../common/Constants'; + +@Extend(Text) +function verifyCodeUnitStyle() { + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Bold) + .textAlign(TextAlign.Center) + .width($r('app.float.text_height')) + .aspectRatio(Constants.LINE_HEIGHT) + .margin({ + left: $r('app.float.text_margin'), + right: $r('app.float.text_margin') + }) + .borderRadius($r('app.float.row_width')) +} + +@Entry +@Component +struct BackgroundColorChange { + @State codeText: string = ''; + private inputController: inputMethod.InputMethodController = inputMethod.getController(); + private arrArea: number[] = [0.0, 1, 0]; + private verifyCodeLength: number = 6; + private codeIndexArray: Array = Array.from([0, 1, 2, 3, 4, 5]); + private textConfig: inputMethod.TextConfig = { + inputAttribute: { + textInputType: inputMethod.TextInputType.NUMBER, + enterKeyType: inputMethod.EnterKeyType.GO + } + }; + + aboutToDisappear(): void { + this.detach(); + } + + async attach() { + await this.inputController.attach(true, this.textConfig); + } + + listen() { + this.inputController.on('insertText', (text: string) => { + if (this.codeText.length >= this.verifyCodeLength || isNaN(Number(text)) || text === ' ') { + return; + } + this.codeText += text; + }) + this.inputController.on('deleteLeft', () => { + this.codeText = this.codeText.substring(0, this.codeText.length - 1); + }) + } + + detach(): void { + this.inputController.off('insertText'); + this.inputController.off('deleteLeft'); + this.inputController.detach((_err: BusinessError) => {}); + } + + @Builder + buildVerifyCodeComponent() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { + ForEach(this.codeIndexArray, (item: number) => { + Text(this.codeText[item]) + .verifyCodeUnitStyle() + .backgroundColor(this.codeText[item] === undefined ? $r('app.color.index_background') : + $r('app.color.theme_color_m')) + }, (item: number) => JSON.stringify(item)) + } + .onVisibleAreaChange(this.arrArea, async (isVisible: boolean, currentRatio: number) => { + if (isVisible && currentRatio >= 1.0) { + await this.attach(); + this.listen(); + } + if (!isVisible && currentRatio <= 0.0) { + this.detach(); + } + }) + .backgroundColor(Color.Transparent) + .height($r('app.float.text_height')) + .margin({ + left: $r('app.float.background_margin'), + right: $r('app.float.background_margin') + }) + .defaultFocus(true) + .onClick(() => { + this.attach(); + }) + } + + build() { + Column() { + Row() { + Text($r('app.string.enter_the_verification_code')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Medium) + } + .height($r('app.float.list_padding_top')) + + Row() { + Text($r('app.string.Verification_code_sent_to')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.phone_color')) + .fontWeight(FontWeight.Regular) + Text($r('app.string.phone_number1')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.theme_color')) + .fontWeight(FontWeight.Regular) + } + .margin({ + top: $r('app.float.row_width'), + bottom: $r('app.float.margin_bottom') + }) + + this.buildVerifyCodeComponent() + + Row() { + Text($r('app.string.reacquire')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.theme_color')) + } + .width(Constants.NINETY_PERCENT) + .margin({ top: $r('app.float.row_margin') }) + .justifyContent(FlexAlign.End) + } + .padding({ top: Constants.LINE_WIDTH }) + .height(Constants.ONE_HUNDRED_PERCENT) + .width(Constants.ONE_HUNDRED_PERCENT) + } +} + +@Builder +export function getColorChange(name: string): void { + if (name === 'BackgroundColorChange') { + NavDestination() { + BackgroundColorChange() + } + } +} + +export const wrappedBuilderColorChange: WrappedBuilder<[string, number]> = wrapBuilder(getColorChange); \ No newline at end of file diff --git a/entry/src/main/ets/pages/BottomWithBar.ets b/entry/src/main/ets/pages/BottomWithBar.ets new file mode 100644 index 0000000000000000000000000000000000000000..ff97138fd90b33c4c0d308da63c3f7f3bddaff07 --- /dev/null +++ b/entry/src/main/ets/pages/BottomWithBar.ets @@ -0,0 +1,93 @@ +/* + * 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 Constants from '../common/Constants'; + +@Entry +@Component +struct BottomWithBar { + private maxLength: number = 6; + private strokeWidth: number = 1; + + build() { + Column() { + Row() { + Text($r('app.string.enter_the_verification_code')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Medium) + } + .height($r('app.float.list_padding_top')) + + Row() { + Text($r('app.string.Verification_code_sent_to')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.phone_color')) + .fontWeight(FontWeight.Regular) + Text($r('app.string.phone_number1')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.theme_color')) + .fontWeight(FontWeight.Regular) + } + .margin({ + top: $r('app.float.row_width'), + bottom: $r('app.float.margin_bottom_one') + }) + + Row() { + TextInput() + .backgroundColor(Color.Transparent) + .width(Constants.EIGHTY_PERCENT) + .maxLength(this.maxLength) + .type(InputType.Number) + .translate({ x: Constants.NEGATIVE_TWELVE }) + Text($r('app.string.reacquire')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.theme_color')) + } + .width(Constants.EIGHTY_FIVE_PERCENT) + + Divider() + .strokeWidth(this.strokeWidth) + .width(Constants.EIGHTY_FIVE_PERCENT) + .color($r('app.color.line_divider')) + .margin({ + top: $r('app.float.text_margin'), + bottom: $r('app.float.divider_bottom') + }) + + Button($r('app.string.login')) + .backgroundColor($r('app.color.theme_color')) + .fontColor(Color.White) + .width(Constants.EIGHTY_FIVE_PERCENT) + .height($r('app.float.bottom_height')) + + } + .padding({ top: Constants.LINE_WIDTH }) + .height(Constants.ONE_HUNDRED_PERCENT) + .width(Constants.ONE_HUNDRED_PERCENT) + } +} + +@Builder +export function getBottomWithBar(name: string): void { + if (name === 'BottomWithBar') { + NavDestination() { + BottomWithBar() + } + } +} + +export const wrappedBuilderBottomWithBar: WrappedBuilder<[string, number]> = wrapBuilder(getBottomWithBar); \ 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..803b983658639fca669cf4ce14abb41b33080ad7 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,206 @@ +/* + * 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 Constants from '../common/Constants'; +import { NavDestinationItem } from '../viewmodel/NavDestinationItem'; +import { GlobalBuilderContext } from '../common/GlobalBuilderContext'; + +@Entry +@Component +struct Index { + private NavDestinationData: NavDestinationItem[] = Constants.NAV_DESTINATION_DATA; + private stringName: string = 'VerificationCode'; + private stringName1: string = 'SliderVerification'; + pageInfos: NavPathStack = new NavPathStack(); + + @Builder + PagesMap(name: string) { + if ((GlobalBuilderContext.getContext().getObject(name)) !== undefined) { + (GlobalBuilderContext.getContext().getObject(name) as WrappedBuilder<[string, number]>) + .builder(name, Constants.ZERO); + } + } + + @Builder + itemHead(text: Resource) { + Text(text) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + .width(Constants.ONE_HUNDRED_PERCENT) + .padding({ bottom: $r('app.float.padding_bottom') }) + .fontColor($r('sys.color.mask_secondary')) + } + + aboutToAppear(): void { + AppStorage.setOrCreate('listData', this.NavDestinationData); + } + + build() { + Column() { + Navigation(this.pageInfos) { + List() { + this.itemHead($r('app.string.verification_code')) + ForEach(this.NavDestinationData, (item: NavDestinationItem, index: number) => { + ListItem() { + Column() { + Row() { + Column() { + Text(item.detail) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + } + .alignItems(HorizontalAlign.Start) + + Blank() + Row() + .width($r('app.float.row_width')) + .height($r('app.float.row_width')) + .margin({ right: $r('app.float.row_margin') }) + .border({ + width: { + top: $r('app.float.border_width'), + right: $r('app.float.border_width') + }, + color: $r('app.color.border_color') + }) + .rotate({ angle: Constants.ANGLE }) + } + .borderRadius({ + topLeft: index === Constants.ZERO ? $r('app.float.padding') : $r('app.float.zero'), + topRight: index === Constants.ZERO ? $r('app.float.padding') : $r('app.float.zero'), + bottomLeft: index === Constants.TWO ? $r('app.float.padding') : $r('app.float.zero'), + bottomRight: index === Constants.TWO ? $r('app.float.padding') : $r('app.float.zero') + }) + .width(Constants.ONE_HUNDRED_PERCENT) + .height($r('app.float.list_item_height')) + .alignItems(VerticalAlign.Center) + .padding({ + left: $r('app.float.padding'), + top: $r('app.float.padding'), + bottom: $r('app.float.padding') + }) + .backgroundColor(Color.White) + .onClick(() => { + this.pageInfos.pushPathByName(item.name, Constants.ZERO); + }) + + Row() + .height($r('app.float.row_height_one')) + .width(Constants.NINETY_PERCENT) + .backgroundColor($r('app.color.line_color')) + } + .width(Constants.ONE_HUNDRED_PERCENT) + .backgroundColor(Color.White) + .borderRadius({ + topLeft: index === Constants.ZERO ? $r('app.float.padding') : $r('app.float.zero'), + topRight: index === Constants.ZERO ? $r('app.float.padding') : $r('app.float.zero'), + bottomLeft: index === Constants.TWO ? $r('app.float.padding') : $r('app.float.zero'), + bottomRight: index === Constants.TWO ? $r('app.float.padding') : $r('app.float.zero') + }) + } + }, (item: NavDestinationItem) => JSON.stringify(item)) + + ListItem() { + Row() { + Column() { + Text($r('app.string.select_verification_code')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + } + .alignItems(HorizontalAlign.Start) + + Blank() + Row() + .width($r('app.float.row_width')) + .height($r('app.float.row_width')) + .margin({ right: $r('app.float.row_margin') }) + .border({ + width: { + top: $r('app.float.border_width'), + right: $r('app.float.border_width') + }, + color: $r('app.color.border_color') + }) + .rotate({ angle: Constants.ANGLE }) + } + .borderRadius($r('app.float.padding')) + .width(Constants.ONE_HUNDRED_PERCENT) + .height($r('app.float.list_item_height')) + .alignItems(VerticalAlign.Center) + .padding({ + left: $r('app.float.padding'), + top: $r('app.float.padding'), + bottom: $r('app.float.padding') + }) + .backgroundColor(Color.White) + .onClick(() => { + this.pageInfos.pushPathByName(this.stringName, Constants.ZERO); + }) + } + .margin({ top: $r('app.float.item_list') }) + + ListItem() { + Row() { + Column() { + Text($r('app.string.slider_verification_code')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + } + .alignItems(HorizontalAlign.Start) + + Blank() + Row() + .width($r('app.float.row_width')) + .height($r('app.float.row_width')) + .margin({ right: $r('app.float.row_margin') }) + .border({ + width: { top: $r('app.float.border_width'), right: $r('app.float.border_width') }, + color: $r('app.color.border_color') + }) + .rotate({ angle: Constants.ANGLE }) + } + .borderRadius($r('app.float.padding')) + .width(Constants.ONE_HUNDRED_PERCENT) + .height($r('app.float.list_item_height')) + .alignItems(VerticalAlign.Center) + .padding({ + left: $r('app.float.padding'), + top: $r('app.float.padding'), + bottom: $r('app.float.padding') + }) + .backgroundColor(Color.White) + .onClick(() => { + this.pageInfos.pushPathByName(this.stringName1, Constants.ZERO); + }) + } + .margin({ top: $r('app.float.item_list') }) + } + .height(Constants.ONE_HUNDRED_PERCENT) + .width(Constants.ONE_HUNDRED_PERCENT) + .padding({ + left: $r('app.float.change'), + right: $r('app.float.change'), + top: $r('app.float.list_padding_top') + }) + } + .mode(NavigationMode.Stack) + .navDestination(this.PagesMap) + } + .expandSafeArea([SafeAreaType.KEYBOARD, SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM, SafeAreaEdge.TOP]) + .height(Constants.ONE_HUNDRED_PERCENT) + .width(Constants.ONE_HUNDRED_PERCENT) + .backgroundColor($r('app.color.index_background')) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/SelectVerificationCode.ets b/entry/src/main/ets/pages/SelectVerificationCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..bebdc158653c45280123527869a7d6c5eca97333 --- /dev/null +++ b/entry/src/main/ets/pages/SelectVerificationCode.ets @@ -0,0 +1,315 @@ +/* + * 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 Constants from '../common/Constants'; + +@Extend(Text) +function word() { + .fontSize($r('app.float.font_size_max')) + .fontColor($r('app.color.word_color')) + .fontWeight(FontWeight.Bold) +} + +@Extend(Text) +function number() { + .fontSize($r('app.float.font_size')) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .backgroundColor($r('app.color.theme_color')) + .width($r('app.float.margin_bottom')) + .height($r('app.float.margin_bottom')) + .borderRadius($r('app.float.padding')) + .textAlign(TextAlign.Center) +} + +@Extend(Text) +function toast() { + .fontSize($r('app.float.font_size')) + .fontColor(Color.Black) + .height($r('app.float.toast_height')) + .backgroundColor(Color.White) + .padding({ + left: $r('app.float.change'), + right: $r('app.float.change') + }) + .margin({ top: $r('app.float.toast_margin_m') }) + .borderRadius($r('app.float.toast_border_radius')) + .shadow({ + radius: $r('app.float.shadow'), + type: ShadowType.COLOR, + color: $r('app.color.shadow') + }) + .animation({ + duration: Constants.TWO_THOUSAND, + curve: Curve.Ease + }) +} + +@Entry +@Component +struct SelectVerificationCode { + @State text: string = ''; + @State wordNumber: number = 1; + @State wordArr: string[] = []; + @State flag: boolean = true; + @State opacitySuccess: number = 0; + @State opacityFail: number = 0; + @State oneX: number = 0; + @State oneY: number = 0; + @State twoX: number = 0; + @State twoY: number = 0; + @State threeX: number = 0; + @State threeY: number = 0; + @State fourX: number = 0; + @State fourY: number = 0; + private timer: number = 0; + private flagWordOne: boolean = true; + private flagWordTwo: boolean = true; + private flagWordThree: boolean = true; + private flagWordFour: boolean = true; + private flagWordFive: boolean = true; + private flagWordSix: boolean = true; + private flagWordSeven: boolean = true; + + clickContent(flag: boolean, word: string, e: ClickEvent): boolean { + if (flag && this.wordArr.length < 4) { + this.wordArr.push(word); + if (this.wordNumber === 1) { + this.oneX = e.displayX; + this.oneY = e.displayY; + this.wordNumber++; + } else if (this.wordNumber === 2) { + this.twoX = e.displayX; + this.twoY = e.displayY; + this.wordNumber++; + } else if (this.wordNumber === 3) { + this.threeX = e.displayX; + this.threeY = e.displayY; + this.wordNumber++; + } else if (this.wordNumber === 4) { + this.fourX = e.displayX; + this.fourY = e.displayY; + this.wordNumber++; + } + } + return false; + } + + initWord(): void { + this.wordArr = []; + this.wordNumber = Constants.LINE_HEIGHT; + this.oneX = Constants.ZERO; + this.oneY = Constants.ZERO; + this.twoX = Constants.ZERO; + this.twoY = Constants.ZERO; + this.threeX = Constants.ZERO; + this.threeY = Constants.ZERO; + this.fourX = Constants.ZERO; + this.fourY = Constants.ZERO; + this.flagWordOne = true; + this.flagWordTwo = true; + this.flagWordThree = true; + this.flagWordFour = true; + this.flagWordFive = true; + this.flagWordSix = true; + this.flagWordSeven = true; + } + + build() { + Column() { + Stack() { + Text(Constants.LINE_HEIGHT.toString()) + .number() + .translate({ + x: Constants.ONE_HUNDRED_NINETY_SEVEN + this.oneX, + y: Constants.ONE_HUNDRED_FOURTEEN + this.oneY + }) + Text(Constants.TWO.toString()) + .number() + .translate({ + x: Constants.ONE_HUNDRED_NINETY_SEVEN + this.twoX, + y: Constants.ONE_HUNDRED_FOURTEEN + this.twoY + }) + Text(Constants.THREE.toString()) + .number() + .translate({ + x: Constants.ONE_HUNDRED_NINETY_SEVEN + this.threeX, + y: Constants.ONE_HUNDRED_FOURTEEN + this.threeY + }) + Text(Constants.FOUR.toString()) + .number() + .translate({ + x: Constants.ONE_HUNDRED_NINETY_SEVEN + this.fourX, + y: Constants.ONE_HUNDRED_FOURTEEN + this.fourY + }) + } + .zIndex(Constants.ONE_HUNDRED) + + Row() { + Text($r('app.string.complete')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Medium) + } + .height($r('app.float.list_padding_top')) + .margin({ bottom: $r('app.float.margin_bottom') }) + + Stack() { + Image($r('app.media.img_1')) + .width($r('app.float.image_width')) + .height($r('app.float.image_height')) + Column() { + Text(Constants.DRAW) + .word() + .translate({ + x: Constants.NEGATIVE_ONE_HUNDRED_TWENTY, + y: Constants.THIRTY + }) + .rotate({ angle: Constants.NEGATIVE_TWENTY }) + .onClick((e) => { + this.flagWordOne = this.clickContent(this.flagWordOne, Constants.DRAW, e); + }) + Text(Constants.THEREFORE) + .word() + .translate({ x: Constants.MINUS_THIRTY }) + .rotate({ angle: Constants.TWENTY }) + .onClick((e) => { + this.flagWordTwo = this.clickContent(this.flagWordTwo, Constants.THEREFORE, e); + }) + Text(Constants.WEIR) + .word() + .translate({ + x: Constants.FORTY, + y: Constants.NEGATIVE_TWENTY_FIVE + }) + .rotate({ angle: Constants.NEGATIVE_TWENTY }) + .onClick((e) => { + this.flagWordThree = this.clickContent(this.flagWordThree, Constants.WEIR, e); + }) + Text(Constants.COMMUNES) + .word() + .translate({ + x: Constants.ONE_HUNDRED_FORTY, + y: Constants.NEGATIVE_ONE_HUNDRED + }) + .onClick((e) => { + this.flagWordFour = this.clickContent(this.flagWordFour, Constants.COMMUNES, e); + }) + Text(Constants.HUA) + .word() + .translate({ + x: Constants.NEGATIVE_ONE_HUNDRED, + y: Constants.NEGATIVE_THIRTY_FIVE + }) + .rotate({ angle: Constants.TEN }) + .onClick((e) => { + this.flagWordFive = this.clickContent(this.flagWordFive, Constants.HUA, e); + }) + Text(Constants.ANCIENTS) + .word() + .translate({ + x: Constants.NEGATIVE_FIVE, + y: Constants.NEGATIVE_SEVENTY_FIVE + }) + .rotate({ angle: Constants.NEGATIVE_SIXTY }) + .onClick((e) => { + this.flagWordSix = this.clickContent(this.flagWordSix, Constants.ANCIENTS, e); + }) + Text(Constants.HUNAN) + .word() + .translate({ + x: Constants.NINETY_FIVE, + y: Constants.NEGATIVE_ONE_HUNDRED_TEN + }) + .rotate({ angle: Constants.TEN }) + .onClick((e) => { + this.flagWordSeven = this.clickContent(this.flagWordSeven, Constants.HUNAN, e); + }) + } + .width($r('app.float.image_width')) + .height($r('app.float.image_height')) + } + + Row() { + Text($r('app.string.sentence')) + .fontColor($r('app.color.word_color')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + Text($r('app.string.change_another')) + .fontSize($r('app.float.font_size_min')) + .fontWeight(FontWeight.Regular) + .fontColor($r('app.color.theme_color')) + .textAlign(TextAlign.Center) + .margin({ right: $r('app.float.change_margin') }) + Image($r('app.media.img')) + .width($r('app.float.change')) + .height($r('app.float.change')) + .backgroundColor(Color.White) + } + .margin({ + top: $r('app.float.word_margin_top'), + bottom: $r('app.float.word_margin_bottom') + }) + .width(Constants.EIGHTY_FIVE_PERCENT) + .justifyContent(FlexAlign.SpaceBetween) + + Button($r('app.string.commit')) + .backgroundColor($r('app.color.theme_color')) + .fontColor(Color.White) + .width(Constants.EIGHTY_FIVE_PERCENT) + .height($r('app.float.bottom_height')) + .onClick(() => { + clearTimeout(this.timer); + if (this.wordArr.join('') === Constants.WORD) { + this.opacitySuccess = Constants.LINE_HEIGHT; + this.flag = true; + this.initWord(); + this.timer = setTimeout(() => { + this.opacitySuccess = Constants.ZERO; + }, Constants.THREE_THOUSAND); + } else { + this.opacityFail = Constants.LINE_HEIGHT; + this.flag = false; + this.initWord(); + this.timer = setTimeout(() => { + this.opacityFail = Constants.ZERO; + }, Constants.THREE_THOUSAND); + } + }) + + if (this.flag) { + Text($r('app.string.verification_passed')) + .opacity(this.opacitySuccess) + .toast() + } else { + Text($r('app.string.verification_fail')) + .opacity(this.opacityFail) + .toast() + } + } + .width(Constants.ONE_HUNDRED_PERCENT) + .height(Constants.ONE_HUNDRED_PERCENT) + } +} + +@Builder +export function getVerificationCode(name: string): void { + if (name === 'VerificationCode') { + NavDestination() { + SelectVerificationCode() + } + } +} + +export const wrappedBuilderVerificationCode: WrappedBuilder<[string, number]> = wrapBuilder(getVerificationCode); \ No newline at end of file diff --git a/entry/src/main/ets/pages/SliderVerificationCode.ets b/entry/src/main/ets/pages/SliderVerificationCode.ets new file mode 100644 index 0000000000000000000000000000000000000000..68e28c9e5a2d54f026fb9f74e4f5e4977777eef9 --- /dev/null +++ b/entry/src/main/ets/pages/SliderVerificationCode.ets @@ -0,0 +1,158 @@ +/* + * 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 Constants from '../common/Constants'; + +@Entry +@Component +struct SliderVerificationCode { + @State tipText: string = ''; + @State inSetValueOne: number = 0; + @State opacityNumber: number = 0; + + getTargetTranslateX() { + return this.inSetValueOne * Constants.COEFFICIENT; + } + + build() { + Column() { + Row() { + Text($r('app.string.complete')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Medium) + } + .height($r('app.float.list_padding_top')) + .margin({ + bottom: $r('app.float.margin_bottom'), + top: $r('app.float.margin_bottom') + }) + + Stack() { + Image($r('app.media.sliderBackground')) + .width($r('app.float.image_width')) + .height($r('app.float.image_height')) + + Image($r('app.media.slider')) + .width($r('app.float.image_width_m')) + .height($r('app.float.image_height_m')) + .translate({ + x: this.getTargetTranslateX(), + y: Constants.NEGATIVE_TWO + }) + } + .alignContent(Alignment.Start) + + Stack() { + Row() + .width($r('app.float.row_width_l')) + .height(Constants.ANGLE) + .backgroundColor($r('app.color.row_background_color')) + .borderRadius($r('app.float.cursor_height')) + Text($r('app.string.slide')) + .fontColor($r('sys.color.mask_tertiary')) + + Row() { + Slider({ + value: this.inSetValueOne, + min: Constants.ZERO, + max: Constants.ONE_HUNDRED, + style: SliderStyle.InSet + }) + .width(Constants.THREE_HUNDRED_AND_FORTY) + .trackColor(Color.Transparent) + .selectedColor($r('app.color.select_color')) + .showTips(false) + .trackThickness(Constants.ANGLE) + .sliderInteractionMode(SliderInteraction.SLIDE_ONLY) + .onChange((value: number, mode: SliderChangeMode) => { + this.inSetValueOne = value; + if (value === Constants.CHANGE_VALUE && mode.valueOf() === Constants.TWO) { + this.inSetValueOne = Constants.CHANGE_VALUE; + this.opacityNumber = Constants.LINE_HEIGHT; + setTimeout(() => { + this.opacityNumber = Constants.ZERO; + if (this.inSetValueOne === Constants.CHANGE_VALUE) { + this.inSetValueOne = Constants.ZERO; + } + }, Constants.THREE_THOUSAND); + } + if (value !== Constants.CHANGE_VALUE && mode.valueOf() === Constants.TWO) { + this.inSetValueOne = Constants.ZERO; + } + }) + } + + Image($r('app.media.button')) + .fillColor(Color.White) + .width($r('app.float.button_width')) + .height($r('app.float.button_width')) + .margin({ left: $r('app.float.margin_left') }) + .translate({ x: this.getTargetTranslateX() }) + .hitTestBehavior(HitTestMode.Transparent) + } + .margin({ top: $r('app.float.padding') }) + + Row() { + Text($r('app.string.change')) + .fontSize($r('app.float.font_size_min')) + .fontColor($r('app.color.change_color')) + .textAlign(TextAlign.Center) + .margin({ top: $r('app.float.row_margin') }) + .lineHeight($r('app.float.change')) + Image($r('app.media.img')) + .width($r('app.float.change')) + .height($r('app.float.change')) + .translate({ + y: Constants.TEN, + x: Constants.ITEM_DIVIDER + }) + .backgroundColor(Color.White) + } + .justifyContent(FlexAlign.Center) + .alignItems(VerticalAlign.Center) + + Text($r('app.string.verification_passed')) + .opacity(this.opacityNumber) + .fontSize($r('app.float.font_size')) + .fontColor(Color.Black) + .height($r('app.float.toast_height')) + .backgroundColor(Color.White) + .padding({ + left: $r('app.float.change'), + right: $r('app.float.change') + }) + .margin({ top: $r('app.float.toast_margin') }) + .borderRadius($r('app.float.toast_border_radius')) + .shadow({ + radius: $r('app.float.shadow'), + type: ShadowType.COLOR, + color: $r('app.color.shadow') + }) + } + .width(Constants.ONE_HUNDRED_PERCENT) + .height(Constants.ONE_HUNDRED_PERCENT) + } +} + +@Builder +export function getSliderVerification(name: string): void { + if (name === 'SliderVerification') { + NavDestination() { + SliderVerificationCode() + } + } +} + +export const wrappedBuilderSliderVerification: WrappedBuilder<[string, number]> = wrapBuilder(getSliderVerification); \ No newline at end of file diff --git a/entry/src/main/ets/pages/TextBoxShowCursor.ets b/entry/src/main/ets/pages/TextBoxShowCursor.ets new file mode 100644 index 0000000000000000000000000000000000000000..797024c54933b62db07691edd418f33aed42867b --- /dev/null +++ b/entry/src/main/ets/pages/TextBoxShowCursor.ets @@ -0,0 +1,239 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BusinessError } from '@kit.BasicServicesKit'; +import { inputMethod } from '@kit.IMEKit'; +import Constants from '../common/Constants'; + +@Extend(Text) +function verifyCodeUnitStyle() { + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Bold) + .fontColor($r('app.color.theme_color')) + .textAlign(TextAlign.Center) + .width($r('app.float.text_height')) + .height(Constants.ONE_HUNDRED_PERCENT) + .margin({ + left: $r('app.float.text_margin'), + right: $r('app.float.text_margin') + }) +} + +@Entry +@Component +struct TextBoxShowCursor { + @State codeText: string = ''; + @State opacityColumn: number = 0; + @State flag: boolean = true; + private arrArea: number[] = [0.0, 1, 0]; + private inputController: inputMethod.InputMethodController = inputMethod.getController(); + private verifyCodeLength: number = 6; + private codeIndexArray: Array = Array.from([0, 1, 2, 3, 4, 5]); + private textConfig: inputMethod.TextConfig = { + inputAttribute: { + textInputType: inputMethod.TextInputType.NUMBER, + enterKeyType: inputMethod.EnterKeyType.GO + } + }; + + aboutToAppear(): void { + this.attach(); + } + + aboutToDisappear(): void { + this.detach(); + } + + /** + * Binding an Input Method and Subscribing to Input Method-related Events. + */ + async attach() { + await this.inputController.attach(true, this.textConfig); + } + + /** + * Subscribe to the events of inserting and deleting leftward in the input method to obtain the input content of + * the keyboard. + */ + listen() { + this.inputController.on('insertText', (text: string) => { + if (this.codeText.length >= this.verifyCodeLength || isNaN(Number(text)) || text === ' ') { + return; + } + this.codeText += text; + if (this.codeText.length === this.verifyCodeLength) { + this.flag = false; + } + }) + this.inputController.on('deleteLeft', () => { + this.codeText = this.codeText.substring(0, this.codeText.length - 1); + if (this.codeText.length !== this.verifyCodeLength) { + this.flag = true; + } + }) + } + + /** + * Unbinding. + */ + detach() { + this.inputController.off('insertText'); + this.inputController.off('deleteLeft'); + this.inputController.detach((_err: BusinessError) => { + }) + } + + /** + * In some verification code scenarios, the functions of selecting and copying entered verification codes must be disabled. + * Therefore, the Text component can be used. + */ + @Builder + buildVerifyCodeComponent() { + Stack() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { + ForEach(this.codeIndexArray, (item: number) => { + Text(this.codeText[item]) + .verifyCodeUnitStyle() + .border({ + width: { bottom: $r('app.float.row_height_one') }, + color: { + bottom: this.codeText[item] === undefined ? $r('app.color.line_divider') : $r('app.color.theme_color') + }, + style: { bottom: BorderStyle.Solid } + }) + }, (item: number) => item.toString()) + } + // When the visible area changes, binding registration and unbinding are performed. + .onVisibleAreaChange(this.arrArea, async (isVisible: boolean, currentRatio: number) => { + if (isVisible && currentRatio >= 1) { + this.opacityColumn = 1; + await this.attach(); + this.listen(); + } + if (!isVisible && currentRatio <= 0) { + this.detach(); + } + }) + .backgroundColor(Color.Transparent) + .height($r('app.float.text_height')) + .width($r('app.float.context_area')) + .margin({ + left: $r('sys.float.ohos_id_card_margin_start'), + right: $r('sys.float.ohos_id_card_margin_start') + }) + .defaultFocus(true) + .onClick(() => { + // When you click this component, the input method is displayed. Because the Text component is used here, + // you need to re-attach it instead of directly using showSoftKeyboard. + this.attach(); + }) + + Row() { + Column() { + Text() + .opacity(this.opacityColumn) + .width(Constants.TWO) + .height($r('app.float.cursor_height')) + .backgroundColor($r('app.color.theme_color')) + .borderRadius($r('app.float.row_height_one')) + .animation({ + duration: Constants.EIGHT_HUNDRED, + curve: Curve.Rhythm, + iterations: Constants.ITERATION, + playMode: PlayMode.Alternate, + expectedFrameRateRange: { + min: Constants.TWENTY, + max: Constants.ONE_HUNDRED_AND_TWENTY, + expected: Constants.NINETY + } + }) + + Text() + .height(Constants.LINE_HEIGHT) + .width(Constants.LINE_WIDTH) + .backgroundColor($r('app.color.theme_color')) + .translate({ y: Constants.LINE_MOVE }) + } + .visibility(this.flag ? Visibility.Visible : Visibility.Hidden) + .translate({ + x: this.codeText.length === Constants.ZERO ? Constants.ITEM_DIVIDER : this.codeText.length * + (this.codeText.length > Constants.TWO ? (this.codeText.length === Constants.ITEM_DIVIDER ? + Constants.FIFTY_EIGHT_POINT_FIVE : Constants.FIFTY_NINE) : Constants.SIXTY) + }) + .hitTestBehavior(HitTestMode.Transparent) + .onClick(() => { + this.attach(); + }) + .justifyContent(FlexAlign.Center) + .height(Constants.ONE_HUNDRED_PERCENT) + } + .hitTestBehavior(HitTestMode.Transparent) + .height($r('app.float.text_height')) + .width($r('app.float.context_area')) + } + } + + build() { + Column() { + Row() { + Text($r('app.string.enter_the_verification_code')) + .fontSize($r('app.float.font_size_l')) + .fontWeight(FontWeight.Medium) + } + .height($r('app.float.list_padding_top')) + + Row() { + Text($r('app.string.Verification_code_sent_to')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.phone_color')) + .fontWeight(FontWeight.Regular) + Text($r('app.string.phone_number')) + .fontSize($r('app.float.font_size_m')) + .fontColor($r('app.color.theme_color')) + .fontWeight(FontWeight.Regular) + } + .margin({ + top: $r('app.float.row_width'), + bottom: $r('app.float.margin_bottom') + }) + + this.buildVerifyCodeComponent() + + Row() { + Text($r('app.string.reacquire')) + .fontSize($r('app.float.font_size')) + .fontWeight(FontWeight.Medium) + .fontColor($r('app.color.theme_color')) + } + .width(Constants.NINETY_PERCENT) + .margin({ top: $r('app.float.row_margin') }) + .justifyContent(FlexAlign.End) + } + .padding({ top: Constants.LINE_WIDTH }) + .height(Constants.ONE_HUNDRED_PERCENT) + .width(Constants.ONE_HUNDRED_PERCENT) + } +} + +@Builder +export function getShowCursor(name: string): void { + if (name === 'TextBoxShowCursor') { + NavDestination() { + TextBoxShowCursor() + } + } +} + +export const wrappedBuilderShowCursor: WrappedBuilder<[string, number]> = wrapBuilder(getShowCursor); \ No newline at end of file diff --git a/entry/src/main/ets/viewmodel/NavDestinationItem.ets b/entry/src/main/ets/viewmodel/NavDestinationItem.ets new file mode 100644 index 0000000000000000000000000000000000000000..c1725b9965e0d913c4d54f7e1d56dc6249607902 --- /dev/null +++ b/entry/src/main/ets/viewmodel/NavDestinationItem.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * Route type define. + */ +export interface NavDestinationItem { + name: string, + detail: string +} \ 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..5f6f8e183e9195d8178183502bf018e80c02f9a1 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,36 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "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..785931c9b1b5721fbce9e639f41d9027c2b16e7f --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,56 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "border_color", + "value": "#cccccc" + }, + { + "name": "index_background", + "value": "#FFF1F3F5" + }, + { + "name": "line_color", + "value": "#f9f9f9" + }, + { + "name": "theme_color", + "value": "#0a59f7" + }, + { + "name": "line_divider", + "value": "#f2f2f2" + }, + { + "name": "phone_color", + "value": "#6e6e6e" + }, + { + "name": "theme_color_m", + "value": "#330a59f7" + }, + { + "name": "row_background_color", + "value": "#f3f3f3" + }, + { + "name": "select_color", + "value": "#B8D9F9" + }, + { + "name": "change_color", + "value": "#2070F3" + }, + { + "name": "word_color", + "value": "#191919" + }, + { + "name": "shadow", + "value": "#40000000" + } + ] +} \ 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..9e77f356f9cd40949a224cb3cdb1dad370b3b3c7 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,180 @@ +{ + "float": [ + { + "name": "font_size", + "value": "16fp" + }, + { + "name": "padding_bottom", + "value": "8vp" + }, + { + "name": "row_width", + "value": "10vp" + }, + { + "name": "row_margin", + "value": "20vp" + }, + { + "name": "border_width", + "value": "2vp" + }, + { + "name": "zero", + "value": "0vp" + }, + { + "name": "padding", + "value": "15vp" + }, + { + "name": "list_item_height", + "value": "60vp" + }, + { + "name": "row_height_one", + "value": "1vp" + }, + { + "name": "list_padding_left", + "value": "24vp" + }, + { + "name": "list_padding_top", + "value": "32vp" + }, + { + "name": "text_height", + "value": "50vp" + }, + { + "name": "text_margin", + "value": "5vp" + }, + { + "name": "context_area", + "value": "345vp" + }, + { + "name": "cursor_height", + "value": "22vp" + }, + { + "name": "translate_one", + "value": "14vp" + }, + { + "name": "font_size_l", + "value": "24fp" + }, + { + "name": "font_size_m", + "value": "14fp" + }, + { + "name": "margin_bottom", + "value": "30vp" + }, + { + "name": "margin_bottom_one", + "value": "37vp" + }, + { + "name": "bottom_height", + "value": "40vp" + }, + { + "name": "divider_bottom", + "value": "55vp" + }, + { + "name": "image_width", + "value": "326vp" + }, + { + "name": "image_height", + "value": "174vp" + }, + { + "name": "image_width_m", + "value": "43.5vp" + }, + { + "name": "image_height_m", + "value": "52vp" + }, + { + "name": "row_width_l", + "value": "330vp" + }, + { + "name": "image_width_min", + "value": "25vp" + }, + { + "name": "image_height_min", + "value": "35vp" + }, + { + "name": "margin_left", + "value": "-285vp" + }, + { + "name": "change", + "value": "16vp" + }, + { + "name": "font_size_min", + "value": "12fp" + }, + { + "name": "font_size_max", + "value": "30fp" + }, + { + "name": "button_width", + "value": "44vp" + }, + { + "name": "toast_height", + "value": "36vp" + }, + { + "name": "toast_margin", + "value": "250vp" + }, + { + "name": "toast_border_radius", + "value": "18vp" + }, + { + "name": "shadow", + "value": "120vp" + }, + { + "name": "toast_margin_m", + "value": "220vp" + }, + { + "name": "change_margin", + "value": "-65vp" + }, + { + "name": "word_margin_top", + "value": "17vp" + }, + { + "name": "word_margin_bottom", + "value": "42vp" + }, + { + "name": "background_margin", + "value": "19vp" + }, + { + "name": "item_list", + "value": "12vp" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/integer.json b/entry/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..f17dd4e9fb9b99b3d68e3a83cd2956aeac5bb82c --- /dev/null +++ b/entry/src/main/resources/base/element/integer.json @@ -0,0 +1,20 @@ +{ + "integer": [ + { + "name": "verify_code_code_unit_with", + "value": 60 + }, + { + "name": "verify_code_code_unit_margin", + "value": 5 + }, + { + "name": "verify_code_code_border_width", + "value": 1 + }, + { + "name": "verify_code_verify_code_height", + "value": 50 + } + ] +} \ 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..176e125087cf92c972e28c5fd02ea28b09e8c048 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "验证码场景实例" + }, + { + "name": "verification_code", + "value": "短信验证码" + }, + { + "name": "select_verification_code", + "value": "选择验证码" + }, + { + "name": "slider_verification_code", + "value": "滑块验证码" + }, + { + "name": "enter_the_verification_code", + "value": "请输入验证码" + }, + { + "name": "Verification_code_sent_to", + "value": "验证码已发送至" + }, + { + "name": "phone_number", + "value": "+86 186****2770" + }, + { + "name": "reacquire", + "value": "重新获取" + }, + { + "name": "phone_number1", + "value": "+86 186******70" + }, + { + "name": "login", + "value": "登录/注册" + }, + { + "name": "complete", + "value": "请完成验证" + }, + { + "name": "slide", + "value": "向右滑动滑块填充拼图" + }, + { + "name": "verification_passed", + "value": "验证通过" + }, + { + "name": "verification_fail", + "value": "验证失败" + }, + { + "name": "change", + "value": "看不清?换一张" + }, + { + "name": "sentence", + "value": "请依次点击“古 堰 画 乡”" + }, + { + "name": "change_another", + "value": "换一张" + }, + { + "name": "commit", + "value": "提交" + } + ] +} \ 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/button.png b/entry/src/main/resources/base/media/button.png new file mode 100644 index 0000000000000000000000000000000000000000..f842093362d3fac036de54d44ee71e8744c5800f Binary files /dev/null and b/entry/src/main/resources/base/media/button.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/img.png b/entry/src/main/resources/base/media/img.png new file mode 100644 index 0000000000000000000000000000000000000000..056e2b564bcdc548ba7c5b236d2ceb2a1f860b20 Binary files /dev/null and b/entry/src/main/resources/base/media/img.png differ diff --git a/entry/src/main/resources/base/media/img_1.png b/entry/src/main/resources/base/media/img_1.png new file mode 100644 index 0000000000000000000000000000000000000000..f9d80d7b008a78b398ba54e6eb1456880e17ca1a Binary files /dev/null and b/entry/src/main/resources/base/media/img_1.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/slider.png b/entry/src/main/resources/base/media/slider.png new file mode 100644 index 0000000000000000000000000000000000000000..1eef802a9c84b72c52bd505b9027f607a6aba8a3 Binary files /dev/null and b/entry/src/main/resources/base/media/slider.png differ diff --git a/entry/src/main/resources/base/media/sliderBackground.png b/entry/src/main/resources/base/media/sliderBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..41ac37916fe10cdbde6c7944cf36c7ad1a675571 Binary files /dev/null and b/entry/src/main/resources/base/media/sliderBackground.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/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/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..505e1fe5de5d31505acea478c46c65bff5e14dcd --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "Verification Code Scenario Example" + }, + { + "name": "verification_code", + "value": "SMS verification code" + }, + { + "name": "select_verification_code", + "value": "Select verification code" + }, + { + "name": "slider_verification_code", + "value": "Slider verification code" + }, + { + "name": "enter_the_verification_code", + "value": "Please enter the verification code" + }, + { + "name": "Verification_code_sent_to", + "value": "Verification code has been sent to" + }, + { + "name": "phone_number", + "value": "+86 186****2770" + }, + { + "name": "reacquire", + "value": "Reacquire" + }, + { + "name": "phone_number1", + "value": "+86 186******70" + }, + { + "name": "login", + "value": "Log In / Register" + }, + { + "name": "complete", + "value": "Please complete verification" + }, + { + "name": "slide", + "value": "Slide the slider to the right to fill the puzzle" + }, + { + "name": "verification_passed", + "value": "Verification Passed" + }, + { + "name": "verification_fail", + "value": "Validation failed" + }, + { + "name": "change", + "value": "Can't see? Change it." + }, + { + "name": "sentence", + "value": "Please click \"Ancients Weir Painting Village\"" + }, + { + "name": "change_another", + "value": "change another" + }, + { + "name": "commit", + "value": "commit" + } + ] +} \ 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..1dbe0d65d27d385915ab6549ccf5ff0695f1ec4c --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "验证码场景实例" + }, + { + "name": "verification_code", + "value": "短信验证码" + }, + { + "name": "select_verification_code", + "value": "选择验证码" + }, + { + "name": "slider_verification_code", + "value": "滑块验证码" + }, + { + "name": "enter_the_verification_code", + "value": "请输入验证码" + }, + { + "name": "Verification_code_sent_to", + "value": "验证码已发送至" + }, + { + "name": "phone_number", + "value": "+86 186****2770" + }, + { + "name": "reacquire", + "value": "重新获取" + }, + { + "name": "phone_number1", + "value": "+86 186******70" + }, + { + "name": "login", + "value": "登录/注册" + }, + { + "name": "complete", + "value": "请完成验证" + }, + { + "name": "slide", + "value": "向右滑动滑块填充拼图" + }, + { + "name": "verification_passed", + "value": "验证通过" + }, + { + "name": "verification_fail", + "value": "验证失败" + }, + { + "name": "change", + "value": "看不清?换一张" + }, + { + "name": "sentence", + "value": "请依次点击“古 堰 画 乡”" + }, + { + "name": "change_another", + "value": "换一张" + }, + { + "name": "commit", + "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..2662c04148f9901f7fdcbc0436754f5e2a1766fd --- /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*/ + } +} \ No newline at end of file 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..60a170aa52d32841644eb5dd54f463d11262ce51 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,8 @@ +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + } +} \ No newline at end of file diff --git a/screenshots/device/verification.gif b/screenshots/device/verification.gif new file mode 100644 index 0000000000000000000000000000000000000000..904860ecaf5d76222487d768ed8b0eb17fe9ac4c Binary files /dev/null and b/screenshots/device/verification.gif differ