diff --git a/README.md b/README.md index cd598fd4493937e70e96c6192d883b2a6e720f45..693c75cf57b030ea02f594b5351110d4597541de 100644 --- a/README.md +++ b/README.md @@ -2,61 +2,4 @@ ### 介绍 -本示例介绍了文本框显示光标、底部加横条、背景颜色改变、选择验证码、滑块验证码五种验证码实例。 - -### 效果预览 -| 文本框显示光标 | 底部加横条 | 背景颜色改变 | 选择验证码 | -|----------------------------------------|-----------------------------------------|---------------------------------------------|-----------------------------------------| -| ![image](screenshots/device/text.gif) | ![image](screenshots/device/bottom.gif) | ![image](screenshots/device/background.gif) | ![image](screenshots/device/choose.gif) | -| 滑动验证码 | -| ![image](screenshots/device/slide.gif) | - -### 使用说明: - -加载完成后显示首页的5个验证码实例,点击对应按钮,进入相应的验证码页面: -1. 文本框显示光标:输入数字光标会移动到下一个文本框,同时下边框变色。 -2. 底部加横条:在输入框内输入6位数字。 -3. 背景颜色改变:输入数字后背景颜色改变。 -4. 选择验证码:按照提示文字的顺序点击图片上的文字,然后点击提交。 -5. 滑块验证码:点击滑块按钮向右滑动,直到将图片拼接完整时松手。 - -### 工程目录 - -``` -├──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. 文本框显示光标:当前TextInput暂时无法监听到删除键,这里使用了Text组件,订阅输入法插入、删除事件,从而获取输入内容,当组件的可视面积变化的时候进行绑定与解绑,光标通过属性动画显隐效果实现。 -2. 底部加横条:通过TextInput实现,限制最大输入个数为6个数字,使用Divider在下面添加一条横线实现效果。 -3. 背景颜色改变:与文本框显示光标相同的原理,背景颜色改变是通过判断是否输入了数字,有数字的背景颜色改变。 -4. 选择验证码:通过Stack组件将数字覆盖到图片上,当点击数字时获取当前点击位置相对于页面的横纵坐标和点击的文字内容,并将文字添加到数组中,通过坐标移动代表点击顺序的数字,点击提交按钮判断数组中的文字内容和顺序是否正确。 -5. 滑块验证码:通过Slider组件的onChange方法获取互动的距离,从而移动图片上的滑块把图片拼接完整。 - -### 相关权限 -不涉及。 - -### 约束与限制 - -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 +此分支仅供HMOS世界集成使用 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4278fb0641d84107c3c134047ac487368e..40e65c51cee6f6491df201590259816fbab0f047 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -30,6 +30,10 @@ ] } ] + }, + { + "name": "verificationcodemodule", + "srcPath": "./verificationcodemodule", } ] } \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 803b25293388deda7b9a05a21b5aeadeb716b4d5..6dd3e31467a1e05c8e44523a785db2e2284c5b58 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -5,5 +5,7 @@ "main": "", "author": "", "license": "", - "dependencies": {} + "dependencies": { + "@ohos_samples/verificationcodemodule": "file:../verificationcodemodule" + } } \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index 803b983658639fca669cf4ce14abb41b33080ad7..3b661df771a444a58e4ee23a34daf545ea660b46 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -12,195 +12,15 @@ * 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'; +import { VerificationCodePage } from '@ohos_samples/verificationcodemodule'; @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) + Stack() { + VerificationCodePage() } - .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/verificationcodemodule/.gitignore b/verificationcodemodule/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/verificationcodemodule/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/verificationcodemodule/Index.ets b/verificationcodemodule/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad4da0dd0ab3c5b14c7361f8946c3de9dccba6e3 --- /dev/null +++ b/verificationcodemodule/Index.ets @@ -0,0 +1 @@ +export { VerificationCodePage } from './src/main/ets/pages/VerificationCodePage' \ No newline at end of file diff --git a/verificationcodemodule/build-profile.json5 b/verificationcodemodule/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/verificationcodemodule/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/verificationcodemodule/consumer-rules.txt b/verificationcodemodule/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/verificationcodemodule/hvigorfile.ts b/verificationcodemodule/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/verificationcodemodule/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/verificationcodemodule/obfuscation-rules.txt b/verificationcodemodule/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/verificationcodemodule/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/verificationcodemodule/oh-package.json5 b/verificationcodemodule/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8f23899f8823f6842a9276982fc489148a693c17 --- /dev/null +++ b/verificationcodemodule/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "verificationcodemodule", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/entry/src/main/ets/common/Constants.ets b/verificationcodemodule/src/main/ets/common/Constants.ets similarity index 100% rename from entry/src/main/ets/common/Constants.ets rename to verificationcodemodule/src/main/ets/common/Constants.ets diff --git a/entry/src/main/ets/common/GlobalBuilderContext.ets b/verificationcodemodule/src/main/ets/common/GlobalBuilderContext.ets similarity index 100% rename from entry/src/main/ets/common/GlobalBuilderContext.ets rename to verificationcodemodule/src/main/ets/common/GlobalBuilderContext.ets diff --git a/entry/src/main/ets/pages/BackgroundColorChange.ets b/verificationcodemodule/src/main/ets/pages/BackgroundColorChange.ets similarity index 100% rename from entry/src/main/ets/pages/BackgroundColorChange.ets rename to verificationcodemodule/src/main/ets/pages/BackgroundColorChange.ets diff --git a/entry/src/main/ets/pages/BottomWithBar.ets b/verificationcodemodule/src/main/ets/pages/BottomWithBar.ets similarity index 100% rename from entry/src/main/ets/pages/BottomWithBar.ets rename to verificationcodemodule/src/main/ets/pages/BottomWithBar.ets diff --git a/entry/src/main/ets/pages/SelectVerificationCode.ets b/verificationcodemodule/src/main/ets/pages/SelectVerificationCode.ets similarity index 100% rename from entry/src/main/ets/pages/SelectVerificationCode.ets rename to verificationcodemodule/src/main/ets/pages/SelectVerificationCode.ets diff --git a/entry/src/main/ets/pages/SliderVerificationCode.ets b/verificationcodemodule/src/main/ets/pages/SliderVerificationCode.ets similarity index 100% rename from entry/src/main/ets/pages/SliderVerificationCode.ets rename to verificationcodemodule/src/main/ets/pages/SliderVerificationCode.ets diff --git a/entry/src/main/ets/pages/TextBoxShowCursor.ets b/verificationcodemodule/src/main/ets/pages/TextBoxShowCursor.ets similarity index 100% rename from entry/src/main/ets/pages/TextBoxShowCursor.ets rename to verificationcodemodule/src/main/ets/pages/TextBoxShowCursor.ets diff --git a/verificationcodemodule/src/main/ets/pages/VerificationCodePage.ets b/verificationcodemodule/src/main/ets/pages/VerificationCodePage.ets new file mode 100644 index 0000000000000000000000000000000000000000..96a0f8b23fe0f9bc167d76a624e562c774b641a2 --- /dev/null +++ b/verificationcodemodule/src/main/ets/pages/VerificationCodePage.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 +export struct VerificationCodePage { + 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/viewmodel/NavDestinationItem.ets b/verificationcodemodule/src/main/ets/viewmodel/NavDestinationItem.ets similarity index 100% rename from entry/src/main/ets/viewmodel/NavDestinationItem.ets rename to verificationcodemodule/src/main/ets/viewmodel/NavDestinationItem.ets diff --git a/verificationcodemodule/src/main/module.json5 b/verificationcodemodule/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..63b3f701c035d9efc7cd2ffb5bac3c7c366c85b0 --- /dev/null +++ b/verificationcodemodule/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "verificationcodemodule", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/verificationcodemodule/src/main/resources/base/element/color.json b/verificationcodemodule/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..0ca72cc3029919cc2145dc18a3865c7b120de4fc --- /dev/null +++ b/verificationcodemodule/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": "#1A000000" + } + ] +} \ No newline at end of file diff --git a/verificationcodemodule/src/main/resources/base/element/float.json b/verificationcodemodule/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..55ecf675377297113a709aa9212a7f0796a3eedd --- /dev/null +++ b/verificationcodemodule/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": "80vp" + }, + { + "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/verificationcodemodule/src/main/resources/base/element/integer.json b/verificationcodemodule/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..f17dd4e9fb9b99b3d68e3a83cd2956aeac5bb82c --- /dev/null +++ b/verificationcodemodule/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/verificationcodemodule/src/main/resources/base/element/string.json b/verificationcodemodule/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4d528efab84c3498a209a8c75c2ece6495d7d0cc --- /dev/null +++ b/verificationcodemodule/src/main/resources/base/element/string.json @@ -0,0 +1,124 @@ +{ + "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": "提交" + }, + { + "name": "word", + "value": "文本框显示光标" + }, + { + "name": "bottom", + "value": "底部加横条" + }, + { + "name": "background", + "value": "背景颜色改变" + }, + { + "name": "hua", + "value": "画" + }, + { + "name": "cause", + "value": "故" + }, + { + "name": "yan", + "value": "堰" + }, + { + "name": "xiang", + "value": "乡" + }, + { + "name": "china", + "value": "华" + }, + { + "name": "gu", + "value": "古" + }, + { + "name": "hunan", + "value": "湘" + } + ] +} \ No newline at end of file diff --git a/verificationcodemodule/src/main/resources/base/media/background.png b/verificationcodemodule/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/background.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/button.png b/verificationcodemodule/src/main/resources/base/media/button.png new file mode 100644 index 0000000000000000000000000000000000000000..f842093362d3fac036de54d44ee71e8744c5800f Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/button.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/foreground.png b/verificationcodemodule/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/foreground.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/img.png b/verificationcodemodule/src/main/resources/base/media/img.png new file mode 100644 index 0000000000000000000000000000000000000000..056e2b564bcdc548ba7c5b236d2ceb2a1f860b20 Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/img.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/img_1.png b/verificationcodemodule/src/main/resources/base/media/img_1.png new file mode 100644 index 0000000000000000000000000000000000000000..f9d80d7b008a78b398ba54e6eb1456880e17ca1a Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/img_1.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/layered_image.json b/verificationcodemodule/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/verificationcodemodule/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/verificationcodemodule/src/main/resources/base/media/slider.png b/verificationcodemodule/src/main/resources/base/media/slider.png new file mode 100644 index 0000000000000000000000000000000000000000..1eef802a9c84b72c52bd505b9027f607a6aba8a3 Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/slider.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/sliderBackground.png b/verificationcodemodule/src/main/resources/base/media/sliderBackground.png new file mode 100644 index 0000000000000000000000000000000000000000..41ac37916fe10cdbde6c7944cf36c7ad1a675571 Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/sliderBackground.png differ diff --git a/verificationcodemodule/src/main/resources/base/media/startIcon.png b/verificationcodemodule/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/verificationcodemodule/src/main/resources/base/media/startIcon.png differ diff --git a/verificationcodemodule/src/main/resources/base/profile/main_pages.json b/verificationcodemodule/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..b91cd3016521076c7702755479ffc65c86c8455b --- /dev/null +++ b/verificationcodemodule/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/VerificationCodePage" + ] +} diff --git a/verificationcodemodule/src/main/resources/en_US/element/string.json b/verificationcodemodule/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9d6a163d322d4cbe8cf87ebe2d356a6e5035c23e --- /dev/null +++ b/verificationcodemodule/src/main/resources/en_US/element/string.json @@ -0,0 +1,124 @@ +{ + "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": "Click \"Gu Yan Hua Xiang\"" + }, + { + "name": "change_another", + "value": "change" + }, + { + "name": "commit", + "value": "Commit" + }, + { + "name": "word", + "value": "The text box displays the cursor" + }, + { + "name": "bottom", + "value": "Add horizontal bars at the bottom" + }, + { + "name": "background", + "value": "Background color change" + }, + { + "name": "hua", + "value": "Hua" + }, + { + "name": "cause", + "value": "cause" + }, + { + "name": "yan", + "value": "Yan" + }, + { + "name": "xiang", + "value": "Xiang" + }, + { + "name": "china", + "value": "china" + }, + { + "name": "gu", + "value": "Gu" + }, + { + "name": "hunan", + "value": "hunan" + } + ] +} \ No newline at end of file diff --git a/verificationcodemodule/src/main/resources/zh_CN/element/string.json b/verificationcodemodule/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..19e01f72a5fd2f761e5abeffade99dfda48a0433 --- /dev/null +++ b/verificationcodemodule/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,124 @@ +{ + "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": "提交" + }, + { + "name": "word", + "value": "文本框显示光标" + }, + { + "name": "bottom", + "value": "底部加横条" + }, + { + "name": "background", + "value": "背景颜色改变" + }, + { + "name": "hua", + "value": "画" + }, + { + "name": "cause", + "value": "故" + }, + { + "name": "yan", + "value": "堰" + }, + { + "name": "xiang", + "value": "乡" + }, + { + "name": "china", + "value": "华" + }, + { + "name": "gu", + "value": "古" + }, + { + "name": "hunan", + "value": "湘" + } + ] +} \ No newline at end of file diff --git a/verificationcodemodule/src/ohosTest/ets/test/Ability.test.ets b/verificationcodemodule/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/verificationcodemodule/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/verificationcodemodule/src/ohosTest/ets/test/List.test.ets b/verificationcodemodule/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/verificationcodemodule/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/verificationcodemodule/src/ohosTest/module.json5 b/verificationcodemodule/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..aa4110bfac89bf6d4a088686e0f2eeec0832515e --- /dev/null +++ b/verificationcodemodule/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "verificationcodemodule_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/verificationcodemodule/src/test/List.test.ets b/verificationcodemodule/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/verificationcodemodule/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/verificationcodemodule/src/test/LocalUnit.test.ets b/verificationcodemodule/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/verificationcodemodule/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file