Initial scaffold: Expo SDK 56, expo-router, expo-sqlite, NativeWind
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import * as SecureStore from "expo-secure-store";
|
||||
|
||||
export interface Settings {
|
||||
homeView: "dashboard" | "capture";
|
||||
inputMode: "form" | "voice";
|
||||
onboardingDone: boolean;
|
||||
}
|
||||
|
||||
const DEFAULTS: Settings = {
|
||||
homeView: "dashboard",
|
||||
inputMode: "form",
|
||||
onboardingDone: false,
|
||||
};
|
||||
|
||||
export function useSettings() {
|
||||
const [settings, setSettings] = useState<Settings>(DEFAULTS);
|
||||
const [ready, setReady] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const [hv, im, od] = await Promise.all([
|
||||
SecureStore.getItemAsync("pref_home_view"),
|
||||
SecureStore.getItemAsync("pref_input_mode"),
|
||||
SecureStore.getItemAsync("onboarding_done"),
|
||||
]);
|
||||
setSettings({
|
||||
homeView: (hv as Settings["homeView"]) ?? DEFAULTS.homeView,
|
||||
inputMode: (im as Settings["inputMode"]) ?? DEFAULTS.inputMode,
|
||||
onboardingDone: od === "true",
|
||||
});
|
||||
setReady(true);
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return { settings, ready };
|
||||
}
|
||||
Reference in New Issue
Block a user