From 5fb4b2f5e01e2a4d8d0ead30fa265c69fb970fa1 Mon Sep 17 00:00:00 2001 From: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> Date: Tue, 15 Jul 2025 12:38:17 +0000 Subject: [PATCH 1/4] update entry/src/main/resources/base/element/float.json. Signed-off-by: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> --- entry/src/main/resources/base/element/float.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index 55ecf67..fb19859 100644 --- a/entry/src/main/resources/base/element/float.json +++ b/entry/src/main/resources/base/element/float.json @@ -175,6 +175,10 @@ { "name": "item_list", "value": "12vp" + }, + { + "name": "text_border_width", + "value": "1.5vp" } ] } \ No newline at end of file -- Gitee From 84a57741ad7925b4e1ce11376b9949797be4e5f9 Mon Sep 17 00:00:00 2001 From: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> Date: Tue, 15 Jul 2025 12:38:52 +0000 Subject: [PATCH 2/4] update entry/src/main/ets/common/Constants.ets. Signed-off-by: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> --- entry/src/main/ets/common/Constants.ets | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/entry/src/main/ets/common/Constants.ets b/entry/src/main/ets/common/Constants.ets index 73369f0..5acb284 100644 --- a/entry/src/main/ets/common/Constants.ets +++ b/entry/src/main/ets/common/Constants.ets @@ -126,6 +126,26 @@ export default class Constants { */ static readonly THREE_HUNDRED_AND_FORTY: number = 340; + /** + * Total width. + */ + static readonly TOTAL_WIDTH: number = 345; + + /** + * One text width. + */ + static readonly ONE_TEXT_WIDTH: number = 50; + + /** + * All text count. + */ + static readonly ALL_TEXT_COUNT: number = 6; + + /** + * All margin count. + */ + static readonly ALL_MARGIN_COUNT: number = 5; + /** * Ninety. */ -- Gitee From 5d20ee6fed9f6c3da90e9265c3f427cfbe3817d5 Mon Sep 17 00:00:00 2001 From: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> Date: Tue, 15 Jul 2025 12:39:38 +0000 Subject: [PATCH 3/4] update entry/src/main/ets/pages/TextBoxShowCursor.ets. Signed-off-by: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> --- .../src/main/ets/pages/TextBoxShowCursor.ets | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/pages/TextBoxShowCursor.ets b/entry/src/main/ets/pages/TextBoxShowCursor.ets index 82772fa..371dcd0 100644 --- a/entry/src/main/ets/pages/TextBoxShowCursor.ets +++ b/entry/src/main/ets/pages/TextBoxShowCursor.ets @@ -123,7 +123,7 @@ struct TextBoxShowCursor { @Builder buildVerifyCodeComponent() { Stack() { - Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center }) { + Row() { ForEach(this.codeIndexArray, (item: number) => { Text(this.codeText[item]) .verifyCodeUnitStyle() @@ -149,11 +149,8 @@ struct TextBoxShowCursor { .backgroundColor(Color.Transparent) .height($r('app.float.text_height')) .width($r('app.float.context_area')) - .margin({ - left: $r('sys.float.ohos_id_card_margin_start'), - right: $r('sys.float.ohos_id_card_margin_start') - }) .defaultFocus(true) + .justifyContent(FlexAlign.SpaceBetween) .onClick(() => { // When you click this component, the input method is displayed. Because the Text component is used here, // you need to re-attach it instead of directly using showSoftKeyboard. @@ -179,25 +176,22 @@ struct TextBoxShowCursor { expected: Constants.NINETY } }) - - Text() - .height(Constants.LINE_HEIGHT) - .width(Constants.LINE_WIDTH) - .backgroundColor($r('app.color.theme_color')) - .translate({ y: Constants.LINE_MOVE }) } .visibility(this.flag ? Visibility.Visible : Visibility.Hidden) .translate({ - x: this.codeText.length === Constants.ZERO ? Constants.ITEM_DIVIDER : this.codeText.length * - (this.codeText.length > Constants.TWO ? (this.codeText.length === Constants.ITEM_DIVIDER ? - Constants.FIFTY_EIGHT_POINT_FIVE : Constants.FIFTY_NINE) : Constants.SIXTY) + x: this.codeText.length === Constants.ZERO ? Constants.ZERO : + (((Constants.TOTAL_WIDTH - (Constants.ONE_TEXT_WIDTH * Constants.ALL_TEXT_COUNT)) / + Constants.ALL_MARGIN_COUNT) + Constants.ONE_TEXT_WIDTH) * this.codeText.length }) .hitTestBehavior(HitTestMode.Transparent) .onClick(() => { this.inputController.attach(true, this.textConfig); }) .justifyContent(FlexAlign.Center) + .width($r('app.float.text_height')) .height(Constants.ONE_HUNDRED_PERCENT) + .borderWidth({ bottom: $r('app.float.text_border_width') }) + .borderColor($r('app.color.theme_color')) } .hitTestBehavior(HitTestMode.Transparent) .height($r('app.float.text_height')) -- Gitee From ee02f9c108efdd6ad372af621eb03cb9e02294de Mon Sep 17 00:00:00 2001 From: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> Date: Tue, 15 Jul 2025 12:44:11 +0000 Subject: [PATCH 4/4] update entry/src/main/ets/pages/TextBoxShowCursor.ets. Signed-off-by: ZhangQ <12903047+zq-kexin@user.noreply.gitee.com> --- entry/src/main/ets/pages/TextBoxShowCursor.ets | 4 ---- 1 file changed, 4 deletions(-) diff --git a/entry/src/main/ets/pages/TextBoxShowCursor.ets b/entry/src/main/ets/pages/TextBoxShowCursor.ets index 371dcd0..dc10082 100644 --- a/entry/src/main/ets/pages/TextBoxShowCursor.ets +++ b/entry/src/main/ets/pages/TextBoxShowCursor.ets @@ -27,10 +27,6 @@ function verifyCodeUnitStyle() { .textAlign(TextAlign.Center) .width($r('app.float.text_height')) .height(Constants.ONE_HUNDRED_PERCENT) - .margin({ - left: $r('app.float.text_margin'), - right: $r('app.float.text_margin') - }) } const TAG = 'TextBoxShowCursor'; -- Gitee