Skip to content

Commit 85cc70a

Browse files
committed
fix(send): allow to nav back from pin to confirm screen
1 parent 41dcdd2 commit 85cc70a

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendConfirmScreen.kt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import androidx.compose.runtime.getValue
2525
import androidx.compose.runtime.mutableStateOf
2626
import androidx.compose.runtime.remember
2727
import androidx.compose.runtime.rememberCoroutineScope
28+
import androidx.compose.runtime.rememberUpdatedState
2829
import androidx.compose.runtime.saveable.rememberSaveable
2930
import androidx.compose.runtime.setValue
3031
import androidx.compose.ui.Alignment
@@ -95,9 +96,9 @@ fun SendConfirmScreen(
9596
onNavigateToPin: () -> Unit,
9697
) {
9798
val scope = rememberCoroutineScope()
98-
// TODO handle loading via uiState?
9999
var isLoading by rememberSaveable { mutableStateOf(false) }
100100
var showBiometrics by remember { mutableStateOf(false) }
101+
val currentOnEvent by rememberUpdatedState(onEvent)
101102

102103
val settings = settingsViewModel ?: return
103104
val isPinEnabled by settings.isPinEnabled.collectAsStateWithLifecycle()
@@ -115,18 +116,22 @@ fun SendConfirmScreen(
115116
}
116117
}
117118

118-
// Handle pay confirm with auth check if needed
119+
// Confirm with pin or bio if required
119120
LaunchedEffect(uiState.shouldConfirmPay) {
120-
if (uiState.shouldConfirmPay) {
121-
if (isPinEnabled && pinForPayments) {
122-
if (isBiometricEnabled && isBiometrySupported) {
123-
showBiometrics = true
124-
} else {
125-
onNavigateToPin()
126-
}
121+
if (!uiState.shouldConfirmPay) {
122+
isLoading = false
123+
return@LaunchedEffect
124+
}
125+
126+
if (isPinEnabled && pinForPayments) {
127+
currentOnEvent(SendEvent.ClearPayConfirmation)
128+
if (isBiometricEnabled && isBiometrySupported) {
129+
showBiometrics = true
127130
} else {
128-
onEvent(SendEvent.PayConfirmed)
131+
onNavigateToPin()
129132
}
133+
} else {
134+
currentOnEvent(SendEvent.PayConfirmed)
130135
}
131136
}
132137

app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ class AppViewModel @Inject constructor(
294294
is SendEvent.ConfirmAmountWarning -> onConfirmAmountWarning(it.warning)
295295
SendEvent.DismissAmountWarning -> onDismissAmountWarning()
296296
SendEvent.PayConfirmed -> onConfirmPay()
297+
SendEvent.ClearPayConfirmation -> _sendUiState.update { it.copy(shouldConfirmPay = false) }
297298
SendEvent.BackToAmount -> setSendEffect(SendEffect.PopBack(SendRoute.Amount))
298299
SendEvent.NavToAddress -> setSendEffect(SendEffect.NavigateToAddress)
299300
}
@@ -1586,6 +1587,7 @@ sealed interface SendEvent {
15861587
data class ConfirmAmountWarning(val warning: SanityWarning) : SendEvent
15871588
data object DismissAmountWarning : SendEvent
15881589
data object PayConfirmed : SendEvent
1590+
data object ClearPayConfirmation : SendEvent
15891591
data object BackToAmount : SendEvent
15901592
data object NavToAddress : SendEvent
15911593
}

0 commit comments

Comments
 (0)