diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/SettingsRow.kt b/core/ui/src/main/java/com/tangem/core/ui/components/SettingsRow.kt index 823a93b8e3..6b497b4af0 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/SettingsRow.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/SettingsRow.kt @@ -7,8 +7,7 @@ import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.* import androidx.compose.material.Icon import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.runtime.getValue +import androidx.compose.runtime.* import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color @@ -24,6 +23,7 @@ fun SimpleSettingsRow( @DrawableRes icon: Int, onItemsClick: () -> Unit, modifier: Modifier = Modifier, + rowColors: RowColors = getDefaultRowColors(), enabled: Boolean = true, subtitle: String? = null, ) { @@ -41,24 +41,17 @@ fun SimpleSettingsRow( horizontalArrangement = Arrangement.Start, verticalAlignment = Alignment.CenterVertically, ) { - val textColor: Color by animateColorAsState( - targetValue = if (enabled) { - TangemTheme.colors.text.primary1 - } else { - TangemTheme.colors.text.secondary - }, - ) Icon( painter = painterResource(id = icon), contentDescription = null, modifier = Modifier.padding(horizontal = TangemTheme.dimens.spacing20), - tint = textColor, + tint = rowColors.iconColor(enabled = enabled).value, ) Column(modifier = Modifier.padding(end = TangemTheme.dimens.spacing20)) { Text( text = title, style = TangemTheme.typography.subtitle1, - color = textColor, + color = rowColors.titleColor(enabled = enabled).value, ) AnimatedVisibility( visible = !subtitle.isNullOrEmpty(), @@ -66,9 +59,75 @@ fun SimpleSettingsRow( Text( text = subtitle ?: "", style = TangemTheme.typography.body2, - color = TangemTheme.colors.text.secondary, + color = rowColors.subtitleColor(enabled = enabled).value, ) } } } +} + +@Composable +fun getWarningRowColors(): RowColors = DefaultRowColors( + titleColor = TangemTheme.colors.text.warning, + iconColor = TangemTheme.colors.text.warning, + disabledTitleColor = TangemTheme.colors.text.secondary, + disabledIconColor = TangemTheme.colors.text.secondary, +) + +@Composable +fun getDefaultRowColors(): RowColors = DefaultRowColors( + titleColor = TangemTheme.colors.text.primary1, + iconColor = TangemTheme.colors.text.primary1, + disabledTitleColor = TangemTheme.colors.text.secondary, + disabledIconColor = TangemTheme.colors.text.secondary, +) + +@Immutable +private class DefaultRowColors( + private val titleColor: Color, + private val iconColor: Color, + private val disabledTitleColor: Color, + private val disabledIconColor: Color, +) : RowColors { + @Composable + override fun titleColor(enabled: Boolean): State { + return animateColorAsState( + targetValue = if (enabled) { + titleColor + } else { + disabledTitleColor + }, + ) + } + + @Composable + override fun subtitleColor(enabled: Boolean): State { + return rememberUpdatedState(newValue = TangemTheme.colors.text.secondary) + } + + @Composable + override fun iconColor(enabled: Boolean): State { + return animateColorAsState( + targetValue = if (enabled) { + iconColor + } else { + disabledIconColor + }, + ) + } +} + +@Stable +interface RowColors { + @Suppress("TopLevelComposableFunctions") + @Composable + fun titleColor(enabled: Boolean): State + + @Suppress("TopLevelComposableFunctions") + @Composable + fun subtitleColor(enabled: Boolean): State + + @Suppress("TopLevelComposableFunctions") + @Composable + fun iconColor(enabled: Boolean): State } \ No newline at end of file diff --git a/core/ui/src/main/res/drawable/ic_hide_24.xml b/core/ui/src/main/res/drawable/ic_hide_24.xml new file mode 100644 index 0000000000..64b5a4c393 --- /dev/null +++ b/core/ui/src/main/res/drawable/ic_hide_24.xml @@ -0,0 +1,19 @@ + + + + diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt index 69902f587b..2c1bac9277 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/common/WalletPreviewData.kt @@ -312,6 +312,7 @@ internal object WalletPreviewData { TokenActionButtonConfig( text = TextReference.Str("Send"), iconResId = R.drawable.ic_share_24, + isWarning = false, onClick = {}, ), ).toImmutableList(), diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/TokenActionButtonConfig.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/TokenActionButtonConfig.kt index 2c95c35f55..db94522760 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/TokenActionButtonConfig.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/TokenActionButtonConfig.kt @@ -9,11 +9,13 @@ import com.tangem.core.ui.extensions.TextReference * @property text text * @property iconResId icon resource id * @property onClick lambda be invoked when action component is clicked + * @property isWarning if warning row * @property enabled enabled */ data class TokenActionButtonConfig( val text: TextReference, @DrawableRes val iconResId: Int, val onClick: () -> Unit, + val isWarning: Boolean, val enabled: Boolean = true, ) \ No newline at end of file diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/TokenActionsProvider.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/TokenActionsProvider.kt index b7b52537f5..9b60ca31e3 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/TokenActionsProvider.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/factory/TokenActionsProvider.kt @@ -98,7 +98,7 @@ internal class TokenActionsProvider( } is TokenActionsState.ActionState.HideToken -> { title = resourceReference(R.string.token_details_hide_token) - icon = R.drawable.ic_trash_24 + icon = R.drawable.ic_hide_24 action = { clickIntents.onHideTokensClick(cryptoCurrencyStatus) } } } @@ -106,6 +106,7 @@ internal class TokenActionsProvider( text = title, iconResId = icon, onClick = action, + isWarning = actionsState is TokenActionsState.ActionState.HideToken, enabled = actionsState.enabled, ) } diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt index c729131842..104b25308d 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/ui/components/TokenActionsBottomSheet.kt @@ -10,6 +10,8 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter import com.tangem.core.ui.components.SimpleSettingsRow import com.tangem.core.ui.components.bottomsheets.TangemBottomSheet import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig +import com.tangem.core.ui.components.getDefaultRowColors +import com.tangem.core.ui.components.getWarningRowColors import com.tangem.core.ui.extensions.resolveReference import com.tangem.core.ui.res.TangemTheme import com.tangem.feature.wallet.presentation.common.WalletPreviewData @@ -29,10 +31,16 @@ private fun ActionsBottomSheetContent(actions: ImmutableList if (action.enabled) { + val rowColors = if (action.isWarning) { + getWarningRowColors() + } else { + getDefaultRowColors() + } SimpleSettingsRow( title = action.text.resolveReference(), icon = action.iconResId, enabled = action.enabled, + rowColors = rowColors, onItemsClick = action.onClick, ) }