Updated on 2026-08-14

This commit is contained in:
Tangem 2025-01-09 11:45:37 +03:00
parent 477a3c11dd
commit 88a80a7d3a
49 changed files with 68 additions and 70 deletions

View file

@ -35,7 +35,7 @@ internal class MainScreenStateHolder(private val intents: MainIntents) {
stateFlowInternal.update { state ->
state.copy(
modalNotification = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = intents::onDismissBottomSheet,
content = notificationsFactory.createBalancesAreHiddenModalNotification(),
),
@ -45,7 +45,7 @@ internal class MainScreenStateHolder(private val intents: MainIntents) {
fun updateWithoutModalNotification() {
stateFlowInternal.update { state ->
state.copy(modalNotification = state.modalNotification?.copy(isShow = false))
state.copy(modalNotification = state.modalNotification?.copy(isShown = false))
}
}

View file

@ -125,7 +125,7 @@ internal class MainViewModel @Inject constructor(
it.isBalanceHidingNotificationEnabled && it.isBalanceHidden
}
.onEach {
if (state.value.modalNotification?.isShow != true && !it.isUpdateFromToast) {
if (state.value.modalNotification?.isShown != true && !it.isUpdateFromToast) {
listenToFlipsUseCase.changeUpdateEnabled(false)
stateHolder.updateWithHiddenBalancesNotification()
router.push(AppRoute.ModalNotification)

View file

@ -50,7 +50,7 @@ internal class ModalNotificationBottomSheetFragment : ComposeBottomSheetFragment
}
LaunchedEffect(notification) {
if (!notification.isShow) {
if (!notification.isShown) {
dismiss()
}
}

View file

@ -296,7 +296,7 @@ private fun Preview_GiveTxPermissionBottomSheet() {
TangemThemePreview {
GiveTxPermissionBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = previewData,
),

View file

@ -2,7 +2,6 @@ package com.tangem.core.ui.components.bottomsheets
import androidx.activity.compose.BackHandler
import androidx.activity.compose.LocalOnBackPressedDispatcherOwner
import androidx.compose.foundation.background
import androidx.compose.foundation.focusable
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
@ -99,7 +98,7 @@ inline fun <reified T : TangemBottomSheetConfigContent> DefaultBottomSheet(
crossinline title: @Composable (BoxScope.(T) -> Unit),
crossinline content: @Composable (ColumnScope.(T) -> Unit),
) {
var isVisible by remember { mutableStateOf(value = config.isShow) }
var isVisible by remember { mutableStateOf(value = config.isShown) }
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = skipPartiallyExpanded)
if (isVisible && config.content is T) {
@ -114,8 +113,8 @@ inline fun <reified T : TangemBottomSheetConfigContent> DefaultBottomSheet(
)
}
LaunchedEffect(key1 = config.isShow) {
if (config.isShow) {
LaunchedEffect(key1 = config.isShown) {
if (config.isShown) {
isVisible = true
} else {
sheetState.collapse { isVisible = false }

View file

@ -3,12 +3,12 @@ package com.tangem.core.ui.components.bottomsheets
/**
* Tangem bottom sheet config
*
* @property isShow flag that determine if bottom sheet is shown
* @property isShown flag that determine if bottom sheet is shown
* @property onDismissRequest lambda be invoked when bottom sheet is dismissed
* @property content content config
*/
data class TangemBottomSheetConfig(
val isShow: Boolean,
val isShown: Boolean,
val onDismissRequest: () -> Unit,
val content: TangemBottomSheetConfigContent,
) {

View file

@ -112,7 +112,7 @@ private fun Preview_NotificationBottomSheet(
MessageBottomSheet(
config = TangemBottomSheetConfig(
content = params,
isShow = true,
isShown = true,
onDismissRequest = {},
),
)

View file

@ -279,7 +279,7 @@ private fun Preview_TokenReceiveBottomSheet(
) {
TangemThemePreview {
val config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
content = params,
onDismissRequest = {},
)

View file

@ -76,7 +76,7 @@ fun EventMessageEffect(
@Composable
private fun MessageBottomSheet(message: BottomSheetMessage, onDismissRequest: () -> Unit) {
val config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
content = MessageBottomSheetUM(
iconResId = message.iconResId,
title = message.title,

View file

@ -62,7 +62,7 @@ internal class DefaultAddCustomTokenComponent @AssistedInject constructor(
override fun BottomSheet() {
val config = remember {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = initialConfiguration.step.toContentModel(::popBack),
)

View file

@ -29,7 +29,7 @@ internal class PreviewAddCustomTokenComponent(
override fun BottomSheet() {
val config by previewConfig.collectAsStateWithLifecycle()
val bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = config.step.toContentModel(::dismiss),
)

View file

@ -205,7 +205,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
body = MarketsTokenDetailsUM.Body.Loading,
triggerPriceChange = consumedEvent(),
bottomSheetConfig = TangemBottomSheetConfig(
isShow = false,
isShown = false,
onDismissRequest = {},
content = TangemBottomSheetConfigContent.Empty,
),
@ -510,7 +510,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
state.update { stateToUpdate ->
stateToUpdate.copy(
bottomSheetConfig = stateToUpdate.bottomSheetConfig.copy(
isShow = true,
isShown = true,
onDismissRequest = ::hideBottomSheet,
content = content,
),
@ -521,7 +521,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
private fun hideBottomSheet() {
state.update { stateToUpdate ->
stateToUpdate.copy(
bottomSheetConfig = stateToUpdate.bottomSheetConfig.copy(isShow = false),
bottomSheetConfig = stateToUpdate.bottomSheetConfig.copy(isShown = false),
)
}
}

View file

@ -336,7 +336,7 @@ private fun Preview() {
onSelectedIntervalChange = { },
body = MarketsTokenDetailsUM.Body.Loading,
bottomSheetConfig = TangemBottomSheetConfig(
isShow = false,
isShown = false,
onDismissRequest = {},
content = TangemBottomSheetConfigContent.Empty,
),

View file

@ -152,7 +152,7 @@ private fun Preview_ExchangesBottomSheet(
config = TangemBottomSheetConfig(
onDismissRequest = {},
content = content,
isShow = true,
isShown = true,
),
)
}

View file

@ -181,7 +181,7 @@ private fun SecurityScoreBottomSheetPreview() {
TangemThemePreview {
SecurityScoreBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = SecurityScorePreviewData.bottomSheetContent,
),

View file

@ -50,7 +50,7 @@ internal class AddToPortfolioBSContentUMFactory(
alreadyAddedNetworks: Set<String>?,
): TangemBottomSheetConfig {
return TangemBottomSheetConfig(
isShow = portfolioUIData.portfolioBSVisibilityModel.addToPortfolioBSVisibility,
isShown = portfolioUIData.portfolioBSVisibilityModel.addToPortfolioBSVisibility,
onDismissRequest = { onAddToPortfolioVisibilityChange(false) },
content = if (selectedWallet != null && alreadyAddedNetworks != null) {
AddToPortfolioBSContentUM(
@ -107,7 +107,7 @@ internal class AddToPortfolioBSContentUMFactory(
selectedWalletId: UserWalletId,
): TangemBottomSheetConfig {
return TangemBottomSheetConfig(
isShow = isShow,
isShown = isShow,
onDismissRequest = { onWalletSelectorVisibilityChange(false) },
content = WalletSelectorBSContentUM(
userWallets = portfolioData.walletsWithCurrencies

View file

@ -101,10 +101,10 @@ internal class TokenActionsHandler @AssistedInject constructor(
updateTokenReceiveBSConfig {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {
updateTokenReceiveBSConfig {
it.copy(isShow = false)
it.copy(isShown = false)
}
},
content = TokenReceiveBottomSheetConfig(

View file

@ -295,7 +295,7 @@ private fun Preview(
TangemThemePreview {
AddToPortfolioBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
content = content,
onDismissRequest = {},
),
@ -370,7 +370,7 @@ private fun PreviewContentTestOnDevice(
AddToPortfolioBottomSheet(
config = TangemBottomSheetConfig(
isShow = isShow,
isShown = isShow,
content = contentState,
onDismissRequest = { isShow = false },
),

View file

@ -72,7 +72,7 @@ private fun Preview() {
Box(Modifier.background(TangemTheme.colors.background.secondary)) {
TokenActionsBottomSheet(
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = TokenActionsBSContentUM(
title = "Wallet 1",

View file

@ -94,7 +94,7 @@ private fun Preview() {
TangemThemePreview {
WalletSelectorBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = WalletSelectorBSContentUM(
userWallets = persistentListOf(

View file

@ -26,8 +26,8 @@ internal class MarketsListUMStateManager(
) {
private var sortByBottomSheetIsShown
get() = state.value.sortByBottomSheet.isShow
set(value) = state.update { it.copy(sortByBottomSheet = it.sortByBottomSheet.copy(isShow = value)) }
get() = state.value.sortByBottomSheet.isShown
set(value) = state.update { it.copy(sortByBottomSheet = it.sortByBottomSheet.copy(isShown = value)) }
var searchQuery
get() = state.value.searchBar.query
@ -203,7 +203,7 @@ internal class MarketsListUMStateManager(
onIntervalClick = { selectedInterval = it },
onSortByButtonClick = { sortByBottomSheetIsShown = true },
sortByBottomSheet = TangemBottomSheetConfig(
isShow = false,
isShown = false,
onDismissRequest = { sortByBottomSheetIsShown = false },
content = SortByBottomSheetContentUM(
selectedOption = SortByTypeUM.Rating,
@ -217,7 +217,7 @@ internal class MarketsListUMStateManager(
it.copy(
selectedSortBy = sortByTypeUM,
sortByBottomSheet = it.sortByBottomSheet.copy(
isShow = false,
isShown = false,
content = (it.sortByBottomSheet.content as SortByBottomSheetContentUM).copy(
selectedOption = sortByTypeUM,
),

View file

@ -62,7 +62,7 @@ internal fun MarketsList(
)
MarketsListSortByBottomSheet(config = state.sortByBottomSheet)
KeyboardEvents(
isSortByBottomSheetShown = state.sortByBottomSheet.isShow,
isSortByBottomSheetShown = state.sortByBottomSheet.isShown,
bottomSheetState = bottomSheetState,
)
}
@ -321,7 +321,7 @@ private fun Preview() {
onIntervalClick = {},
onSortByButtonClick = {},
sortByBottomSheet = TangemBottomSheetConfig(
isShow = false,
isShown = false,
onDismissRequest = {},
content = SortByBottomSheetContentUM(selectedOption = SortByTypeUM.Rating) {},
),

View file

@ -72,7 +72,7 @@ private fun Preview() {
Box(Modifier.background(TangemTheme.colors.background.secondary)) {
MarketsListSortByBottomSheet(
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = SortByBottomSheetContentUM(
selectedOption = SortByTypeUM.Trending,

View file

@ -51,7 +51,7 @@ class MultiWalletAccessCodeComponent(
val bsConfig = remember(this, showBs) {
TangemBottomSheetConfig(
isShow = showBs,
isShown = showBs,
onDismissRequest = { dismiss() },
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -157,7 +157,7 @@ internal class ImportSeedPhraseUiStateBuilder(
updateUiState { state ->
state.copy(
infoBottomSheetConfig = TangemBottomSheetConfig.Empty.copy(
isShow = true,
isShown = true,
onDismissRequest = {
updateUiState { it.copy(infoBottomSheetConfig = TangemBottomSheetConfig.Empty) }
},

View file

@ -69,7 +69,7 @@ class ImportSeedPhraseStateBuilder {
return uiState.copy(
importSeedPhraseState = uiState.importSeedPhraseState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismiss,
content = ShowPassphraseInfoBottomSheetContent(onDismiss),
),
@ -81,7 +81,7 @@ class ImportSeedPhraseStateBuilder {
return uiState.copy(
importSeedPhraseState = uiState.importSeedPhraseState.copy(
bottomSheetConfig = uiState.importSeedPhraseState.bottomSheetConfig?.copy(
isShow = false,
isShown = false,
),
),
)

View file

@ -47,7 +47,7 @@ internal class DefaultConfirmResidencyComponent @AssistedInject constructor(
val bottomSheet by bottomSheetSlot.subscribeAsState()
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -33,7 +33,7 @@ internal class PreviewConfirmResidencyComponent(
val state by previewState.collectAsStateWithLifecycle()
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -24,7 +24,7 @@ internal class DefaultSelectPaymentMethodComponent @AssistedInject constructor(
override fun BottomSheet() {
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = PaymentMethodsBottomSheetConfig(
selectedMethodId = params.selectedMethodId,

View file

@ -52,7 +52,7 @@ internal class DefaultSelectProviderComponent @AssistedInject constructor(
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -33,7 +33,7 @@ internal class DefaultSelectCountryComponent @AssistedInject constructor(
val state by model.state.collectAsStateWithLifecycle()
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -33,7 +33,7 @@ internal class DefaultSelectCurrencyComponent @AssistedInject constructor(
val state by model.state.collectAsStateWithLifecycle()
val bottomSheetConfig = remember(key1 = this) {
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = ::dismiss,
content = TangemBottomSheetConfigContent.Empty,
)

View file

@ -83,7 +83,7 @@ private fun Preview_CameraDeniedBottomSheet() {
TangemThemePreview {
CameraDeniedBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = CameraDeniedBottomSheetConfig(
onSettingsClick = {},

View file

@ -12,7 +12,7 @@ internal class ShowCameraDeniedBottomSheetTransformer(
override fun transform(prevState: QrScanningState): QrScanningState {
return prevState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = clickIntents::onBackClick,
content = CameraDeniedBottomSheetConfig(
onSettingsClick = clickIntents::onSettingsClick,

View file

@ -17,7 +17,7 @@ internal class ShowActionSelectorBottomSheetTransformer(
override fun transform(prevState: StakingUiState): StakingUiState {
return prevState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
content = StakingActionSelectionBottomSheetConfig(
title = resourceReference(R.string.common_choose_action),
actions = pendingActions,

View file

@ -17,7 +17,7 @@ internal class ShowInfoBottomSheetStateTransformer(
return prevState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
onDismissRequest = onDismiss,
isShow = true,
isShown = true,
content = when (infoType) {
InfoType.ANNUAL_PERCENTAGE_RATE -> StakingInfoBottomSheetConfig(
title = resourceReference(R.string.staking_details_annual_percentage_rate),

View file

@ -13,7 +13,7 @@ internal class SetApprovalBottomSheetInProgressTransformer(
return prevState.copy(
bottomSheetConfig = prevState.bottomSheetConfig?.copy(
onDismissRequest = onDismiss,
isShow = true,
isShown = true,
content = approvalBottomSheetConfig?.let { config ->
config.copy(
data = config.data.copy(

View file

@ -45,7 +45,7 @@ internal class ShowApprovalBottomSheetTransformer(
)
return prevState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismiss,
content = GiveTxPermissionBottomSheetConfig(
data = GiveTxPermissionState.ReadyForRequest(

View file

@ -67,7 +67,7 @@ private fun Preview_StakingActionSelectorBottomSheet() {
TangemThemePreview {
StakingActionSelectorBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = StakingActionSelectionBottomSheetConfig(
title = resourceReference(R.string.common_select_action),

View file

@ -52,7 +52,7 @@ private fun Preview_StakingInfoBottomSheet() {
TangemThemePreview {
StakingInfoBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = StakingInfoBottomSheetConfig(
title = stringReference("Title"),

View file

@ -170,7 +170,7 @@ private fun Preview_ChooseFeeBottomSheet() {
TangemThemePreview {
ChooseFeeBottomSheet(
config = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = content,
),

View file

@ -134,7 +134,7 @@ private fun Preview_ChooseProviderBottomSheet() {
TangemThemePreview {
ChooseProviderBottomSheet(
TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = {},
content = content,
),

View file

@ -10,7 +10,6 @@ import com.tangem.core.ui.components.currency.icon.converter.CryptoCurrencyToIco
import com.tangem.core.ui.event.consumedEvent
import com.tangem.core.ui.event.triggeredEvent
import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.format.bigdecimal.*
import com.tangem.core.ui.format.bigdecimal.anyDecimals
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.format
@ -946,7 +945,7 @@ internal class StateBuilder(
)
return uiState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismiss,
content = config,
),
@ -957,7 +956,7 @@ internal class StateBuilder(
fun dismissBottomSheet(uiState: SwapStateHolder): SwapStateHolder {
return uiState.copy(
bottomSheetConfig = uiState.bottomSheetConfig?.copy(isShow = false),
bottomSheetConfig = uiState.bottomSheetConfig?.copy(isShown = false),
)
}
@ -981,7 +980,7 @@ internal class StateBuilder(
)
return uiState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismiss,
content = config,
),
@ -1044,7 +1043,7 @@ internal class StateBuilder(
)
return uiState.copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismiss,
content = config,
),

View file

@ -1024,7 +1024,7 @@ internal class SwapViewModel @Inject constructor(
},
onBackClicked = {
val bottomSheet = uiState.bottomSheetConfig
if (bottomSheet != null && bottomSheet.isShow) {
if (bottomSheet != null && bottomSheet.isShown) {
uiState = stateBuilder.dismissBottomSheet(uiState)
} else {
if (swapRouter.currentScreen == SwapNavScreen.SelectToken) {

View file

@ -254,7 +254,7 @@ internal class TokenDetailsStateFactory(
): TokenDetailsState {
return currentStateProvider().copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = clickIntents::onDismissBottomSheet,
content = TokenReceiveBottomSheetConfig(
name = currency.name,
@ -275,7 +275,7 @@ internal class TokenDetailsStateFactory(
): TokenDetailsState {
return currentStateProvider().copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = clickIntents::onDismissBottomSheet,
content = ChooseAddressBottomSheetConfig(
addressModels = networkAddress.availableAddresses.mapToAddressModels(currency).toImmutableList(),
@ -288,7 +288,7 @@ internal class TokenDetailsStateFactory(
fun getStateWithClosedBottomSheet(): TokenDetailsState {
val state = currentStateProvider()
return state.copy(
bottomSheetConfig = state.bottomSheetConfig?.copy(isShow = false),
bottomSheetConfig = state.bottomSheetConfig?.copy(isShown = false),
)
}

View file

@ -133,7 +133,7 @@ internal class ExpressStatusFactory @AssistedInject constructor(
return currentStateProvider().copy(
bottomSheetConfig = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = clickIntents::onDismissBottomSheet,
content = ExpressStatusBottomSheetConfig(
value = expressState,

View file

@ -180,7 +180,7 @@ internal object WalletPreviewData {
val bottomSheet by lazy {
TangemBottomSheetConfig(
isShow = false,
isShown = false,
onDismissRequest = {},
content = WalletBottomSheetConfig.UnlockWallets(
onUnlockClick = {},

View file

@ -29,6 +29,6 @@ internal class CloseBottomSheetTransformer(userWalletId: UserWalletId) : WalletS
}
private fun updateConfig(prevState: WalletState) = prevState.bottomSheetConfig?.copy(
isShow = false,
isShown = false,
)
}

View file

@ -35,7 +35,7 @@ internal class OpenBottomSheetTransformer(
}
private fun updateConfig() = TangemBottomSheetConfig(
isShow = true,
isShown = true,
onDismissRequest = onDismissBottomSheet,
content = content,
)