Waseel: driver app, dispatch, POI suggestions, map fixes

This commit is contained in:
Krikorios
2026-08-25 02:57:49 +03:00
parent 899ca93cd5
commit 1d84003e0a
50 changed files with 3625 additions and 625 deletions
+53
View File
@@ -0,0 +1,53 @@
import {
activateKeepAwakeAsync,
deactivateKeepAwake,
} from "expo-keep-awake";
import { I18nManager } from "react-native";
import { useEffect, type ReactNode } from "react";
import { useSettingsStore } from "@/lib/settings";
const KEEP_AWAKE_TAG = "waseel-settings";
/**
* Boots the settings store and owns the two cross-cutting side-effects that
* must run for the whole app lifetime regardless of which screen is mounted:
* the keep-awake wake lock (imperative, so it survives navigation away from
* Settings) and the Arabic RTL flip.
*/
export const SettingsProvider = ({ children }: { children: ReactNode }) => {
const hydrated = useSettingsStore((state) => state.hydrated);
const keepAwake = useSettingsStore((state) => state.keepAwake);
const lang = useSettingsStore((state) => state.lang);
const hydrate = useSettingsStore((state) => state.hydrate);
useEffect(() => {
void hydrate();
}, [hydrate]);
useEffect(() => {
if (keepAwake) {
activateKeepAwakeAsync(KEEP_AWAKE_TAG).catch((error) =>
console.warn("[KEEP_AWAKE]: ", error),
);
} else {
deactivateKeepAwake(KEEP_AWAKE_TAG);
}
}, [keepAwake]);
useEffect(() => {
const shouldRTL = lang === "ar";
if (I18nManager.isRTL !== shouldRTL) {
I18nManager.forceRTL(shouldRTL);
I18nManager.swapLeftAndRightInRTL(shouldRTL);
}
}, [lang]);
// Until SecureStore has been read we'd otherwise flash the defaults
// (English / light) before the persisted values apply. The root layout
// already gates on fonts; gating here too avoids the theme/lang flash.
if (!hydrated) return null;
return <>{children}</>;
};