Add scrim, outlineVariant and surfaceTint color to custom color schemes

This commit is contained in:
MM20
2022-10-15 12:42:47 +02:00
parent 0b152a2fa5
commit c47a880d72
8 changed files with 67 additions and 11 deletions
@@ -362,6 +362,20 @@ fun CustomColorSchemeSettingsScreen() {
}
)
ColorPreference(
title = "Surface Tint",
value = lightScheme?.let { Color(it.surfaceTint) },
onValueChanged = {
if (it == null) return@ColorPreference
val colors = lightScheme ?: return@ColorPreference
viewModel.setLightScheme(
colors.toBuilder()
.setSurfaceTint(it.toArgb())
.build()
)
}
)
ColorPreference(
title = "Surface Variant",
value = lightScheme?.let { Color(it.surfaceVariant) },
@@ -711,6 +725,19 @@ fun CustomColorSchemeSettingsScreen() {
)
}
)
ColorPreference(
title = "Surface Tint",
value = darkScheme?.let { Color(it.surfaceTint) },
onValueChanged = {
if (it == null) return@ColorPreference
val colors = darkScheme ?: return@ColorPreference
viewModel.setDarkScheme(
colors.toBuilder()
.setSurfaceTint(it.toArgb())
.build()
)
}
)
ColorPreference(
title = "Surface Variant",
@@ -126,6 +126,7 @@ class CustomColorSchemeSettingsScreenVM : ViewModel(), KoinComponent {
return CustomColors.Scheme.newBuilder()
.setPrimary(a1.tone(80))
.setSurfaceTint(a1.tone(80))
.setOnPrimary(a1.tone(20))
.setPrimaryContainer(a1.tone(30))
.setOnPrimaryContainer(a1.tone(90))
@@ -148,9 +149,11 @@ class CustomColorSchemeSettingsScreenVM : ViewModel(), KoinComponent {
.setSurfaceVariant(n2.tone(30))
.setOnSurfaceVariant(n2.tone(80))
.setOutline(n2.tone(60))
.setOutlineVariant(n2.tone(30))
.setInverseSurface(n1.tone(90))
.setInverseOnSurface(n1.tone(20))
.setInversePrimary(a1.tone(40))
.setScrim(n1.tone(0))
.build()
}
@@ -164,6 +167,7 @@ class CustomColorSchemeSettingsScreenVM : ViewModel(), KoinComponent {
return CustomColors.Scheme.newBuilder()
.setPrimary(a1.tone(40))
.setSurfaceTint(a1.tone(40))
.setOnPrimary(a1.tone(100))
.setPrimaryContainer(a1.tone(90))
.setOnPrimaryContainer(a1.tone(10))
@@ -186,9 +190,11 @@ class CustomColorSchemeSettingsScreenVM : ViewModel(), KoinComponent {
.setSurfaceVariant(n2.tone(90))
.setOnSurfaceVariant(n2.tone(30))
.setOutline(n2.tone(50))
.setOutlineVariant(n2.tone(80))
.setInverseSurface(n1.tone(20))
.setInverseOnSurface(n1.tone(95))
.setInversePrimary(a1.tone(80))
.setScrim(n1.tone(0))
.build()
}
}
@@ -28,7 +28,7 @@ fun CustomColorScheme(colors: Settings.AppearanceSettings.CustomColors.Scheme) :
inverseSurface = Color(colors.inverseSurface),
inverseOnSurface = Color(colors.inverseOnSurface),
inversePrimary = Color(colors.inversePrimary),
surfaceTint = Color(colors.primary),
surfaceTint = Color(colors.surfaceTint),
error = Color(colors.error),
onError = Color(colors.onError),
errorContainer = Color(colors.errorContainer),
@@ -43,8 +43,7 @@ fun MaterialYouCompatScheme(wallpaperColors: WallpaperColors, darkTheme: Boolean
onError = Color(scheme.onError),
errorContainer = Color(scheme.errorContainer),
onErrorContainer = Color(scheme.onErrorContainer),
//TODO: handle outline variant and scrim properly
scrim = Color.Black,
outlineVariant = Color(scheme.surfaceVariant),
scrim = Color(scheme.scrim),
outlineVariant = Color(scheme.outlineVariant),
)
}