Updated on 2026-08-14
This commit is contained in:
parent
cdd87e5629
commit
651531a532
10 changed files with 88 additions and 75 deletions
|
|
@ -15,18 +15,18 @@ data class CardSettingsScreenState(
|
|||
)
|
||||
|
||||
sealed class CardInfo(
|
||||
val titleRes: TextReference, val subtitle: TextReference, val clickable: Boolean = false,
|
||||
val titleRes: TextReference,
|
||||
val subtitle: TextReference,
|
||||
val clickable: Boolean = false,
|
||||
) {
|
||||
class CardId(subtitle: String) : CardInfo(
|
||||
titleRes = TextReference.Res(R.string.details_row_title_cid),
|
||||
subtitle = TextReference
|
||||
.Str(subtitle),
|
||||
subtitle = TextReference.Str(subtitle),
|
||||
)
|
||||
|
||||
class Issuer(subtitle: String) : CardInfo(
|
||||
titleRes = TextReference.Res(R.string.details_row_title_issuer),
|
||||
subtitle = TextReference
|
||||
.Str(subtitle),
|
||||
subtitle = TextReference.Str(subtitle),
|
||||
)
|
||||
|
||||
class SignedHashes(hashes: String) : CardInfo(
|
||||
|
|
@ -34,10 +34,7 @@ sealed class CardInfo(
|
|||
subtitle = TextReference.Res(R.string.details_row_subtitle_signed_hashes_format, hashes),
|
||||
)
|
||||
|
||||
class SecurityMode(
|
||||
securityOption: SecurityOption,
|
||||
clickable: Boolean,
|
||||
) : CardInfo(
|
||||
class SecurityMode(securityOption: SecurityOption, clickable: Boolean) : CardInfo(
|
||||
titleRes = TextReference.Res(R.string.card_settings_security_mode),
|
||||
subtitle = TextReference.Res(securityOption.toTitleRes()),
|
||||
clickable = clickable,
|
||||
|
|
@ -49,9 +46,9 @@ sealed class CardInfo(
|
|||
clickable = true,
|
||||
)
|
||||
|
||||
object ResetToFactorySettings : CardInfo(
|
||||
class ResetToFactorySettings(subtitle: TextReference.Res) : CardInfo(
|
||||
titleRes = TextReference.Res(R.string.card_settings_reset_card_to_factory),
|
||||
subtitle = TextReference.Res(R.string.card_settings_reset_card_to_factory_footer),
|
||||
subtitle = subtitle,
|
||||
clickable = true,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.tangem.tap.common.analytics.events.Settings
|
|||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.features.details.redux.CardSettingsState
|
||||
import com.tangem.tap.features.details.redux.DetailsAction
|
||||
import com.tangem.wallet.R
|
||||
import org.rekotlin.Store
|
||||
|
||||
class CardSettingsViewModel(private val store: Store<AppState>) {
|
||||
|
|
@ -46,7 +47,17 @@ class CardSettingsViewModel(private val store: Store<AppState>) {
|
|||
cardDetails.add(CardInfo.ChangeAccessCode)
|
||||
}
|
||||
if (state.resetCardAllowed) {
|
||||
cardDetails.add(CardInfo.ResetToFactorySettings)
|
||||
cardDetails.add(
|
||||
CardInfo.ResetToFactorySettings(
|
||||
subtitle = TextReference.Res(
|
||||
if (state.card.backupStatus?.isActive == true) {
|
||||
R.string.reset_card_with_backup_to_factory_message
|
||||
} else {
|
||||
R.string.reset_card_without_backup_to_factory_message
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
CardSettingsScreenState(
|
||||
|
|
|
|||
|
|
@ -32,77 +32,64 @@ import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
|||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
fun ResetCardScreen(
|
||||
state: ResetCardScreenState,
|
||||
onBackPressed: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
SettingsScreensScaffold(
|
||||
content = { ResetCardView(state = state, modifier = modifier) },
|
||||
onBackClick = onBackPressed,
|
||||
backgroundColor = Color.Transparent,
|
||||
)
|
||||
fun ResetCardScreen(state: ResetCardScreenState, onBackPressed: () -> Unit) {
|
||||
SettingsScreensScaffold(
|
||||
content = { ResetCardView(state = state) },
|
||||
onBackClick = onBackPressed,
|
||||
backgroundColor = Color.Transparent,
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun ResetCardView(
|
||||
state: ResetCardScreenState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
fun ResetCardView(state: ResetCardScreenState) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.verticalScroll(rememberScrollState()),
|
||||
verticalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
Box(
|
||||
modifier = modifier,
|
||||
) {
|
||||
Box {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_reset_background),
|
||||
contentDescription = "",
|
||||
modifier = modifier.offset(y = (-82).dp),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.offset(y = (-82).dp),
|
||||
)
|
||||
ScreenTitle(titleRes = R.string.card_settings_reset_card_to_factory)
|
||||
}
|
||||
Spacer(
|
||||
modifier = modifier.weight(1f),
|
||||
)
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
Column(
|
||||
modifier = modifier
|
||||
.offset(y = (-32).dp),
|
||||
modifier = Modifier.offset(y = (-32).dp),
|
||||
verticalArrangement = Arrangement.Bottom,
|
||||
) {
|
||||
Text(
|
||||
text = stringResource(id = R.string.common_attention),
|
||||
modifier = modifier.padding(start = 20.dp, end = 20.dp),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
style = TangemTypography.headline3,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
)
|
||||
|
||||
Spacer(modifier = modifier.size(24.dp))
|
||||
Spacer(modifier = Modifier.size(24.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = R.string.reset_card_to_factory_message),
|
||||
modifier = modifier
|
||||
.padding(start = 20.dp, end = 20.dp),
|
||||
text = stringResource(id = state.descriptionResId),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
style = TangemTypography.body1,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
)
|
||||
|
||||
Spacer(modifier = modifier.size(28.dp))
|
||||
Spacer(modifier = Modifier.size(28.dp))
|
||||
Row(
|
||||
modifier = modifier
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable(
|
||||
onClick = { state.onAcceptWarningToggleClick(!state.accepted) },
|
||||
)
|
||||
onClick = { state.onAcceptWarningToggleClick(!state.accepted) },
|
||||
)
|
||||
.padding(top = 16.dp, bottom = 16.dp),
|
||||
) {
|
||||
IconToggleButton(
|
||||
checked = state.accepted,
|
||||
onCheckedChange = state.onAcceptWarningToggleClick,
|
||||
modifier = modifier.padding(start = 20.dp, end = 20.dp),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
) {
|
||||
Icon(
|
||||
painter = painterResource(
|
||||
|
|
@ -124,15 +111,13 @@ fun ResetCardView(
|
|||
text = stringResource(id = R.string.reset_card_to_factory_warning_message),
|
||||
style = TangemTypography.body2,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
modifier = modifier
|
||||
.padding(end = 20.dp),
|
||||
modifier = Modifier.padding(end = 20.dp),
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = modifier.size(16.dp))
|
||||
Spacer(modifier = Modifier.size(16.dp))
|
||||
Box(
|
||||
modifier = modifier
|
||||
.padding(start = 16.dp, end = 16.dp, bottom = 32.dp),
|
||||
modifier = Modifier.padding(start = 16.dp, end = 16.dp, bottom = 32.dp),
|
||||
) {
|
||||
DetailsMainButton(
|
||||
title = stringResource(id = R.string.reset_card_to_factory_button_title),
|
||||
|
|
@ -146,8 +131,14 @@ fun ResetCardView(
|
|||
|
||||
@Composable
|
||||
@Preview
|
||||
fun ResetCardScreenPreview(
|
||||
|
||||
) {
|
||||
ResetCardScreen(state = ResetCardScreenState(onAcceptWarningToggleClick = {}, accepted = true) {}, {})
|
||||
fun ResetCardScreenPreview() {
|
||||
ResetCardScreen(
|
||||
state = ResetCardScreenState(
|
||||
descriptionResId = R.string.reset_card_without_backup_to_factory_message,
|
||||
accepted = false,
|
||||
onAcceptWarningToggleClick = {},
|
||||
onResetButtonClick = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
)
|
||||
}
|
||||
|
|
@ -1,6 +1,9 @@
|
|||
package com.tangem.tap.features.details.ui.resetcard
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
data class ResetCardScreenState(
|
||||
@StringRes val descriptionResId: Int,
|
||||
val accepted: Boolean = false,
|
||||
val onAcceptWarningToggleClick: (Boolean) -> Unit,
|
||||
val onResetButtonClick: () -> Unit,
|
||||
|
|
|
|||
|
|
@ -3,12 +3,18 @@ package com.tangem.tap.features.details.ui.resetcard
|
|||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.features.details.redux.CardSettingsState
|
||||
import com.tangem.tap.features.details.redux.DetailsAction
|
||||
import com.tangem.wallet.R
|
||||
import org.rekotlin.Store
|
||||
|
||||
class ResetCardViewModel(private val store: Store<AppState>) {
|
||||
|
||||
fun updateState(state: CardSettingsState?): ResetCardScreenState {
|
||||
return ResetCardScreenState(
|
||||
descriptionResId = if (state?.card?.backupStatus?.isActive == true) {
|
||||
R.string.reset_card_with_backup_to_factory_message
|
||||
} else {
|
||||
R.string.reset_card_without_backup_to_factory_message
|
||||
},
|
||||
accepted = state?.resetConfirmed ?: false,
|
||||
onAcceptWarningToggleClick = { store.dispatch(DetailsAction.ResetToFactory.Confirm(it)) },
|
||||
onResetButtonClick = { store.dispatch(DetailsAction.ResetToFactory.Proceed) },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue