diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt index 65b331e15c..cc09da8dbc 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Buttons.kt @@ -27,7 +27,7 @@ import com.tangem.core.ui.res.textColor @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryStartIconButton_Enabled_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { PrimaryStartIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = true, onClicked = {}) } } @@ -35,7 +35,7 @@ fun Preview_PrimaryStartIconButton_Enabled_InLightTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryStartIconButton_Enabled_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { PrimaryStartIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = true, onClicked = {}) } } @@ -43,7 +43,7 @@ fun Preview_PrimaryStartIconButton_Enabled_InDarkTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryStartIconButton_Disabled_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { PrimaryStartIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem, @@ -56,7 +56,7 @@ fun Preview_PrimaryStartIconButton_Disabled_InLightTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryStartIconButton_Disabled_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { PrimaryStartIconButton( text = "Manage tokens", iconResId = R.drawable.ic_tangem, @@ -69,7 +69,7 @@ fun Preview_PrimaryStartIconButton_Disabled_InDarkTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryEndIconButton_Enabled_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { PrimaryEndIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = true, onClicked = {}) } } @@ -77,7 +77,7 @@ fun Preview_PrimaryEndIconButton_Enabled_InLightTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryEndIconButton_Enabled_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { PrimaryEndIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = true, onClicked = {}) } } @@ -85,7 +85,7 @@ fun Preview_PrimaryEndIconButton_Enabled_InDarkTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryEndIconButton_Disabled_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { PrimaryEndIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = false, onClicked = {}) } } @@ -93,7 +93,7 @@ fun Preview_PrimaryEndIconButton_Disabled_InLightTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_PrimaryEndIconButton_Disabled_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { PrimaryEndIconButton(text = "Manage tokens", iconResId = R.drawable.ic_tangem, enabled = false, onClicked = {}) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt index 57a47dff46..ef25595ace 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/Cards.kt @@ -22,7 +22,7 @@ import com.tangem.core.ui.res.textColor @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_SimpleInfoCard_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { SmallInfoCard(startText = "Balance", endText = "0.4405434 BTC") } } @@ -30,7 +30,7 @@ fun Preview_SimpleInfoCard_InLightTheme() { @Preview(widthDp = 328, heightDp = 48, showBackground = true) @Composable fun Preview_SimpleInfoCard_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { SmallInfoCard(startText = "Balance", endText = "0.4405434 BTC") } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt index 73cca24307..34f25fe87c 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithAdditionalButtons.kt @@ -79,7 +79,7 @@ fun AppBarWithAdditionalButtons( @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithAdditionalButtons_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -97,7 +97,7 @@ fun Preview_AppBarWithAdditionalButtons_InLightTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithAdditionalButtons_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -115,7 +115,7 @@ fun Preview_AppBarWithAdditionalButtons_InDarkTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithOnlyStartButtons_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -129,7 +129,7 @@ fun Preview_AppBarWithOnlyStartButtons_InLightTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithOnlyStartButtons_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { AppBarWithAdditionalButtons( text = "Tangem", startButton = AdditionalButton( @@ -143,7 +143,7 @@ fun Preview_AppBarWithOnlyStartButtons_InDarkTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithOnlyEndButtons_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { AppBarWithAdditionalButtons( text = "Tangem", endButton = AdditionalButton( @@ -157,7 +157,7 @@ fun Preview_AppBarWithOnlyEndButtons_InLightTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun Preview_AppBarWithOnlyEndButtons_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { AppBarWithAdditionalButtons( text = "Tangem", endButton = AdditionalButton( diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt index 99d6aa527a..629f6f7592 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/appbar/AppBarWithBackButton.kt @@ -21,7 +21,7 @@ import com.tangem.core.ui.res.TangemTheme @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun PreviewAppBarWithBackButtonInLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { AppBarWithBackButton(text = "Title", onBackClick = {}) } } @@ -29,7 +29,7 @@ fun PreviewAppBarWithBackButtonInLightTheme() { @Preview(widthDp = 360, heightDp = 56, showBackground = true) @Composable fun PreviewAppBarWithBackButtonInDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { AppBarWithBackButton(text = "Title", onBackClick = {}) } } diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt index edf127e645..800b674c51 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/components/atoms/BottomSheetIndicator.kt @@ -46,7 +46,7 @@ fun BottomSheetIndicator() { @Preview(heightDp = 20, showBackground = true) @Composable fun Preview_BottomSheetIndicator_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { BottomSheetIndicator() } } @@ -54,7 +54,7 @@ fun Preview_BottomSheetIndicator_InLightTheme() { @Preview(heightDp = 20, showBackground = true) @Composable fun Preview_BottomSheetIndicator_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { BottomSheetIndicator() } } \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColor.kt b/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColor.kt index cb6607c8a3..427be16fe5 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColor.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/ButtonColor.kt @@ -3,7 +3,15 @@ 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), diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/Color.kt b/core/ui/src/main/java/com/tangem/core/ui/res/Color.kt deleted file mode 100644 index 4d37ecee45..0000000000 --- a/core/ui/src/main/java/com/tangem/core/ui/res/Color.kt +++ /dev/null @@ -1,45 +0,0 @@ -package com.tangem.core.ui.res - -import androidx.compose.ui.graphics.Color - -// region Base -val Black = Color(0xFF000000) -val White = Color(0xFFFFFFFF) -// endregion Base - -// region Dark -val Dark1 = Color(0xFF919191) -val Dark2 = Color(0xFF656565) -val Dark3 = Color(0xFF494949) -val Dark4 = Color(0xFF3B3B3B) -val Dark5 = Color(0xFF303030) -val Dark6 = Color(0xFF1E1E1E) -// endregion Dark - -// region Light -val Light1 = Color(0xFFF5F5F5) -val Light2 = Color(0xFFEBEBEB) -val Light3 = Color(0xFFD3D3D3) -val Light4 = Color(0xFFC9C9C9) -val Light5 = Color(0xFFB0B0B0) -// endregion Light - -// region Green -val Meadow = Color(0xFF1ACE80) -val MagicMint = Color(0xFFA3EBCC) -val DarkGreen = Color(0xFF06311F) -// endregion Green - -// region Blue -val Cobalt = Color(0xFF0029FF) -val Azure = Color(0xFF007AFF) -// endregion Blue - -// region Red -val Amaranth = Color(0xFFDE1010) -val Flamingo = Color(0xFFED7979) -// endregion Red - -// region Yellow -val Tangerine = Color(0xFFFFB71B) -// endregion Yellow \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/IconColor.kt b/core/ui/src/main/java/com/tangem/core/ui/res/IconColor.kt index 72cc8936bb..11dab52a7b 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/IconColor.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/IconColor.kt @@ -3,7 +3,19 @@ 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.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.Meadow +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), diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemColorPalette.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemColorPalette.kt new file mode 100644 index 0000000000..5f9617639f --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemColorPalette.kt @@ -0,0 +1,48 @@ +package com.tangem.core.ui.res + +import androidx.compose.ui.graphics.Color + +@Suppress("unused") +object TangemColorPalette { + // region Base + val Black = Color(0xFF000000) + val White = Color(0xFFFFFFFF) + // endregion Base + + // region Dark + val Dark1 = Color(0xFF919191) + val Dark2 = Color(0xFF656565) + val Dark3 = Color(0xFF494949) + val Dark4 = Color(0xFF3B3B3B) + val Dark5 = Color(0xFF303030) + val Dark6 = Color(0xFF1E1E1E) + // endregion Dark + + // region Light + val Light1 = Color(0xFFF5F5F5) + val Light2 = Color(0xFFEBEBEB) + val Light3 = Color(0xFFD3D3D3) + val Light4 = Color(0xFFC9C9C9) + val Light5 = Color(0xFFB0B0B0) + // endregion Light + + // region Green + val Meadow = Color(0xFF1ACE80) + val MagicMint = Color(0xFFA3EBCC) + val DarkGreen = Color(0xFF06311F) + // endregion Green + + // region Blue + val Cobalt = Color(0xFF0029FF) + val Azure = Color(0xFF007AFF) + // endregion Blue + + // region Red + val Amaranth = Color(0xFFDE1010) + val Flamingo = Color(0xFFED7979) + // endregion Red + + // region Yellow + val Tangerine = Color(0xFFFFB71B) + // endregion Yellow +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemColors.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemColors.kt new file mode 100644 index 0000000000..371e70d22e --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemColors.kt @@ -0,0 +1,237 @@ +package com.tangem.core.ui.res + +import androidx.compose.runtime.Stable +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue +import androidx.compose.ui.graphics.Color + +@Suppress("unused", "MemberVisibilityCanBePrivate") +@Stable +class TangemColors internal constructor( + text: Text, + icon: Icon, + button: Button, + background: Background, + control: Control, + stroke: Stroke, + field: Field, +) { + var text by mutableStateOf(text) + private set + var icon by mutableStateOf(icon) + private set + var button by mutableStateOf(button) + private set + var background by mutableStateOf(background) + private set + var control by mutableStateOf(control) + private set + var stroke by mutableStateOf(stroke) + private set + var field by mutableStateOf(field) + private set + + @Stable + class Text internal constructor( + primary1: Color, + primary2: Color, + secondary: Color, + tertiary: Color, + disabled: Color, + accent: Color = TangemColorPalette.Meadow, + warning: Color = TangemColorPalette.Amaranth, + attention: Color = TangemColorPalette.Tangerine, + constantWhite: Color = TangemColorPalette.White, + ) { + var primary1 by mutableStateOf(primary1) + private set + var primary2 by mutableStateOf(primary2) + private set + var secondary by mutableStateOf(secondary) + private set + var tertiary by mutableStateOf(tertiary) + private set + var disabled by mutableStateOf(disabled) + private set + var accent by mutableStateOf(accent) + private set + var warning by mutableStateOf(warning) + private set + var attention by mutableStateOf(attention) + private set + var constantWhite by mutableStateOf(constantWhite) + private set + + fun update(other: Text) { + primary1 = other.primary1 + primary2 = other.primary2 + secondary = other.secondary + tertiary = other.tertiary + disabled = other.disabled + accent = other.accent + } + } + + @Stable + class Icon internal constructor( + primary1: Color, + primary2: Color, + secondary: Color, + informative: Color, + inactive: Color, + accent: Color = TangemColorPalette.Meadow, + warning: Color = TangemColorPalette.Amaranth, + attention: Color = TangemColorPalette.Tangerine, + ) { + var primary1 by mutableStateOf(primary1) + private set + var primary2 by mutableStateOf(primary2) + private set + var secondary by mutableStateOf(secondary) + private set + var informative by mutableStateOf(informative) + private set + var inactive by mutableStateOf(inactive) + private set + var accent by mutableStateOf(accent) + private set + var warning by mutableStateOf(warning) + private set + var attention by mutableStateOf(attention) + private set + + fun update(other: Icon) { + primary1 = other.primary1 + primary2 = other.primary2 + secondary = other.secondary + informative = other.informative + inactive = other.inactive + accent = other.accent + warning = other.warning + attention = other.attention + } + } + + @Stable + class Button internal constructor( + primary: Color, + secondary: Color, + disabled: Color, + positive: Color = TangemColorPalette.Meadow, + positiveDisabled: Color, + ) { + var primary by mutableStateOf(primary) + private set + var secondary by mutableStateOf(secondary) + private set + var disabled by mutableStateOf(disabled) + private set + var positive by mutableStateOf(positive) + private set + var positiveDisabled by mutableStateOf(positiveDisabled) + private set + + fun update(other: Button) { + primary = other.primary + secondary = other.secondary + disabled = other.disabled + positive = other.positive + positiveDisabled = other.positiveDisabled + } + } + + @Stable + class Background internal constructor( + primary: Color, + secondary: Color, + plain: Color, + action: Color, + fade: Color, + ) { + var primary by mutableStateOf(primary) + private set + var secondary by mutableStateOf(secondary) + private set + var plain by mutableStateOf(plain) + private set + var action by mutableStateOf(action) + private set + var fade by mutableStateOf(fade) + private set + + fun update(other: Background) { + primary = other.primary + secondary = other.secondary + plain = other.plain + action = other.action + fade = other.fade + } + } + + @Stable + class Control internal constructor( + checked: Color, + unchecked: Color, + key: Color, + ) { + var checked by mutableStateOf(checked) + private set + var unchecked by mutableStateOf(unchecked) + private set + var key by mutableStateOf(key) + private set + + fun update(other: Control) { + checked = other.checked + unchecked = other.unchecked + key = other.key + } + } + + @Stable + class Stroke internal constructor( + primary: Color, + secondary: Color, + transparency: Color, + ) { + var primary by mutableStateOf(primary) + private set + var secondary by mutableStateOf(secondary) + private set + var transparency by mutableStateOf(transparency) + private set + + fun update(other: Stroke) { + primary = other.primary + secondary = other.secondary + transparency = other.transparency + } + } + + @Stable + class Field internal constructor( + primary: Color, + focused: Color, + ) { + var primary by mutableStateOf(primary) + private set + var focused by mutableStateOf(focused) + private set + + fun update(other: Field) { + primary = other.primary + focused = other.focused + } + } + + fun update(other: TangemColors) { + text.update(other.text) + icon.update(other.icon) + button.update(other.button) + background.update(other.background) + control.update(other.control) + stroke.update(other.stroke) + field.update(other.field) + } +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt new file mode 100644 index 0000000000..441b0bfd52 --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemDimens.kt @@ -0,0 +1,61 @@ +package com.tangem.core.ui.res + +import androidx.compose.runtime.Immutable +import androidx.compose.ui.unit.Dp +import androidx.compose.ui.unit.dp + +@Immutable +data class TangemDimens internal constructor( + // region Elevation + val elevation0: Dp = 0.dp, + val elevation1: Dp = 1.dp, + val elevation2: Dp = 2.dp, + val elevation3: Dp = 3.dp, + val elevation4: Dp = 4.dp, + val elevation6: Dp = 6.dp, + val elevation8: Dp = 8.dp, + val elevation12: Dp = 12.dp, + val elevation16: Dp = 16.dp, + val elevation24: Dp = 24.dp, + // endregion Elevation + // region Radius + val radius2: Dp = 2.dp, + val radius4: Dp = 4.dp, + val radius6: Dp = 6.dp, + val radius12: Dp = 12.dp, + val radius16: Dp = 16.dp, + val radius28: Dp = 28.dp, + // endregion Radius + // region Size + val size0: Dp = 0.dp, + val size4: Dp = 4.dp, + val size8: Dp = 8.dp, + val size11: Dp = 11.dp, + val size16: Dp = 16.dp, + val size20: Dp = 20.dp, + val size24: Dp = 24.dp, + val size28: Dp = 28.dp, + val size32: Dp = 32.dp, + val size40: Dp = 40.dp, + val size48: Dp = 48.dp, + val size56: Dp = 56.dp, + val size84: Dp = 84.dp, + val size86: Dp = 86.dp, + val size102: Dp = 102.dp, + val size164: Dp = 164.dp, + val size200: Dp = 200.dp, + // endregion Size + // region Spacing + val spacing2: Dp = 2.dp, + val spacing4: Dp = 4.dp, + val spacing8: Dp = 8.dp, + val spacing10: Dp = 10.dp, + val spacing12: Dp = 12.dp, + val spacing16: Dp = 16.dp, + val spacing24: Dp = 24.dp, + val spacing32: Dp = 32.dp, + val spacing44: Dp = 44.dp, + val spacing50: Dp = 50.dp, + val spacing54: Dp = 54.dp, + // endregion Spacing +) \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt new file mode 100644 index 0000000000..99a87a701e --- /dev/null +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemShapes.kt @@ -0,0 +1,22 @@ +package com.tangem.core.ui.res + +import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.runtime.Immutable +import androidx.compose.ui.graphics.Shape + +@Immutable +data class TangemShapes internal constructor( + val roundedCornersSmall: Shape, + val roundedCornersSmall2: Shape, + val roundedCornersMedium: Shape, + val roundedCornersLarge: Shape, + val bottomSheet: Shape, +) { + constructor(dimens: TangemDimens) : this( + roundedCornersSmall = RoundedCornerShape(size = dimens.radius2), + roundedCornersSmall2 = RoundedCornerShape(size = dimens.radius4), + roundedCornersMedium = RoundedCornerShape(size = dimens.radius12), + roundedCornersLarge = RoundedCornerShape(size = dimens.radius28), + bottomSheet = RoundedCornerShape(size = dimens.radius16), + ) +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TangemTheme.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TangemTheme.kt index ebd0da2f57..8ff81a2640 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TangemTheme.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TangemTheme.kt @@ -1,53 +1,200 @@ package com.tangem.core.ui.res +import androidx.compose.material.Colors import androidx.compose.material.MaterialTheme -import androidx.compose.material.darkColors -import androidx.compose.material.lightColors +import androidx.compose.material.ProvideTextStyle +import androidx.compose.material.Typography import androidx.compose.runtime.Composable -import androidx.compose.runtime.SideEffect -import com.google.accompanist.systemuicontroller.rememberSystemUiController +import androidx.compose.runtime.CompositionLocalProvider +import androidx.compose.runtime.ReadOnlyComposable +import androidx.compose.runtime.Stable +import androidx.compose.runtime.remember +import androidx.compose.runtime.staticCompositionLocalOf internal val isSystemInDarkTheme: Boolean = false // TODO: use isSystemInDarkTheme() for automatic color detection @Composable fun TangemTheme( - isDarkTheme: Boolean = isSystemInDarkTheme, + isDark: Boolean = false, + typography: Typography = TangemTheme.typography, + dimens: TangemDimens = TangemTheme.dimens, content: @Composable () -> Unit, ) { - val systemUiController = rememberSystemUiController() - SideEffect { - systemUiController.setSystemBarsColor(color = if (isDarkTheme) Black else Light1, darkIcons = !isDarkTheme) - } + val themeColors = if (isDark) darkThemeColors() else lightThemeColors() + val rememberedColors = remember { themeColors } + .also { it.update(themeColors) } + + val shapes = remember { TangemShapes(dimens) } MaterialTheme( - colors = if (isDarkTheme) DarkColors else LightColors, - typography = TangemTypography, - content = content, + colors = materialThemeColors(colors = themeColors, isDark = isDark), + typography = typography, + ) { + CompositionLocalProvider( + LocalTangemColors provides rememberedColors, + LocalTangemTypography provides typography, + LocalTangemDimens provides dimens, + LocalTangemShapes provides shapes, + ) { + ProvideTextStyle( + value = TangemTheme.typography.body1, + content = content, + ) + } + } +} + +object TangemTheme { + val colors: TangemColors + @Composable + @ReadOnlyComposable + get() = LocalTangemColors.current + + val typography: Typography + @Composable + @ReadOnlyComposable + get() = LocalTangemTypography.current + + val dimens: TangemDimens + @Composable + @ReadOnlyComposable + get() = LocalTangemDimens.current + + val shapes: TangemShapes + @Composable + @ReadOnlyComposable + get() = LocalTangemShapes.current +} + +@Stable +@Composable +private fun materialThemeColors( + colors: TangemColors, + isDark: Boolean, +): Colors { + return Colors( + primary = colors.background.primary, + primaryVariant = colors.background.secondary, + secondary = colors.button.primary, + secondaryVariant = colors.text.accent, + background = colors.background.primary, + surface = colors.background.plain, + error = colors.text.warning, + onPrimary = colors.text.primary1, + onSecondary = colors.text.primary1, + onBackground = colors.text.primary1, + onSurface = colors.text.primary1, + onError = colors.text.primary2, + isLight = !isDark, ) } -private val LightColors = lightColors( - primary = Light1, - primaryVariant = Light1, - secondary = White, - background = Light1, - surface = White, - error = Amaranth, - onPrimary = Dark6, - onSecondary = Dark6, - onBackground = Dark6, - onSurface = Dark6, -) +@Composable +private fun lightThemeColors(): TangemColors { + return TangemColors( + text = TangemColors.Text( + primary1 = TangemColorPalette.Dark6, + primary2 = TangemColorPalette.White, + secondary = TangemColorPalette.Dark2, + tertiary = TangemColorPalette.Dark1, + disabled = TangemColorPalette.Light4, + ), + icon = TangemColors.Icon( + primary1 = TangemColorPalette.Black, + primary2 = TangemColorPalette.White, + secondary = TangemColorPalette.Dark2, + informative = TangemColorPalette.Light5, + inactive = TangemColorPalette.Light4, + ), + button = TangemColors.Button( + primary = TangemColorPalette.Dark6, + secondary = TangemColorPalette.Light2, + disabled = TangemColorPalette.Light2, + positiveDisabled = TangemColorPalette.MagicMint, + ), + background = TangemColors.Background( + primary = TangemColorPalette.White, + secondary = TangemColorPalette.Light1, + plain = TangemColorPalette.White, + action = TangemColorPalette.Black, + fade = TangemColorPalette.White, + ), + control = TangemColors.Control( + checked = TangemColorPalette.Meadow, + unchecked = TangemColorPalette.Light2, + key = TangemColorPalette.White, + ), + stroke = TangemColors.Stroke( + primary = TangemColorPalette.Light2, + secondary = TangemColorPalette.Dark4, + transparency = TangemColorPalette.White, + ), + field = TangemColors.Field( + primary = TangemColorPalette.Light1, + focused = TangemColorPalette.Light2, + ), + ) +} -private val DarkColors = darkColors( - primary = Black, - primaryVariant = Black, - secondary = Dark6, - background = Black, - surface = Dark6, - error = Amaranth, - onPrimary = White, - onSecondary = White, - onBackground = White, - onSurface = White, -) \ No newline at end of file +@Composable +private fun darkThemeColors(): TangemColors { + return TangemColors( + text = TangemColors.Text( + primary1 = TangemColorPalette.White, + primary2 = TangemColorPalette.Dark6, + secondary = TangemColorPalette.Light5, + tertiary = TangemColorPalette.Dark1, + disabled = TangemColorPalette.Dark3, + ), + icon = TangemColors.Icon( + primary1 = TangemColorPalette.White, + primary2 = TangemColorPalette.Dark6, + secondary = TangemColorPalette.Dark1, + informative = TangemColorPalette.Dark2, + inactive = TangemColorPalette.Dark4, + ), + button = TangemColors.Button( + primary = TangemColorPalette.Light1, + secondary = TangemColorPalette.Dark5, + disabled = TangemColorPalette.Dark6, + positiveDisabled = TangemColorPalette.DarkGreen, + ), + background = TangemColors.Background( + primary = TangemColorPalette.Dark6, + secondary = TangemColorPalette.Black, + plain = TangemColorPalette.Black, + action = TangemColorPalette.Light4, + fade = TangemColorPalette.Black, + ), + control = TangemColors.Control( + checked = TangemColorPalette.Meadow, + unchecked = TangemColorPalette.Dark4, + key = TangemColorPalette.Light1, + ), + stroke = TangemColors.Stroke( + primary = TangemColorPalette.Dark5, + secondary = TangemColorPalette.Dark1, + transparency = TangemColorPalette.Dark6, + ), + field = TangemColors.Field( + primary = TangemColorPalette.Dark5, + focused = TangemColorPalette.Dark4, + ), + ) +} + +private val LocalTangemColors = staticCompositionLocalOf { + error("No TangemColors provided") +} + +private val LocalTangemTypography = staticCompositionLocalOf { + TangemTypography +} + +private val LocalTangemDimens = staticCompositionLocalOf { + TangemDimens() +} + +private val LocalTangemShapes = staticCompositionLocalOf { + error("No TangemShapes provided") +} \ No newline at end of file diff --git a/core/ui/src/main/java/com/tangem/core/ui/res/TextColor.kt b/core/ui/src/main/java/com/tangem/core/ui/res/TextColor.kt index 44f94e1157..0fce11d9e7 100644 --- a/core/ui/src/main/java/com/tangem/core/ui/res/TextColor.kt +++ b/core/ui/src/main/java/com/tangem/core/ui/res/TextColor.kt @@ -3,7 +3,18 @@ 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.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), diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt index a1f8adc86c..e7d30282c8 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementBottomSheetContent.kt @@ -66,7 +66,7 @@ private fun AgreementHtmlView(url: String) { @Preview @Composable fun Preview_AgreementBottomSheet_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { AgreementBottomSheetContent(url = "https://tangem.com/en/") } } @@ -74,7 +74,7 @@ fun Preview_AgreementBottomSheet_InLightTheme() { @Preview @Composable fun Preview_AgreementBottomSheet_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { AgreementBottomSheetContent(url = "https://tangem.com/en/") } } \ No newline at end of file diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt index 133b6b374e..cbdcdaeb50 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/AgreementText.kt @@ -25,7 +25,7 @@ import com.tangem.feature.referral.presentation.R @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_AgreementText_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { Box(modifier = Modifier.background(MaterialTheme.colors.primary)) { AgreementText(firstPartResId = R.string.referral_tou_not_enroled_prefix, onClicked = {}) } @@ -35,7 +35,7 @@ fun Preview_AgreementText_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_AgreementText_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { Box(modifier = Modifier.background(MaterialTheme.colors.primary)) { AgreementText(firstPartResId = R.string.referral_tou_not_enroled_prefix, onClicked = {}) } 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 59b7ab8148..2706490417 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 @@ -26,7 +26,7 @@ import com.tangem.feature.referral.presentation.R @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_NonParticipateBottomBlock_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { Column(Modifier.background(MaterialTheme.colors.primary)) { NonParticipateBottomBlock( purchasedWalletCount = 3, @@ -42,7 +42,7 @@ fun Preview_NonParticipateBottomBlock_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_NonParticipateBottomBlock_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { Column(Modifier.background(MaterialTheme.colors.primary)) { NonParticipateBottomBlock( purchasedWalletCount = 3, 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 7294cbd3f7..f6c6eced81 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 @@ -16,7 +16,7 @@ import com.tangem.feature.referral.presentation.R @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ParticipateBottomBlock_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { Column(Modifier.background(MaterialTheme.colors.primary)) { ParticipateBottomBlock(onAgreementClicked = {}, onParticipateClicked = {}) } @@ -26,7 +26,7 @@ fun Preview_ParticipateBottomBlock_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ParticipateBottomBlock_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { Column(Modifier.background(MaterialTheme.colors.primary)) { ParticipateBottomBlock(onAgreementClicked = {}, onParticipateClicked = {}) } diff --git a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt index a9935a04cc..7091674dcd 100644 --- a/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt +++ b/features/referral/presentation/src/main/java/com/tangem/feature/referral/ui/ReferralScreen.kt @@ -42,9 +42,9 @@ import com.tangem.core.ui.components.VerticalSpacer import com.tangem.core.ui.components.appbar.AppBarWithBackButton import com.tangem.core.ui.res.ButtonColorType import com.tangem.core.ui.res.IconColorType +import com.tangem.core.ui.res.TangemColorPalette import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TextColorType -import com.tangem.core.ui.res.White import com.tangem.core.ui.res.buttonColor import com.tangem.core.ui.res.iconColor import com.tangem.core.ui.res.textColor @@ -291,14 +291,14 @@ private fun ShimmerInfo() { .clip(RoundedCornerShape(dimensionResource(id = R.dimen.radius6))) .width(dimensionResource(id = R.dimen.size102)) .height(dimensionResource(id = R.dimen.size16)) - .background(White), + .background(TangemColorPalette.White), ) Box( modifier = Modifier .clip(RoundedCornerShape(dimensionResource(id = R.dimen.radius6))) .width(dimensionResource(id = R.dimen.size40)) .height(dimensionResource(id = R.dimen.size11)) - .background(White), + .background(TangemColorPalette.White), ) } } @@ -325,7 +325,7 @@ private fun NonParticipantBottomBlock(state: ReferralInfoState.NonParticipantCon @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_Participant_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -347,7 +347,7 @@ fun Preview_ReferralScreen_Participant_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_Participant_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -370,7 +370,7 @@ fun Preview_ReferralScreen_Participant_InDarkTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_NonParticipant_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -395,7 +395,7 @@ fun Preview_ReferralScreen_NonParticipant_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_NonParticipant_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -420,7 +420,7 @@ fun Preview_ReferralScreen_NonParticipant_InDarkTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_Loading_InLightTheme() { - TangemTheme(isDarkTheme = false) { + TangemTheme(isDark = false) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -437,7 +437,7 @@ fun Preview_ReferralScreen_Loading_InLightTheme() { @Preview(widthDp = 360, showBackground = true) @Composable fun Preview_ReferralScreen_Loading_InDarkTheme() { - TangemTheme(isDarkTheme = true) { + TangemTheme(isDark = true) { ReferralScreen( stateHolder = ReferralStateHolder( headerState = ReferralStateHolder.HeaderState(onBackClicked = {}), @@ -449,5 +449,4 @@ fun Preview_ReferralScreen_Loading_InDarkTheme() { ), ) } -} - +} \ No newline at end of file