From 9f6d8cb6b5dd1125b85a1f452c15c90627028ce1 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 14 May 2026 16:50:03 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../TangemPayEditDisplayNameComponent.kt | 1 + .../tangempay/entity/TangemPayDetailsUM.kt | 1 + .../entity/TangemPayEditDisplayNameUM.kt | 1 + .../model/TangemPayEditDisplayNameModel.kt | 7 +++-- .../tangempay/ui/TangemPayCardDetailsBlock.kt | 17 ++++++----- .../tangempay/ui/TangemPayDetailsScreen.kt | 1 + .../ui/TangemPayEditDisplayNameScreen.kt | 28 ++++++------------- 7 files changed, 26 insertions(+), 30 deletions(-) diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayEditDisplayNameComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayEditDisplayNameComponent.kt index 571c294824..162a780e99 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayEditDisplayNameComponent.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/TangemPayEditDisplayNameComponent.kt @@ -35,6 +35,7 @@ internal class TangemPayEditDisplayNameComponent( displayNameState = DisplayNameState.Editing( displayName = state.editingValue.text, editingValue = state.editingValue, + isSubmitEnabled = state.isDoneEnabled, onValueChanged = state.onValueChanged, onSubmit = state.onDoneClick, onDismiss = state.onDismiss, diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt index 50fb7a2683..2a192392ec 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsUM.kt @@ -47,6 +47,7 @@ internal sealed interface DisplayNameState { data class Editing( override val displayName: String, val editingValue: TextFieldValue, + val isSubmitEnabled: Boolean, val onValueChanged: (TextFieldValue) -> Unit, val onSubmit: () -> Unit, val onDismiss: () -> Unit, diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayEditDisplayNameUM.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayEditDisplayNameUM.kt index 8d4c09a816..9885d4f337 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayEditDisplayNameUM.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayEditDisplayNameUM.kt @@ -5,6 +5,7 @@ import androidx.compose.ui.text.input.TextFieldValue internal data class TangemPayEditDisplayNameUM( val editingValue: TextFieldValue, val isLoading: Boolean, + val isDoneEnabled: Boolean, val onValueChanged: (TextFieldValue) -> Unit, val onDoneClick: () -> Unit, val onDismiss: () -> Unit, diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayEditDisplayNameModel.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayEditDisplayNameModel.kt index 352d5d1373..b9f9fe24d8 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayEditDisplayNameModel.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/model/TangemPayEditDisplayNameModel.kt @@ -49,6 +49,7 @@ internal class TangemPayEditDisplayNameModel @Inject constructor( selection = TextRange(originalDisplayName.length), ), isLoading = false, + isDoneEnabled = true, onValueChanged = ::onValueChanged, onDoneClick = ::onDoneClick, onDismiss = ::onDismiss, @@ -84,9 +85,9 @@ internal class TangemPayEditDisplayNameModel @Inject constructor( } private fun onValueChanged(value: TextFieldValue) { - if (value.text.length <= CardDisplayName.MAX_LENGTH) { - uiState.update { it.copy(editingValue = value) } - } + val displayName = CardDisplayName(value.text) + val isAvailableForConfirm = displayName.isRight() + uiState.update { it.copy(editingValue = value, isDoneEnabled = isAvailableForConfirm) } } private fun onDoneClick() { diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayCardDetailsBlock.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayCardDetailsBlock.kt index 0a58c2672a..18bf622b32 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayCardDetailsBlock.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayCardDetailsBlock.kt @@ -50,7 +50,6 @@ import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.core.ui.test.TangemPayTestTags -import com.tangem.domain.models.account.CardDisplayName import com.tangem.domain.visa.model.TangemPayCardFrozenState import com.tangem.features.tangempay.details.impl.R import com.tangem.features.tangempay.entity.DisplayNameState @@ -273,11 +272,7 @@ private fun EditingCardDisplayName(state: DisplayNameState.Editing, modifier: Mo BasicTextField( value = state.editingValue, - onValueChange = { newValue -> - if (newValue.text.length <= CardDisplayName.MAX_LENGTH) { - state.onValueChanged(newValue) - } - }, + onValueChange = state.onValueChanged, modifier = modifier .width(textWidthDp.coerceAtLeast(1.dp)) .focusRequester(focusRequester), @@ -285,7 +280,13 @@ private fun EditingCardDisplayName(state: DisplayNameState.Editing, modifier: Mo singleLine = true, cursorBrush = SolidColor(TangemTheme.colors.text.constantWhite), keyboardOptions = KeyboardOptions(imeAction = ImeAction.Done), - keyboardActions = KeyboardActions(onDone = { state.onSubmit() }), + keyboardActions = KeyboardActions( + onDone = if (state.isSubmitEnabled) { + { state.onSubmit() } + } else { + null + }, + ), decorationBox = { innerTextField -> Box { if (state.editingValue.text.isEmpty()) { @@ -481,6 +482,7 @@ private class TangemPayCardDetailsUMProvider : CollectionPreviewParameterProvide displayName = "Tangem", editingValue = TextFieldValue(text = "movet", selection = TextRange("movet".length)), onValueChanged = {}, + isSubmitEnabled = true, onSubmit = {}, onDismiss = {}, ), @@ -500,6 +502,7 @@ private class TangemPayCardDetailsUMProvider : CollectionPreviewParameterProvide displayName = "Tangem", editingValue = TextFieldValue(text = ""), onValueChanged = {}, + isSubmitEnabled = true, onSubmit = {}, onDismiss = {}, ), diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt index c6f426ec27..fabad9ef58 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreen.kt @@ -106,6 +106,7 @@ internal fun TangemPayDetailsScreen( TangemPayDetailsBalanceBlock( modifier = Modifier .padding(horizontal = TangemTheme.dimens.spacing16) + .padding(top = 12.dp) .fillMaxWidth(), state = state.balanceBlockState, isBalanceHidden = state.isBalanceHidden, diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayEditDisplayNameScreen.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayEditDisplayNameScreen.kt index 6acfea29a1..18008536a7 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayEditDisplayNameScreen.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayEditDisplayNameScreen.kt @@ -1,25 +1,15 @@ package com.tangem.features.tangempay.ui import androidx.compose.foundation.background -import androidx.compose.foundation.layout.Box -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.fillMaxSize -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.imePadding -import androidx.compose.foundation.layout.navigationBarsPadding -import androidx.compose.foundation.layout.padding -import androidx.compose.foundation.layout.statusBarsPadding +import androidx.compose.foundation.layout.* import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp -import com.tangem.common.ui.navigationButtons.NavigationButton -import com.tangem.common.ui.navigationButtons.NavigationPrimaryButton -import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.components.PrimaryButton +import com.tangem.core.ui.extensions.stringResourceSafe import com.tangem.core.ui.res.TangemTheme import com.tangem.features.tangempay.components.cardDetails.TangemPayCardDetailsBlockComponent import com.tangem.features.tangempay.details.impl.R @@ -66,17 +56,15 @@ internal fun TangemPayEditDisplayNameScreen( Spacer(modifier = Modifier.weight(1f)) - NavigationPrimaryButton( + PrimaryButton( modifier = Modifier .imePadding() .padding(start = 16.dp, end = 16.dp, bottom = 16.dp) .fillMaxWidth(), - primaryButton = NavigationButton( - textReference = resourceReference(R.string.common_done), - onClick = state.onDoneClick, - shouldShowProgress = state.isLoading, - isEnabled = !state.isLoading && state.editingValue.text.isNotBlank(), - ), + text = stringResourceSafe(R.string.common_done), + onClick = state.onDoneClick, + showProgress = state.isLoading, + enabled = !state.isLoading && state.isDoneEnabled, ) } } \ No newline at end of file