Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-07 14:49:17 +05:00
parent 776d00eb57
commit a352aea4d2
4 changed files with 23 additions and 2 deletions

View file

@ -65,8 +65,12 @@ internal fun QrScanningContent(
TangemTopAppBar( TangemTopAppBar(
modifier = Modifier.statusBarsPadding(), modifier = Modifier.statusBarsPadding(),
title = null, title = uiState.topBarConfig.title?.resolveReference(),
startButton = TopAppBarButtonUM.Back(uiState.onBackClick), startButton = TopAppBarButtonUM(
iconRes = uiState.topBarConfig.startIcon,
onIconClicked = uiState.onBackClick,
),
textColor = TangemTheme.colors.text.constantWhite,
iconTint = TangemColorPalette.White, iconTint = TangemColorPalette.White,
containerColor = Color.Transparent, containerColor = Color.Transparent,
endContent = { endContent = {

View file

@ -1,11 +1,13 @@
package com.tangem.feature.qrscanning.presentation package com.tangem.feature.qrscanning.presentation
import androidx.annotation.DrawableRes
import androidx.compose.runtime.Immutable import androidx.compose.runtime.Immutable
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
import com.tangem.core.ui.extensions.TextReference import com.tangem.core.ui.extensions.TextReference
@Immutable @Immutable
internal data class QrScanningState( internal data class QrScanningState(
val topBarConfig: TopBarConfig,
val message: TextReference?, val message: TextReference?,
val onQrScanned: (String) -> Unit, val onQrScanned: (String) -> Unit,
val onBackClick: () -> Unit, val onBackClick: () -> Unit,
@ -14,6 +16,8 @@ internal data class QrScanningState(
val bottomSheetConfig: TangemBottomSheetConfig? = null, val bottomSheetConfig: TangemBottomSheetConfig? = null,
) )
internal data class TopBarConfig(val title: TextReference?, @DrawableRes val startIcon: Int)
@Immutable @Immutable
internal sealed interface PasteAction { internal sealed interface PasteAction {
data object None : PasteAction data object None : PasteAction

View file

@ -26,6 +26,7 @@ internal class QrScanningStateController @Inject constructor() {
private fun getInitialState(): QrScanningState { private fun getInitialState(): QrScanningState {
return QrScanningState( return QrScanningState(
topBarConfig = TopBarConfig(title = null, startIcon = 0),
message = null, message = null,
onBackClick = {}, onBackClick = {},
onQrScanned = {}, onQrScanned = {},

View file

@ -9,6 +9,7 @@ import com.tangem.feature.qrscanning.impl.R
import com.tangem.feature.qrscanning.model.QrScanningClickIntents import com.tangem.feature.qrscanning.model.QrScanningClickIntents
import com.tangem.feature.qrscanning.presentation.PasteAction import com.tangem.feature.qrscanning.presentation.PasteAction
import com.tangem.feature.qrscanning.presentation.QrScanningState import com.tangem.feature.qrscanning.presentation.QrScanningState
import com.tangem.feature.qrscanning.presentation.TopBarConfig
private const val WC_SCHEME = "wc" private const val WC_SCHEME = "wc"
@ -26,6 +27,7 @@ internal class InitializeQrScanningStateTransformer(
} }
return QrScanningState( return QrScanningState(
topBarConfig = constructTopBarConfig(),
message = message, message = message,
onBackClick = clickIntents::onBackClick, onBackClick = clickIntents::onBackClick,
onQrScanned = clickIntents::onQrScanned, onQrScanned = clickIntents::onQrScanned,
@ -34,6 +36,16 @@ internal class InitializeQrScanningStateTransformer(
) )
} }
private fun constructTopBarConfig(): TopBarConfig {
return when (source) {
SourceType.SEND -> TopBarConfig(title = null, startIcon = R.drawable.ic_back_24)
SourceType.WALLET_CONNECT -> TopBarConfig(
title = resourceReference(R.string.wc_new_connection),
startIcon = R.drawable.ic_close_24,
)
}
}
private fun constructPasteAction(): PasteAction { private fun constructPasteAction(): PasteAction {
val uri = clipboardManager.getText() val uri = clipboardManager.getText()
return if (source == SourceType.WALLET_CONNECT && uri != null && isWalletConnectUri(uri)) { return if (source == SourceType.WALLET_CONNECT && uri != null && isWalletConnectUri(uri)) {