Add scrim, outlineVariant and surfaceTint color to custom color schemes
This commit is contained in:
parent
0b152a2fa5
commit
c47a880d72
@ -22,7 +22,7 @@ internal val Context.dataStore: LauncherDataStore by dataStore(
|
||||
}
|
||||
)
|
||||
|
||||
internal const val SchemaVersion = 10
|
||||
internal const val SchemaVersion = 11
|
||||
|
||||
internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
|
||||
return listOf(
|
||||
@ -36,5 +36,6 @@ internal fun getMigrations(context: Context): List<DataMigration<Settings>> {
|
||||
Migration_7_8(),
|
||||
Migration_8_9(),
|
||||
Migration_9_10(),
|
||||
Migration_10_11(),
|
||||
)
|
||||
}
|
||||
@ -205,9 +205,9 @@ internal val DefaultLightCustomColorScheme: Settings.AppearanceSettings.CustomCo
|
||||
.setInverseOnSurface(scheme.inverseOnSurface)
|
||||
.setInversePrimary(scheme.inversePrimary)
|
||||
.setOutline(scheme.outline)
|
||||
//TODO: handle outline variant and scrim properly
|
||||
.setScrim(Color.BLACK)
|
||||
.setOutlineVariant(scheme.surfaceVariant)
|
||||
.setScrim(scheme.scrim)
|
||||
.setOutlineVariant(scheme.outlineVariant)
|
||||
.setSurfaceTint(scheme.primary)
|
||||
.build()
|
||||
}
|
||||
|
||||
@ -241,8 +241,8 @@ internal val DefaultDarkCustomColorScheme: Settings.AppearanceSettings.CustomCol
|
||||
.setInverseOnSurface(scheme.inverseOnSurface)
|
||||
.setInversePrimary(scheme.inversePrimary)
|
||||
.setOutline(scheme.outline)
|
||||
//TODO: handle outline variant and scrim properly
|
||||
.setScrim(Color.BLACK)
|
||||
.setOutlineVariant(scheme.surfaceVariant)
|
||||
.setScrim(scheme.scrim)
|
||||
.setOutlineVariant(scheme.outlineVariant)
|
||||
.setSurfaceTint(scheme.primary)
|
||||
.build()
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
package de.mm20.launcher2.preferences.migrations
|
||||
|
||||
import de.mm20.launcher2.preferences.Settings
|
||||
|
||||
class Migration_10_11: VersionedMigration(10, 11) {
|
||||
override suspend fun applyMigrations(builder: Settings.Builder): Settings.Builder {
|
||||
return builder.setAppearance(
|
||||
builder.appearance.toBuilder()
|
||||
.setCustomColors(
|
||||
builder.appearance.customColors.toBuilder()
|
||||
.setLightScheme(
|
||||
builder.appearance.customColors.lightScheme.toBuilder()
|
||||
.setSurfaceTint(builder.appearance.customColors.lightScheme.primary)
|
||||
)
|
||||
.setDarkScheme(
|
||||
builder.appearance.customColors.darkScheme.toBuilder()
|
||||
.setSurfaceTint(builder.appearance.customColors.darkScheme.primary)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -60,6 +60,7 @@ message Settings {
|
||||
uint32 on_error_container = 26;
|
||||
uint32 outline_variant = 27;
|
||||
uint32 scrim = 28;
|
||||
uint32 surface_tint = 29;
|
||||
}
|
||||
Scheme light_scheme = 3;
|
||||
Scheme dark_scheme = 4;
|
||||
|
||||
@ -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),
|
||||
)
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user