(feat) shape schemes

This commit is contained in:
MM20
2025-06-01 17:13:12 +02:00
parent 17c4a51ca5
commit cfb7bb0c72
41 changed files with 2129 additions and 921 deletions
@@ -1740,4 +1740,44 @@ private val _BreezyWeather = materialIcon("Icons.Rounded.BreezyWeather") {
}
val Icons.Rounded.BreezyWeather
get() = _BreezyWeather
get() = _BreezyWeather
val _CutCorner = materialIcon("Icons.Rounded.CutCorner") {
materialPath {
moveTo(2f, 3f)
verticalLineTo(22f)
horizontalLineTo(21f)
verticalLineTo(11.585938f)
lineTo(12.414063f, 3f)
close()
moveToRelative(2f, 2f)
horizontalLineToRelative(7.585938f)
lineTo(19f, 12.414063f)
verticalLineTo(20f)
horizontalLineTo(4f)
close()
}
}
val Icons.Rounded.CutCorner
get() = _CutCorner
val _RoundedCornerAlt = materialIcon("Icons.Rounded.RoundedCornerAlt") {
materialPath {
moveTo(2f, 3f)
verticalLineTo(22f)
horizontalLineTo(21f)
verticalLineTo(12f)
curveTo(21f, 7.0412819f, 16.958718f, 3f, 12f, 3f)
close()
moveToRelative(2f, 2f)
horizontalLineToRelative(8f)
curveToRelative(3.877838f, 0f, 7f, 3.1221621f, 7f, 7f)
verticalLineToRelative(8f)
horizontalLineTo(4f)
close()
}
}
val Icons.Rounded.RoundedCornerAlt
get() = _RoundedCornerAlt
@@ -438,6 +438,11 @@
<string name="preference_mdy_color_source">Source for dynamic colors</string>
<string name="preference_mdy_color_source_system">System</string>
<string name="preference_mdy_color_source_wallpaper">Wallpaper</string>
<string name="preference_screen_shapes">Shapes</string>
<string name="preference_shapes_default">Default</string>
<string name="preference_shapes_extra_round">Extra round</string>
<string name="preference_shapes_rect">Rectangualar</string>
<string name="preference_shapes_base">Base shape</string>
<string name="preference_font">Font</string>
<string name="preference_font_system">System default</string>
<string name="preference_screen_about">About</string>
@@ -819,7 +824,9 @@
<string name="note_widget_file_write_error">Error saving note</string>
<string name="note_widget_file_write_error_description">The note could not be written to the linked file. Possibly, it has been moved or deleted. A copy has been saved to the launcher\'s internal storage.</string>
<string name="confirmation_delete_color_scheme">Do you really want to delete the color scheme %1$s\?</string>
<string name="confirmation_delete_shapes_scheme">Do you really want to delete the shapes scheme %1$s\?</string>
<string name="new_color_scheme_name">New color scheme</string>
<string name="new_shapes_name">New shapes</string>
<string name="theme_color_scheme_system_default">Use system default</string>
<string name="theme_color_scheme_autogenerate">From primary color</string>
<string name="theme_color_scheme_palette_color">Palette</string>
@@ -11,7 +11,10 @@ data class LauncherSettingsData internal constructor(
val schemaVersion: Int = 5,
val uiColorScheme: ColorScheme = ColorScheme.System,
val uiTheme: ThemeDescriptor = ThemeDescriptor.Default,
@JsonNames("uiTheme")
val uiColors: ColorsDescriptor = ColorsDescriptor.Default,
val uiShapes: ShapesDescriptor = ShapesDescriptor.Default,
val uiCompatModeColors: Boolean = false,
val uiFont: Font = Font.Outfit,
@Deprecated("No longer in use, only used for migration")
@@ -121,8 +124,10 @@ data class LauncherSettingsData internal constructor(
val systemBarsNavColors: SystemBarColors = SystemBarColors.Auto,
val surfacesOpacity: Float = 1f,
@Deprecated("Replaces with shape schemes")
val surfacesRadius: Int = 24,
val surfacesBorderWidth: Int = 0,
@Deprecated("Replaces with shape schemes")
val surfacesShape: SurfaceShape = SurfaceShape.Rounded,
val widgetsEditButton: Boolean = true,
@@ -201,20 +206,45 @@ enum class Font {
@Serializable
sealed interface ThemeDescriptor {
sealed interface ColorsDescriptor {
@Serializable
@SerialName("default")
data object Default : ThemeDescriptor
data object Default : ColorsDescriptor
@Serializable
@SerialName("bw")
data object BlackAndWhite : ThemeDescriptor
data object BlackAndWhite : ColorsDescriptor
@Serializable
@SerialName("custom")
data class Custom(
val id: String,
) : ThemeDescriptor
) : ColorsDescriptor
}
@Serializable
sealed interface ShapesDescriptor {
@Serializable
@SerialName("default")
data object Default : ShapesDescriptor
@Serializable
@SerialName("cut")
data object Cut : ShapesDescriptor
@Serializable
@SerialName("extra_round")
data object ExtraRound : ShapesDescriptor
@Serializable
@SerialName("rect")
data object Rect : ShapesDescriptor
@Serializable
@SerialName("custom")
data class Custom(
val id: String,
) : ShapesDescriptor
}
internal enum class ClockWidgetStyleEnum {
@@ -7,16 +7,14 @@ import de.mm20.launcher2.preferences.LauncherDataStore
import de.mm20.launcher2.preferences.ScreenOrientation
import de.mm20.launcher2.preferences.SearchBarColors
import de.mm20.launcher2.preferences.SearchBarStyle
import de.mm20.launcher2.preferences.SurfaceShape
import de.mm20.launcher2.preferences.SystemBarColors
import de.mm20.launcher2.preferences.ThemeDescriptor
import de.mm20.launcher2.preferences.ColorsDescriptor
import de.mm20.launcher2.preferences.ShapesDescriptor
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
data class CardStyle(
val opacity: Float = 1f,
val cornerRadius: Int = 0,
val shape: SurfaceShape = SurfaceShape.Rounded,
val borderWidth: Int = 0,
)
@@ -90,8 +88,6 @@ class UiSettings internal constructor(
get() = launcherDataStore.data.map {
CardStyle(
opacity = it.surfacesOpacity,
cornerRadius = it.surfacesRadius,
shape = it.surfacesShape,
borderWidth = it.surfacesBorderWidth,
)
}
@@ -102,24 +98,12 @@ class UiSettings internal constructor(
}
}
fun setCardRadius(radius: Int) {
launcherDataStore.update {
it.copy(surfacesRadius = radius)
}
}
fun setCardBorderWidth(borderWidth: Int) {
launcherDataStore.update {
it.copy(surfacesBorderWidth = borderWidth)
}
}
fun setCardShape(shape: SurfaceShape) {
launcherDataStore.update {
it.copy(surfacesShape = shape)
}
}
val dimWallpaper
get() = launcherDataStore.data.map {
it.wallpaperDim
@@ -302,14 +286,25 @@ class UiSettings internal constructor(
}
val theme
val colors
get() = launcherDataStore.data.map {
it.uiTheme
it.uiColors
}.distinctUntilChanged()
fun setTheme(theme: ThemeDescriptor) {
fun setColors(colors: ColorsDescriptor) {
launcherDataStore.update {
it.copy(uiTheme = theme)
it.copy(uiColors = colors)
}
}
val shapes
get() = launcherDataStore.data.map {
it.uiShapes
}.distinctUntilChanged()
fun setShapes(shapes: ShapesDescriptor) {
launcherDataStore.update {
it.copy(uiShapes = shapes)
}
}