-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprefs.ts
35 lines (28 loc) · 995 Bytes
/
prefs.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type {
DarkModeGetterResult,
DarkModeSyncStatusBar,
} from '@aparajita/capacitor-dark-mode'
import { DarkModeAppearance } from '@aparajita/capacitor-dark-mode'
export function getAppearancePref(): DarkModeGetterResult {
const item = localStorage.getItem('appearance')
if (item) {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return item as DarkModeAppearance
}
return DarkModeAppearance.system
}
export function getSyncStatusBarPref(): DarkModeSyncStatusBar {
const item = localStorage.getItem('syncStatusBar')
return item === 'textOnly' ? item : item === 'true'
}
export function setAppearancePref(appearance: DarkModeAppearance): void {
localStorage.setItem('appearance', appearance)
}
export function setSyncStatusBarPref(
syncStatusBar: DarkModeSyncStatusBar,
): void {
localStorage.setItem('syncStatusBar', String(syncStatusBar))
}
if (localStorage.getItem('syncStatusBar') === null) {
setSyncStatusBarPref(true)
}