From 1b6fded61cec261d8b868832211e52307076198a Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 2 Apr 2026 13:38:14 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../state/ExpressTransactionsBlockState.kt | 7 - .../tokendetails/TokenDetailsDialogConfig.kt | 155 ------------------ .../EmptyExpressTransactionsComponent.kt | 1 - ...reviewEmptyExpressTransactionsComponent.kt | 1 - .../tangempay/ui/TangemPayDetailsScreen.kt | 2 - .../tokendetails/TokenDetailsPreviewData.kt | 2 - .../model/ExpressTransactionsModel.kt | 28 +++- .../model/TokenDetailsClickIntents.kt | 2 - .../tokendetails/model/TokenDetailsModel.kt | 107 +++++++++--- .../tokendetails/state/TokenDetailsState.kt | 2 - .../state/factory/ExpressStateFactory.kt | 35 ---- .../TokenDetailsSkeletonStateConverter.kt | 1 - .../state/factory/TokenDetailsStateFactory.kt | 93 ----------- .../ui/TokenDetailsScreenLegacy.kt | 6 - .../ui/components/TokenDetailsDialogs.kt | 35 ---- 15 files changed, 108 insertions(+), 369 deletions(-) delete mode 100644 common/ui/src/main/java/com/tangem/common/ui/tokendetails/TokenDetailsDialogConfig.kt delete mode 100644 features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsDialogs.kt diff --git a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/state/ExpressTransactionsBlockState.kt b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/state/ExpressTransactionsBlockState.kt index bd12e6323b..1d223a1ead 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/expressStatus/state/ExpressTransactionsBlockState.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/expressStatus/state/ExpressTransactionsBlockState.kt @@ -1,7 +1,6 @@ package com.tangem.common.ui.expressStatus.state import androidx.compose.runtime.Composable -import com.tangem.common.ui.tokendetails.TokenDetailsDialogConfig import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import kotlinx.collections.immutable.PersistentList @@ -9,15 +8,9 @@ data class ExpressTransactionsBlockState( val transactions: PersistentList, val transactionsToDisplay: PersistentList, val bottomSheetSlot: BottomSheetSlot?, - val dialogSlot: DialogSlot?, ) data class BottomSheetSlot( val config: TangemBottomSheetConfig, val content: @Composable () -> Unit, -) - -data class DialogSlot( - val config: TokenDetailsDialogConfig, - val content: @Composable () -> Unit, ) \ No newline at end of file diff --git a/common/ui/src/main/java/com/tangem/common/ui/tokendetails/TokenDetailsDialogConfig.kt b/common/ui/src/main/java/com/tangem/common/ui/tokendetails/TokenDetailsDialogConfig.kt deleted file mode 100644 index 8681f259a6..0000000000 --- a/common/ui/src/main/java/com/tangem/common/ui/tokendetails/TokenDetailsDialogConfig.kt +++ /dev/null @@ -1,155 +0,0 @@ -package com.tangem.common.ui.tokendetails - -import com.tangem.core.ui.R -import com.tangem.core.ui.extensions.TextReference -import com.tangem.core.ui.extensions.resourceReference -import com.tangem.core.ui.extensions.wrappedList - -/** - * Wallet bottom sheet config - * - * @property isShow flag that determine if bottom sheet is shown - * @property onDismissRequest lambda be invoked when bottom sheet is dismissed - * @property content content config - */ -data class TokenDetailsDialogConfig( - val isShow: Boolean, - val onDismissRequest: () -> Unit, - val content: DialogContentConfig, -) { - - sealed class DialogContentConfig { - - abstract val title: TextReference? - abstract val message: TextReference - abstract val confirmButtonConfig: ButtonConfig - abstract val cancelButtonConfig: ButtonConfig? - - data class ButtonConfig( - val text: TextReference, - val onClick: () -> Unit, - val hasWarning: Boolean = false, - ) - - data class ConfirmHideConfig( - val currencyTitle: String, - val onConfirmClick: () -> Unit, - val onCancelClick: () -> Unit, - ) : DialogContentConfig() { - override val title: TextReference = TextReference.Res( - id = R.string.token_details_hide_alert_title, - formatArgs = wrappedList(currencyTitle), - ) - - override val message: TextReference = TextReference.Res(R.string.token_details_hide_alert_message) - - override val cancelButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_cancel), - onClick = onCancelClick, - ) - - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.token_details_hide_alert_hide), - onClick = onConfirmClick, - hasWarning = true, - ) - } - - data class HasLinkedTokensConfig( - val currencyName: String, - val currencySymbol: String, - val networkName: String, - val onConfirmClick: () -> Unit, - ) : DialogContentConfig() { - override val title: TextReference = TextReference.Res( - id = R.string.token_details_unable_hide_alert_title, - formatArgs = wrappedList(currencySymbol), - ) - - override val message: TextReference = TextReference.Res( - id = R.string.token_details_unable_hide_alert_message, - formatArgs = wrappedList(currencyName, currencySymbol, networkName), - ) - - override val cancelButtonConfig: ButtonConfig? - get() = null - - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_ok), - onClick = onConfirmClick, - ) - } - - data class DisabledButtonReasonDialogConfig( - val text: TextReference, - val onConfirmClick: () -> Unit, - ) : DialogContentConfig() { - - override val title = null - - override val message: TextReference = text - - override val cancelButtonConfig = null - - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_ok), - onClick = onConfirmClick, - ) - } - - data class RemoveIncompleteTransactionConfirmDialogConfig( - val onConfirmClick: () -> Unit, - val onCancelClick: () -> Unit, - ) : DialogContentConfig() { - override val title = null - - override val message: TextReference = TextReference.Res( - id = R.string.warning_kaspa_unfinished_token_transaction_discard_message, - ) - - override val cancelButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_cancel), - onClick = onCancelClick, - ) - - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_yes), - onClick = onConfirmClick, - ) - } - - data class ErrorDialogConfig( - val text: TextReference, - val onConfirmClick: () -> Unit, - ) : DialogContentConfig() { - - override val title = null - - override val message: TextReference = text - - override val cancelButtonConfig = null - - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = TextReference.Res(R.string.common_ok), - onClick = onConfirmClick, - ) - } - - data class ConfirmExpressStatusHideDialogConfig( - val onConfirmClick: () -> Unit, - val onCancelClick: () -> Unit, - ) : DialogContentConfig() { - override val title: TextReference = resourceReference(R.string.express_status_hide_dialog_title) - override val message: TextReference = resourceReference(R.string.express_status_hide_dialog_text) - override val confirmButtonConfig: ButtonConfig = ButtonConfig( - text = resourceReference(R.string.common_hide), - onClick = onConfirmClick, - ) - - override val cancelButtonConfig: ButtonConfig = ButtonConfig( - text = resourceReference(R.string.common_cancel), - onClick = onCancelClick, - ) - } - } -} \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/EmptyExpressTransactionsComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/EmptyExpressTransactionsComponent.kt index e8eeac64b5..47eccba438 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/EmptyExpressTransactionsComponent.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/EmptyExpressTransactionsComponent.kt @@ -29,7 +29,6 @@ internal class EmptyExpressTransactionsComponent( transactions = persistentListOf(), transactionsToDisplay = persistentListOf(), bottomSheetSlot = null, - dialogSlot = null, ) } } \ No newline at end of file diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/PreviewEmptyExpressTransactionsComponent.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/PreviewEmptyExpressTransactionsComponent.kt index ee4fe81f30..a1d6ba6634 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/PreviewEmptyExpressTransactionsComponent.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/components/express/PreviewEmptyExpressTransactionsComponent.kt @@ -27,7 +27,6 @@ internal class PreviewEmptyExpressTransactionsComponent : ExpressTransactionsCom transactions = persistentListOf(), transactionsToDisplay = persistentListOf(), bottomSheetSlot = null, - dialogSlot = null, ) } } \ No newline at end of file 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 11e52a71c4..1e3a51c9a4 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 @@ -74,7 +74,6 @@ internal fun TangemPayDetailsScreen( val cardDetailsState by cardDetailsBlockComponent.state.collectAsStateWithLifecycle() val expressState by expressTransactionsComponent.state.collectAsStateWithLifecycle() val expressTransactionsBottomSheetState = expressState.bottomSheetSlot - val expressTransactionsDialogState = expressState.dialogSlot TangemPullToRefreshContainer( config = state.pullToRefreshConfig, @@ -158,7 +157,6 @@ internal fun TangemPayDetailsScreen( with(txHistoryComponent) { txHistoryContent(listState = listState, state = txHistoryState) } } } - expressTransactionsDialogState?.content() expressTransactionsBottomSheetState?.content() } } diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt index fa2e9d6908..e7ada8cb1c 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/TokenDetailsPreviewData.kt @@ -169,7 +169,6 @@ internal object TokenDetailsPreviewData { marketPriceBlockState = marketPriceLoading, stakingBlocksState = stakingLoadingBlock, notifications = persistentListOf(), - dialogConfig = null, expressTxs = persistentListOf(), expressTxsToDisplay = persistentListOf(), pullToRefreshConfig = pullToRefreshConfig, @@ -194,7 +193,6 @@ internal object TokenDetailsPreviewData { ), stakingBlocksState = stakingAvailableBlock, notifications = persistentListOf(), - dialogConfig = null, expressTxs = persistentListOf(), expressTxsToDisplay = persistentListOf(), pullToRefreshConfig = pullToRefreshConfig, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/ExpressTransactionsModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/ExpressTransactionsModel.kt index bd24cb6cc5..bdeb591c42 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/ExpressTransactionsModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/ExpressTransactionsModel.kt @@ -5,9 +5,15 @@ import arrow.core.getOrElse import com.tangem.common.ui.expressStatus.ExpressStatusBottomSheetConfig import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM import com.tangem.common.ui.expressStatus.state.ExpressTransactionsBlockState +import com.tangem.core.decompose.di.GlobalUiMessageSender import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.decompose.model.Model import com.tangem.core.decompose.model.ParamsContainer +import com.tangem.core.decompose.ui.UiMessageSender +import com.tangem.core.ui.extensions.resourceReference +import com.tangem.core.ui.message.DialogMessage +import com.tangem.core.ui.message.EventMessageAction +import com.tangem.features.tokendetails.impl.R import com.tangem.domain.account.status.usecase.GetAccountCurrencyStatusUseCase import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.model.AppCurrency @@ -36,6 +42,7 @@ import kotlin.coroutines.cancellation.CancellationException @ModelScoped internal class ExpressTransactionsModel @Inject constructor( override val dispatchers: CoroutineDispatcherProvider, + @GlobalUiMessageSender private val uiMessageSender: UiMessageSender, paramsContainer: ParamsContainer, expressStatusFactory: ExpressStatusFactory.Factory, getUserWalletUseCase: GetUserWalletUseCase, @@ -66,7 +73,6 @@ internal class ExpressTransactionsModel @Inject constructor( private val stateFactory by lazy(mode = LazyThreadSafetyMode.NONE) { ExpressStateFactory( currentStateProvider = currentStateProvider, - expressTransactionsClickIntents = this, ) } @@ -109,7 +115,21 @@ internal class ExpressTransactionsModel @Inject constructor( } override fun onConfirmDisposeExpressStatus() { - internalUiState.value = stateFactory.getStateWithConfirmHideExpressStatus() + uiMessageSender.send( + DialogMessage( + title = resourceReference(R.string.express_status_hide_dialog_title), + message = resourceReference(R.string.express_status_hide_dialog_text), + firstActionBuilder = { + EventMessageAction( + title = resourceReference(R.string.common_hide), + onClick = { + onDisposeExpressStatus() + }, + ) + }, + secondActionBuilder = { cancelAction() }, + ), + ) } override fun onDisposeExpressStatus() { @@ -136,10 +156,6 @@ internal class ExpressTransactionsModel @Inject constructor( internalUiState.value = stateFactory.getStateWithClosedBottomSheet() } - override fun onDismissDialog() { - internalUiState.value = stateFactory.getStateWithClosedDialog() - } - override fun onDestroy() { clear() super.onDestroy() diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsClickIntents.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsClickIntents.kt index bc6d1d4b7e..af6e80b86e 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsClickIntents.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsClickIntents.kt @@ -101,8 +101,6 @@ interface ExpressTransactionsClickIntents { fun onDisposeExpressStatus() fun onDismissBottomSheet() - - fun onDismissDialog() } @Suppress("TooManyFunctions") diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsModel.kt index 1adbb5051c..1aec75edd1 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/model/TokenDetailsModel.kt @@ -26,6 +26,7 @@ import com.tangem.core.decompose.model.Model import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.decompose.ui.UiMessageSender import com.tangem.core.navigation.url.UrlOpener +import com.tangem.common.ui.tokens.getUnavailabilityReasonText import com.tangem.core.ui.clipboard.ClipboardManager import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig import com.tangem.core.ui.components.currency.icon.CurrencyIconState @@ -36,6 +37,8 @@ import com.tangem.core.ui.extensions.stringReference import com.tangem.core.ui.extensions.wrappedList import com.tangem.core.ui.haptic.TangemHapticEffect import com.tangem.core.ui.haptic.VibratorHapticManager +import com.tangem.core.ui.message.DialogMessage +import com.tangem.core.ui.message.EventMessageAction import com.tangem.core.ui.message.SnackbarMessage import com.tangem.domain.account.status.usecase.GetAccountCurrencyStatusUseCase import com.tangem.domain.account.status.usecase.IsCryptoCurrencyCouldHideUseCase @@ -739,10 +742,6 @@ internal class TokenDetailsModel @Inject constructor( } } - override fun onDismissDialog() { - internalUiState.value = stateFactory.getStateWithClosedDialog() - } - override fun onHideClick() { analyticsEventsHandler.send(TokenScreenAnalyticsEvent.ButtonRemoveToken(cryptoCurrency.symbol)) @@ -752,10 +751,10 @@ internal class TokenDetailsModel @Inject constructor( cryptoCurrency = cryptoCurrency, ) - internalUiState.value = if (canHide) { - stateFactory.getStateWithConfirmHideTokenDialog(cryptoCurrency) + if (canHide) { + showConfirmHideTokenDialog(cryptoCurrency) } else { - stateFactory.getStateWithLinkedTokensDialog(cryptoCurrency) + showLinkedTokensDialog(cryptoCurrency) } } } @@ -968,7 +967,7 @@ internal class TokenDetailsModel @Inject constructor( } } if (message != null) { - internalUiState.value = stateFactory.getStateWithErrorDialog(stringReference(message)) + showErrorDialog(stringReference(message)) TangemLogger.e(message) } }, @@ -1012,7 +1011,7 @@ internal class TokenDetailsModel @Inject constructor( } if (message != null) { - internalUiState.value = stateFactory.getStateWithErrorDialog(message) + showErrorDialog(message) } }, ifRight = { internalUiState.value = stateFactory.getStateWithRemovedRequiredTrustlineNotification() }, @@ -1027,9 +1026,7 @@ internal class TokenDetailsModel @Inject constructor( blockchain = cryptoCurrency.network.name, ), ) - modelScope.launch { - internalUiState.value = stateFactory.getStateWithDismissIncompleteTransactionConfirmDialog() - } + showDismissIncompleteTransactionConfirmDialog() } override fun onConfirmDismissIncompleteTransactionClick() { @@ -1039,9 +1036,7 @@ internal class TokenDetailsModel @Inject constructor( currency = cryptoCurrency, ).fold( ifLeft = { e -> - internalUiState.value = stateFactory.getStateWithErrorDialog( - stringReference(e.message.orEmpty()), - ) + showErrorDialog(stringReference(e.message.orEmpty())) TangemLogger.e("Error: $e") }, ifRight = { @@ -1066,7 +1061,7 @@ internal class TokenDetailsModel @Inject constructor( ifLeft = { e -> when (e) { is AssociateAssetError.NotEnoughBalance -> { - internalUiState.value = stateFactory.getStateWithErrorDialog( + showErrorDialog( resourceReference( id = R.string.warning_hedera_token_association_not_enough_hbar_message, formatArgs = wrappedList(e.feeCurrency.symbol), @@ -1074,9 +1069,7 @@ internal class TokenDetailsModel @Inject constructor( ) } is AssociateAssetError.DataError -> { - internalUiState.value = stateFactory.getStateWithErrorDialog( - stringReference(e.message.orEmpty()), - ) + showErrorDialog(stringReference(e.message.orEmpty())) TangemLogger.e("Error: $e") } } @@ -1091,7 +1084,7 @@ internal class TokenDetailsModel @Inject constructor( } override fun onConfirmDisposeExpressStatus() { - internalUiState.value = stateFactory.getStateWithConfirmHideExpressStatus() + showConfirmHideExpressStatusDialog() } override fun onDisposeExpressStatus() { @@ -1125,7 +1118,7 @@ internal class TokenDetailsModel @Inject constructor( private fun handleUnavailabilityReason(unavailabilityReason: ScenarioUnavailabilityReason): Boolean { if (unavailabilityReason == ScenarioUnavailabilityReason.None) return false - internalUiState.value = stateFactory.getStateWithActionButtonErrorDialog(unavailabilityReason) + showErrorDialog(unavailabilityReason.getUnavailabilityReasonText()) return true } @@ -1154,6 +1147,78 @@ internal class TokenDetailsModel @Inject constructor( uiMessageSender.send(SnackbarMessage(resourceReference(R.string.staking_error_no_validators_title))) } + private fun showConfirmHideTokenDialog(currency: CryptoCurrency) { + uiMessageSender.send( + DialogMessage( + title = resourceReference( + id = R.string.token_details_hide_alert_title, + formatArgs = wrappedList(currency.name), + ), + message = resourceReference(R.string.token_details_hide_alert_message), + firstActionBuilder = { + EventMessageAction( + title = resourceReference(R.string.token_details_hide_alert_hide), + isWarning = true, + onClick = ::onHideConfirmed, + ) + }, + secondActionBuilder = { cancelAction() }, + ), + ) + } + + private fun showLinkedTokensDialog(currency: CryptoCurrency) { + uiMessageSender.send( + DialogMessage( + title = resourceReference( + id = R.string.token_details_unable_hide_alert_title, + formatArgs = wrappedList(currency.symbol), + ), + message = resourceReference( + id = R.string.token_details_unable_hide_alert_message, + formatArgs = wrappedList(currency.name, currency.symbol, currency.network.name), + ), + ), + ) + } + + private fun showDismissIncompleteTransactionConfirmDialog() { + uiMessageSender.send( + DialogMessage( + message = resourceReference(R.string.warning_kaspa_unfinished_token_transaction_discard_message), + firstActionBuilder = { + EventMessageAction( + title = resourceReference(R.string.common_yes), + onClick = ::onConfirmDismissIncompleteTransactionClick, + ) + }, + secondActionBuilder = { cancelAction() }, + ), + ) + } + + private fun showConfirmHideExpressStatusDialog() { + uiMessageSender.send( + DialogMessage( + title = resourceReference(R.string.express_status_hide_dialog_title), + message = resourceReference(R.string.express_status_hide_dialog_text), + firstActionBuilder = { + EventMessageAction( + title = resourceReference(R.string.common_hide), + onClick = { + onDisposeExpressStatus() + }, + ) + }, + secondActionBuilder = { cancelAction() }, + ), + ) + } + + private fun showErrorDialog(text: TextReference) { + uiMessageSender.send(DialogMessage(message = text)) + } + private fun checkForActionUpdates() { combine( tokenDetailsDeepLinkActionListener.tokenDetailsActionFlow, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt index 8fc3962fe6..721e190ecc 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/TokenDetailsState.kt @@ -1,7 +1,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state import com.tangem.common.ui.expressStatus.state.ExpressTransactionStateUM -import com.tangem.common.ui.tokendetails.TokenDetailsDialogConfig import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.containers.pullToRefresh.PullToRefreshConfig import com.tangem.core.ui.components.marketprice.MarketPriceBlockState @@ -18,7 +17,6 @@ internal data class TokenDetailsState( val notifications: ImmutableList, val expressTxsToDisplay: PersistentList, val expressTxs: PersistentList, - val dialogConfig: TokenDetailsDialogConfig?, val pullToRefreshConfig: PullToRefreshConfig, val bottomSheetConfig: TangemBottomSheetConfig?, val isBalanceHidden: Boolean, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/ExpressStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/ExpressStateFactory.kt index 950bd50f41..c3b8678b1a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/ExpressStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/ExpressStateFactory.kt @@ -1,17 +1,11 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory -import androidx.compose.runtime.Composable -import com.tangem.common.ui.expressStatus.state.DialogSlot import com.tangem.common.ui.expressStatus.state.ExpressTransactionsBlockState -import com.tangem.common.ui.tokendetails.TokenDetailsDialogConfig -import com.tangem.feature.tokendetails.presentation.tokendetails.model.ExpressTransactionsClickIntents -import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.TokenDetailsDialogs import com.tangem.utils.Provider import kotlinx.collections.immutable.persistentListOf internal class ExpressStateFactory( private val currentStateProvider: Provider, - private val expressTransactionsClickIntents: ExpressTransactionsClickIntents, ) { fun getInitialState(): ExpressTransactionsBlockState { @@ -19,40 +13,11 @@ internal class ExpressStateFactory( transactions = persistentListOf(), transactionsToDisplay = persistentListOf(), bottomSheetSlot = null, - dialogSlot = null, ) } - fun getStateWithClosedDialog(): ExpressTransactionsBlockState { - val state = currentStateProvider() - return state.copy(dialogSlot = null) - } - fun getStateWithClosedBottomSheet(): ExpressTransactionsBlockState { val state = currentStateProvider() return state.copy(bottomSheetSlot = null) } - - fun getStateWithConfirmHideExpressStatus(): ExpressTransactionsBlockState { - return currentStateProvider().copy( - dialogSlot = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.ConfirmExpressStatusHideDialogConfig( - onConfirmClick = { - expressTransactionsClickIntents.onDisposeExpressStatus() - expressTransactionsClickIntents.onDismissDialog() - }, - onCancelClick = expressTransactionsClickIntents::onDismissDialog, - ), - ).toDialogSlot(), - ) - } - - private fun TokenDetailsDialogConfig.toDialogSlot(): DialogSlot { - val contentLambda: @Composable () -> Unit = { - TokenDetailsDialogs(this) - } - return DialogSlot(config = this, content = contentLambda) - } } \ No newline at end of file diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt index 5580bcc639..649b2b064a 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsSkeletonStateConverter.kt @@ -65,7 +65,6 @@ internal class TokenDetailsSkeletonStateConverter( notifications = persistentListOf(), expressTxs = persistentListOf(), expressTxsToDisplay = persistentListOf(), - dialogConfig = null, pullToRefreshConfig = createPullToRefresh(), bottomSheetConfig = null, isBalanceHidden = true, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt index aa14a1aa20..fe79d03388 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsStateFactory.kt @@ -2,8 +2,6 @@ package com.tangem.feature.tokendetails.presentation.tokendetails.state.factory import arrow.core.Either import com.tangem.common.ui.bottomsheet.chooseaddress.ChooseAddressBottomSheetConfig -import com.tangem.common.ui.tokendetails.TokenDetailsDialogConfig -import com.tangem.common.ui.tokens.getUnavailabilityReasonText import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.dropdownmenu.TangemDropdownMenuItem import com.tangem.core.ui.extensions.TextReference @@ -20,7 +18,6 @@ import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.staking.model.StakingAvailability import com.tangem.domain.staking.model.StakingEntryInfo import com.tangem.domain.tokens.error.CurrencyStatusError -import com.tangem.domain.tokens.model.ScenarioUnavailabilityReason import com.tangem.domain.tokens.model.TokenActionsState import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.wallets.usecase.GetUserWalletUseCase @@ -124,79 +121,6 @@ internal class TokenDetailsStateFactory( return tokenDetailsButtonsConverter.convert(actions) } - fun getStateWithClosedDialog(): TokenDetailsState { - val state = currentStateProvider() - return state.copy(dialogConfig = state.dialogConfig?.copy(isShow = false)) - } - - fun getStateWithConfirmHideTokenDialog(currency: CryptoCurrency): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.ConfirmHideConfig( - currencyTitle = currency.name, - onConfirmClick = tokenDetailsClickIntents::onHideConfirmed, - onCancelClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - - fun getStateWithLinkedTokensDialog(currency: CryptoCurrency): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.HasLinkedTokensConfig( - currencyName = currency.name, - currencySymbol = currency.symbol, - networkName = currency.network.name, - onConfirmClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - - fun getStateWithDismissIncompleteTransactionConfirmDialog(): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.RemoveIncompleteTransactionConfirmDialogConfig( - onConfirmClick = tokenDetailsClickIntents::onConfirmDismissIncompleteTransactionClick, - onCancelClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - - fun getStateWithActionButtonErrorDialog(unavailabilityReason: ScenarioUnavailabilityReason): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.DisabledButtonReasonDialogConfig( - text = unavailabilityReason.getUnavailabilityReasonText(), - onConfirmClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - - fun getStateWithErrorDialog(text: TextReference): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.ErrorDialogConfig( - text = text, - onConfirmClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - fun getRefreshingState(): TokenDetailsState { return refreshStateConverter.convert(true) } @@ -259,7 +183,6 @@ internal class TokenDetailsStateFactory( val state = currentStateProvider() return state.copy( notifications = notificationConverter.removeKaspaIncompleteTransactionWarning(state), - dialogConfig = state.dialogConfig?.copy(isShow = false), ) } @@ -302,22 +225,6 @@ internal class TokenDetailsStateFactory( ) } - fun getStateWithConfirmHideExpressStatus(): TokenDetailsState { - return currentStateProvider().copy( - dialogConfig = TokenDetailsDialogConfig( - isShow = true, - onDismissRequest = expressTransactionsClickIntents::onDismissDialog, - content = TokenDetailsDialogConfig.DialogContentConfig.ConfirmExpressStatusHideDialogConfig( - onConfirmClick = { - expressTransactionsClickIntents.onDisposeExpressStatus() - expressTransactionsClickIntents.onDismissDialog() - }, - onCancelClick = expressTransactionsClickIntents::onDismissDialog, - ), - ), - ) - } - private fun TokenDetailsAppBarMenuConfig.updateMenu( userWallet: UserWallet, hasDerivations: Boolean, diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreenLegacy.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreenLegacy.kt index da6b9c913b..cecd5b8b08 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreenLegacy.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/TokenDetailsScreenLegacy.kt @@ -30,7 +30,6 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.StakingBl import com.tangem.feature.tokendetails.presentation.tokendetails.state.TokenDetailsState import com.tangem.feature.tokendetails.presentation.tokendetails.state.components.TokenDetailsNotification import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.TokenDetailsBalanceBlockLegacy -import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.TokenDetailsDialogs import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.TokenDetailsTopAppBar import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.TokenInfoBlock import com.tangem.feature.tokendetails.presentation.tokendetails.ui.components.clore.CloreMigrationBottomSheet @@ -62,7 +61,6 @@ internal fun TokenDetailsScreenLegacy( ) { scaffoldPaddings -> val listState = rememberLazyListState() val txHistoryComponentState by txHistoryComponent.txHistoryState.collectAsStateWithLifecycle() - val dialogConfig = state.dialogConfig val betweenItemsPadding = TangemTheme.dimens.spacing12 val horizontalPadding = TangemTheme.dimens.spacing16 val itemModifier = Modifier @@ -161,10 +159,6 @@ internal fun TokenDetailsScreenLegacy( } } - if (dialogConfig != null) { - TokenDetailsDialogs(dialogConfig = dialogConfig) - } - state.bottomSheetConfig?.let { config -> when (config.content) { is ChooseAddressBottomSheetConfig -> { diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsDialogs.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsDialogs.kt deleted file mode 100644 index 5428e5d949..0000000000 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/ui/components/TokenDetailsDialogs.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.tangem.feature.tokendetails.presentation.tokendetails.ui.components - -import androidx.compose.runtime.Composable -import com.tangem.common.ui.tokendetails.TokenDetailsDialogConfig -import com.tangem.core.ui.components.BasicDialog -import com.tangem.core.ui.components.DialogButtonUM -import com.tangem.core.ui.extensions.resolveReference - -@Composable -internal fun TokenDetailsDialogs(dialogConfig: TokenDetailsDialogConfig) { - if (dialogConfig.isShow) { - TokenDetailsDialog(config = dialogConfig) - } -} - -@Composable -private fun TokenDetailsDialog(config: TokenDetailsDialogConfig) { - BasicDialog( - message = config.content.message.resolveReference(), - confirmButton = DialogButtonUM( - title = config.content.confirmButtonConfig.text.resolveReference(), - isWarning = config.content.confirmButtonConfig.hasWarning, - onClick = config.content.confirmButtonConfig.onClick, - ), - onDismissDialog = config.onDismissRequest, - title = config.content.title?.resolveReference(), - dismissButton = config.content.cancelButtonConfig?.let { cancelButtonConfig -> - DialogButtonUM( - title = cancelButtonConfig.text.resolveReference(), - isWarning = cancelButtonConfig.hasWarning, - onClick = cancelButtonConfig.onClick, - ) - }, - ) -} \ No newline at end of file