From 676936e07374ad9af10c4907f0df3eb2960b0bec Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 11 Mar 2024 15:06:39 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../components/inputrow/inner/PasteButton.kt | 10 +++++-- .../ui/fee/SendSpeedAndFeeContent.kt | 27 +------------------ .../presentation/viewmodel/SendViewModel.kt | 24 ++++++++++------- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt index 1d7d0fab95..88ed54192f 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/inputrow/inner/PasteButton.kt @@ -36,7 +36,12 @@ import com.tangem.core.ui.utils.DEFAULT_ANIMATION_DURATION fun PasteButton(isPasteButtonVisible: Boolean, onClick: (String) -> Unit, modifier: Modifier = Modifier) { val clipboardManager = LocalClipboardManager.current val hapticFeedback = LocalHapticFeedback.current - + val isPasteEnabled = !clipboardManager.getText()?.text.isNullOrEmpty() + val color = if (isPasteEnabled) { + TangemTheme.colors.button.primary + } else { + TangemTheme.colors.button.secondary + } AnimatedVisibility( visible = isPasteButtonVisible, label = "Paste Button Visibility Animation", @@ -50,7 +55,7 @@ fun PasteButton(isPasteButtonVisible: Boolean, onClick: (String) -> Unit, modifi color = TangemTheme.colors.text.primary2, modifier = Modifier .background( - color = TangemTheme.colors.button.primary, + color = color, shape = TangemTheme.shapes.roundedCornersXMedium, ) .padding( @@ -60,6 +65,7 @@ fun PasteButton(isPasteButtonVisible: Boolean, onClick: (String) -> Unit, modifi .clickable( interactionSource = remember { MutableInteractionSource() }, indication = rememberRipple(radius = TangemTheme.dimens.radius8), + enabled = isPasteEnabled, onClick = { hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) onClick( diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedAndFeeContent.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedAndFeeContent.kt index 1695763049..444d03e9a6 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedAndFeeContent.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/ui/fee/SendSpeedAndFeeContent.kt @@ -18,7 +18,6 @@ import com.tangem.features.send.impl.presentation.state.fee.FeeSelectorState import com.tangem.features.send.impl.presentation.state.fee.SendFeeNotification import com.tangem.features.send.impl.presentation.viewmodel.SendClickIntents import kotlinx.collections.immutable.ImmutableList -import kotlinx.collections.immutable.toImmutableList private const val FEE_SELECTOR_KEY = "FEE_SELECTOR_KEY" private const val FEE_CUSTOM_KEY = "FEE_CUSTOM_KEY" @@ -37,9 +36,8 @@ internal fun SendSpeedAndFeeContent(state: SendStates.FeeState?, clickIntents: S ), ) { feeSelector(state, clickIntents) - topNotifications(notifications) customFee(feeSendState) - middleNotifications(notifications) + notifications(notifications) } } @@ -56,29 +54,6 @@ private fun LazyListScope.feeSelector(state: SendStates.FeeState, clickIntents: } } -private fun LazyListScope.topNotifications( - configs: ImmutableList, - modifier: Modifier = Modifier, -) { - notifications( - configs = configs.filter { - it is SendFeeNotification.Error.ExceedsBalance || - it is SendFeeNotification.Warning.NetworkFeeUnreachable - }.toImmutableList(), - modifier = modifier, - ) -} - -private fun LazyListScope.middleNotifications( - configs: ImmutableList, - modifier: Modifier = Modifier, -) { - notifications( - configs = configs.filterIsInstance().toImmutableList(), - modifier = modifier, - ) -} - @OptIn(ExperimentalFoundationApi::class) private fun LazyListScope.notifications( configs: ImmutableList, diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt index 1b356af2b9..30b3e00367 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/viewmodel/SendViewModel.kt @@ -1,4 +1,3 @@ - package com.tangem.features.send.impl.presentation.viewmodel import androidx.compose.runtime.getValue @@ -308,15 +307,22 @@ internal class SendViewModel @Inject constructor( coinCryptoCurrencyStatus = coinCurrencyStatus feeCryptoCurrencyStatus = feeCurrencyStatus - if (transactionId != null && amount != null && destinationAddress != null) { - uiState = stateFactory.getReadyState(amount, destinationAddress) - stateRouter.showFee() - } else { - getWalletsAndRecent() - uiState = stateFactory.getReadyState() - stateRouter.showRecipient() + when { + uiState.sendState.isSuccess -> { + stateRouter.showSend() + } + transactionId != null && amount != null && destinationAddress != null -> { + uiState = stateFactory.getReadyState(amount, destinationAddress) + stateRouter.showFee() + updateNotifications() + } + else -> { + getWalletsAndRecent() + uiState = stateFactory.getReadyState() + stateRouter.showRecipient() + updateNotifications() + } } - updateNotifications() } private fun getWalletsAndRecent() {