diff --git a/README.en.md b/README.en.md
index 68c39e0af35e8fe8d6bae7003a139ac2beedc6f5..bf47a34e141ffed1cd478ea9d5aa5019de3db74d 100644
--- a/README.en.md
+++ b/README.en.md
@@ -5,7 +5,7 @@
This sample describes five verification code scenarios: displaying the cursor in the text box, adding a horizontal bar at the bottom, changing the background color, selecting a verification code, and sliding a verification code.
### Preview
-
+
### How to Use
@@ -19,22 +19,32 @@ After the loading is complete, five verification code instances are displayed on
### Project Directory
```
-├──entry/src/main/ets/
+verificationcodescenariolibrary
+├──src/main/ets/
│ ├──common
+│ │ │ utils
+│ │ │ ├──BreakpointSystem.ets // Breakpoint System
+│ │ │ └──WindowUtil.ets // Window Utils
│ │ ├──Constants.ets // Common constant class
│ │ └──GlobalBuilderContext.ets // Global page information
-│ ├──entryability
-│ │ └──EntryAbility.ets // Entry ability
-│ ├──pages
+│ ├──view
│ │ ├──BackgroundColorChange.ets // Background color change
│ │ ├──BottomWithBar.ets // Add a horizontal bar at the bottom.
-│ │ ├──Index.ets // Home page
│ │ ├──SelectVerificationCode.ets // Select verification codes
│ │ ├──SliderVerificationCode.ets // Slider verification codes
-│ │ └──TextBoxShowCursor.ets // Display the cursor in the text box.
-│ └──viewmodel
-│ └──NavDestinationItem.ets // Route type
-└──entry/src/main/resources // App resource directory
+│ │ ├──TextBoxShowCursor.ets // Display the cursor in the text box.
+│ │ └──VerificationCodeScenarioView.ets // Home page
+│ ├──viewmodel
+│ │ └──NavDestinationItem.ets // Route type
+│ └──VerificationCodeController.ets
+└──src/main/resources // App resource directory
+verificationcodescenariosample
+├──src/main/ets
+│ ├──entryability
+│ │ └──EntryAbility.ets
+│ └──pages
+│ └──Index.ets
+└──src/main/resources
```
### How to Implement
diff --git a/README.md b/README.md
index 6b0f5dcc61ea4923157092ed6ee567070e2d9683..bc068449d5e67f4facb7e9e24a33ff7904505001 100644
--- a/README.md
+++ b/README.md
@@ -21,20 +21,29 @@
```
├──entry/src/main/ets/
│ ├──common
+│ │ │ utils
+│ │ │ ├──BreakpointSystem.ets // 断点
+│ │ │ └──WindowUtil.ets // 窗口工具
│ │ ├──Constants.ets // 公共常量类
│ │ └──GlobalBuilderContext.ets // 全局页面信息
-│ ├──entryability
-│ │ └──EntryAbility.ets // 程序入口类
-│ ├──pages
+│ ├──view
│ │ ├──BackgroundColorChange.ets // 背景颜色改变
│ │ ├──BottomWithBar.ets // 底部加横条
-│ │ ├──Index.ets // 首页
│ │ ├──SelectVerificationCode.ets // 选择验证码
│ │ ├──SliderVerificationCode.ets // 滑块验证码
-│ │ └──TextBoxShowCursor.ets // 文本框显示光标
-│ └──viewmodel
-│ └──NavDestinationItem.ets // 路由类型
+│ │ ├──TextBoxShowCursor.ets // 文本框显示光标
+│ │ └──VerificationCodeScenarioView.ets // 首页
+│ ├──viewmodel
+│ │ └──NavDestinationItem.ets // 路由类型
+│ └──VerificationCodeController.ets
└──entry/src/main/resources // 应用资源目录
+verificationcodescenariosample
+├──src/main/ets
+│ ├──entryability
+│ │ └──EntryAbility.ets
+│ └──pages
+│ └──Index.ets
+└──src/main/resources
```
### 具体实现
diff --git a/screenshots/device/index.en.png b/screenshots/device/index.en.png
deleted file mode 100644
index 5fb263c90636aeb521dcd7a79adb262968f2750c..0000000000000000000000000000000000000000
Binary files a/screenshots/device/index.en.png and /dev/null differ
diff --git a/screenshots/device/index.png b/screenshots/device/index.png
index 562ddf92bbdde97eae1ef390428496703702d993..589f05c41294008a8ea8b4a824f3000f18cd1f42 100644
Binary files a/screenshots/device/index.png and b/screenshots/device/index.png differ
diff --git a/screenshots/device/index_en.png b/screenshots/device/index_en.png
new file mode 100644
index 0000000000000000000000000000000000000000..a35b0bded2c6da7bdc34753190cd8b7a4ebbb75f
Binary files /dev/null and b/screenshots/device/index_en.png differ
diff --git a/verificationcodescenariolibrary/BuildProfile.ets b/verificationcodescenariolibrary/BuildProfile.ets
deleted file mode 100644
index 3a501e5ddee8ea6d28961648fc7dd314a5304bd4..0000000000000000000000000000000000000000
--- a/verificationcodescenariolibrary/BuildProfile.ets
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Use these variables when you tailor your ArkTS code. They must be of the const type.
- */
-export const HAR_VERSION = '1.0.0';
-export const BUILD_MODE_NAME = 'debug';
-export const DEBUG = true;
-export const TARGET_NAME = 'default';
-
-/**
- * BuildProfile Class is used only for compatibility purposes.
- */
-export default class BuildProfile {
- static readonly HAR_VERSION = HAR_VERSION;
- static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
- static readonly DEBUG = DEBUG;
- static readonly TARGET_NAME = TARGET_NAME;
-}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/CHANGELOG.md b/verificationcodescenariolibrary/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..10f7f3f76c5898a057d503600cef2c3ae87d79da
--- /dev/null
+++ b/verificationcodescenariolibrary/CHANGELOG.md
@@ -0,0 +1,6 @@
+# 版本记录
+## 1.0.0(2025.07.10)
+
+---
+### Initial
+- 初始版本
diff --git a/verificationcodescenariolibrary/Index.ets b/verificationcodescenariolibrary/Index.ets
index 64a59f4c51ba62a373c350d1bd986d4911351a57..b0ed89000a509e7654446ca43f1da763f649ab5d 100644
--- a/verificationcodescenariolibrary/Index.ets
+++ b/verificationcodescenariolibrary/Index.ets
@@ -1,2 +1,3 @@
-export { VerificationCodeScenarioPage } from './src/main/ets/pages/VerificationCodeScenarioPage';
-export { WindowUtil } from './src/main/ets/common/utils/WindowUtil';
\ No newline at end of file
+export { VerificationCodeScenarioView as VerificationCodeScenarioComponent } from './src/main/ets/view/VerificationCodeScenarioView';
+
+export { VerificationCodeController } from './src/main/ets/VerificationCodeController';
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/LICENSE b/verificationcodescenariolibrary/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0
--- /dev/null
+++ b/verificationcodescenariolibrary/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/verificationcodescenariolibrary/README.md b/verificationcodescenariolibrary/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..240413785ba488f650c3157f36f57b6c6968e176
--- /dev/null
+++ b/verificationcodescenariolibrary/README.md
@@ -0,0 +1,50 @@
+## 验证码场景合集
+
+### 介绍
+
+本示例实现了5种验证码场景,基本涵盖了大部分应用的验证码场景。开发者可按需下载代码,实现自己应用的验证码场景。
+
+### 下载安装
+
+使用ohpm安装依赖
+
+```
+ohpm install @ohos_samples/verificationcodescenariolibrary
+```
+
+或者按需在模块中修改oh-package.json5
+
+```
+{
+ "dependencies": {
+ "@ohos_samples/verificationcodescenariolibrary": "^1.0.0"
+ }
+}
+```
+
+### 使用说明
+
+```
+import { VerificationCodeScenarioComponent, VerificationCodeController } from '@ohos_samples/verificationcodescenariolibrary';
+```
+按需在文件中使用导出模块即可,其中VerificationCodeScenarioComponent是整个sample的入口页面。
+加载完成后显示首页的5个验证码实例,点击对应按钮,进入相应的验证码页面:
+ 1. 文本框显示光标:输入数字光标会移动到下一个文本框,同时下边框变色。
+ 2. 底部加横条:在输入框内输入6位数字。
+ 3. 背景颜色改变:输入数字后背景颜色改变。
+ 4. 选择验证码:按照提示文字的顺序点击图片上的文字,然后点击提交。
+ 5. 滑块验证码:点击滑块按钮向右滑动,直到将图片拼接完整时松手。
+
+VerificationCodeController封装了沉浸式、设备断点判断、避让区域计算等窗口能力。示例如下:
+```
+// Index.ets
+import { VerificationCodeScenarioComponent } from '@ohos_samples/verificationcodescenariolibrary';
+Stack() {
+ VerificationCodeScenarioComponent()
+}
+
+// EntryAbility.ets
+import { VerificationCodeController } from '@ohos_samples/verificationcodescenariolibrary';
+// onWindowStageCreate回调里的loadContent方法里初始化
+VerificationCodeController.initWindowConfig(windowStage);
+```
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/build-profile.json5 b/verificationcodescenariolibrary/build-profile.json5
index 312d38eb08629793b3484c7373213f22840c8d82..cda3307123ec7c43181580a86ef7e82a18319a34 100644
--- a/verificationcodescenariolibrary/build-profile.json5
+++ b/verificationcodescenariolibrary/build-profile.json5
@@ -8,7 +8,7 @@
"arkOptions": {
"obfuscation": {
"ruleOptions": {
- "enable": true,
+ "enable": false,
"files": [
"./obfuscation-rules.txt"
]
diff --git a/verificationcodescenariolibrary/oh-package.json5 b/verificationcodescenariolibrary/oh-package.json5
index 7b64a65799faf31642a183efd2b2cbc0e6044a82..4b2a361fc2c0a87749cae1a7bba9d2722d3218a5 100644
--- a/verificationcodescenariolibrary/oh-package.json5
+++ b/verificationcodescenariolibrary/oh-package.json5
@@ -1,9 +1,10 @@
{
- "name": "verificationcodescenariolibrary",
+ "name": "@ohos_samples/verificationcodescenariolibrary",
"version": "1.0.0",
- "description": "Please describe the basic information.",
+ "description": "This sample describes five verification code scenarios: displaying the cursor in the text box, adding a horizontal bar at the bottom, changing the background color, selecting a verification code, and sliding a verification code.",
"main": "Index.ets",
- "author": "",
+ "author": "@ohos_samples",
"license": "Apache-2.0",
+ "repository": "https://gitee.com/harmonyos_samples/verification-code-scenario/tree/br_release_hmos/",
"dependencies": {}
-}
+}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/ets/VerificationCodeController.ets b/verificationcodescenariolibrary/src/main/ets/VerificationCodeController.ets
new file mode 100644
index 0000000000000000000000000000000000000000..3633cac3d04fdd427eb7c683933a679bd9eb1b1a
--- /dev/null
+++ b/verificationcodescenariolibrary/src/main/ets/VerificationCodeController.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.
+ */
+import { window } from '@kit.ArkUI';
+import { WindowUtil } from './common/utils/WindowUtil';
+
+export class VerificationCodeController {
+ public static initWindowConfig(windowStage: window.WindowStage): void {
+ WindowUtil.initialize(windowStage);
+ }
+}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/ets/common/Constants.ets b/verificationcodescenariolibrary/src/main/ets/common/Constants.ets
index d05832fb36d06e4ff1c27f23d3b2ce69ecf7a36d..e02244c78726e4a278b85b17f5b033b9ab829e9f 100644
--- a/verificationcodescenariolibrary/src/main/ets/common/Constants.ets
+++ b/verificationcodescenariolibrary/src/main/ets/common/Constants.ets
@@ -112,6 +112,18 @@ export default class Constants {
* Line height.
*/
public static readonly LINE_HEIGHT: number = 1;
+ /**
+ * Item code start.
+ */
+ public static readonly ITEM_CODE_START: number = 30;
+ /**
+ * Item divider.
+ */
+ public static readonly ITEM_CODE_WIDTH: number = 60;
+ /**
+ * Item divider.
+ */
+ public static readonly ITEM_FOLD_CODE_WIDTH: number = 51;
/**
* Item divider.
*/
@@ -146,7 +158,7 @@ export default class Constants {
public static readonly NEGATIVE_ONE_HUNDRED: number = -100;
/**
* Negative one hundred ten.
- */
+ */
public static readonly NEGATIVE_ONE_HUNDRED_TEN: number = -110;
/**
* Negative thirty-five.
@@ -264,29 +276,14 @@ export default class Constants {
name: 'SliderVerification', detail: $r('app.string.slider_verification_code')
}
];
-}
-
-export class BreakpointType {
- public sm: T
- public md: T
- public lg: T
-
- constructor(sm: T, md: T, lg: T) {
- this.sm = sm;
- this.md = md;
- this.lg = lg;
- }
-
- GetValue(currentBreakpoint: string) {
- if (currentBreakpoint === 'sm') {
- return this.sm;
- }
- if (currentBreakpoint === 'md') {
- return this.md;
- }
- if (currentBreakpoint === 'lg') {
- return this.lg;
- }
- return undefined;
- }
+ /**
+ * AppStorage key
+ */
+ public static readonly KEY_PREFIX: string = 'verificationCode';
+ public static readonly KEY_BREAKPOINT: string = Constants.KEY_PREFIX + 'BreakPoint';
+ public static readonly KEY_STATUS_BAR_HEIGHT: string = Constants.KEY_PREFIX + 'StatusBarHeight';
+ public static readonly KEY_NAV_INDICATOR_HEIGHT: string = Constants.KEY_PREFIX + 'NavIndicatorHeight';
+ public static readonly KEY_PATH_STACK: string = Constants.KEY_PREFIX + 'PathStack';
+ public static readonly KEY_UI_CONTEXT: string = Constants.KEY_PREFIX + 'UIContext';
+ public static readonly KEY_WINDOWS: string = Constants.KEY_PREFIX + 'WindowClass';
}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/ets/common/GlobalBuilderContext.ets b/verificationcodescenariolibrary/src/main/ets/common/GlobalBuilderContext.ets
index 8674f1be1607390b6eb701bffa7b7dcbe305bc02..6c4673505eff696751bdbb163e05d31296d6e359 100644
--- a/verificationcodescenariolibrary/src/main/ets/common/GlobalBuilderContext.ets
+++ b/verificationcodescenariolibrary/src/main/ets/common/GlobalBuilderContext.ets
@@ -13,11 +13,11 @@
* 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';
+import { wrappedBuilderColorChange } from '../view/BackgroundColorChange';
+import { wrappedBuilderBottomWithBar } from '../view/BottomWithBar';
+import { wrappedBuilderVerificationCode } from '../view/SelectVerificationCode';
+import { wrappedBuilderSliderVerification } from '../view/SliderVerificationCode';
+import { wrappedBuilderShowCursor } from '../view/TextBoxShowCursor';
export class GlobalBuilderContext {
private static instance: GlobalBuilderContext;
diff --git a/verificationcodescenariolibrary/src/main/ets/common/utils/BreakpointSystem.ets b/verificationcodescenariolibrary/src/main/ets/common/utils/BreakpointSystem.ets
index aa7581b2047323eac83c8d9a031e21faabc55bd2..2755f5b8323d58c6db8c49cae7ca950fe660e75a 100644
--- a/verificationcodescenariolibrary/src/main/ets/common/utils/BreakpointSystem.ets
+++ b/verificationcodescenariolibrary/src/main/ets/common/utils/BreakpointSystem.ets
@@ -16,6 +16,7 @@
import { window } from '@kit.ArkUI';
import type { BusinessError } from '@kit.BasicServicesKit';
import { hilog } from '@kit.PerformanceAnalysisKit';
+import Constants from '../Constants';
const TAG: string = '[BreakpointSystem]';
@@ -77,6 +78,7 @@ export class BreakpointSystem {
public static getInstance(): BreakpointSystem {
if (!BreakpointSystem.instance) {
BreakpointSystem.instance = new BreakpointSystem();
+ AppStorage.setOrCreate(Constants.KEY_BREAKPOINT, BreakpointTypeEnum.MD);
}
return BreakpointSystem.instance;
}
@@ -84,7 +86,7 @@ export class BreakpointSystem {
public updateCurrentBreakpoint(breakpoint: BreakpointTypeEnum): void {
if (this.currentBreakpoint !== breakpoint) {
this.currentBreakpoint = breakpoint;
- AppStorage.setOrCreate('currentBreakpoint', this.currentBreakpoint);
+ AppStorage.setOrCreate(Constants.KEY_BREAKPOINT, this.currentBreakpoint);
}
}
@@ -96,7 +98,7 @@ export class BreakpointSystem {
try {
const mainWindow: window.WindowProperties = window.getWindowProperties();
const windowWidth: number = mainWindow.windowRect.width;
- const windowWidthVp = px2vp(windowWidth);
+ const windowWidthVp = window.getUIContext().px2vp(windowWidth);
let widthBp: BreakpointTypeEnum = BreakpointTypeEnum.MD;
if (windowWidthVp < 320) {
widthBp = BreakpointTypeEnum.XS;
diff --git a/verificationcodescenariolibrary/src/main/ets/common/utils/WindowUtil.ets b/verificationcodescenariolibrary/src/main/ets/common/utils/WindowUtil.ets
index c60b494dc867671bf4650835c2b23d6a2d43ce15..99e54ce01fac47c3ab974036a3c959ba15e652e9 100644
--- a/verificationcodescenariolibrary/src/main/ets/common/utils/WindowUtil.ets
+++ b/verificationcodescenariolibrary/src/main/ets/common/utils/WindowUtil.ets
@@ -15,56 +15,73 @@
import { window } from '@kit.ArkUI';
import type { BusinessError } from '@kit.BasicServicesKit';
-import { BreakpointSystem } from './BreakpointSystem';
import { hilog } from '@kit.PerformanceAnalysisKit';
+import Constants from '../Constants';
+import { BreakpointSystem } from './BreakpointSystem';
const TAG: string = '[WindowUtil]';
export class WindowUtil {
- public static requestFullScreen(windowStage: window.WindowStage): void {
- windowStage.getMainWindow((err: BusinessError, data: window.Window) => {
- if (err.code) {
- return;
- }
- const windowClass: window.Window = data;
- // Realize the immersive effect.
- try {
- const promise: Promise = windowClass.setWindowLayoutFullScreen(true);
- promise.then(() => {
- hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.');
- }).catch((err: BusinessError) => {
- hilog.info(0x0000, TAG,
- `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`);
- });
- } catch {
- hilog.error(0x0000, TAG, 'Failed to set the window layout to full-screen mode. ');
- }
- });
+ private static windowClass: window.Window;
+
+ public static initialize(windowStage: window.WindowStage) {
+ try {
+ WindowUtil.windowClass = windowStage.getMainWindowSync();
+ AppStorage.setOrCreate(Constants.KEY_WINDOWS, WindowUtil.windowClass);
+ const uiContext: UIContext = WindowUtil.windowClass.getUIContext();
+ AppStorage.setOrCreate(Constants.KEY_UI_CONTEXT, uiContext);
+ WindowUtil.requestFullScreen(WindowUtil.windowClass);
+ WindowUtil.registerBreakPoint(WindowUtil.windowClass);
+ } catch (err) {
+ const error = err as BusinessError;
+ hilog.error(0x0000, TAG, `Initialize failed. Cause code: ${error.code}, message: ${error.message}`);
+ }
+ }
+
+ public static requestFullScreen(data: window.Window): void {
+ // Realize the immersive effect.
+ try {
+ const promise: Promise = data.setWindowLayoutFullScreen(true);
+ promise.then(() => {
+ hilog.info(0x0000, TAG, 'Succeeded in setting the window layout to full-screen mode.');
+ }).catch((err: BusinessError) => {
+ hilog.error(0x0000, TAG,
+ `Failed to set the window layout to full-screen mode. Cause: ${err.code}, ${err.message}`);
+ });
+ } catch (err) {
+ const error = err as BusinessError;
+ hilog.error(0x0000, TAG,
+ `Failed to set the window layout to full-screen mode.code: ${error.code}, message: ${error.message} `);
+ }
}
- public static registerBreakPoint(windowStage: window.WindowStage) {
- windowStage.getMainWindow((err: BusinessError, data: window.Window) => {
- if (err.code) {
- hilog.error(0x0000, TAG, `Failed to get main window: ${err.message}`);
- return;
- }
- AppStorage.setOrCreate('windowClass', data);
+ public static registerBreakPoint(data: window.Window) {
+ try {
+ BreakpointSystem.getInstance().updateWidthBp(data);
+ const systemAvoidArea: window.AvoidArea = data.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM);
+ const navIndicatorAvoidArea: window.AvoidArea =
+ data.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR);
+ WindowUtil.setAvoidArea(data, window.AvoidAreaType.TYPE_SYSTEM, systemAvoidArea);
+ WindowUtil.setAvoidArea(data, window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR, navIndicatorAvoidArea);
data.on('windowSizeChange', () => BreakpointSystem.getInstance().onWindowSizeChange(data));
data.on('avoidAreaChange', (avoidAreaOption) => {
- if (avoidAreaOption.type === window.AvoidAreaType.TYPE_SYSTEM ||
- avoidAreaOption.type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
- WindowUtil.setAvoidArea(avoidAreaOption.type, avoidAreaOption.area);
- }
+ WindowUtil.setAvoidArea(data, avoidAreaOption.type, avoidAreaOption.area);
});
- })
+ } catch (err) {
+ const error = err as BusinessError;
+ hilog.error(0x0000, TAG,
+ `Register avoidAreaChange or windowSizeChange failed. code: ${error.code}, message: ${error.message}`);
+ }
+
}
// Get status bar height and indicator height.
- public static setAvoidArea(type: window.AvoidAreaType, area: window.AvoidArea) {
+ private static setAvoidArea(data: window.Window, type: window.AvoidAreaType, area: window.AvoidArea) {
+ const context: UIContext = data.getUIContext();
if (type === window.AvoidAreaType.TYPE_SYSTEM) {
- AppStorage.setOrCreate('topRectHeight', px2vp(area.topRect.height));
- } else {
- AppStorage.setOrCreate('bottomRectHeight', px2vp(area.bottomRect.height));
+ AppStorage.setOrCreate(Constants.KEY_STATUS_BAR_HEIGHT, context.px2vp(area.topRect.height));
+ } else if (type === window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) {
+ AppStorage.setOrCreate(Constants.KEY_NAV_INDICATOR_HEIGHT, context.px2vp(area.bottomRect.height));
}
}
}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/BackgroundColorChange.ets b/verificationcodescenariolibrary/src/main/ets/view/BackgroundColorChange.ets
similarity index 80%
rename from verificationcodescenariolibrary/src/main/ets/pages/BackgroundColorChange.ets
rename to verificationcodescenariolibrary/src/main/ets/view/BackgroundColorChange.ets
index 54033fac347b2956556ebbf39bd4b5844c2c7faf..66078b4de231c4fb213624d0b0c0ffb58ed9133d 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/BackgroundColorChange.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/BackgroundColorChange.ets
@@ -13,11 +13,12 @@
* limitations under the License.
*/
+import { window } from '@kit.ArkUI';
import { BusinessError } from '@kit.BasicServicesKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
import { inputMethod } from '@kit.IMEKit';
-import { window } from '@kit.ArkUI';
-import Constants, { BreakpointType } from '../common/Constants';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import Constants from '../common/Constants';
+import { BreakpointType } from '../common/utils/BreakpointSystem';
@Extend(Text)
function verifyCodeUnitStyle() {
@@ -39,10 +40,9 @@ const TAG = 'BackgroundColorChange';
@Component
struct BackgroundColorChange {
@State codeText: string = '';
- @Consume('pathInfos') pathInfos: NavPathStack;
- @StorageProp('currentBreakpoint') curBp: string = Constants.BREAK_POINT_SM;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Consume(Constants.KEY_PATH_STACK) pathInfos: NavPathStack;
+ @StorageProp(Constants.KEY_BREAKPOINT) curBp: string = Constants.BREAK_POINT_SM;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0;
private inputController: inputMethod.InputMethodController = inputMethod.getController();
private arrArea: number[] = [0.0, 1, 0];
private verifyCodeLength: number = 6;
@@ -53,7 +53,7 @@ struct BackgroundColorChange {
enterKeyType: inputMethod.EnterKeyType.GO
}
};
- private windowClass: window.Window = AppStorage.get('windowClass') as window.Window;
+ private windowClass: window.Window = AppStorage.get(Constants.KEY_WINDOWS) as window.Window;
private isFirstOpenPage: boolean = true;
private registerCount: number = 1;
@@ -116,6 +116,14 @@ struct BackgroundColorChange {
}
}
+ private unicodeToDigit(unicodeValue: number): number {
+ // Check for half-width digits('0'to'9')
+ if (unicodeValue >= 48 && unicodeValue <= 57) {
+ return unicodeValue - 48;
+ }
+ return 0;
+ }
+
@Builder
buildVerifyCodeComponent() {
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
@@ -134,13 +142,23 @@ struct BackgroundColorChange {
this.detach();
}
})
- .width(328)
+ .width($r('app.float.input_width'))
.backgroundColor(Color.Transparent)
.height($r('app.float.text_height'))
.defaultFocus(true)
.onClick(() => {
this.inputController.attach(true, this.textConfig);
})
+ .onKeyPreIme((key: KeyEvent) => {
+ if (key.type === KeyType.Up && key.unicode && (key.unicode >= 48 && key.unicode <= 57)) {
+ if (this.codeText.length >= this.verifyCodeLength) {
+ return;
+ }
+ this.codeText += this.unicodeToDigit(key.unicode);
+ return true;
+ }
+ return false;
+ })
}
build() {
@@ -196,17 +214,27 @@ struct BackgroundColorChange {
.fontColor($r('sys.color.brand'))
}
.margin({ top: $r('sys.float.padding_level6') })
- .padding({ right: new BreakpointType(0, 6, 6).GetValue(this.curBp) })
+ .padding({ right: new BreakpointType({
+ sm: $r('sys.float.padding_level0'),
+ md: $r('sys.float.padding_level3'),
+ lg: $r('sys.float.padding_level3')
+ }).getValue(this.curBp) })
.alignSelf(ItemAlign.Center)
.justifyContent(FlexAlign.End)
- .width(this.curBp === 'sm' ? '100%' : 328)
+ .width(this.curBp === 'sm' ? '100%' : $r('app.float.input_width'))
}
.padding({
- left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- top: this.topRectHeight
+ left: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ right: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ top: this.statusBarHeight
})
.height(Constants.ONE_HUNDRED_PERCENT)
.width(Constants.ONE_HUNDRED_PERCENT)
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/BottomWithBar.ets b/verificationcodescenariolibrary/src/main/ets/view/BottomWithBar.ets
similarity index 77%
rename from verificationcodescenariolibrary/src/main/ets/pages/BottomWithBar.ets
rename to verificationcodescenariolibrary/src/main/ets/view/BottomWithBar.ets
index ceb96b05dffa9d326157aec2bc2305e288d881d7..da2e439628167e477489be5bd29ed75e197d00ff 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/BottomWithBar.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/BottomWithBar.ets
@@ -13,15 +13,16 @@
* limitations under the License.
*/
-import Constants, { BreakpointType } from '../common/Constants';
+import Constants from '../common/Constants';
+import { BreakpointType } from '../common/utils/BreakpointSystem';
@Entry
@Component
struct BottomWithBar {
- @Consume('pathInfos') pathInfos: NavPathStack;
- @StorageProp('currentBreakpoint') curBp: string = Constants.BREAK_POINT_SM;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Consume(Constants.KEY_PATH_STACK) pathInfos: NavPathStack;
+ @StorageProp(Constants.KEY_BREAKPOINT) curBp: string = Constants.BREAK_POINT_SM;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT)
+ statusBarHeight: number = 0;
private maxLength: number = 6;
private strokeWidth: number = 1;
@@ -74,7 +75,7 @@ struct BottomWithBar {
.maxLength(this.maxLength)
.type(InputType.Number)
.translate({ x: Constants.NEGATIVE_TWELVE })
- .width(this.curBp === 'sm' ? '100%' : 328)
+ .width(this.curBp === 'sm' ? '100%' : $r('app.float.input_width'))
.alignSelf(ItemAlign.Center)
Divider()
@@ -84,7 +85,7 @@ struct BottomWithBar {
top: $r('app.float.text_margin'),
bottom: $r('sys.float.padding_level6')
})
- .width(this.curBp === 'sm' ? '100%' : 328)
+ .width(this.curBp === 'sm' ? '100%' : $r('app.float.input_width'))
Row() {
Text($r('app.string.reacquire'))
@@ -94,15 +95,21 @@ struct BottomWithBar {
}
.alignSelf(ItemAlign.Center)
.justifyContent(FlexAlign.End)
- .width(this.curBp === 'sm' ? '100%' : 328)
+ .width(this.curBp === 'sm' ? '100%' : $r('app.float.input_width'))
.margin({ top: $r('sys.float.padding_level6') })
}
.padding({
- left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- top: this.topRectHeight
+ left: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ right: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ top: this.statusBarHeight
})
.height(Constants.ONE_HUNDRED_PERCENT)
.width(Constants.ONE_HUNDRED_PERCENT)
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/SelectVerificationCode.ets b/verificationcodescenariolibrary/src/main/ets/view/SelectVerificationCode.ets
similarity index 87%
rename from verificationcodescenariolibrary/src/main/ets/pages/SelectVerificationCode.ets
rename to verificationcodescenariolibrary/src/main/ets/view/SelectVerificationCode.ets
index 267a16b2e780679a0aca65f6c73dda1a7791ba91..8946139299ebc8a33d5100165fc0c1bcc0b74699 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/SelectVerificationCode.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/SelectVerificationCode.ets
@@ -13,7 +13,8 @@
* limitations under the License.
*/
-import Constants, { BreakpointType } from '../common/Constants';
+import Constants from '../common/Constants';
+import { BreakpointType } from '../common/utils/BreakpointSystem';
@Extend(Text)
function word() {
@@ -60,12 +61,10 @@ function toast() {
@Entry
@Component
struct SelectVerificationCode {
- @Consume('pathInfos') pathInfos: NavPathStack;
- @StorageProp('currentBreakpoint') @Watch('deviceTypeChange') curBp: string = Constants.BREAK_POINT_SM;
- @StorageProp('bottomRectHeight')
- bottomRectHeight: number = 0;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Consume(Constants.KEY_PATH_STACK) pathInfos: NavPathStack;
+ @StorageProp(Constants.KEY_BREAKPOINT) @Watch('deviceTypeChange') curBp: string = Constants.BREAK_POINT_SM;
+ @StorageProp(Constants.KEY_NAV_INDICATOR_HEIGHT) navIndicatorHeight: number = 0;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0;
@State showNumberIcon: Visibility[] = [Visibility.Hidden, Visibility.Hidden, Visibility.Hidden, Visibility.Hidden];
@State text: string = '';
@State wordNumber: number = 1;
@@ -171,7 +170,7 @@ struct SelectVerificationCode {
.translate({
x: this.oneX - (this.curBp === 'sm' ? Constants.PADDING_SM :
this.curBp === 'md' ? Constants.PADDING_MD : Constants.PADDING_LG),
- y: this.oneY - this.topRectHeight - Constants.BAR_HEIGHT
+ y: this.oneY - this.statusBarHeight - Constants.BAR_HEIGHT
})
.visibility(this.showNumberIcon[0])
Text(Constants.TWO.toString())
@@ -179,7 +178,7 @@ struct SelectVerificationCode {
.translate({
x: this.twoX - (this.curBp === 'sm' ? Constants.PADDING_SM :
this.curBp === 'md' ? Constants.PADDING_MD : Constants.PADDING_LG),
- y: this.twoY - this.topRectHeight - Constants.BAR_HEIGHT
+ y: this.twoY - this.statusBarHeight - Constants.BAR_HEIGHT
})
.visibility(this.showNumberIcon[1])
Text(Constants.THREE.toString())
@@ -187,7 +186,7 @@ struct SelectVerificationCode {
.translate({
x: this.threeX - (this.curBp === 'sm' ? Constants.PADDING_SM :
this.curBp === 'md' ? Constants.PADDING_MD : Constants.PADDING_LG),
- y: this.threeY - this.topRectHeight - Constants.BAR_HEIGHT
+ y: this.threeY - this.statusBarHeight - Constants.BAR_HEIGHT
})
.visibility(this.showNumberIcon[2])
@@ -196,7 +195,7 @@ struct SelectVerificationCode {
.translate({
x: this.fourX - (this.curBp === 'sm' ? Constants.PADDING_SM :
this.curBp === 'md' ? Constants.PADDING_MD : Constants.PADDING_LG),
- y: this.fourY - this.topRectHeight - Constants.BAR_HEIGHT
+ y: this.fourY - this.statusBarHeight - Constants.BAR_HEIGHT
})
.visibility(this.showNumberIcon[3])
@@ -285,15 +284,17 @@ struct SelectVerificationCode {
.fontColor($r('sys.color.font_primary'))
.fontSize($r('app.float.font_size'))
.fontWeight(FontWeight.Medium)
- Text($r('app.string.change_another'))
- .fontSize($r('app.float.font_size'))
- .fontWeight(FontWeight.Regular)
- .fontColor($r('sys.color.brand'))
- .textAlign(TextAlign.Center)
- .margin({ right: $r('app.float.change_margin') })
- SymbolGlyph($r('sys.symbol.arrow_clockwise'))
- .fontSize($r('app.float.change'))
- .fontColor([$r('sys.color.brand')])
+ Row() {
+ Text($r('app.string.change_another'))
+ .fontSize($r('app.float.font_size'))
+ .fontWeight(FontWeight.Regular)
+ .fontColor($r('sys.color.brand'))
+ .textAlign(TextAlign.Center)
+ .margin({ right: $r('app.float.change_margin') })
+ SymbolGlyph($r('sys.symbol.arrow_clockwise'))
+ .fontSize($r('app.float.change'))
+ .fontColor([$r('sys.color.brand')])
+ }
}
.margin({
top: $r('app.float.word_margin_top'),
@@ -338,11 +339,17 @@ struct SelectVerificationCode {
}
}
.padding({
- left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- top: this.topRectHeight
+ left: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ right: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ top: this.statusBarHeight
})
.width(Constants.ONE_HUNDRED_PERCENT)
.height(Constants.ONE_HUNDRED_PERCENT)
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/SliderVerificationCode.ets b/verificationcodescenariolibrary/src/main/ets/view/SliderVerificationCode.ets
similarity index 85%
rename from verificationcodescenariolibrary/src/main/ets/pages/SliderVerificationCode.ets
rename to verificationcodescenariolibrary/src/main/ets/view/SliderVerificationCode.ets
index c4e557cbce649fca20a16f07926138253eb272ff..83ce11956c4d532a17d75ad9fd6952c8ec108271 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/SliderVerificationCode.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/SliderVerificationCode.ets
@@ -13,7 +13,8 @@
* limitations under the License.
*/
-import Constants, { BreakpointType } from '../common/Constants';
+import Constants from '../common/Constants';
+import { BreakpointType } from '../common/utils/BreakpointSystem';
@Entry
@Component
@@ -21,12 +22,10 @@ struct SliderVerificationCode {
@State tipText: string = '';
@State inSetValueOne: number = 0;
@State opacityNumber: number = 0;
- @Consume('pathInfos') pathInfos: NavPathStack;
- @StorageProp('currentBreakpoint') curBp: string = Constants.BREAK_POINT_SM;
- @StorageProp('bottomRectHeight')
- bottomRectHeight: number = 0;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Consume(Constants.KEY_PATH_STACK) pathInfos: NavPathStack;
+ @StorageProp(Constants.KEY_BREAKPOINT) curBp: string = Constants.BREAK_POINT_SM;
+ @StorageProp(Constants.KEY_NAV_INDICATOR_HEIGHT) navIndicatorHeight: number = 0;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0;
getTargetTranslateX() {
return this.inSetValueOne * Constants.COEFFICIENT;
@@ -54,10 +53,16 @@ struct SliderVerificationCode {
.height($r('app.float.bar_height'))
.zIndex(2)
.padding({
- left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
+ left: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ right: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
})
Stack() {
@@ -89,7 +94,7 @@ struct SliderVerificationCode {
.blockSize({ width: $r('app.float.button_width'), height: $r('app.float.button_width') })
.blockStyle({ type: SliderBlockType.IMAGE, image: $r('app.media.button') })
.width(this.curBp === 'sm' ? $r('app.float.image_width') : $r('app.float.image_width'))
- .trackColor(Color.Transparent)
+ .trackColor($r('sys.color.ohos_id_color_hover'))
.selectedColor($r('app.color.select_color'))
.showTips(false)
.trackThickness(Constants.ANGLE)
@@ -150,7 +155,7 @@ struct SliderVerificationCode {
})
}
.padding({
- top: this.topRectHeight
+ top: this.statusBarHeight
})
.width(Constants.ONE_HUNDRED_PERCENT)
.height(Constants.ONE_HUNDRED_PERCENT)
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/TextBoxShowCursor.ets b/verificationcodescenariolibrary/src/main/ets/view/TextBoxShowCursor.ets
similarity index 79%
rename from verificationcodescenariolibrary/src/main/ets/pages/TextBoxShowCursor.ets
rename to verificationcodescenariolibrary/src/main/ets/view/TextBoxShowCursor.ets
index 0aa7b1d90bd90376f0095acef58424a01abac013..9c2d06e5aa1ece84060b0762883e453e733ab49b 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/TextBoxShowCursor.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/TextBoxShowCursor.ets
@@ -13,11 +13,12 @@
* limitations under the License.
*/
-import { BusinessError } from '@kit.BasicServicesKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
+import { display, window } from '@kit.ArkUI';
+import { BusinessError, deviceInfo } from '@kit.BasicServicesKit';
import { inputMethod } from '@kit.IMEKit';
-import { window } from '@kit.ArkUI';
-import Constants, { BreakpointType } from '../common/Constants';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import Constants from '../common/Constants';
+import { BreakpointType } from '../common/utils/BreakpointSystem';
@Extend(Text)
function verifyCodeUnitStyle() {
@@ -38,10 +39,9 @@ const TAG = 'TextBoxShowCursor';
@Entry
@Component
struct TextBoxShowCursor {
- @Consume('pathInfos') pathInfos: NavPathStack;
- @StorageProp('currentBreakpoint') curBp: string = Constants.BREAK_POINT_SM;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Consume(Constants.KEY_PATH_STACK) pathInfos: NavPathStack;
+ @StorageProp(Constants.KEY_BREAKPOINT) curBp: string = Constants.BREAK_POINT_SM;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0;
@State codeText: string = '';
@State opacityColumn: number = 0;
@State flag: boolean = true;
@@ -55,7 +55,7 @@ struct TextBoxShowCursor {
enterKeyType: inputMethod.EnterKeyType.GO
}
};
- private windowClass: window.Window = AppStorage.get('windowClass') as window.Window;
+ private windowClass: window.Window = AppStorage.get(Constants.KEY_WINDOWS) as window.Window;
private isFirstOpenPage: boolean = true;
private registerCount: number = 1;
@@ -140,6 +140,30 @@ struct TextBoxShowCursor {
}
}
+ getCursorTranslateX(): number {
+ if (canIUse('SystemCapability.Window.SessionManager')) {
+ let foldStatus = display.getFoldStatus();
+ if (deviceInfo.productSeries === 'VDE' && foldStatus === display.FoldStatus.FOLD_STATUS_EXPANDED) {
+ return Constants.ITEM_CODE_START + this.codeText.length * Constants.ITEM_CODE_WIDTH;
+ }
+ if (foldStatus === display.FoldStatus.FOLD_STATUS_FOLDED) {
+ return Constants.ITEM_DIVIDER + this.codeText.length * Constants.ITEM_FOLD_CODE_WIDTH;
+ }
+ }
+ return (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))
+ }
+
+ private unicodeToDigit(unicodeValue: number): number {
+ // Check for half-width digits('0'to'9')
+ if (unicodeValue >= 48 && unicodeValue <= 57) {
+ return unicodeValue - 48;
+ }
+ return 0;
+ }
+
/**
* In some verification code scenarios, the functions of selecting and copying entered verification codes must be
* disabled.
@@ -148,7 +172,7 @@ struct TextBoxShowCursor {
@Builder
buildVerifyCodeComponent() {
Stack() {
- Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) {
+ Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
ForEach(this.codeIndexArray, (item: number) => {
Text(this.codeText[item])
.verifyCodeUnitStyle()
@@ -186,6 +210,19 @@ struct TextBoxShowCursor {
}
})
.width(this.curBp === 'sm' ? Constants.FULL_WIDTH : $r('app.float.context_area'))
+ .onKeyPreIme((key: KeyEvent) => {
+ if (key.type === KeyType.Up && key.unicode && (key.unicode >= 48 && key.unicode <= 57)) {
+ if (this.codeText.length >= this.verifyCodeLength) {
+ return;
+ }
+ this.codeText += this.unicodeToDigit(key.unicode);
+ if (this.codeText.length === this.verifyCodeLength) {
+ this.flag = false;
+ }
+ return true;
+ }
+ return false;
+ })
Row() {
Column() {
@@ -208,12 +245,7 @@ struct TextBoxShowCursor {
})
}
.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))
- })
+ .translate({ x: this.getCursorTranslateX() })
.hitTestBehavior(HitTestMode.Transparent)
.onClick(() => {
try {
@@ -288,15 +320,21 @@ struct TextBoxShowCursor {
.margin({ top: $r('sys.float.padding_level6') })
.alignSelf(ItemAlign.Center)
.justifyContent(FlexAlign.End)
- .width(this.curBp === 'sm' ? '100%' : 328)
+ .width(this.curBp === 'sm' ? '100%' : $r('app.float.input_width'))
}
.backgroundColor($r('sys.color.background_secondary'))
.padding({
- left: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- right: new BreakpointType($r('sys.float.padding_level8'), $r('sys.float.padding_level12'),
- $r('sys.float.padding_level16')).GetValue(this.curBp),
- top: this.topRectHeight
+ left: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ right: new BreakpointType({
+ sm: $r('sys.float.padding_level8'),
+ md: $r('sys.float.padding_level12'),
+ lg: $r('sys.float.padding_level16')
+ }).getValue(this.curBp),
+ top: this.statusBarHeight
})
.height(Constants.ONE_HUNDRED_PERCENT)
.width(Constants.ONE_HUNDRED_PERCENT)
diff --git a/verificationcodescenariolibrary/src/main/ets/pages/VerificationCodeScenarioPage.ets b/verificationcodescenariolibrary/src/main/ets/view/VerificationCodeScenarioView.ets
similarity index 63%
rename from verificationcodescenariolibrary/src/main/ets/pages/VerificationCodeScenarioPage.ets
rename to verificationcodescenariolibrary/src/main/ets/view/VerificationCodeScenarioView.ets
index a3cad0ada7f2b42d232e56e1d1d742d79330b2b6..c6d9e6de0923f65856a72e2b7c8c30e6cd89254f 100644
--- a/verificationcodescenariolibrary/src/main/ets/pages/VerificationCodeScenarioPage.ets
+++ b/verificationcodescenariolibrary/src/main/ets/view/VerificationCodeScenarioView.ets
@@ -1,16 +1,29 @@
-import Constants from "../common/Constants";
-import { GlobalBuilderContext } from "../common/GlobalBuilderContext";
-import { NavDestinationItem } from "../viewmodel/NavDestinationItem";
+/*
+ * 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 { GlobalBuilderContext } from '../common/GlobalBuilderContext';
+import { NavDestinationItem } from '../viewmodel/NavDestinationItem';
@Component
-export struct VerificationCodeScenarioPage {
+export struct VerificationCodeScenarioView {
private navDestinationData: NavDestinationItem[] = Constants.NAV_DESTINATION_DATA;
- @Provide('pathInfos') pathInfos: NavPathStack = new NavPathStack();
- @StorageProp('currentBreakpoint') curBp: string = Constants.BREAKPOINTS[0];
- @StorageProp('bottomRectHeight')
- bottomRectHeight: number = 0;
- @StorageProp('topRectHeight')
- topRectHeight: number = 0;
+ @Provide(Constants.KEY_PATH_STACK) pathInfos: NavPathStack = new NavPathStack();
+ @StorageProp(Constants.KEY_BREAKPOINT) curBp: string = Constants.BREAKPOINTS[0];
+ @StorageProp(Constants.KEY_NAV_INDICATOR_HEIGHT) navIndicatorHeight: number = 0;
+ @StorageProp(Constants.KEY_STATUS_BAR_HEIGHT) statusBarHeight: number = 0;
@Builder
PagesMap(name: string) {
@@ -62,12 +75,12 @@ export struct VerificationCodeScenarioPage {
.padding({
left: $r('sys.float.padding_level8'),
right: $r('sys.float.padding_level8'),
- top: Constants.PADDING_TOP_INDEX + this.topRectHeight,
- bottom: Constants.PADDING_BOTTOM_INDEX + this.bottomRectHeight
+ top: Constants.PADDING_TOP_INDEX + this.statusBarHeight,
+ bottom: Constants.PADDING_BOTTOM_INDEX + this.navIndicatorHeight
})
}
.mode(NavigationMode.Stack)
.hideTitleBar(true)
.navDestination(this.PagesMap)
}
-}
+}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/resources/base/element/color.json b/verificationcodescenariolibrary/src/main/resources/base/element/color.json
index 98540a85770a437c64a579e7ea29002ea8b22b13..0c0aa714a1daf852f749b2f9e83c2c11b6c9b354 100644
--- a/verificationcodescenariolibrary/src/main/resources/base/element/color.json
+++ b/verificationcodescenariolibrary/src/main/resources/base/element/color.json
@@ -1,9 +1,5 @@
{
"color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
{
"name": "theme_color",
"value": "#0a59f7"
diff --git a/verificationcodescenariolibrary/src/main/resources/base/element/float.json b/verificationcodescenariolibrary/src/main/resources/base/element/float.json
index d353d58335d488f0fb11e2231161cba1039596ba..082028be72ab563d227c379ac3604f5d4564ee31 100644
--- a/verificationcodescenariolibrary/src/main/resources/base/element/float.json
+++ b/verificationcodescenariolibrary/src/main/resources/base/element/float.json
@@ -12,6 +12,10 @@
"name": "row_margin",
"value": "20vp"
},
+ {
+ "name": "input_width",
+ "value": "328vp"
+ },
{
"name": "index_button_width_lg",
"value": "448vp"
@@ -130,7 +134,7 @@
},
{
"name": "change_margin",
- "value": "-65vp"
+ "value": "8vp"
},
{
"name": "word_margin_top",
diff --git a/verificationcodescenariolibrary/src/main/resources/base/element/string.json b/verificationcodescenariolibrary/src/main/resources/base/element/string.json
index dbf552087cfffae36963ba4677bf6729d934946f..7e313e9a8486a8e5c45b4e02e7f712effde4675a 100644
--- a/verificationcodescenariolibrary/src/main/resources/base/element/string.json
+++ b/verificationcodescenariolibrary/src/main/resources/base/element/string.json
@@ -1,32 +1,20 @@
{
"string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "验证码场景实例"
- },
{
"name": "select_verification_code",
- "value": "选择验证码"
+ "value": "Select verification code"
},
{
"name": "slider_verification_code",
- "value": "滑块验证码"
+ "value": "Slider verification code"
},
{
"name": "enter_the_verification_code",
- "value": "请输入验证码"
+ "value": "Please enter the verification code"
},
{
"name": "Verification_code_sent_to",
- "value": "验证码已发送至"
+ "value": "Verification code has been sent to"
},
{
"name": "phone_number",
@@ -34,7 +22,7 @@
},
{
"name": "reacquire",
- "value": "重新获取"
+ "value": "Reacquire"
},
{
"name": "phone_number1",
@@ -42,75 +30,79 @@
},
{
"name": "slide",
- "value": "向右滑动滑块填充拼图"
+ "value": "Slide right to fit the puzzle piece"
},
{
"name": "verification_passed",
- "value": "验证通过"
+ "value": "Verification Passed"
},
{
"name": "verification_fail",
- "value": "验证失败"
+ "value": "Validation failed"
},
{
"name": "change",
- "value": "看不清?换一张"
+ "value": "Can't see? Change it."
},
{
"name": "sentence",
- "value": "请依次点击 '古 堰 画 乡'"
+ "value": "Click \"Gu Yan Hua Xiang\""
},
{
"name": "change_another",
- "value": "换一张"
+ "value": "change"
},
{
"name": "commit",
- "value": "提交"
+ "value": "Commit"
},
{
"name": "word",
- "value": "光标风格"
+ "value": "Cursor style"
},
{
"name": "bottom",
- "value": "底部横条风格"
+ "value": "Bottom bar style"
},
{
"name": "background",
- "value": "背景改变风格"
+ "value": "Background change style"
},
{
"name": "hua",
- "value": "画"
+ "value": "Hua"
},
{
"name": "cause",
- "value": "故"
+ "value": "cause"
},
{
"name": "yan",
- "value": "堰"
+ "value": "Yan"
},
{
"name": "xiang",
- "value": "乡"
+ "value": "Xiang"
},
{
"name": "china",
- "value": "华"
+ "value": "china"
},
{
"name": "gu",
- "value": "古"
+ "value": "Gu"
},
{
"name": "hunan",
- "value": "湘"
+ "value": "hunan"
},
{
"name": "project_name",
"value": "Collection Of Verification Codes"
+ },
+ {
+ "name": "prompt_message",
+ "value": "Keyboard input is currently not supported on 2-in-1 devices."
}
]
}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/resources/en_US/element/string.json b/verificationcodescenariolibrary/src/main/resources/en_US/element/string.json
index 85ca03e1cf40775f56d545396c94d05f0d31d799..7e313e9a8486a8e5c45b4e02e7f712effde4675a 100644
--- a/verificationcodescenariolibrary/src/main/resources/en_US/element/string.json
+++ b/verificationcodescenariolibrary/src/main/resources/en_US/element/string.json
@@ -1,17 +1,5 @@
{
"string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "Verification Code Scenario Example"
- },
{
"name": "select_verification_code",
"value": "Select verification code"
@@ -42,7 +30,7 @@
},
{
"name": "slide",
- "value": "Slide the slider to the right to fill the puzzle"
+ "value": "Slide right to fit the puzzle piece"
},
{
"name": "verification_passed",
@@ -111,6 +99,10 @@
{
"name": "project_name",
"value": "Collection Of Verification Codes"
+ },
+ {
+ "name": "prompt_message",
+ "value": "Keyboard input is currently not supported on 2-in-1 devices."
}
]
}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/resources/zh_CN/element/string.json b/verificationcodescenariolibrary/src/main/resources/zh_CN/element/string.json
index 4e77cba4e4fd4379261454c61f83f4f826722708..e5cf0cbdb9e1895a8b37d42a9f6f00ec1cadd39f 100644
--- a/verificationcodescenariolibrary/src/main/resources/zh_CN/element/string.json
+++ b/verificationcodescenariolibrary/src/main/resources/zh_CN/element/string.json
@@ -1,17 +1,5 @@
{
"string": [
- {
- "name": "module_desc",
- "value": "模块描述"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "验证码场景实例"
- },
{
"name": "select_verification_code",
"value": "选择验证码"
@@ -111,6 +99,10 @@
{
"name": "project_name",
"value": "验证码合集"
+ },
+ {
+ "name": "prompt_message",
+ "value": "2in1设备暂不支持键盘输入!"
}
]
}
\ No newline at end of file
diff --git a/verificationcodescenariosample/oh-package-lock.json5 b/verificationcodescenariosample/oh-package-lock.json5
deleted file mode 100644
index a4eddf9931e267778e30206055eeaaeeb6e6d5a0..0000000000000000000000000000000000000000
--- a/verificationcodescenariosample/oh-package-lock.json5
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "meta": {
- "stableOrder": true
- },
- "lockfileVersion": 3,
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
- "specifiers": {
- "verificationcodescenariolibrary@../verificationcodescenariolibrary": "verificationcodescenariolibrary@../verificationcodescenariolibrary"
- },
- "packages": {
- "verificationcodescenariolibrary@../verificationcodescenariolibrary": {
- "name": "verificationcodescenariolibrary",
- "version": "1.0.0",
- "resolved": "../verificationcodescenariolibrary",
- "registryType": "local"
- }
- }
-}
\ No newline at end of file
diff --git a/verificationcodescenariosample/oh-package.json5 b/verificationcodescenariosample/oh-package.json5
index 283d99fbbf513762f5c6c50818b21f545cbb25cc..850379fb12c00ce5b0d2d447672e0d17dd0e2015 100644
--- a/verificationcodescenariosample/oh-package.json5
+++ b/verificationcodescenariosample/oh-package.json5
@@ -6,6 +6,6 @@
"author": "",
"license": "",
"dependencies": {
- "verificationcodescenariolibrary": "file:../verificationcodescenariolibrary"
+ "@ohos_samples/verificationcodescenariolibrary": "file:../verificationcodescenariolibrary"
}
}
\ No newline at end of file
diff --git a/verificationcodescenariosample/src/main/ets/entryability/EntryAbility.ets b/verificationcodescenariosample/src/main/ets/entryability/EntryAbility.ets
index e15bcb0add95ff10175a0e3f9f8bae358f4b29fc..5eca7fdae817671284d7687121dd8aa443199c9e 100644
--- a/verificationcodescenariosample/src/main/ets/entryability/EntryAbility.ets
+++ b/verificationcodescenariosample/src/main/ets/entryability/EntryAbility.ets
@@ -16,14 +16,11 @@
import { ConfigurationConstant, UIAbility } from '@kit.AbilityKit';
import { window } from '@kit.ArkUI';
import { hilog } from '@kit.PerformanceAnalysisKit';
-import { WindowUtil } from 'verificationcodescenariolibrary';
-
+import { VerificationCodeController } from '@ohos_samples/verificationcodescenariolibrary';
const TAG: string = '[EntryAbility]';
export default class EntryAbility extends UIAbility {
- private curBp: string = '';
-
onCreate(): void {
hilog.info(0x0000, TAG, '%{public}s', 'Ability onCreate');
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
@@ -34,14 +31,13 @@ export default class EntryAbility extends UIAbility {
}
onWindowStageCreate(windowStage: window.WindowStage): void {
- WindowUtil.requestFullScreen(windowStage)
- WindowUtil.registerBreakPoint(windowStage)
windowStage.loadContent('pages/Index', (err, _data) => {
if (err.code) {
hilog.error(0x0000, TAG, 'Failed to load the content. Cause: %{public}s',
`the code is ${err.code}, the message is ${err.message}`);
return;
}
+ VerificationCodeController.initWindowConfig(windowStage);
hilog.info(0x0000, TAG, 'Succeed in loading the content.');
});
}
diff --git a/verificationcodescenariosample/src/main/ets/pages/Index.ets b/verificationcodescenariosample/src/main/ets/pages/Index.ets
index 6aaa5002898a96ccc9e7ec7791a867c5f146f1cd..18a2351a7a84e1dc50ae35ab5b3f9a57f46c7aac 100644
--- a/verificationcodescenariosample/src/main/ets/pages/Index.ets
+++ b/verificationcodescenariosample/src/main/ets/pages/Index.ets
@@ -13,17 +13,14 @@
* limitations under the License.
*/
-import Constants from 'verificationcodescenariolibrary/src/main/ets/common/Constants';
-import { NavDestinationItem } from 'verificationcodescenariolibrary/src/main/ets/viewmodel/NavDestinationItem';
-import { GlobalBuilderContext } from 'verificationcodescenariolibrary/src/main/ets/common/GlobalBuilderContext';
-import { VerificationCodeScenarioPage } from 'verificationcodescenariolibrary';
+import { VerificationCodeScenarioComponent } from '@ohos_samples/verificationcodescenariolibrary';
@Entry
@Component
struct Index {
build() {
Stack() {
- VerificationCodeScenarioPage()
+ VerificationCodeScenarioComponent()
}
}
}
\ No newline at end of file
diff --git a/verificationcodescenariosample/src/main/resources/base/element/color.json b/verificationcodescenariosample/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02
--- /dev/null
+++ b/verificationcodescenariosample/src/main/resources/base/element/color.json
@@ -0,0 +1,8 @@
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/verificationcodescenariosample/src/main/resources/base/element/string.json b/verificationcodescenariosample/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..c6dcb8b75368ce8cbee27a8fe1273035b8e17d24
--- /dev/null
+++ b/verificationcodescenariosample/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "Verification Code Scenario Example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/verificationcodescenariolibrary/src/main/resources/base/media/background.png b/verificationcodescenariosample/src/main/resources/base/media/background.png
similarity index 100%
rename from verificationcodescenariolibrary/src/main/resources/base/media/background.png
rename to verificationcodescenariosample/src/main/resources/base/media/background.png
diff --git a/verificationcodescenariolibrary/src/main/resources/base/media/foreground.png b/verificationcodescenariosample/src/main/resources/base/media/foreground.png
similarity index 100%
rename from verificationcodescenariolibrary/src/main/resources/base/media/foreground.png
rename to verificationcodescenariosample/src/main/resources/base/media/foreground.png
diff --git a/verificationcodescenariolibrary/src/main/resources/base/media/layered_image.json b/verificationcodescenariosample/src/main/resources/base/media/layered_image.json
similarity index 100%
rename from verificationcodescenariolibrary/src/main/resources/base/media/layered_image.json
rename to verificationcodescenariosample/src/main/resources/base/media/layered_image.json
diff --git a/verificationcodescenariolibrary/src/main/resources/base/media/startIcon.png b/verificationcodescenariosample/src/main/resources/base/media/startIcon.png
similarity index 100%
rename from verificationcodescenariolibrary/src/main/resources/base/media/startIcon.png
rename to verificationcodescenariosample/src/main/resources/base/media/startIcon.png
diff --git a/verificationcodescenariosample/src/main/resources/en_US/element/string.json b/verificationcodescenariosample/src/main/resources/en_US/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..c6dcb8b75368ce8cbee27a8fe1273035b8e17d24
--- /dev/null
+++ b/verificationcodescenariosample/src/main/resources/en_US/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "Verification Code Scenario Example"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/verificationcodescenariosample/src/main/resources/zh_CN/element/string.json b/verificationcodescenariosample/src/main/resources/zh_CN/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..f5bff6f169f69b904c4912e06e7968e04bed0b94
--- /dev/null
+++ b/verificationcodescenariosample/src/main/resources/zh_CN/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "描述"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "验证码场景实例"
+ }
+ ]
+}
\ No newline at end of file