diff --git a/entry/src/main/ets/common/Constants.ets b/entry/src/main/ets/common/Constants.ets index 73369f005b16104a968e347981c332f446cb580e..5acb284901a7a9e368f4d8651926f8e11c300d9d 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. */ diff --git a/entry/src/main/ets/pages/TextBoxShowCursor.ets b/entry/src/main/ets/pages/TextBoxShowCursor.ets index 82772fadaa116eeeb65bed2e467910e402482032..dc100825eff504f133277fd764b9578b30c9f381 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'; @@ -123,7 +119,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 +145,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 +172,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')) diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json index 55ecf675377297113a709aa9212a7f0796a3eedd..fb198593ce9fb921cd48af05f3d1aac2c9df3d4c 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