Updated on 2026-08-14
This commit is contained in:
parent
3a754e96a6
commit
34609aeb8c
10 changed files with 123 additions and 38 deletions
|
|
@ -50,6 +50,7 @@ import com.tangem.feature.wallet.presentation.wallet.utils.ScreenLifecycleProvid
|
|||
import com.tangem.features.biometry.AskBiometryComponent
|
||||
import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks
|
||||
import com.tangem.features.wallet.deeplink.WalletDeepLinkActionListener
|
||||
import com.tangem.features.wallet.featuretoggles.WalletFeatureToggles
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.coroutines.*
|
||||
import kotlinx.coroutines.*
|
||||
|
|
@ -102,6 +103,7 @@ internal class WalletModel @Inject constructor(
|
|||
private val appsFlyerStore: AppsFlyerStore,
|
||||
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
|
||||
private val getWalletIconUseCase: GetWalletIconUseCase,
|
||||
private val walletFeatureToggles: WalletFeatureToggles,
|
||||
val screenLifecycleProvider: ScreenLifecycleProvider,
|
||||
val innerWalletRouter: InnerWalletRouter,
|
||||
) : Model() {
|
||||
|
|
@ -522,6 +524,7 @@ internal class WalletModel @Inject constructor(
|
|||
wallets = action.wallets,
|
||||
clickIntents = clickIntents,
|
||||
walletImageResolver = walletImageResolver,
|
||||
isMainScreenQrScanningEnabled = walletFeatureToggles.isMainScreenQrScanningEnabled,
|
||||
getWalletIconUseCase = getWalletIconUseCase,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -82,9 +82,11 @@ internal interface WalletContentClickIntents {
|
|||
fun onDisposeExpressStatus()
|
||||
|
||||
fun onNFTClick(userWallet: UserWallet)
|
||||
|
||||
fun onScanQrClick()
|
||||
}
|
||||
|
||||
@Suppress("LongParameterList", "LargeClass")
|
||||
@Suppress("LongParameterList", "LargeClass", "TooManyFunctions")
|
||||
@ModelScoped
|
||||
internal class WalletContentClickIntentsImplementor @Inject constructor(
|
||||
private val stateHolder: WalletStateController,
|
||||
|
|
@ -369,4 +371,8 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
|
||||
router.openNFT(userWallet)
|
||||
}
|
||||
|
||||
override fun onScanQrClick() {
|
||||
router.openQrScanner()
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ import kotlinx.collections.immutable.persistentListOf
|
|||
@Suppress("LargeClass")
|
||||
internal object WalletPreviewDataLegacy {
|
||||
|
||||
val topBarConfig by lazy { WalletTopBarConfig(onDetailsClick = {}) }
|
||||
val topBarConfig by lazy { WalletTopBarConfig() }
|
||||
|
||||
val walletCardContentState by lazy {
|
||||
WalletCardState.Content(
|
||||
|
|
|
|||
|
|
@ -161,4 +161,8 @@ internal class DefaultWalletRouter @Inject constructor(
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
override fun openQrScanner() {
|
||||
router.push(AppRoute.QrScanning(source = AppRoute.QrScanning.Source.MainScreen))
|
||||
}
|
||||
}
|
||||
|
|
@ -86,4 +86,7 @@ internal interface InnerWalletRouter {
|
|||
|
||||
/** Open token action sheet */
|
||||
fun openTokenActionSheet(userWallet: UserWallet, tokenActionList: ImmutableList<TokenActionButtonUM>)
|
||||
|
||||
/** Open QR scanner screen */
|
||||
fun openQrScanner()
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ internal class WalletStateController @Inject constructor(
|
|||
|
||||
private fun getInitialState(): WalletScreenState {
|
||||
return WalletScreenState(
|
||||
topBarConfig = WalletTopBarConfig(onDetailsClick = {}),
|
||||
topBarConfig = WalletTopBarConfig(),
|
||||
selectedWalletIndex = NOT_INITIALIZED_WALLET_INDEX,
|
||||
wallets = persistentListOf(),
|
||||
wallets2 = persistentListOf(),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,16 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.model
|
||||
|
||||
import androidx.compose.runtime.Immutable
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBarActionUM
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
/**
|
||||
* Wallet screen top bar config
|
||||
*
|
||||
* @property onDetailsClick lambda be invoked when details button is clicked
|
||||
* @property endActions list of top bar end action buttons (e.g. QR scan, More)
|
||||
*/
|
||||
internal data class WalletTopBarConfig(val onDetailsClick: () -> Unit)
|
||||
@Immutable
|
||||
internal data class WalletTopBarConfig(
|
||||
val endActions: ImmutableList<TangemTopBarActionUM> = persistentListOf(),
|
||||
)
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package com.tangem.feature.wallet.presentation.wallet.state.transformers
|
||||
|
||||
import com.tangem.core.ui.R as CoreUiR
|
||||
import com.tangem.common.ui.userwallet.converter.WalletIconUMConverter
|
||||
import com.tangem.core.ui.ds.button.TangemButtonUM
|
||||
import com.tangem.core.ui.ds.topbar.TangemTopBarActionUM
|
||||
import com.tangem.domain.card.common.util.cardTypesResolver
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.isLocked
|
||||
|
|
@ -25,6 +27,7 @@ internal class InitializeWalletsTransformer(
|
|||
private val clickIntents: WalletClickIntents,
|
||||
private val walletImageResolver: WalletImageResolver,
|
||||
private val getWalletIconUseCase: GetWalletIconUseCase,
|
||||
private val isMainScreenQrScanningEnabled: Boolean = false,
|
||||
) : WalletScreenStateTransformer {
|
||||
|
||||
private val walletLoadingStateFactory by lazy {
|
||||
|
|
@ -60,7 +63,20 @@ internal class InitializeWalletsTransformer(
|
|||
|
||||
private fun createTopBarConfig(): WalletTopBarConfig {
|
||||
return WalletTopBarConfig(
|
||||
onDetailsClick = clickIntents::onDetailsClick,
|
||||
endActions = listOfNotNull(
|
||||
if (isMainScreenQrScanningEnabled) {
|
||||
TangemTopBarActionUM(
|
||||
iconRes = CoreUiR.drawable.ic_qrcode_scaner_24,
|
||||
onClick = clickIntents::onScanQrClick,
|
||||
)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
TangemTopBarActionUM(
|
||||
iconRes = CoreUiR.drawable.ic_more_default_24,
|
||||
onClick = clickIntents::onDetailsClick,
|
||||
),
|
||||
).toPersistentList(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import com.tangem.feature.wallet.impl.R
|
|||
import com.tangem.feature.wallet.presentation.common.WalletPreviewDataLegacy
|
||||
import com.tangem.feature.wallet.presentation.wallet.state.model.WalletTopBarConfig
|
||||
import dev.chrisbanes.haze.HazeProgressive
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
private const val VISIBILITY_THRESHOLD = 0.5f
|
||||
|
||||
|
|
@ -54,16 +55,11 @@ internal fun WalletTopBar(
|
|||
|
||||
TangemTopBar(
|
||||
title = wrappedBalance,
|
||||
startActionUM = TangemTopBarActionUM(
|
||||
startAction = TangemTopBarActionUM(
|
||||
iconRes = R.drawable.ic_tangem_24,
|
||||
isActionable = false,
|
||||
),
|
||||
endActionUM = TangemTopBarActionUM(
|
||||
iconRes = R.drawable.ic_more_default_24,
|
||||
isActionable = true,
|
||||
onClick = topBarConfig.onDetailsClick,
|
||||
ghostModeProgress = behavior.state.collapsedFraction,
|
||||
),
|
||||
endActions = topBarConfig.endActions,
|
||||
modifier = Modifier
|
||||
.statusBarsPadding()
|
||||
.testTag(MainScreenTestTags.TOP_BAR),
|
||||
|
|
@ -85,8 +81,15 @@ internal fun WalletTopBar(config: WalletTopBarConfig) {
|
|||
Icon(painter = painterResource(id = R.drawable.img_tangem_logo_90_24), contentDescription = null)
|
||||
},
|
||||
actions = {
|
||||
IconButton(onClick = config.onDetailsClick, modifier = Modifier.testTag(MainScreenTestTags.MORE_BUTTON)) {
|
||||
Icon(painter = painterResource(id = R.drawable.ic_more_vertical_24), contentDescription = null)
|
||||
config.endActions.forEach { action ->
|
||||
if (action.onClick != null) {
|
||||
IconButton(onClick = action.onClick!!) {
|
||||
Icon(
|
||||
painter = painterResource(id = action.iconRes),
|
||||
contentDescription = null,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
|
|
@ -115,7 +118,31 @@ private fun Preview_WalletTopBar() {
|
|||
private fun WalletTopBar_Preview() {
|
||||
TangemThemePreviewRedesign {
|
||||
WalletTopBar(
|
||||
topBarConfig = WalletTopBarConfig(onDetailsClick = {}),
|
||||
topBarConfig = WalletTopBarConfig(),
|
||||
walletBalance = stringReference("$ 8923,05"),
|
||||
behavior = rememberTangemExitUntilCollapsedScrollBehavior(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Preview(showBackground = true, widthDp = 360, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
private fun WalletTopBar_WithQrButton_Preview() {
|
||||
TangemThemePreviewRedesign {
|
||||
WalletTopBar(
|
||||
topBarConfig = WalletTopBarConfig(
|
||||
endActions = persistentListOf(
|
||||
TangemTopBarActionUM(
|
||||
iconRes = com.tangem.core.ui.R.drawable.ic_qrcode_scaner_24,
|
||||
onClick = {},
|
||||
),
|
||||
TangemTopBarActionUM(
|
||||
iconRes = R.drawable.ic_more_default_24,
|
||||
onClick = {},
|
||||
),
|
||||
),
|
||||
),
|
||||
walletBalance = stringReference("$ 8923,05"),
|
||||
behavior = rememberTangemExitUntilCollapsedScrollBehavior(),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue