From e881eaa3deb898699b1b5ca52c0a26583af46e0d Mon Sep 17 00:00:00 2001 From: Tangem Date: Sun, 22 Oct 2023 09:55:02 +0800 Subject: [PATCH] Updated on 2026-08-14 --- .../bottomsheets/TangemBottomSheet.kt | 47 ++++++++++++++----- .../TangemBottomSheetConfigContent.kt | 3 ++ .../chooseaddress/ChooseAddressBottomSheet.kt | 8 +--- .../ChooseAddressBottomSheetConfig.kt | 3 +- .../tokenreceive/TokenReceiveBottomSheet.kt | 8 +--- .../state/factory/TokenDetailsStateFactory.kt | 15 +++--- .../presentation/common/WalletPreviewData.kt | 3 -- .../wallet/state/ActionsBottomSheetConfig.kt | 10 ++-- .../wallet/state/WalletMultiCurrencyState.kt | 1 - .../factory/WalletSkeletonStateConverter.kt | 1 - .../state/factory/WalletStateFactory.kt | 13 ++--- .../factory/WalletsUnlockStateConverter.kt | 1 - .../presentation/wallet/ui/WalletScreen.kt | 22 ++------- .../ui/components/TokenActionsBottomSheet.kt | 22 +++------ .../ui/components/common/WalletBottomSheet.kt | 6 +-- .../wallet/viewmodels/WalletClickIntents.kt | 2 - .../wallet/viewmodels/WalletViewModel.kt | 20 ++------ 17 files changed, 75 insertions(+), 110 deletions(-) diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheet.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheet.kt index b8b5086187..2d9d85b164 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheet.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheet.kt @@ -3,29 +3,52 @@ package com.tangem.core.ui.components.bottomsheets import androidx.compose.foundation.layout.ColumnScope import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ModalBottomSheet +import androidx.compose.material3.SheetState import androidx.compose.material3.rememberModalBottomSheetState -import androidx.compose.runtime.Composable +import androidx.compose.runtime.* import com.tangem.core.ui.res.TangemTheme +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch /** * Tangem bottom sheet with custom draggable header and config * - * @param config data model containing logic and ui models + * @param config data model containing logic and ui models * @param content custom bottom sheet content */ @OptIn(ExperimentalMaterial3Api::class) @Composable -fun TangemBottomSheet( +inline fun TangemBottomSheet( config: TangemBottomSheetConfig, - content: @Composable ColumnScope.(TangemBottomSheetConfigContent) -> Unit, + crossinline content: @Composable ColumnScope.(T) -> Unit, ) { - ModalBottomSheet( - onDismissRequest = config.onDismissRequest, - sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), - containerColor = TangemTheme.colors.background.primary, - shape = TangemTheme.shapes.bottomSheetLarge, - dragHandle = { TangemBottomSheetDraggableHeader() }, - ) { - content(config.content) + var isVisible by remember { mutableStateOf(value = config.isShow) } + + val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) + if (isVisible && config.content is T) { + ModalBottomSheet( + onDismissRequest = config.onDismissRequest, + sheetState = sheetState, + containerColor = TangemTheme.colors.background.primary, + shape = TangemTheme.shapes.bottomSheetLarge, + dragHandle = { TangemBottomSheetDraggableHeader() }, + ) { + content(config.content) + } + } + + LaunchedEffect(key1 = config.isShow) { + if (config.isShow) { + isVisible = true + } else { + sheetState.collapse { isVisible = false } + } + } +} + +@OptIn(ExperimentalMaterial3Api::class) +suspend fun SheetState.collapse(onCollapsed: () -> Unit) { + coroutineScope { + launch { hide() }.invokeOnCompletion { onCollapsed() } } } \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfigContent.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfigContent.kt index 812d593533..409e1430d0 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfigContent.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfigContent.kt @@ -1,6 +1,9 @@ package com.tangem.core.ui.components.bottomsheets +import androidx.compose.runtime.Immutable + /** * General interface for bottom sheet config model */ +@Immutable interface TangemBottomSheetConfigContent \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheet.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheet.kt index 5b41ed7fe6..4bec68b142 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheet.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheet.kt @@ -12,12 +12,8 @@ import com.tangem.core.ui.res.TangemTheme @Composable fun ChooseAddressBottomSheet(config: TangemBottomSheetConfig) { - if (config.content is ChooseAddressBottomSheetConfig && config.isShow) { - TangemBottomSheet(config) { content -> - ChooseAddressBottomSheetContent( - content = content as ChooseAddressBottomSheetConfig, - ) - } + TangemBottomSheet(config) { content: ChooseAddressBottomSheetConfig -> + ChooseAddressBottomSheetContent(content = content) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheetConfig.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheetConfig.kt index 27984d9852..2bbbe6c79e 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheetConfig.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/chooseaddress/ChooseAddressBottomSheetConfig.kt @@ -2,8 +2,9 @@ package com.tangem.core.ui.components.bottomsheets.chooseaddress import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent import com.tangem.core.ui.components.bottomsheets.tokenreceive.AddressModel +import kotlinx.collections.immutable.ImmutableList class ChooseAddressBottomSheetConfig( - val addressModels: List, + val addressModels: ImmutableList, val onClick: (AddressModel) -> Unit, ) : TangemBottomSheetConfigContent \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/tokenreceive/TokenReceiveBottomSheet.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/tokenreceive/TokenReceiveBottomSheet.kt index 15f594db35..0555bfe0e1 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/tokenreceive/TokenReceiveBottomSheet.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/tokenreceive/TokenReceiveBottomSheet.kt @@ -33,12 +33,8 @@ import com.tangem.core.ui.res.TangemTheme @Composable fun TokenReceiveBottomSheet(config: TangemBottomSheetConfig) { - if (config.content is TokenReceiveBottomSheetConfig && config.isShow) { - TangemBottomSheet(config) { content -> - TokenReceiveBottomSheetContent( - content = content as TokenReceiveBottomSheetConfig, - ) - } + TangemBottomSheet(config) { content: TokenReceiveBottomSheetConfig -> + TokenReceiveBottomSheetContent(content = content) } } 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 dd73a40465..3c0f5ba562 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 @@ -23,6 +23,7 @@ import com.tangem.feature.tokendetails.presentation.tokendetails.state.component import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsLoadedTxHistoryConverter import com.tangem.feature.tokendetails.presentation.tokendetails.state.factory.txhistory.TokenDetailsLoadingTxHistoryConverter import com.tangem.feature.tokendetails.presentation.tokendetails.viewmodels.TokenDetailsClickIntents +import kotlinx.collections.immutable.toImmutableList import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow @@ -188,12 +189,14 @@ internal class TokenDetailsStateFactory( isShow = true, onDismissRequest = clickIntents::onDismissBottomSheet, content = ChooseAddressBottomSheetConfig( - addressModels = addresses.map { - AddressModel( - value = it.value, - type = AddressModel.Type.valueOf(it.type.name), - ) - }, + addressModels = addresses + .map { address -> + AddressModel( + value = address.value, + type = AddressModel.Type.valueOf(address.type.name), + ) + } + .toImmutableList(), onClick = clickIntents::onAddressTypeSelected, ), ), diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index 4506069426..69902f587b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -308,8 +308,6 @@ internal object WalletPreviewData { } val actionsBottomSheet = ActionsBottomSheetConfig( - isShow = true, - onDismissRequest = {}, actions = listOf( TokenActionButtonConfig( text = TextReference.Str("Send"), @@ -386,7 +384,6 @@ internal object WalletPreviewData { WalletNotification.Warning.NetworksUnreachable, ), bottomSheetConfig = bottomSheet, - tokenActionsBottomSheet = actionsBottomSheet, onManageTokensClick = {}, event = consumedEvent(), isBalanceHidden = false, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/ActionsBottomSheetConfig.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/ActionsBottomSheetConfig.kt index cb7e79cee3..42cf37464b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/ActionsBottomSheetConfig.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/ActionsBottomSheetConfig.kt @@ -1,17 +1,13 @@ package com.tangem.feature.wallet.presentation.wallet.state +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent import kotlinx.collections.immutable.ImmutableList /** * Config for the token actions bottom sheet * - * @property isShow flag that determine if bottom sheet is shown - * @property onDismissRequest lambda be invoked when bottom sheet is dismissed - * @property actions actions - * + * @property actions actions */ internal data class ActionsBottomSheetConfig( - val isShow: Boolean, - val onDismissRequest: () -> Unit, val actions: ImmutableList, -) \ No newline at end of file +) : TangemBottomSheetConfigContent \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt index 1e8fcbcc9e..109b58c2b2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/WalletMultiCurrencyState.kt @@ -28,7 +28,6 @@ internal sealed class WalletMultiCurrencyState : WalletState.ContentState() { override val event: StateEvent = consumedEvent(), override val isBalanceHidden: Boolean, val isManageTokensAvailable: Boolean = true, - val tokenActionsBottomSheet: ActionsBottomSheetConfig?, val onManageTokensClick: () -> Unit, ) : WalletMultiCurrencyState() diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt index ead7b287fc..974d4c6aad 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletSkeletonStateConverter.kt @@ -56,7 +56,6 @@ internal class WalletSkeletonStateConverter( tokensListState = WalletTokensListState.Loading(), notifications = persistentListOf(), bottomSheetConfig = null, - tokenActionsBottomSheet = null, onManageTokensClick = clickIntents::onManageTokensClick, isBalanceHidden = isBalanceHiddenProvider(), ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt index bcf2170eef..f06c6dd7f3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletStateFactory.kt @@ -220,16 +220,9 @@ internal class WalletStateFactory( } fun getStateWithTokenActionBottomSheet(tokenActions: TokenActionsState): WalletState { - return when (val state = currentStateProvider() as WalletState.ContentState) { - is WalletMultiCurrencyState.Content -> state.copy( - tokenActionsBottomSheet = ActionsBottomSheetConfig( - isShow = true, - actions = tokenActionsProvider.provideActions(tokenActions), - onDismissRequest = clickIntents::onDismissActionsBottomSheet, - ), - ) - else -> state - } + return getStateWithOpenWalletBottomSheet( + content = ActionsBottomSheetConfig(actions = tokenActionsProvider.provideActions(tokenActions)), + ) } fun getLoadingTxHistoryState(itemsCountEither: Either): WalletState { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt index b1488f51a6..b6bbef70d2 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/WalletsUnlockStateConverter.kt @@ -52,7 +52,6 @@ internal class WalletsUnlockStateConverter( tokensListState = WalletTokensListState.Loading(), notifications = persistentListOf(), bottomSheetConfig = null, - tokenActionsBottomSheet = null, onManageTokensClick = clickIntents::onManageTokensClick, isBalanceHidden = isBalanceHidden, ) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt index 0ab69639d0..f2720ee831 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/WalletScreen.kt @@ -28,10 +28,7 @@ import com.tangem.core.ui.components.transactions.state.TxHistoryState import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.impl.R import com.tangem.feature.wallet.presentation.common.WalletPreviewData -import com.tangem.feature.wallet.presentation.wallet.state.WalletAlertState -import com.tangem.feature.wallet.presentation.wallet.state.WalletMultiCurrencyState -import com.tangem.feature.wallet.presentation.wallet.state.WalletSingleCurrencyState -import com.tangem.feature.wallet.presentation.wallet.state.WalletState +import com.tangem.feature.wallet.presentation.wallet.state.* import com.tangem.feature.wallet.presentation.wallet.state.components.WalletBottomSheetConfig import com.tangem.feature.wallet.presentation.wallet.state.components.WalletPullToRefreshConfig import com.tangem.feature.wallet.presentation.wallet.state.components.WalletTokensListState @@ -242,20 +239,11 @@ private fun ManageTokensButton(onManageTokensClick: () -> Unit) { @Composable private fun WalletBottomSheets(state: WalletState) { val bottomSheetConfig = (state as? WalletState.ContentState)?.bottomSheetConfig - if (bottomSheetConfig != null && bottomSheetConfig.isShow) { + if (bottomSheetConfig != null) { when (bottomSheetConfig.content) { - is WalletBottomSheetConfig -> { - WalletBottomSheet(config = bottomSheetConfig) - } - is TokenReceiveBottomSheetConfig -> { - TokenReceiveBottomSheet(config = bottomSheetConfig) - } - } - } - - (state as? WalletMultiCurrencyState.Content)?.let { multiCurrencyState -> - if (multiCurrencyState.tokenActionsBottomSheet != null && multiCurrencyState.tokenActionsBottomSheet.isShow) { - TokenActionsBottomSheet(config = multiCurrencyState.tokenActionsBottomSheet) + is WalletBottomSheetConfig -> WalletBottomSheet(config = bottomSheetConfig) + is TokenReceiveBottomSheetConfig -> TokenReceiveBottomSheet(config = bottomSheetConfig) + is ActionsBottomSheetConfig -> TokenActionsBottomSheet(config = bottomSheetConfig) } } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt index bf7208a505..c729131842 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt @@ -2,16 +2,14 @@ package com.tangem.feature.wallet.presentation.wallet.ui.components import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column -import androidx.compose.material3.BottomSheetDefaults -import androidx.compose.material3.ExperimentalMaterial3Api -import androidx.compose.material3.ModalBottomSheet -import androidx.compose.material3.rememberModalBottomSheetState import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import com.tangem.core.ui.components.SimpleSettingsRow +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet +import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.presentation.common.WalletPreviewData @@ -19,24 +17,16 @@ import com.tangem.feature.wallet.presentation.wallet.state.ActionsBottomSheetCon import com.tangem.feature.wallet.presentation.wallet.state.TokenActionButtonConfig import kotlinx.collections.immutable.ImmutableList -@OptIn(ExperimentalMaterial3Api::class) @Composable -internal fun TokenActionsBottomSheet(config: ActionsBottomSheetConfig) { - ModalBottomSheet( - onDismissRequest = config.onDismissRequest, - sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true), - containerColor = TangemTheme.colors.background.primary, - dragHandle = { BottomSheetDefaults.DragHandle() }, - ) { - ActionsBottomSheetContent(config.actions) +internal fun TokenActionsBottomSheet(config: TangemBottomSheetConfig) { + TangemBottomSheet(config = config) { + ActionsBottomSheetContent(actions = it.actions) } } @Composable private fun ActionsBottomSheetContent(actions: ImmutableList) { - Column( - modifier = Modifier.background(TangemTheme.colors.background.primary), - ) { + Column(modifier = Modifier.background(TangemTheme.colors.background.primary)) { actions.forEach { action -> if (action.enabled) { SimpleSettingsRow( diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBottomSheet.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBottomSheet.kt index a5e778dce6..b77393f8d6 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBottomSheet.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/common/WalletBottomSheet.kt @@ -30,10 +30,8 @@ import com.tangem.feature.wallet.presentation.wallet.state.components.WalletBott */ @Composable internal fun WalletBottomSheet(config: TangemBottomSheetConfig) { - TangemBottomSheet(config) { content -> - BottomSheetContent( - config = content as WalletBottomSheetConfig, - ) + TangemBottomSheet(config) { content: WalletBottomSheetConfig -> + BottomSheetContent(config = content) } } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt index 193377047c..5c390dcb0b 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletClickIntents.kt @@ -41,8 +41,6 @@ internal interface WalletClickIntents { fun onTokenItemLongClick(cryptoCurrencyStatus: CryptoCurrencyStatus) - fun onDismissActionsBottomSheet() - fun onRenameClick(userWalletId: UserWalletId, name: String) fun onDeleteBeforeConfirmationClick(userWalletId: UserWalletId) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 9cf23e5a0e..b53e790e88 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -907,12 +907,8 @@ internal class WalletViewModel @Inject constructor( viewModelScope.launch(dispatchers.io) { removeCurrencyUseCase(userWallet.walletId, cryptoCurrencyStatus.currency) .fold( - ifLeft = { - showSnackbar(resourceReference(R.string.common_error)) - }, - ifRight = { - onDismissActionsBottomSheet() - }, + ifLeft = { showToast(resourceReference(R.string.common_error)) }, + ifRight = { uiState = stateFactory.getStateWithClosedBottomSheet() }, ) } } @@ -937,16 +933,6 @@ internal class WalletViewModel @Inject constructor( uiState = stateFactory.getStateWithClosedBottomSheet() } - override fun onDismissActionsBottomSheet() { - (uiState as? WalletMultiCurrencyState.Content)?.let { state -> - uiState = state.copy( - tokenActionsBottomSheet = state.tokenActionsBottomSheet?.copy( - isShow = false, - ), - ) - } - } - override fun onTransactionClick(txHash: String) { viewModelScope.launch(dispatchers.io) { val wallet = getWallet( @@ -1005,7 +991,7 @@ internal class WalletViewModel @Inject constructor( } } - private fun showSnackbar(message: TextReference) { + private fun showToast(message: TextReference) { uiState = stateFactory.getStateAndTriggerEvent( state = uiState, event = WalletEvent.ShowToast(message),