Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Create True Black mode for amoled screens #3538

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions screen/home/src/main/java/com/ivy/home/HomeMoreMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -445,21 +445,25 @@ private fun QuickAccess(
icon = when (theme) {
Theme.LIGHT -> R.drawable.home_more_menu_light_mode
Theme.DARK -> R.drawable.home_more_menu_dark_mode
Theme.AMOLED_DARK -> R.drawable.home_more_menu_amoled_dark_mode
Theme.AUTO -> R.drawable.home_more_menu_auto_mode
},
label = when (theme) {
Theme.LIGHT -> stringResource(R.string.light_mode)
Theme.DARK -> stringResource(R.string.dark_mode)
Theme.AMOLED_DARK -> stringResource(R.string.amoled_mode)
Theme.AUTO -> stringResource(R.string.auto_mode)
},
backgroundColor = when (theme) {
Theme.LIGHT -> UI.colors.pure
Theme.DARK -> UI.colors.pureInverse
Theme.AMOLED_DARK -> UI.colors.pureInverse
Theme.AUTO -> UI.colors.pure
},
tint = when (theme) {
Theme.LIGHT -> UI.colors.pureInverse
Theme.DARK -> UI.colors.pure
Theme.AMOLED_DARK -> UI.colors.pure
Theme.AUTO -> UI.colors.pureInverse
}
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,13 @@ private fun BoxWithConstraintsScope.UI(
icon = when (theme) {
Theme.LIGHT -> R.drawable.home_more_menu_light_mode
Theme.DARK -> R.drawable.home_more_menu_dark_mode
Theme.AMOLED_DARK -> R.drawable.home_more_menu_amoled_dark_mode
Theme.AUTO -> R.drawable.home_more_menu_auto_mode
},
label = when (theme) {
Theme.LIGHT -> stringResource(R.string.light_mode)
Theme.DARK -> stringResource(R.string.dark_mode)
Theme.AMOLED_DARK -> stringResource(R.string.amoled_mode)
Theme.AUTO -> stringResource(R.string.auto_mode)
}
) {
Expand Down
2 changes: 1 addition & 1 deletion shared/base/src/main/java/com/ivy/base/legacy/Theme.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import androidx.compose.runtime.Immutable
@Deprecated("Old design system. Use `:ivy-design` and Material3")
@Immutable
enum class Theme {
LIGHT, DARK, AUTO
LIGHT, DARK, AUTO, AMOLED_DARK
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import com.ivy.design.system.colors.IvyColors
@Composable
fun IvyMaterial3Theme(
dark: Boolean,
isTrueBlack: Boolean,
content: @Composable () -> Unit
) {
MaterialTheme(
colorScheme = if (dark) ivyDarkColorScheme() else ivyLightColorScheme(),
colorScheme = if (dark) ivyDarkColorScheme(isTrueBlack) else ivyLightColorScheme(),
content = content,
)
}
Expand Down Expand Up @@ -51,7 +52,7 @@ private fun ivyLightColorScheme(): ColorScheme = ColorScheme(
scrim = IvyColors.ExtraDarkGray.copy(alpha = 0.8f)
)

private fun ivyDarkColorScheme(): ColorScheme = ColorScheme(
private fun ivyDarkColorScheme(isTrueBlack: Boolean): ColorScheme = ColorScheme(
primary = IvyColors.Purple.primary,
onPrimary = IvyColors.White,
primaryContainer = IvyColors.Purple.light,
Expand All @@ -71,15 +72,15 @@ private fun ivyDarkColorScheme(): ColorScheme = ColorScheme(
errorContainer = IvyColors.Red.light,
onErrorContainer = IvyColors.White,

background = IvyColors.Black,
background = if (isTrueBlack) IvyColors.TrueBlack else IvyColors.Black,
onBackground = IvyColors.White,
surface = IvyColors.Black,
surface = if (isTrueBlack) IvyColors.TrueBlack else IvyColors.Black,
onSurface = IvyColors.White,
surfaceVariant = IvyColors.ExtraDarkGray,
onSurfaceVariant = IvyColors.White,
surfaceTint = IvyColors.White,
inverseSurface = IvyColors.LightGray,
inverseOnSurface = IvyColors.Black,
inverseOnSurface = if (isTrueBlack) IvyColors.TrueBlack else IvyColors.Black,

outline = IvyColors.Gray,
outlineVariant = IvyColors.LightGray,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ object IvyColors {
val DarkGray = Color(0xFF303033)
val ExtraDarkGray = Color(0xFF1C1C1F)
val Black = Color(0xFF09090A)
val TrueBlack = Color(0xFF000000)
paulolima18 marked this conversation as resolved.
Show resolved Hide resolved

val Red = ColorShades(
extraLight = Color(0xFFF5ABAB),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:pathData="M3.0238,12.38C3.3398,17.0138 7.1752,20.7838 11.7654,20.9907C15.004,21.1347 17.9003,19.5871 19.638,17.1487C20.3577,16.15 19.9716,15.4842 18.7692,15.7091C18.1811,15.8171 17.5755,15.8621 16.9436,15.8351C12.6518,15.6551 9.1412,11.9751 9.1236,7.6292C9.1148,6.4595 9.3518,5.3528 9.7819,4.345C10.2558,3.2293 9.6853,2.6984 8.5882,3.1753C5.1127,4.6779 2.7342,8.268 3.0238,12.38Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#292D32"
android:strokeColor="#292D32"
android:strokeLineCap="round" />
</vector>
1 change: 1 addition & 0 deletions shared/ui/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="settings">Settings</string>
<string name="light_mode">Light mode</string>
<string name="dark_mode">Dark mode</string>
<string name="amoled_mode">Amoled Dark mode</string>
<string name="auto_mode">Auto mode</string>
<string name="planned_payments">Planned\nPayments</string>
<string name="share_ivy">Share Ivy</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ open class PaparazziScreenshotTest {
dark = when (theme) {
PaparazziTheme.Light -> false
PaparazziTheme.Dark -> true
}
},
isTrueBlack = false
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ fun IvyPreview(
content: @Composable () -> Unit,
) {
NavigationRoot(navigation = Navigation()) {
IvyMaterial3Theme(dark = dark, content = content)
IvyMaterial3Theme(dark = dark, isTrueBlack = false, content = content)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ open class PaparazziScreenshotTest {
dark = when (theme) {
PaparazziTheme.Light -> false
PaparazziTheme.Dark -> true
}
},
isTrueBlack = false
) {
content()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class SettingsAct @Inject constructor(
val currentSettings = this(Unit)
val newTheme = when (currentSettings.theme) {
Theme.LIGHT -> Theme.DARK
Theme.DARK -> Theme.AUTO
Theme.DARK -> Theme.AMOLED_DARK
Theme.AMOLED_DARK -> Theme.AUTO
Theme.AUTO -> Theme.LIGHT
}
return currentSettings.copy(theme = newTheme)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,29 @@ abstract class IvyWalletDesign : IvyDesign {
override val isLight = false
}

Theme.AMOLED_DARK -> object : IvyColors {
override val pure = TrueBlack
override val pureInverse = White
override val gray = Gray
override val medium = MediumBlack
override val mediumInverse = MediumWhite

override val primary = Purple
override val primary1 = IvyLight

override val green = Green
override val green1 = GreenDark

override val orange = Orange
override val orange1 = OrangeDark

override val red = Red
override val red1 = RedDark
override val red1Inverse = RedLight

override val isLight = false
}

Theme.AUTO -> if (isDarkModeEnabled) {
colors(Theme.DARK, true)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ val Red2Dark = Color(0xFF802030)
val Red3Dark = Color(0xFF802653)
// --------------------------------------------------------------------------------------------------

@Deprecated("Old design system. Use `:ivy-design` and Material3")
val TrueBlack = Color(0xFF000000)

@Deprecated("Old design system. Use `:ivy-design` and Material3")
val MediumBlack = Color(0xFF2B2C2D)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ fun IvyTheme(

IvyMaterial3Theme(
dark = !colors.isLight,
isTrueBlack = theme == Theme.AMOLED_DARK,
content = content,
)
}
Expand Down