From fe23b8ccc319aa90cdb800b5b0c94aed08ee4e72 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 16 Apr 2024 15:44:42 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../send/impl/presentation/ui/SendScreen.kt | 57 ++++++++++--------- .../presentation/ui/amount/AmountField.kt | 18 ++++-- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/SendScreen.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/SendScreen.kt index 0294fefa3b..caf0a2f4f2 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/SendScreen.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/SendScreen.kt @@ -98,33 +98,36 @@ private fun SendScreenContent(uiState: SendUiState, currentState: SendUiCurrentS AnimatedContentTransitionScope.SlideDirection.End } } - AnimatedContent( - targetState = currentState, - label = "Send Scree Navigation", - modifier = modifier, - transitionSpec = { - lastState = currentState.type.ordinal - slideIntoContainer(towards = direction, animationSpec = tween()) - .togetherWith(slideOutOfContainer(towards = direction, animationSpec = tween())) - }, - ) { state -> - when (state.type) { - SendUiStateType.Amount -> SendAmountContent( - amountState = uiState.amountState, - isBalanceHiding = uiState.isBalanceHidden, - clickIntents = uiState.clickIntents, - ) - SendUiStateType.Recipient -> SendRecipientContent( - uiState = uiState.recipientState, - clickIntents = uiState.clickIntents, - isBalanceHidden = uiState.isBalanceHidden, - ) - SendUiStateType.Fee -> SendSpeedAndFeeContent( - state = uiState.feeState, - clickIntents = uiState.clickIntents, - ) - SendUiStateType.Send -> SendContent(uiState) - else -> Unit + // Box is needed to fix animation with resizing of AnimatedContent + Box(modifier = modifier) { + AnimatedContent( + targetState = currentState, + label = "Send Scree Navigation", + transitionSpec = { + lastState = currentState.type.ordinal + slideIntoContainer(towards = direction, animationSpec = tween()) + .togetherWith(slideOutOfContainer(towards = direction, animationSpec = tween())) + }, + ) { state -> + + when (state.type) { + SendUiStateType.Amount -> SendAmountContent( + amountState = uiState.amountState, + isBalanceHiding = uiState.isBalanceHidden, + clickIntents = uiState.clickIntents, + ) + SendUiStateType.Recipient -> SendRecipientContent( + uiState = uiState.recipientState, + clickIntents = uiState.clickIntents, + isBalanceHidden = uiState.isBalanceHidden, + ) + SendUiStateType.Fee -> SendSpeedAndFeeContent( + state = uiState.feeState, + clickIntents = uiState.clickIntents, + ) + SendUiStateType.Send -> SendContent(uiState) + else -> Unit + } } } } \ No newline at end of file diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/AmountField.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/AmountField.kt index 5aa3ec82ac..bb5b97aa51 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/AmountField.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/amount/AmountField.kt @@ -7,9 +7,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.requiredHeightIn import androidx.compose.material3.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.LaunchedEffect -import androidx.compose.runtime.remember +import androidx.compose.runtime.* import androidx.compose.ui.Alignment.Companion.BottomCenter import androidx.compose.ui.Modifier import androidx.compose.ui.focus.FocusRequester @@ -24,6 +22,7 @@ import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.utils.BigDecimalFormatter import com.tangem.core.ui.utils.rememberDecimalFormat import com.tangem.features.send.impl.presentation.state.fields.SendTextField +import kotlinx.coroutines.delay import kotlinx.coroutines.job @Composable @@ -37,6 +36,16 @@ internal fun AmountField(sendField: SendTextField.AmountField, isEnabled: Boolea sendField.cryptoAmount to sendField.value } val requester = remember { FocusRequester() } + var isEnabledProxy by remember { mutableStateOf(isEnabled) } + + // Fix animation from amount screen to summary screen ([REDACTED_TASK_KEY]) + LaunchedEffect(key1 = isEnabled) { + if (isEnabled) { + delay(timeMillis = 700) + } + isEnabledProxy = isEnabled + } + AmountTextField( value = primaryValue, decimals = primaryAmount.decimals, @@ -53,7 +62,7 @@ internal fun AmountField(sendField: SendTextField.AmountField, isEnabled: Boolea color = TangemTheme.colors.text.primary1, textAlign = TextAlign.Center, ), - isEnabled = isEnabled, + isEnabled = isEnabledProxy, isAutoResize = true, modifier = Modifier .focusRequester(requester) @@ -64,6 +73,7 @@ internal fun AmountField(sendField: SendTextField.AmountField, isEnabled: Boolea ) .requiredHeightIn(min = TangemTheme.dimens.size32), ) + LaunchedEffect(key1 = Unit) { this.coroutineContext.job.invokeOnCompletion { requester.requestFocus()