Updated on 2026-08-14
This commit is contained in:
parent
932fa90397
commit
698f1e6047
3 changed files with 43 additions and 1 deletions
|
|
@ -47,6 +47,7 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
title = resourceReference(R.string.force_update_warning_title),
|
||||
description = resourceReference(R.string.force_update_warning_message),
|
||||
onUpdateClick = ::onUpdateClick,
|
||||
onLaterClick = null,
|
||||
onSupportClick = ::onSupportClick,
|
||||
)
|
||||
ForceUpdateComponent.Mode.Brick -> ForceUpdateUM(
|
||||
|
|
@ -55,14 +56,16 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
title = resourceReference(R.string.force_update_brick_title),
|
||||
description = resourceReference(R.string.force_update_brick_description),
|
||||
onUpdateClick = null,
|
||||
onLaterClick = null,
|
||||
onSupportClick = ::onSupportClick,
|
||||
)
|
||||
ForceUpdateComponent.Mode.OsTooOld -> ForceUpdateUM(
|
||||
mode = mode,
|
||||
accent = Accent.Red,
|
||||
accent = Accent.Yellow,
|
||||
title = resourceReference(R.string.force_update_os_title),
|
||||
description = resourceReference(R.string.force_update_os_description),
|
||||
onUpdateClick = null,
|
||||
onLaterClick = ::onLaterClick,
|
||||
onSupportClick = null,
|
||||
)
|
||||
}
|
||||
|
|
@ -71,6 +74,10 @@ internal class ForceUpdateModel @Inject constructor(
|
|||
appStoreOpener.openStorePage()
|
||||
}
|
||||
|
||||
private fun onLaterClick() {
|
||||
forceUpdateContinuation.dismiss()
|
||||
}
|
||||
|
||||
private fun onSupportClick() {
|
||||
modelScope.launch {
|
||||
sendFeedbackEmailUseCase(type = FeedbackEmailType.AppUpdateProblem)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.features.forceupdate.impl.ui
|
||||
|
||||
import android.content.res.Configuration
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
|
|
@ -38,6 +39,10 @@ import com.tangem.features.forceupdate.impl.ui.state.ForceUpdateUM.Accent
|
|||
|
||||
@Composable
|
||||
internal fun ForceUpdateContent(state: ForceUpdateUM, modifier: Modifier = Modifier) {
|
||||
BackHandler(enabled = state.onLaterClick != null) {
|
||||
state.onLaterClick?.invoke()
|
||||
}
|
||||
|
||||
val accentColor = when (state.accent) {
|
||||
Accent.Red -> TangemTheme.colors3.icon.accent.red
|
||||
Accent.Yellow -> TangemTheme.colors3.icon.accent.yellow
|
||||
|
|
@ -114,6 +119,14 @@ private fun Buttons(state: ForceUpdateUM, modifier: Modifier = Modifier) {
|
|||
onClick = onClick,
|
||||
)
|
||||
}
|
||||
state.onLaterClick?.let { onClick ->
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
variant = TangemButton.Variant.Secondary,
|
||||
text = resourceReference(R.string.common_later),
|
||||
onClick = onClick,
|
||||
)
|
||||
}
|
||||
state.onUpdateClick?.let { onClick ->
|
||||
TangemButton(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
|
|
@ -150,6 +163,7 @@ private fun PreviewForce() {
|
|||
title = TextReference.Str("Update Required"),
|
||||
description = TextReference.Str("Please update the application to the latest version."),
|
||||
onUpdateClick = {},
|
||||
onLaterClick = null,
|
||||
onSupportClick = {},
|
||||
),
|
||||
)
|
||||
|
|
@ -168,8 +182,28 @@ private fun PreviewBrick() {
|
|||
title = TextReference.Str("Device not supported"),
|
||||
description = TextReference.Str("This device can't run the OS version Tangem needs."),
|
||||
onUpdateClick = null,
|
||||
onLaterClick = null,
|
||||
onSupportClick = {},
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true, widthDp = 360, heightDp = 780)
|
||||
@Preview(showBackground = true, widthDp = 360, heightDp = 780, uiMode = Configuration.UI_MODE_NIGHT_YES)
|
||||
@Composable
|
||||
private fun PreviewOsTooOld() {
|
||||
TangemThemePreviewRedesign {
|
||||
ForceUpdateContent(
|
||||
state = ForceUpdateUM(
|
||||
mode = ForceUpdateComponent.Mode.OsTooOld,
|
||||
accent = Accent.Yellow,
|
||||
title = TextReference.Str("Update OS"),
|
||||
description = TextReference.Str("Your OS is too old to run Tangem. Update it in Settings."),
|
||||
onUpdateClick = null,
|
||||
onLaterClick = {},
|
||||
onSupportClick = null,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ internal data class ForceUpdateUM(
|
|||
val title: TextReference,
|
||||
val description: TextReference,
|
||||
val onUpdateClick: (() -> Unit)?,
|
||||
val onLaterClick: (() -> Unit)?,
|
||||
val onSupportClick: (() -> Unit)?,
|
||||
) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue