Updated on 2026-08-14
This commit is contained in:
parent
45fa120411
commit
1b6fded61c
15 changed files with 108 additions and 369 deletions
|
|
@ -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<ExpressTransactionStateUM>,
|
||||
val transactionsToDisplay: PersistentList<ExpressTransactionStateUM>,
|
||||
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,
|
||||
)
|
||||
|
|
@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,7 +29,6 @@ internal class EmptyExpressTransactionsComponent(
|
|||
transactions = persistentListOf(),
|
||||
transactionsToDisplay = persistentListOf(),
|
||||
bottomSheetSlot = null,
|
||||
dialogSlot = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -27,7 +27,6 @@ internal class PreviewEmptyExpressTransactionsComponent : ExpressTransactionsCom
|
|||
transactions = persistentListOf(),
|
||||
transactionsToDisplay = persistentListOf(),
|
||||
bottomSheetSlot = null,
|
||||
dialogSlot = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -101,8 +101,6 @@ interface ExpressTransactionsClickIntents {
|
|||
fun onDisposeExpressStatus()
|
||||
|
||||
fun onDismissBottomSheet()
|
||||
|
||||
fun onDismissDialog()
|
||||
}
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<TokenDetailsNotification>,
|
||||
val expressTxsToDisplay: PersistentList<ExpressTransactionStateUM>,
|
||||
val expressTxs: PersistentList<ExpressTransactionStateUM>,
|
||||
val dialogConfig: TokenDetailsDialogConfig?,
|
||||
val pullToRefreshConfig: PullToRefreshConfig,
|
||||
val bottomSheetConfig: TangemBottomSheetConfig?,
|
||||
val isBalanceHidden: Boolean,
|
||||
|
|
|
|||
|
|
@ -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<ExpressTransactionsBlockState>,
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
|
@ -65,7 +65,6 @@ internal class TokenDetailsSkeletonStateConverter(
|
|||
notifications = persistentListOf(),
|
||||
expressTxs = persistentListOf(),
|
||||
expressTxsToDisplay = persistentListOf(),
|
||||
dialogConfig = null,
|
||||
pullToRefreshConfig = createPullToRefresh(),
|
||||
bottomSheetConfig = null,
|
||||
isBalanceHidden = true,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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 -> {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue