Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-23 18:04:31 +04:00
parent ad65a62b3f
commit 97a13da0d7
19 changed files with 176 additions and 56 deletions

View file

@ -9,5 +9,5 @@ interface ForceUpdateComponent : ComposableContentComponent {
data class Params(val mode: Mode)
enum class Mode { Force, Brick, OsTooOld, Optional }
enum class Mode { Force, Brick, OsTooOld }
}

View file

@ -33,6 +33,8 @@ dependencies {
/** Domain modules */
implementation(projects.domain.appUpdate)
implementation(projects.domain.feedback)
implementation(projects.domain.feedback.models)
/** DI */
implementation(deps.hilt.android)

View file

@ -7,6 +7,8 @@ import com.tangem.core.navigation.url.AppStoreOpener
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.domain.appupdate.model.AppUpdateState
import com.tangem.domain.appupdate.usecase.GetAppUpdateStateUseCase
import com.tangem.domain.feedback.SendFeedbackEmailUseCase
import com.tangem.domain.feedback.models.FeedbackEmailType
import com.tangem.features.forceupdate.ForceUpdateComponent
import com.tangem.features.forceupdate.ForceUpdateContinuation
import com.tangem.features.forceupdate.impl.R
@ -25,6 +27,7 @@ internal class ForceUpdateModel @Inject constructor(
private val appStoreOpener: AppStoreOpener,
private val forceUpdateContinuation: ForceUpdateContinuation,
private val getAppUpdateStateUseCase: GetAppUpdateStateUseCase,
private val sendFeedbackEmailUseCase: SendFeedbackEmailUseCase,
paramsContainer: ParamsContainer,
) : Model() {
@ -43,36 +46,24 @@ internal class ForceUpdateModel @Inject constructor(
accent = Accent.Red,
title = resourceReference(R.string.force_update_warning_title),
description = resourceReference(R.string.force_update_warning_message),
isBlocking = true,
onUpdateClick = ::onUpdateClick,
onLaterClick = null,
)
ForceUpdateComponent.Mode.Optional -> ForceUpdateUM(
mode = mode,
accent = Accent.Yellow,
title = resourceReference(R.string.force_update_warning_title),
description = resourceReference(R.string.force_update_warning_message),
isBlocking = false,
onUpdateClick = ::onUpdateClick,
onLaterClick = ::onLaterClick,
onSupportClick = ::onSupportClick,
)
ForceUpdateComponent.Mode.Brick -> ForceUpdateUM(
mode = mode,
accent = Accent.Red,
title = resourceReference(R.string.force_update_brick_title),
description = resourceReference(R.string.force_update_brick_description),
isBlocking = true,
onUpdateClick = null,
onLaterClick = null,
onSupportClick = ::onSupportClick,
)
ForceUpdateComponent.Mode.OsTooOld -> ForceUpdateUM(
mode = mode,
accent = Accent.Red,
title = resourceReference(R.string.force_update_os_title),
description = resourceReference(R.string.force_update_os_description),
isBlocking = true,
onUpdateClick = null,
onLaterClick = null,
onSupportClick = null,
)
}
@ -80,8 +71,10 @@ internal class ForceUpdateModel @Inject constructor(
appStoreOpener.openStorePage()
}
private fun onLaterClick() {
forceUpdateContinuation.dismiss()
private fun onSupportClick() {
modelScope.launch {
sendFeedbackEmailUseCase(type = FeedbackEmailType.AppUpdateProblem)
}
}
/**
@ -105,7 +98,8 @@ internal class ForceUpdateModel @Inject constructor(
AppUpdateState.ForceUpdate -> ForceUpdateComponent.Mode.Force
AppUpdateState.Brick -> ForceUpdateComponent.Mode.Brick
AppUpdateState.OsTooOld -> ForceUpdateComponent.Mode.OsTooOld
AppUpdateState.OptionalUpdate -> ForceUpdateComponent.Mode.Optional
AppUpdateState.NoUpdate -> null
AppUpdateState.OptionalUpdate,
AppUpdateState.NoUpdate,
-> null
}
}

View file

@ -1,7 +1,6 @@
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
@ -39,10 +38,6 @@ import com.tangem.features.forceupdate.impl.ui.state.ForceUpdateUM.Accent
@Composable
internal fun ForceUpdateContent(state: ForceUpdateUM, modifier: Modifier = Modifier) {
BackHandler(enabled = !state.isBlocking) {
state.onLaterClick?.invoke()
}
val accentColor = when (state.accent) {
Accent.Red -> TangemTheme.colors3.icon.accent.red
Accent.Yellow -> TangemTheme.colors3.icon.accent.yellow
@ -111,6 +106,14 @@ private fun Buttons(state: ForceUpdateUM, modifier: Modifier = Modifier) {
modifier = modifier,
verticalArrangement = Arrangement.spacedBy(12.dp),
) {
state.onSupportClick?.let { onClick ->
TangemButton(
modifier = Modifier.fillMaxWidth(),
variant = TangemButton.Variant.Secondary,
text = resourceReference(R.string.common_contact_support),
onClick = onClick,
)
}
state.onUpdateClick?.let { onClick ->
TangemButton(
modifier = Modifier.fillMaxWidth(),
@ -119,14 +122,6 @@ 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,
)
}
}
}
@ -154,9 +149,8 @@ private fun PreviewForce() {
accent = Accent.Red,
title = TextReference.Str("Update Required"),
description = TextReference.Str("Please update the application to the latest version."),
isBlocking = true,
onUpdateClick = {},
onLaterClick = null,
onSupportClick = {},
),
)
}
@ -165,17 +159,16 @@ private fun PreviewForce() {
@Preview(showBackground = true, widthDp = 360, heightDp = 780)
@Preview(showBackground = true, widthDp = 360, heightDp = 780, uiMode = Configuration.UI_MODE_NIGHT_YES)
@Composable
private fun PreviewOptional() {
private fun PreviewBrick() {
TangemThemePreviewRedesign {
ForceUpdateContent(
state = ForceUpdateUM(
mode = ForceUpdateComponent.Mode.Optional,
accent = Accent.Yellow,
title = TextReference.Str("Update Required"),
description = TextReference.Str("Please update the application to the latest version."),
isBlocking = false,
onUpdateClick = {},
onLaterClick = {},
mode = ForceUpdateComponent.Mode.Brick,
accent = Accent.Red,
title = TextReference.Str("Device not supported"),
description = TextReference.Str("This device can't run the OS version Tangem needs."),
onUpdateClick = null,
onSupportClick = {},
),
)
}

View file

@ -10,9 +10,8 @@ internal data class ForceUpdateUM(
val accent: Accent,
val title: TextReference,
val description: TextReference,
val isBlocking: Boolean,
val onUpdateClick: (() -> Unit)?,
val onLaterClick: (() -> Unit)?,
val onSupportClick: (() -> Unit)?,
) {
enum class Accent { Red, Yellow }