Updated on 2026-08-14
This commit is contained in:
parent
a6ab6a6eaf
commit
cdce04bb6f
6 changed files with 82 additions and 21 deletions
|
|
@ -16,29 +16,31 @@ sealed class DetailsAction : Action {
|
|||
val shouldSaveUserWallets: Boolean,
|
||||
) : DetailsAction()
|
||||
|
||||
object ReCreateTwinsWallet : DetailsAction()
|
||||
data object ReCreateTwinsWallet : DetailsAction()
|
||||
|
||||
sealed class ResetToFactory : DetailsAction() {
|
||||
object Start : ResetToFactory()
|
||||
object Proceed : ResetToFactory()
|
||||
data object Start : ResetToFactory()
|
||||
data object Proceed : ResetToFactory()
|
||||
data class AcceptCondition1(val accepted: Boolean) : ResetToFactory()
|
||||
data class AcceptCondition2(val accepted: Boolean) : ResetToFactory()
|
||||
object Failure : ResetToFactory()
|
||||
object Success : ResetToFactory()
|
||||
data object Failure : ResetToFactory()
|
||||
data object Success : ResetToFactory()
|
||||
|
||||
data class LastWarningDialogVisibility(val isShown: Boolean) : ResetToFactory()
|
||||
}
|
||||
|
||||
object ScanCard : DetailsAction()
|
||||
data object ScanCard : DetailsAction()
|
||||
|
||||
data class PrepareCardSettingsData(val card: CardDTO, val cardTypesResolver: CardTypesResolver) : DetailsAction()
|
||||
object ResetCardSettingsData : DetailsAction()
|
||||
object ScanAndSaveUserWallet : DetailsAction() {
|
||||
data object ResetCardSettingsData : DetailsAction()
|
||||
data object ScanAndSaveUserWallet : DetailsAction() {
|
||||
|
||||
object Success : DetailsAction()
|
||||
data object Success : DetailsAction()
|
||||
|
||||
data class Error(val error: TextReference?) : DetailsAction()
|
||||
}
|
||||
|
||||
object DismissError : DetailsAction()
|
||||
data object DismissError : DetailsAction()
|
||||
|
||||
sealed class AccessCodeRecovery : DetailsAction() {
|
||||
object Open : AccessCodeRecovery()
|
||||
|
|
@ -50,14 +52,14 @@ sealed class DetailsAction : Action {
|
|||
}
|
||||
|
||||
sealed class ManageSecurity : DetailsAction() {
|
||||
object OpenSecurity : ManageSecurity()
|
||||
data object OpenSecurity : ManageSecurity()
|
||||
data class SelectOption(val option: SecurityOption) : ManageSecurity()
|
||||
object SaveChanges : ManageSecurity() {
|
||||
object Success : ManageSecurity()
|
||||
object Failure : ManageSecurity()
|
||||
data object SaveChanges : ManageSecurity() {
|
||||
data object Success : ManageSecurity()
|
||||
data object Failure : ManageSecurity()
|
||||
}
|
||||
|
||||
object ChangeAccessCode : ManageSecurity()
|
||||
data object ChangeAccessCode : ManageSecurity()
|
||||
}
|
||||
|
||||
sealed class AppSettings : DetailsAction() {
|
||||
|
|
@ -65,7 +67,7 @@ sealed class DetailsAction : Action {
|
|||
val enable: Boolean,
|
||||
val setting: AppSetting,
|
||||
) : AppSettings() {
|
||||
object Success : AppSettings()
|
||||
data object Success : AppSettings()
|
||||
|
||||
data class Failure(
|
||||
val prevState: Boolean,
|
||||
|
|
@ -77,7 +79,7 @@ sealed class DetailsAction : Action {
|
|||
val lifecycleScope: LifecycleCoroutineScope,
|
||||
) : AppSettings()
|
||||
|
||||
object EnrollBiometrics : AppSettings()
|
||||
data object EnrollBiometrics : AppSettings()
|
||||
data class BiometricsStatusChanged(
|
||||
val needEnrollBiometrics: Boolean,
|
||||
) : AppSettings()
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ private fun handlePrepareCardSettingsScreen(
|
|||
null
|
||||
},
|
||||
isShowPasswordResetRadioButton = isShowPasswordResetRadioButton,
|
||||
isLastWarningDialogShown = false,
|
||||
)
|
||||
return state.copy(cardSettingsState = cardSettingsState)
|
||||
}
|
||||
|
|
@ -181,6 +182,13 @@ private fun handleEraseWallet(action: DetailsAction.ResetToFactory, state: Detai
|
|||
),
|
||||
)
|
||||
}
|
||||
is DetailsAction.ResetToFactory.LastWarningDialogVisibility -> {
|
||||
state.copy(
|
||||
cardSettingsState = cardSettingsState?.copy(
|
||||
isLastWarningDialogShown = action.isShown,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
else -> state
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ data class CardSettingsState(
|
|||
val condition2Checked: Boolean,
|
||||
val accessCodeRecovery: AccessCodeRecoveryState? = null,
|
||||
val isShowPasswordResetRadioButton: Boolean,
|
||||
val isLastWarningDialogShown: Boolean,
|
||||
)
|
||||
|
||||
data class ManageSecurityState(
|
||||
|
|
|
|||
|
|
@ -11,9 +11,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import com.tangem.core.ui.components.SpacerH12
|
||||
import com.tangem.core.ui.components.SpacerH16
|
||||
import com.tangem.core.ui.components.SpacerH24
|
||||
import com.tangem.core.ui.components.*
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.tap.features.details.ui.cardsettings.TextReference
|
||||
import com.tangem.tap.features.details.ui.cardsettings.resolveReference
|
||||
|
|
@ -35,6 +33,8 @@ internal fun ResetCardScreen(state: ResetCardScreenState, onBackClick: () -> Uni
|
|||
},
|
||||
onBackClick = onBackClick,
|
||||
)
|
||||
|
||||
LastWarningDialog(state = state)
|
||||
}
|
||||
|
||||
@Composable
|
||||
|
|
@ -181,6 +181,26 @@ private fun ResetButton(enabled: Boolean, onResetButtonClick: () -> Unit) {
|
|||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun LastWarningDialog(state: ResetCardScreenState) {
|
||||
if (state is ResetCardScreenState.ResetCardScreenContent && state.lastWarningDialog.isShown) {
|
||||
BasicDialog(
|
||||
title = stringResource(id = R.string.common_attention),
|
||||
message = stringResource(id = R.string.card_settings_action_sheet_title),
|
||||
dismissButton = DialogButton(
|
||||
title = stringResource(id = R.string.card_settings_action_sheet_reset),
|
||||
warning = true,
|
||||
onClick = state.lastWarningDialog.onResetButtonClick,
|
||||
),
|
||||
confirmButton = DialogButton(
|
||||
title = stringResource(id = R.string.common_cancel),
|
||||
onClick = state.lastWarningDialog.onDismiss,
|
||||
),
|
||||
onDismissDialog = state.lastWarningDialog.onDismiss,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// region Preview
|
||||
@Composable
|
||||
private fun ResetCardScreenSample(modifier: Modifier = Modifier) {
|
||||
|
|
@ -196,6 +216,11 @@ private fun ResetCardScreenSample(modifier: Modifier = Modifier) {
|
|||
onAcceptCondition1ToggleClick = {},
|
||||
onAcceptCondition2ToggleClick = {},
|
||||
onResetButtonClick = {},
|
||||
lastWarningDialog = ResetCardScreenState.ResetCardScreenContent.LastWarningDialog(
|
||||
isShown = false,
|
||||
onResetButtonClick = {},
|
||||
onDismiss = {},
|
||||
),
|
||||
),
|
||||
onBackClick = {},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,9 +15,16 @@ internal sealed class ResetCardScreenState {
|
|||
val onAcceptCondition1ToggleClick: (Boolean) -> Unit,
|
||||
val onAcceptCondition2ToggleClick: (Boolean) -> Unit,
|
||||
val onResetButtonClick: () -> Unit,
|
||||
val lastWarningDialog: LastWarningDialog,
|
||||
) : ResetCardScreenState() {
|
||||
val resetButtonEnabled: Boolean
|
||||
get() = accepted
|
||||
|
||||
data class LastWarningDialog(
|
||||
val isShown: Boolean,
|
||||
val onResetButtonClick: () -> Unit,
|
||||
val onDismiss: () -> Unit,
|
||||
)
|
||||
}
|
||||
|
||||
internal enum class WarningsToReset {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,25 @@ internal class ResetCardViewModel(private val store: Store<AppState>) {
|
|||
acceptCondition2Checked = state?.condition2Checked ?: false,
|
||||
onAcceptCondition1ToggleClick = { store.dispatch(DetailsAction.ResetToFactory.AcceptCondition1(it)) },
|
||||
onAcceptCondition2ToggleClick = { store.dispatch(DetailsAction.ResetToFactory.AcceptCondition2(it)) },
|
||||
onResetButtonClick = { store.dispatch(DetailsAction.ResetToFactory.Proceed) },
|
||||
onResetButtonClick = { showLastWarningDialog() },
|
||||
lastWarningDialog = ResetCardScreenState.ResetCardScreenContent.LastWarningDialog(
|
||||
isShown = state?.isLastWarningDialogShown ?: false,
|
||||
onResetButtonClick = ::onLastWarningDialogResetClicked,
|
||||
onDismiss = ::onLastWarningDialogDismiss,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun showLastWarningDialog() {
|
||||
store.dispatch(DetailsAction.ResetToFactory.LastWarningDialogVisibility(isShown = true))
|
||||
}
|
||||
|
||||
private fun onLastWarningDialogResetClicked() {
|
||||
store.dispatch(DetailsAction.ResetToFactory.LastWarningDialogVisibility(isShown = false))
|
||||
store.dispatch(DetailsAction.ResetToFactory.Proceed)
|
||||
}
|
||||
|
||||
private fun onLastWarningDialogDismiss() {
|
||||
store.dispatch(DetailsAction.ResetToFactory.LastWarningDialogVisibility(isShown = false))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue