Updated on 2026-08-14

This commit is contained in:
Tangem 2025-08-18 18:13:29 +03:00
parent 6f047b8607
commit 7fe2a4d823
6 changed files with 89 additions and 28 deletions

View file

@ -12,6 +12,7 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.tangem.core.res.R
import com.tangem.core.ui.components.PrimaryButton
import com.tangem.core.ui.components.fields.PinTextColor
import com.tangem.core.ui.components.fields.PinTextField
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.res.TangemTheme
@ -75,6 +76,7 @@ internal fun AccessCode(state: AccessCodeUM, modifier: Modifier = Modifier) {
length = state.accessCodeLength,
isPasswordVisual = true,
value = state.accessCode,
pinTextColor = PinTextColor.Primary,
onValueChange = state.onAccessCodeChange,
)
}

View file

@ -26,8 +26,7 @@ internal class DefaultHotAccessCodeRequestComponent @AssistedInject constructor(
}
override suspend fun successfulAuthentication() {
// TODO handle successful authentication
// TODO add delay
model.successfulAuthentication()
}
override suspend fun requestPassword(hasBiometry: Boolean): HotWalletPasswordRequester.Result {

View file

@ -2,6 +2,7 @@ package com.tangem.features.hotwallet.accesscoderequest
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.decompose.model.Model
import com.tangem.core.ui.components.fields.PinTextColor
import com.tangem.domain.wallets.hot.HotWalletPasswordRequester
import com.tangem.features.hotwallet.accesscode.ACCESS_CODE_LENGTH
import com.tangem.features.hotwallet.accesscoderequest.entity.HotAccessCodeRequestUM
@ -45,13 +46,23 @@ internal class HotAccessCodeRequestModel @Inject constructor(
suspend fun wrongAccessCode() {
uiState.update {
it.copy(
wrongAccessCode = true,
accessCodeColor = PinTextColor.WrongCode,
onAccessCodeChange = {},
)
}
delay(timeMillis = 500) // Delay to show the wrong access code state
}
suspend fun successfulAuthentication() {
uiState.update {
it.copy(
accessCodeColor = PinTextColor.Success,
onAccessCodeChange = {},
)
}
delay(timeMillis = 200) // Delay to show the success state
}
private fun getInitialState() = HotAccessCodeRequestUM(
onDismiss = ::dismiss,
onAccessCodeChange = ::onAccessCodeChange,
@ -66,7 +77,10 @@ internal class HotAccessCodeRequestModel @Inject constructor(
if (accessCode.length > ACCESS_CODE_LENGTH) return
uiState.update {
it.copy(accessCode = accessCode, wrongAccessCode = false)
it.copy(
accessCode = accessCode,
accessCodeColor = PinTextColor.Primary,
)
}
if (accessCode.length == ACCESS_CODE_LENGTH) {

View file

@ -1,9 +1,11 @@
package com.tangem.features.hotwallet.accesscoderequest.entity
import com.tangem.core.ui.components.fields.PinTextColor
internal data class HotAccessCodeRequestUM(
val isShown: Boolean = false,
val accessCode: String = "",
val wrongAccessCode: Boolean = false,
val accessCodeColor: PinTextColor = PinTextColor.Primary,
val useBiometricVisible: Boolean = true,
val useBiometricClick: () -> Unit = {},
val onAccessCodeChange: (String) -> Unit = {},

View file

@ -20,6 +20,7 @@ import com.tangem.core.ui.components.SpacerH
import com.tangem.core.ui.components.SpacerH24
import com.tangem.core.ui.components.appbar.TangemTopAppBar
import com.tangem.core.ui.components.appbar.models.TopAppBarButtonUM
import com.tangem.core.ui.components.fields.PinTextColor
import com.tangem.core.ui.components.fields.PinTextField
import com.tangem.core.ui.extensions.stringResourceSafe
import com.tangem.core.ui.haptic.TangemHapticEffect
@ -85,7 +86,7 @@ internal fun HotAccessCodeRequestFullScreenContent(state: HotAccessCodeRequestUM
length = 6,
isPasswordVisual = true,
value = state.accessCode,
wrongCode = state.wrongAccessCode,
pinTextColor = state.accessCodeColor,
onValueChange = state.onAccessCodeChange,
)
}
@ -106,9 +107,15 @@ internal fun HotAccessCodeRequestFullScreenContent(state: HotAccessCodeRequestUM
val hapticManager = LocalHapticManager.current
LaunchedEffect(state.wrongAccessCode) {
if (state.wrongAccessCode) {
hapticManager.perform(TangemHapticEffect.View.Reject)
LaunchedEffect(state.accessCodeColor) {
when (state.accessCodeColor) {
PinTextColor.WrongCode -> {
hapticManager.perform(TangemHapticEffect.View.Reject)
}
PinTextColor.Success -> {
hapticManager.perform(TangemHapticEffect.View.Confirm)
}
else -> Unit
}
}
}