diff --git a/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchPrefsScreen.kt b/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchPrefsScreen.kt index 2abc2e784..66808a5e9 100644 --- a/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchPrefsScreen.kt +++ b/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchPrefsScreen.kt @@ -135,22 +135,67 @@ fun WatchPref<*>.section(): Section = when (this) { private fun numberPref(item: WatchPreference, libPebble: LibPebble): SettingsItem { val pref = item.pref as NumberWatchPref - return basicSettingsNumberItem( - id = pref.id, - title = pref.displayName, - description = pref.description, - topLevelType = TopLevelType.Watch, - section = pref.section(), - value = item.valueOrDefault(), - min = pref.min, - max = pref.max, - onValueChange = { - libPebble.setWatchPref(item.copy(value = it)) - }, - isDebugSetting = pref.isDebugSetting, - defaultValue = pref.defaultValue, - unit = pref.unit, - ) + return when (pref) { + NumberWatchPref.BacklightTimeoutMs -> { + val secValue = item.valueOrDefault() / 1000 + basicSettingsNumberItem( + id = pref.id, + title = pref.displayName, + description = pref.description, + topLevelType = TopLevelType.Watch, + section = pref.section(), + value = secValue, + min = 1, + max = 10, + onValueChange = { + libPebble.setWatchPref(item.copy(value = it * 1000)) + }, + isDebugSetting = pref.isDebugSetting, + defaultValue = pref.defaultValue / 1000, + unit = "seconds", + valueFormatter = { "$it seconds" }, + ) + } + NumberWatchPref.NotificationTimeoutMs -> { + val secValue = item.valueOrDefault() / 1000 + basicSettingsNumberItem( + id = pref.id, + title = pref.displayName, + description = pref.description, + topLevelType = TopLevelType.Watch, + section = pref.section(), + value = secValue, + min = 0, + max = 600, + onValueChange = { + libPebble.setWatchPref(item.copy(value = it * 1000)) + }, + isDebugSetting = pref.isDebugSetting, + defaultValue = pref.defaultValue / 1000, + unit = "", + valueFormatter = { v -> + "${v / 60}:${(v % 60).toString().padStart(2, '0')}" + }, + stepsOverride = 19, + ) + } + else -> basicSettingsNumberItem( + id = pref.id, + title = pref.displayName, + description = pref.description, + topLevelType = TopLevelType.Watch, + section = pref.section(), + value = item.valueOrDefault(), + min = pref.min, + max = pref.max, + onValueChange = { + libPebble.setWatchPref(item.copy(value = it)) + }, + isDebugSetting = pref.isDebugSetting, + defaultValue = pref.defaultValue, + unit = pref.unit, + ) + } } private fun colorPref(item: WatchPreference, libPebble: LibPebble): SettingsItem { diff --git a/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchSettingsScreen.kt b/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchSettingsScreen.kt index 48574f934..bcddf9e90 100644 --- a/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchSettingsScreen.kt +++ b/pebble/src/commonMain/kotlin/coredevices/pebble/ui/WatchSettingsScreen.kt @@ -2121,6 +2121,7 @@ fun basicSettingsNumberItem( isDebugSetting: Boolean = false, defaultValue: Long? = null, valueFormatter: ((Long) -> String)? = null, + stepsOverride: Int? = null, ) = SettingsItem( id = id, title = title, @@ -2142,9 +2143,8 @@ fun basicSettingsNumberItem( } val minF = remember(min) { min.toFloat() } val maxF = remember(max) { max.toFloat() } - val steps = remember(max, min) { + val steps = stepsOverride ?: remember(max, min) { val range = max - min - // Too many steps ANRs the app if (range in 1..100) range - 1 else 0 } Slider( @@ -2171,7 +2171,7 @@ fun basicSettingsNumberItem( enabled = value != defaultValue, ) { Text( - text = "Default: $defaultValue", + text = "Default: ${valueFormatter?.invoke(defaultValue) ?: "$defaultValue $unit"}", modifier = Modifier.widthIn(max = 150.dp), maxLines = 1, lineHeight = 12.sp,