[WIP] Custom widgets as watch face
This commit is contained in:
@@ -30,6 +30,7 @@ data class LauncherSettingsData internal constructor(
|
||||
@SerialName("clockWidgetStyle2")
|
||||
internal val clockWidgetStyle: ClockWidgetStyleEnum = ClockWidgetStyleEnum.Digital1,
|
||||
val clockWidgetDigital1: ClockWidgetStyle.Digital1 = ClockWidgetStyle.Digital1(),
|
||||
val clockWidgetCustom: ClockWidgetStyle.Custom = ClockWidgetStyle.Custom(),
|
||||
val clockWidgetColors: ClockWidgetColors = ClockWidgetColors.Auto,
|
||||
val clockWidgetShowSeconds: Boolean = false,
|
||||
val clockWidgetUseThemeColor: Boolean = false,
|
||||
@@ -192,6 +193,7 @@ internal enum class ClockWidgetStyleEnum {
|
||||
Binary,
|
||||
Segment,
|
||||
Empty,
|
||||
Custom,
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@@ -234,6 +236,10 @@ sealed interface ClockWidgetStyle {
|
||||
@Serializable
|
||||
@SerialName("empty")
|
||||
data object Empty : ClockWidgetStyle
|
||||
|
||||
@Serializable
|
||||
@SerialName("custom")
|
||||
data class Custom(val widgetId: Int? = null) : ClockWidgetStyle
|
||||
}
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -99,17 +99,22 @@ class ClockWidgetSettings internal constructor(
|
||||
ClockWidgetStyleEnum.Binary -> ClockWidgetStyle.Binary
|
||||
ClockWidgetStyleEnum.Segment -> ClockWidgetStyle.Segment
|
||||
ClockWidgetStyleEnum.Empty -> ClockWidgetStyle.Empty
|
||||
ClockWidgetStyleEnum.Custom -> it.clockWidgetCustom
|
||||
}
|
||||
}
|
||||
|
||||
val digital1: Flow<ClockWidgetStyle.Digital1>
|
||||
get() = launcherDataStore.data.map { it.clockWidgetDigital1 }
|
||||
|
||||
val custom: Flow<ClockWidgetStyle.Custom>
|
||||
get() = launcherDataStore.data.map { it.clockWidgetCustom }
|
||||
|
||||
fun setClockStyle(clockStyle: ClockWidgetStyle) {
|
||||
launcherDataStore.update {
|
||||
it.copy(
|
||||
clockWidgetStyle = clockStyle.enumValue,
|
||||
clockWidgetDigital1 = if (clockStyle is ClockWidgetStyle.Digital1) clockStyle else it.clockWidgetDigital1,
|
||||
clockWidgetCustom = if (clockStyle is ClockWidgetStyle.Custom) clockStyle else it.clockWidgetCustom,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -151,4 +156,5 @@ internal val ClockWidgetStyle.enumValue
|
||||
is ClockWidgetStyle.Binary -> ClockWidgetStyleEnum.Binary
|
||||
is ClockWidgetStyle.Segment -> ClockWidgetStyleEnum.Segment
|
||||
is ClockWidgetStyle.Empty -> ClockWidgetStyleEnum.Empty
|
||||
is ClockWidgetStyle.Custom -> ClockWidgetStyleEnum.Custom
|
||||
}
|
||||
Reference in New Issue
Block a user