From 19af7d4bed825f13cdfb2b359e7f2e72a6eb60ae Mon Sep 17 00:00:00 2001 From: m Date: Wed, 9 Sep 2026 18:26:50 +0200 Subject: [PATCH] index --- mobile/App.tsx | 26 ++++++-------------------- mobile/app/index.jsx | 24 ++++++++++++++++++++++++ mobile/context/AuthContext.jsx | 27 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 mobile/app/index.jsx create mode 100644 mobile/context/AuthContext.jsx diff --git a/mobile/App.tsx b/mobile/App.tsx index 2f97f5f..50094d1 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -1,24 +1,10 @@ -import { StatusBar } from 'expo-status-bar'; -import { StyleSheet, Text, View } from 'react-native'; +import { AuthProvider } from './context/AuthContext'; +import Index from './app/index.jsx'; export default function App() { return ( - - Dot. - - + + + ); -} - -const styles = StyleSheet.create({ - container: { - flex: 1, - backgroundColor: '#fff', - alignItems: 'center', - justifyContent: 'center', - }, - title: { - fontSize: 32, - fontWeight: '600', - }, -}); \ No newline at end of file +} \ No newline at end of file diff --git a/mobile/app/index.jsx b/mobile/app/index.jsx new file mode 100644 index 0000000..581c659 --- /dev/null +++ b/mobile/app/index.jsx @@ -0,0 +1,24 @@ +import { StatusBar } from 'expo-status-bar'; +import { StyleSheet, Text, View } from 'react-native'; + +export default function Index() { + return ( + + Dot. + + + ); +} + +const styles = StyleSheet.create({ + container: { + flex: 1, + backgroundColor: '#fff', + alignItems: 'center', + justifyContent: 'center', + }, + title: { + fontSize: 32, + fontWeight: '600', + }, +}); \ No newline at end of file diff --git a/mobile/context/AuthContext.jsx b/mobile/context/AuthContext.jsx new file mode 100644 index 0000000..03d8be6 --- /dev/null +++ b/mobile/context/AuthContext.jsx @@ -0,0 +1,27 @@ +import { createContext, useCallback, useContext, useMemo, useState } from 'react'; + +const AuthContext = createContext(null); + +export function AuthProvider({ children }) { + const [user, setUser] = useState(null); + + const signIn = useCallback(async (token, profile) => { + setUser({ token, profile }); + }, []); + + const signOut = useCallback(() => { + setUser(null); + }, []); + + const value = useMemo(() => ({ user, signIn, signOut }), [user, signIn, signOut]); + + return {children}; +} + +export function useAuth() { + const ctx = useContext(AuthContext); + if (!ctx) { + throw new Error('useAuth must be used within an AuthProvider'); + } + return ctx; +} \ No newline at end of file