(feat) transparency schemes
This commit is contained in:
+8
-51
@@ -2,18 +2,22 @@ package de.mm20.launcher2.preferences
|
||||
|
||||
import android.content.Context
|
||||
import de.mm20.launcher2.search.SearchFilters
|
||||
import de.mm20.launcher2.serialization.UUIDSerializer
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonNames
|
||||
import java.util.UUID
|
||||
|
||||
@Serializable
|
||||
data class LauncherSettingsData internal constructor(
|
||||
val schemaVersion: Int = 5,
|
||||
|
||||
val uiColorScheme: ColorScheme = ColorScheme.System,
|
||||
@JsonNames("uiTheme")
|
||||
val uiColors: ColorsDescriptor = ColorsDescriptor.Default,
|
||||
val uiShapes: ShapesDescriptor = ShapesDescriptor.Default,
|
||||
@Serializable(with = UUIDSerializer::class)
|
||||
val uiColorsId: UUID = UUID(0L, 0L),
|
||||
@Serializable(with = UUIDSerializer::class)
|
||||
val uiShapesId: UUID = UUID(0L, 0L),
|
||||
@Serializable(with = UUIDSerializer::class)
|
||||
val uiTransparenciesId: UUID = UUID(0L, 0L),
|
||||
|
||||
val uiCompatModeColors: Boolean = false,
|
||||
val uiFont: Font = Font.Outfit,
|
||||
@@ -205,53 +209,6 @@ enum class Font {
|
||||
System,
|
||||
}
|
||||
|
||||
|
||||
@Serializable
|
||||
sealed interface ColorsDescriptor {
|
||||
@Serializable
|
||||
@SerialName("default")
|
||||
data object Default : ColorsDescriptor
|
||||
|
||||
@Serializable
|
||||
@SerialName("high_contrast")
|
||||
data object HighContrast : ColorsDescriptor
|
||||
|
||||
@Serializable
|
||||
@SerialName("bw")
|
||||
data object BlackAndWhite : ColorsDescriptor
|
||||
|
||||
@Serializable
|
||||
@SerialName("custom")
|
||||
data class Custom(
|
||||
val id: String,
|
||||
) : 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 {
|
||||
Digital1,
|
||||
Digital2,
|
||||
|
||||
@@ -8,10 +8,9 @@ import de.mm20.launcher2.preferences.ScreenOrientation
|
||||
import de.mm20.launcher2.preferences.SearchBarColors
|
||||
import de.mm20.launcher2.preferences.SearchBarStyle
|
||||
import de.mm20.launcher2.preferences.SystemBarColors
|
||||
import de.mm20.launcher2.preferences.ColorsDescriptor
|
||||
import de.mm20.launcher2.preferences.ShapesDescriptor
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.map
|
||||
import java.util.UUID
|
||||
|
||||
data class CardStyle(
|
||||
val opacity: Float = 1f,
|
||||
@@ -286,25 +285,36 @@ class UiSettings internal constructor(
|
||||
}
|
||||
|
||||
|
||||
val colors
|
||||
val colorsId
|
||||
get() = launcherDataStore.data.map {
|
||||
it.uiColors
|
||||
it.uiColorsId
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setColors(colors: ColorsDescriptor) {
|
||||
fun setColorsId(colorsId: UUID) {
|
||||
launcherDataStore.update {
|
||||
it.copy(uiColors = colors)
|
||||
it.copy(uiColorsId = colorsId)
|
||||
}
|
||||
}
|
||||
|
||||
val shapes
|
||||
val shapesId
|
||||
get() = launcherDataStore.data.map {
|
||||
it.uiShapes
|
||||
it.uiShapesId
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setShapes(shapes: ShapesDescriptor) {
|
||||
fun setShapesId(shapesId: UUID) {
|
||||
launcherDataStore.update {
|
||||
it.copy(uiShapes = shapes)
|
||||
it.copy(uiShapesId = shapesId)
|
||||
}
|
||||
}
|
||||
|
||||
val transparenciesId
|
||||
get() = launcherDataStore.data.map {
|
||||
it.uiTransparenciesId
|
||||
}.distinctUntilChanged()
|
||||
|
||||
fun setTransparenciesId(transparenciesId: UUID) {
|
||||
launcherDataStore.update {
|
||||
it.copy(uiTransparenciesId = transparenciesId)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user