forked from Blendman974/faceclaw
Repaint top bar on settings changes; add 12/24-hour time setting
This commit is contained in:
1 parent
d97429a21a
commit
17cc0bba83
4 files changed
+55
-3
No files matched your search
@@ -17,6 +17,7 @@ export type NightscoutSettings = {
|
||||
apiToken: string;
|
||||
};
|
||||
export type BatteryDisplayMode = "icon" | "percentage";
|
||||
export type TimeFormat = "24h" | "12h";
|
||||
export type ScreenTimeoutSetting = "15s" | "30s" | "1m" | "never";
|
||||
|
||||
type ConfigSettingOptions<TValue, TId extends string> = {
|
||||
@@ -179,6 +180,15 @@ export const batteryDisplayModeSetting = new ConfigSettingEnum<BatteryDisplayMod
|
||||
formatValue: batteryDisplayModeLabel,
|
||||
});
|
||||
|
||||
export const timeFormatSetting = new ConfigSettingEnum<TimeFormat>({
|
||||
id: "timeFormat",
|
||||
label: "Time format",
|
||||
storageKey: "display.timeFormat",
|
||||
defaultValue: "24h",
|
||||
values: ["24h", "12h"],
|
||||
formatValue: timeFormatLabel,
|
||||
});
|
||||
|
||||
export const screenTimeoutSetting = new ConfigSettingEnum<ScreenTimeoutSetting>({
|
||||
id: "screen-timeout",
|
||||
label: "Screen timeout",
|
||||
@@ -308,6 +318,10 @@ export function batteryDisplayModeLabel(value: BatteryDisplayMode): string {
|
||||
return value === "icon" ? "Icon" : "Percentage";
|
||||
}
|
||||
|
||||
export function timeFormatLabel(value: TimeFormat): string {
|
||||
return value === "12h" ? "12-hour" : "24-hour";
|
||||
}
|
||||
|
||||
export function loadNightscoutSettings(): NightscoutSettings {
|
||||
return {
|
||||
siteUrl: nightscoutSiteUrlSetting.get(),
|
||||
|
||||
Reference in new issue
Block a user