Updated on 2026-08-14

This commit is contained in:
Tangem 2024-08-29 13:32:42 +03:00
commit 20b64f9a12

View file

@ -2,8 +2,11 @@ package com.tangem.feature.wallet.presentation.wallet.ui
import android.content.res.Configuration
import androidx.activity.compose.BackHandler
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.TweenSpec
import androidx.compose.animation.core.animateFloatAsState
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.background
import androidx.compose.foundation.gestures.detectTapGestures
@ -72,7 +75,8 @@ import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.balances
import com.tangem.feature.wallet.presentation.wallet.ui.components.visa.depositButton
import com.tangem.feature.wallet.presentation.wallet.ui.utils.changeWalletAnimator
import com.tangem.features.markets.component.BottomSheetState
import com.tangem.features.markets.component.BottomSheetState.*
import com.tangem.features.markets.component.BottomSheetState.COLLAPSED
import com.tangem.features.markets.component.BottomSheetState.EXPANDED
import com.tangem.features.markets.component.MarketsEntryComponent
import kotlinx.collections.immutable.toImmutableList
import kotlinx.coroutines.launch
@ -220,12 +224,9 @@ private fun WalletContent(
}
if (marketsEntryComponent != null) {
val bottomSheetState = remember {
mutableStateOf(BottomSheetState.COLLAPSED)
}
var headerSize by remember {
mutableStateOf(0.dp)
}
val bottomSheetState = remember { mutableStateOf(COLLAPSED) }
var headerSize by remember { mutableStateOf(0.dp) }
BaseScaffoldWithMarkets(
state = state,
@ -241,17 +242,15 @@ private fun WalletContent(
modifier = Modifier,
)
},
) {
scaffoldContent()
}
content = scaffoldContent,
)
} else {
BaseScaffold(
state = state,
selectedWallet = selectedWallet,
snackbarHostState = snackbarHostState,
) {
scaffoldContent()
}
content = scaffoldContent,
)
}
}
@ -274,16 +273,21 @@ private fun BaseScaffold(
)
},
floatingActionButton = {
val manageTokensButtonConfig by remember(state.selectedWalletIndex) {
mutableStateOf(
(state.wallets[state.selectedWalletIndex] as? WalletState.MultiCurrency)?.manageTokensButtonConfig,
)
}
val manageTokensButtonConfig by rememberUpdatedState(
newValue = (state.wallets[state.selectedWalletIndex] as? WalletState.MultiCurrency)
?.manageTokensButtonConfig,
)
AnimatedVisibility(
visible = manageTokensButtonConfig != null,
enter = fadeIn(),
exit = fadeOut(),
) {
val config = manageTokensButtonConfig ?: return@AnimatedVisibility
manageTokensButtonConfig?.let {
ManageTokensButton(
modifier = Modifier.navigationBarsPadding(),
onClick = it.onClick,
onClick = config.onClick,
)
}
},