Updated on 2026-08-14
This commit is contained in:
parent
1c5519a702
commit
64185e7482
11 changed files with 104 additions and 58 deletions
|
|
@ -4,6 +4,7 @@ import com.tangem.domain.common.CardDTO
|
|||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemNote
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemTwins
|
||||
import com.tangem.domain.common.isTangemTwin
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.domain.extensions.isWalletDataSupported
|
||||
|
|
@ -193,5 +194,12 @@ private fun CardDTO.toCardInfo(): CardInfo {
|
|||
val cardId = this.cardId.chunked(4).joinToString(separator = " ")
|
||||
val issuer = this.issuer.name
|
||||
val signedHashes = this.signedHashesCount()
|
||||
return CardInfo(cardId, issuer, signedHashes)
|
||||
|
||||
return CardInfo(
|
||||
cardId = cardId,
|
||||
issuer = issuer,
|
||||
signedHashes = signedHashes,
|
||||
isTwin = isTangemTwins,
|
||||
hasBackup = backupStatus?.isActive == true,
|
||||
)
|
||||
}
|
||||
|
|
@ -40,6 +40,8 @@ data class CardInfo(
|
|||
val cardId: String,
|
||||
val issuer: String,
|
||||
val signedHashes: Int,
|
||||
val isTwin: Boolean,
|
||||
val hasBackup: Boolean,
|
||||
)
|
||||
|
||||
data class CardSettingsState(
|
||||
|
|
|
|||
|
|
@ -156,18 +156,26 @@ fun CardSettings(
|
|||
)
|
||||
.padding(start = 20.dp, end = 20.dp, bottom = paddingBottom, top = paddingTop),
|
||||
) {
|
||||
val titleColor = if (it.clickable) R.color.text_primary_1 else R.color.text_tertiary
|
||||
val subtitleColor = if (it.clickable) R.color.text_secondary else R.color.text_tertiary
|
||||
val titleColor = if (it.clickable) {
|
||||
TangemTheme.colors.text.primary1
|
||||
} else {
|
||||
TangemTheme.colors.text.tertiary
|
||||
}
|
||||
val subtitleColor = if (it.clickable) {
|
||||
TangemTheme.colors.text.secondary
|
||||
} else {
|
||||
TangemTheme.colors.text.tertiary
|
||||
}
|
||||
Text(
|
||||
text = it.titleRes.resolveReference(),
|
||||
color = colorResource(id = titleColor),
|
||||
style = TangemTypography.subtitle1,
|
||||
color = titleColor,
|
||||
style = TangemTheme.typography.subtitle1,
|
||||
)
|
||||
Spacer(modifier = modifier.size(4.dp))
|
||||
Text(
|
||||
text = it.subtitle.resolveReference(),
|
||||
color = colorResource(id = subtitleColor),
|
||||
style = TangemTypography.body2,
|
||||
color = subtitleColor,
|
||||
style = TangemTheme.typography.body2,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ import androidx.compose.runtime.ReadOnlyComposable
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import com.tangem.tap.features.details.redux.SecurityOption
|
||||
import com.tangem.tap.features.details.ui.securitymode.toTitleRes
|
||||
import com.tangem.tap.features.details.ui.utils.toResetCardDescriptionText
|
||||
import com.tangem.wallet.R
|
||||
import com.tangem.tap.features.details.redux.CardInfo as ReduxCardInfo
|
||||
|
||||
data class CardSettingsScreenState(
|
||||
val cardDetails: List<CardInfo>? = null,
|
||||
|
|
@ -46,9 +48,9 @@ sealed class CardInfo(
|
|||
clickable = true,
|
||||
)
|
||||
|
||||
class ResetToFactorySettings(subtitle: TextReference.Res) : CardInfo(
|
||||
class ResetToFactorySettings(cardInfo: ReduxCardInfo) : CardInfo(
|
||||
titleRes = TextReference.Res(R.string.card_settings_reset_card_to_factory),
|
||||
subtitle = subtitle,
|
||||
subtitle = cardInfo.toResetCardDescriptionText(),
|
||||
clickable = true,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ 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>) {
|
||||
|
|
@ -47,17 +46,7 @@ class CardSettingsViewModel(private val store: Store<AppState>) {
|
|||
cardDetails.add(CardInfo.ChangeAccessCode)
|
||||
}
|
||||
if (state.resetCardAllowed) {
|
||||
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
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
cardDetails.add(CardInfo.ResetToFactorySettings(state.cardInfo))
|
||||
}
|
||||
|
||||
CardSettingsScreenState(
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ import androidx.compose.ui.res.painterResource
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.core.ui.res.TangemTheme
|
||||
import com.tangem.tap.common.compose.TangemTypography
|
||||
import com.tangem.wallet.R
|
||||
|
||||
@Composable
|
||||
|
|
@ -84,8 +83,8 @@ fun ScreenTitle(
|
|||
Text(
|
||||
text = stringResource(id = titleRes),
|
||||
modifier = modifier.padding(start = 20.dp, end = 20.dp),
|
||||
style = TangemTypography.headline1,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
style = TangemTheme.typography.h1,
|
||||
color = TangemTheme.colors.text.primary1,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.tap.features.details.ui.resetcard
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
|
@ -19,13 +20,13 @@ import androidx.compose.material.IconToggleButton
|
|||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.tangem.tap.common.compose.TangemTypography
|
||||
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
|
||||
import com.tangem.tap.features.details.ui.common.DetailsMainButton
|
||||
import com.tangem.tap.features.details.ui.common.ScreenTitle
|
||||
import com.tangem.tap.features.details.ui.common.SettingsScreensScaffold
|
||||
|
|
@ -36,7 +37,6 @@ fun ResetCardScreen(state: ResetCardScreenState, onBackPressed: () -> Unit) {
|
|||
SettingsScreensScaffold(
|
||||
content = { ResetCardView(state = state) },
|
||||
onBackClick = onBackPressed,
|
||||
backgroundColor = Color.Transparent,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ fun ResetCardView(state: ResetCardScreenState) {
|
|||
) {
|
||||
Box {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.ic_reset_background),
|
||||
painter = painterResource(id = R.drawable.ill_reset_background),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.offset(y = (-82).dp),
|
||||
)
|
||||
|
|
@ -64,17 +64,17 @@ fun ResetCardView(state: ResetCardScreenState) {
|
|||
Text(
|
||||
text = stringResource(id = R.string.common_attention),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
style = TangemTypography.headline3,
|
||||
color = colorResource(id = R.color.text_primary_1),
|
||||
style = TangemTheme.typography.h3,
|
||||
color = TangemTheme.colors.text.primary1,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(24.dp))
|
||||
|
||||
Text(
|
||||
text = stringResource(id = state.descriptionResId),
|
||||
text = state.descriptionText.resolveReference(),
|
||||
modifier = Modifier.padding(start = 20.dp, end = 20.dp),
|
||||
style = TangemTypography.body1,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
style = TangemTheme.typography.body1,
|
||||
color = TangemTheme.colors.text.secondary,
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.size(28.dp))
|
||||
|
|
@ -101,16 +101,16 @@ fun ResetCardView(state: ResetCardScreenState) {
|
|||
),
|
||||
contentDescription = null,
|
||||
tint = if (state.accepted) {
|
||||
colorResource(id = R.color.icon_accent)
|
||||
TangemTheme.colors.icon.accent
|
||||
} else {
|
||||
colorResource(id = R.color.icon_secondary)
|
||||
TangemTheme.colors.icon.secondary
|
||||
},
|
||||
)
|
||||
}
|
||||
Text(
|
||||
text = stringResource(id = R.string.reset_card_to_factory_warning_message),
|
||||
style = TangemTypography.body2,
|
||||
color = colorResource(id = R.color.text_secondary),
|
||||
style = TangemTheme.typography.body2,
|
||||
color = TangemTheme.colors.text.secondary,
|
||||
modifier = Modifier.padding(end = 20.dp),
|
||||
)
|
||||
}
|
||||
|
|
@ -129,16 +129,40 @@ fun ResetCardView(state: ResetCardScreenState) {
|
|||
}
|
||||
}
|
||||
|
||||
// region Preview
|
||||
@Composable
|
||||
@Preview
|
||||
fun ResetCardScreenPreview() {
|
||||
ResetCardScreen(
|
||||
state = ResetCardScreenState(
|
||||
descriptionResId = R.string.reset_card_without_backup_to_factory_message,
|
||||
accepted = false,
|
||||
onAcceptWarningToggleClick = {},
|
||||
onResetButtonClick = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
)
|
||||
}
|
||||
private fun ResetCardScreenSample(
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
Column(
|
||||
modifier = modifier
|
||||
.background(TangemTheme.colors.background.secondary),
|
||||
) {
|
||||
ResetCardScreen(
|
||||
state = ResetCardScreenState(
|
||||
accepted = true,
|
||||
descriptionText = TextReference.Res(R.string.reset_card_with_backup_to_factory_message),
|
||||
onAcceptWarningToggleClick = {},
|
||||
onResetButtonClick = {},
|
||||
),
|
||||
onBackPressed = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Composable
|
||||
private fun ResetCardScreenPreview_Light() {
|
||||
TangemTheme {
|
||||
ResetCardScreenSample()
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 360)
|
||||
@Composable
|
||||
private fun ResetCardScreenPreview_Dark() {
|
||||
TangemTheme(isDark = true) {
|
||||
ResetCardScreenSample()
|
||||
}
|
||||
}
|
||||
// endregion Preview
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
package com.tangem.tap.features.details.ui.resetcard
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import com.tangem.tap.features.details.ui.cardsettings.TextReference
|
||||
|
||||
data class ResetCardScreenState(
|
||||
@StringRes val descriptionResId: Int,
|
||||
val accepted: Boolean = false,
|
||||
val descriptionText: TextReference,
|
||||
val onAcceptWarningToggleClick: (Boolean) -> Unit,
|
||||
val onResetButtonClick: () -> Unit,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -3,19 +3,20 @@ 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 com.tangem.tap.features.details.ui.cardsettings.TextReference
|
||||
import com.tangem.tap.features.details.ui.utils.toResetCardDescriptionText
|
||||
import org.rekotlin.Store
|
||||
|
||||
class ResetCardViewModel(private val store: Store<AppState>) {
|
||||
|
||||
fun updateState(state: CardSettingsState?): ResetCardScreenState {
|
||||
val descriptionText = state?.cardInfo
|
||||
?.toResetCardDescriptionText()
|
||||
?: TextReference.Str(value = "")
|
||||
|
||||
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,
|
||||
descriptionText = descriptionText,
|
||||
onAcceptWarningToggleClick = { store.dispatch(DetailsAction.ResetToFactory.Confirm(it)) },
|
||||
onResetButtonClick = { store.dispatch(DetailsAction.ResetToFactory.Proceed) },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.tap.features.details.ui.utils
|
||||
|
||||
import com.tangem.tap.features.details.redux.CardInfo
|
||||
import com.tangem.tap.features.details.ui.cardsettings.TextReference
|
||||
import com.tangem.wallet.R
|
||||
|
||||
internal fun CardInfo.toResetCardDescriptionText(): TextReference {
|
||||
return if (!this.hasBackup || this.isTwin) {
|
||||
TextReference.Res(R.string.reset_card_without_backup_to_factory_message)
|
||||
} else {
|
||||
TextReference.Res(R.string.reset_card_with_backup_to_factory_message)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue