(feat) shape schemes
This commit is contained in:
+35
-5
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user