diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt index 80521c7689..9efe87d846 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/entity/TangemPayDetailsStateFactory.kt @@ -95,8 +95,8 @@ internal class TangemPayDetailsStateFactory( addToWalletBlockState = null, errorNotificationConfig = when (status.error) { null -> null - PaymentAccountStatusValue.Error.NotSynced -> createRenewSessionNotificationConfig() - else -> createAccountUnavailableConfig() + PaymentAccountStatusValue.Error.NotSynced -> createRenewSessionNotificationConfig(isRedesignEnabled) + else -> createAccountUnavailableConfig(isRedesignEnabled) }, accountDeactivatedNotificationConfig = null, ) @@ -121,20 +121,20 @@ internal class TangemPayDetailsStateFactory( isBalanceHidden = false, addToWalletBlockState = null, errorNotificationConfig = null, - accountDeactivatedNotificationConfig = createAccountDeactivatedConfig(), + accountDeactivatedNotificationConfig = createAccountDeactivatedConfig(isRedesignEnabled), ) } - private fun createAccountUnavailableConfig() = NotificationConfig( + private fun createAccountUnavailableConfig(isRedesignEnabled: Boolean) = NotificationConfig( title = resourceReference(R.string.tangempay_temporarily_unavailable), subtitle = resourceReference(R.string.tangempay_service_unreachable_try_later), - iconResId = R.drawable.img_attention_20, + iconResId = if (isRedesignEnabled) R.drawable.ic_alert_circle_24 else R.drawable.img_attention_20, ) - private fun createAccountDeactivatedConfig() = NotificationConfig( + private fun createAccountDeactivatedConfig(isRedesignEnabled: Boolean) = NotificationConfig( title = resourceReference(R.string.tangempay_account_deactivated_message_title), subtitle = resourceReference(R.string.tangempay_account_deactivated_message_subtitle), - iconResId = R.drawable.img_attention_20, + iconResId = if (isRedesignEnabled) R.drawable.ic_alert_circle_24 else R.drawable.img_attention_20, buttonsState = if (isRemoveAccountEnabled) { NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference(R.string.tangempay_remove_account), @@ -145,13 +145,14 @@ internal class TangemPayDetailsStateFactory( }, ) - private fun createRenewSessionNotificationConfig() = NotificationConfig( + private fun createRenewSessionNotificationConfig(isRedesignEnabled: Boolean) = NotificationConfig( title = resourceReference(R.string.tangempay_sync_needed_title), subtitle = resourceReference(R.string.tangempay_sync_needed_body), - iconResId = R.drawable.img_attention_20, + iconResId = if (isRedesignEnabled) 0 else R.drawable.img_attention_20, buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( text = resourceReference(R.string.tangempay_sync_needed_button), onClick = intents::onRenewSession, + iconResId = R.drawable.ic_tangem_24, ), ) diff --git a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreenV2.kt b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreenV2.kt index 78f9cb0669..79e79331e9 100644 --- a/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreenV2.kt +++ b/features/tangempay/details/impl/src/main/kotlin/com/tangem/features/tangempay/ui/TangemPayDetailsScreenV2.kt @@ -10,15 +10,18 @@ import androidx.compose.foundation.background import androidx.compose.foundation.layout.* import androidx.compose.foundation.lazy.* import androidx.compose.foundation.text.TextAutoSize +import androidx.compose.material3.Icon import androidx.compose.material3.Text import androidx.compose.runtime.* import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.testTag +import androidx.compose.ui.res.vectorResource import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.tooling.preview.Devices import androidx.compose.ui.tooling.preview.Preview @@ -34,9 +37,7 @@ import com.tangem.core.ui.components.containers.pullToRefresh.TangemPullToRefres import com.tangem.core.ui.components.notifications.NotificationConfig import com.tangem.core.ui.components.text.applyBladeBrush import com.tangem.core.ui.components.topFade -import com.tangem.core.ui.ds.button.PrimaryInverseTangemButton -import com.tangem.core.ui.ds.button.TangemButtonShape -import com.tangem.core.ui.ds.button.TangemButtonSize +import com.tangem.core.ui.ds.button.* import com.tangem.core.ui.ds.image.TangemIconUM import com.tangem.core.ui.ds.message.TangemMessage import com.tangem.core.ui.ds.message.TangemMessageEffect @@ -179,7 +180,7 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) { else -> { if (state.errorNotificationConfig != null) { item("errorSessionBannerBlock") { - TangemMessage( + ErrorMessage( config = state.errorNotificationConfig, modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), ) @@ -195,7 +196,7 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) { } if (state.accountDeactivatedNotificationConfig != null) { item("deactivationBannerBlock") { - DeactivationBannerBlock(notificationConfig = state.accountDeactivatedNotificationConfig) + ErrorMessage(state.accountDeactivatedNotificationConfig) } } } @@ -203,24 +204,47 @@ private fun LazyListScope.payDetailsBody(state: TangemPayDetailsUM) { } @Composable -private fun DeactivationBannerBlock(notificationConfig: NotificationConfig) { - val removeAccountButton = notificationConfig.buttonsState as? NotificationConfig.ButtonsState.SecondaryButtonConfig +private fun ErrorMessage(config: NotificationConfig, modifier: Modifier = Modifier) { + val button = config.buttonsState TangemMessage( - modifier = Modifier.padding(horizontal = TangemTheme.dimens2.x4), - title = notificationConfig.title, - subtitle = notificationConfig.subtitle, - messageEffect = TangemMessageEffect.Warning, - buttons = removeAccountButton?.let { button -> + modifier = modifier, + title = config.title, + subtitle = config.subtitle, + trailingContent = config.iconResId.takeIf { it != 0 }?.let { iconRes -> { - PrimaryInverseTangemButton( - text = button.text, - onClick = button.onClick, - size = TangemButtonSize.X9, - shape = TangemButtonShape.Rounded, + Icon( + modifier = Modifier.size(20.dp), + imageVector = ImageVector.vectorResource(iconRes), + contentDescription = null, + tint = TangemTheme.colors3.icon.primary, + ) + } + }, + buttons = (button as? NotificationConfig.ButtonsState.SecondaryButtonConfig)?.let { + { + val iconResId = button.iconResId + TangemButton( + buttonUM = TangemButtonUM( + text = button.text, + onClick = button.onClick, + iconPosition = TangemButtonIconPosition.End, + tangemIconUM = if (iconResId != null) { + TangemIconUM.Icon( + iconRes = iconResId, + tintReference = { TangemTheme.colors2.graphic.neutral.primaryInverted }, + ) + } else { + null + }, + size = TangemButtonSize.X9, + type = TangemButtonType.Primary, + shape = TangemButtonShape.Rounded, + ), modifier = Modifier.weight(1f), ) } }, + messageEffect = TangemMessageEffect.Warning, ) }