feat: add expo mobile application source code

This commit is contained in:
2026-05-21 16:06:35 +07:00
parent 76d7a5c5c6
commit 0c65a7811b
77 changed files with 20356 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
import React, { createContext, useContext, useState } from 'react';
import { useAuth } from './AuthContext';
import { ApiService } from '../services/api';
interface RefreshContextType {
refreshing: boolean;
refreshAll: () => Promise<void>;
}
const RefreshContext = createContext<RefreshContextType | undefined>(undefined);
export function RefreshProvider({ children }: { children: React.ReactNode }) {
const [refreshing, setRefreshing] = useState(false);
const { syncUser } = useAuth();
const refreshAll = async () => {
setRefreshing(true);
try {
// Sync User Data
await syncUser();
// You can add more global syncs here (e.g., config, notifications)
} catch (e) {
console.error('Global refresh failed', e);
} finally {
setRefreshing(false);
}
};
return (
<RefreshContext.Provider value={{ refreshing, refreshAll }}>
{children}
</RefreshContext.Provider>
);
}
export function useRefresh() {
const context = useContext(RefreshContext);
if (context === undefined) throw new Error('useRefresh must be used within a RefreshProvider');
return context;
}