forked from Blendman974/faceclaw
iOS porting: Main screen and compositor
This commit is contained in:
1 parent
61b3bf8b7c
commit
99793a37a7
24 files changed
+1124
-70
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { ApplicationSettings } from '@nativescript/core'
|
||||
|
||||
// Main-isolate settings for the initial iOS port. Worker synchronization will
|
||||
// be added when worker-hosted apps are enabled on iOS.
|
||||
const listeners = new Set<(key: string) => void>()
|
||||
function changed(key: string): void {
|
||||
setTimeout(() => { for (const listener of [...listeners]) listener(key) }, 0)
|
||||
}
|
||||
export function getStringSetting(key: string, fallback: string): string {
|
||||
return ApplicationSettings.getString(key, fallback)
|
||||
}
|
||||
export function setStringSetting(key: string, value: string): void {
|
||||
if (getStringSetting(key, '') === value && ApplicationSettings.hasKey(key)) return
|
||||
ApplicationSettings.setString(key, value)
|
||||
changed(key)
|
||||
}
|
||||
export function getBooleanSetting(key: string, fallback: boolean): boolean {
|
||||
return ApplicationSettings.getBoolean(key, fallback)
|
||||
}
|
||||
export function setBooleanSetting(key: string, value: boolean): void {
|
||||
if (getBooleanSetting(key, false) === value && ApplicationSettings.hasKey(key)) return
|
||||
ApplicationSettings.setBoolean(key, value)
|
||||
changed(key)
|
||||
}
|
||||
export function onSettingsStoreChanged(listener: (key: string) => void): () => void {
|
||||
listeners.add(listener)
|
||||
return () => { listeners.delete(listener) }
|
||||
}
|
||||
Reference in new issue
Block a user