From 30ed01cb2fc3ae9c60de447c4ec5bf6c73c6fcc9 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 23 May 2024 14:48:16 +0800 Subject: [PATCH] Updated on 2026-08-14 --- .../core/ui/components/ButtonsDeprecated.kt | 176 ------------------ .../com/tangem/core/ui/res/ButtonColorType.kt | 24 --- .../com/tangem/core/ui/res/IconColorType.kt | 32 ---- .../com/tangem/core/ui/res/TextColorType.kt | 32 ---- .../referral/ui/NonParticipateBottomBlock.kt | 12 +- .../referral/ui/ParticipateBottomBlock.kt | 10 +- 6 files changed, 13 insertions(+), 273 deletions(-) delete mode 100644 core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt delete mode 100644 core/ui/src/main/java/com/tangem/core/ui/res/ButtonColorType.kt delete mode 100644 core/ui/src/main/java/com/tangem/core/ui/res/IconColorType.kt delete mode 100644 core/ui/src/main/java/com/tangem/core/ui/res/TextColorType.kt diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt b/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt deleted file mode 100644 index e8612296a5..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/components/ButtonsDeprecated.kt +++ /dev/null @@ -1,176 +0,0 @@ -package com.tangem.core.ui.components - -import android.content.res.Configuration -import androidx.annotation.DrawableRes -import androidx.compose.foundation.layout.RowScope -import androidx.compose.foundation.layout.fillMaxWidth -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.shape.RoundedCornerShape -import androidx.compose.material.Button -import androidx.compose.material.ButtonDefaults -import androidx.compose.material.Icon -import androidx.compose.material.MaterialTheme -import androidx.compose.material.Text -import androidx.compose.runtime.Composable -import androidx.compose.ui.Modifier -import androidx.compose.ui.res.painterResource -import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.R -import com.tangem.core.ui.res.ButtonColorType -import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.core.ui.res.TangemTheme -import com.tangem.core.ui.res.TextColorType -import com.tangem.core.ui.res.buttonColor -import com.tangem.core.ui.res.textColor - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun Preview_PrimaryStartIconButton_Enabled() { - TangemThemePreview { - PrimaryStartIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = true, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun Preview_PrimaryStartIconButton_Disabled() { - TangemThemePreview { - PrimaryStartIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = false, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun Preview_PrimaryEndIconButton_Enabled() { - TangemThemePreview { - PrimaryEndIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = true, - onClick = {}, - ) - } -} - -@Preview(widthDp = 328, heightDp = 48, showBackground = true) -@Preview(widthDp = 328, heightDp = 48, showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -private fun Preview_PrimaryEndIconButton_Disabled() { - TangemThemePreview { - PrimaryEndIconButton( - text = "Manage tokens", - iconResId = R.drawable.ic_tangem_24, - enabled = false, - onClick = {}, - ) - } -} - -/** - * Primary button with an icon at the beginning of the layout - * - * @param modifier button modifier - * @param text button text - * @param iconResId button icon res id - * @param enabled controls the enabled state of the button - * @param onClick the lambda to be invoked when this button is pressed - * - * @see Figma component - */ -@Deprecated("Use PrimaryButtonIconRight instead") -@Composable -fun PrimaryStartIconButton( - text: String, - @DrawableRes iconResId: Int, - onClick: () -> Unit, - modifier: Modifier = Modifier, - enabled: Boolean = true, -) { - PrimaryButtonRow( - modifier = modifier, - enabled = enabled, - onClick = onClick, - content = { - Icon( - painter = painterResource(id = iconResId), - contentDescription = null, - ) - SpacerW8() - Text(text = text) - }, - ) -} - -/** - * Primary button with an icon at the end of the layout - * - * @param modifier button modifier - * @param text button text - * @param iconResId button icon res id - * @param enabled controls the enabled state of the button - * @param onClick the lambda to be invoked when this button is pressed - * - * @see Figma component - */ -@Deprecated("Use PrimaryButtonIconLeft instead") -@Composable -fun PrimaryEndIconButton( - text: String, - @DrawableRes iconResId: Int, - onClick: () -> Unit, - modifier: Modifier = Modifier, - enabled: Boolean = true, -) { - PrimaryButtonRow( - modifier = modifier, - enabled = enabled, - onClick = onClick, - content = { - Text(text = text) - SpacerW8() - Icon( - painter = painterResource(id = iconResId), - contentDescription = null, - ) - }, - ) -} - -@Composable -private fun PrimaryButtonRow( - enabled: Boolean, - onClick: () -> Unit, - content: @Composable (RowScope.() -> Unit), - modifier: Modifier = Modifier, -) { - Button( - onClick = onClick, - modifier = modifier - .fillMaxWidth() - .height(TangemTheme.dimens.size48), - enabled = enabled, - shape = RoundedCornerShape(TangemTheme.dimens.radius12), - colors = ButtonDefaults.buttonColors( - backgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.PRIMARY), - contentColor = MaterialTheme.colors.textColor(type = TextColorType.PRIMARY2), - disabledBackgroundColor = MaterialTheme.colors.buttonColor(type = ButtonColorType.DISABLED), - disabledContentColor = MaterialTheme.colors.textColor(type = TextColorType.DISABLED), - ), - content = content, - ) -} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColorType.kt b/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColorType.kt deleted file mode 100644 index 2e45dc7577..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColorType.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.tangem.core.ui.res - -import androidx.compose.material.Colors -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import com.tangem.core.ui.res.TangemColorPalette.Dark5 -import com.tangem.core.ui.res.TangemColorPalette.Dark6 -import com.tangem.core.ui.res.TangemColorPalette.DarkGreen -import com.tangem.core.ui.res.TangemColorPalette.Light1 -import com.tangem.core.ui.res.TangemColorPalette.Light2 -import com.tangem.core.ui.res.TangemColorPalette.MagicMint -import com.tangem.core.ui.res.TangemColorPalette.Meadow - -@Deprecated("Use TangemTheme.colors") -enum class ButtonColorType(val lightColor: Color, val darkColor: Color) { - PRIMARY(lightColor = Dark6, darkColor = Light1), - SECONDARY(lightColor = Light2, darkColor = Dark5), - DISABLED(lightColor = Light2, darkColor = Dark6), - POSITIVE(lightColor = Meadow, darkColor = Meadow), - POSITIVE_DISABLED(lightColor = MagicMint, darkColor = DarkGreen), -} - -@Composable -fun Colors.buttonColor(type: ButtonColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/IconColorType.kt b/core/ui/src/main/java/com/tangem/core/ui/res/IconColorType.kt deleted file mode 100644 index 42b0e53057..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/res/IconColorType.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.tangem.core.ui.res - -import androidx.compose.material.Colors -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import com.tangem.core.ui.res.TangemColorPalette.Amaranth -import com.tangem.core.ui.res.TangemColorPalette.Azure -import com.tangem.core.ui.res.TangemColorPalette.Black -import com.tangem.core.ui.res.TangemColorPalette.Dark1 -import com.tangem.core.ui.res.TangemColorPalette.Dark2 -import com.tangem.core.ui.res.TangemColorPalette.Dark4 -import com.tangem.core.ui.res.TangemColorPalette.Dark6 -import com.tangem.core.ui.res.TangemColorPalette.Light4 -import com.tangem.core.ui.res.TangemColorPalette.Light5 -import com.tangem.core.ui.res.TangemColorPalette.Mustard -import com.tangem.core.ui.res.TangemColorPalette.Tangerine -import com.tangem.core.ui.res.TangemColorPalette.White - -@Deprecated("Use TangemTheme.colors") -enum class IconColorType(val lightColor: Color, val darkColor: Color) { - PRIMARY1(lightColor = Black, darkColor = White), - PRIMARY2(lightColor = White, darkColor = Dark6), - SECONDARY(lightColor = Dark2, darkColor = Dark1), - INFORMATIVE(lightColor = Light5, darkColor = Dark2), - INACTIVE(lightColor = Light4, darkColor = Dark4), - ACCENT(lightColor = Azure, darkColor = Azure), - WARNING(lightColor = Amaranth, darkColor = Amaranth), - ATTENTION(lightColor = Tangerine, darkColor = Mustard), -} - -@Composable -fun Colors.iconColor(type: IconColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TextColorType.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TextColorType.kt deleted file mode 100644 index b093f4f7af..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TextColorType.kt +++ /dev/null @@ -1,32 +0,0 @@ -package com.tangem.core.ui.res - -import androidx.compose.material.Colors -import androidx.compose.runtime.Composable -import androidx.compose.ui.graphics.Color -import com.tangem.core.ui.res.TangemColorPalette.Amaranth -import com.tangem.core.ui.res.TangemColorPalette.Dark1 -import com.tangem.core.ui.res.TangemColorPalette.Dark2 -import com.tangem.core.ui.res.TangemColorPalette.Dark3 -import com.tangem.core.ui.res.TangemColorPalette.Dark6 -import com.tangem.core.ui.res.TangemColorPalette.Light4 -import com.tangem.core.ui.res.TangemColorPalette.Light5 -import com.tangem.core.ui.res.TangemColorPalette.Meadow -import com.tangem.core.ui.res.TangemColorPalette.Mustard -import com.tangem.core.ui.res.TangemColorPalette.Tangerine -import com.tangem.core.ui.res.TangemColorPalette.White - -@Deprecated("Use TangemTheme.colors") -enum class TextColorType(val lightColor: Color, val darkColor: Color) { - PRIMARY1(lightColor = Dark6, darkColor = White), - PRIMARY2(lightColor = White, darkColor = Dark6), - SECONDARY(lightColor = Dark2, darkColor = Light5), - TERTIARY(lightColor = Dark1, darkColor = Dark1), - DISABLED(lightColor = Light4, darkColor = Dark3), - ACCENT(lightColor = Meadow, darkColor = Meadow), - WARNING(lightColor = Amaranth, darkColor = Amaranth), - ATTENTION(lightColor = Tangerine, darkColor = Mustard), - CONSTANT_WHITE(lightColor = White, darkColor = White), -} - -@Composable -fun Colors.textColor(type: TextColorType): Color = if (IS_SYSTEM_IN_DARK_THEME) type.darkColor else type.lightColor \ No newline at end of file diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt index d79e4a6f6b..077fb745d0 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/NonParticipateBottomBlock.kt @@ -3,14 +3,15 @@ package com.tangem.feature.referral.ui import android.content.res.Configuration import androidx.compose.foundation.background import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview -import com.tangem.core.ui.components.PrimaryEndIconButton -import com.tangem.core.ui.res.TangemThemePreview +import com.tangem.core.ui.components.PrimaryButtonIconEnd import com.tangem.core.ui.res.TangemTheme +import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.referral.presentation.R @Composable @@ -20,11 +21,14 @@ internal fun NonParticipateBottomBlock(onAgreementClick: () -> Unit, onParticipa firstPartResId = R.string.referral_tos_not_enroled_prefix, onClick = onAgreementClick, ) - PrimaryEndIconButton( - modifier = Modifier.padding(all = TangemTheme.dimens.spacing16), + + PrimaryButtonIconEnd( text = stringResource(id = R.string.referral_button_participate), iconResId = R.drawable.ic_tangem_24, onClick = onParticipateClick, + modifier = Modifier + .fillMaxWidth() + .padding(all = TangemTheme.dimens.spacing16), ) } } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt index 7890ba08a7..39257e4570 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ParticipateBottomBlock.kt @@ -25,7 +25,7 @@ import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.PreviewParameter import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider import androidx.core.content.ContextCompat.startActivity -import com.tangem.core.ui.components.PrimaryStartIconButton +import com.tangem.core.ui.components.PrimaryButtonIconStart import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview import com.tangem.feature.referral.domain.models.ExpectedAward @@ -281,8 +281,7 @@ private fun AdditionalButtons( modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(TangemTheme.dimens.spacing16), ) { - PrimaryStartIconButton( - modifier = Modifier.weight(1f), + PrimaryButtonIconStart( text = stringResource(id = R.string.common_copy), iconResId = R.drawable.ic_copy_24, onClick = { @@ -297,11 +296,11 @@ private fun AdditionalButtons( ) } }, + modifier = Modifier.weight(1f), ) val context = LocalContext.current - PrimaryStartIconButton( - modifier = Modifier.weight(1f), + PrimaryButtonIconStart( text = stringResource(id = R.string.common_share), iconResId = R.drawable.ic_share_24, onClick = { @@ -309,6 +308,7 @@ private fun AdditionalButtons( hapticFeedback.performHapticFeedback(HapticFeedbackType.LongPress) context.shareText(context.getString(R.string.referral_share_link, shareLink)) }, + modifier = Modifier.weight(1f), ) } }