diff --git a/app/(tabs)/_layout.tsx b/app/(app)/(tabs)/_layout.tsx similarity index 100% rename from app/(tabs)/_layout.tsx rename to app/(app)/(tabs)/_layout.tsx diff --git a/app/(tabs)/index.tsx b/app/(app)/(tabs)/index.tsx similarity index 100% rename from app/(tabs)/index.tsx rename to app/(app)/(tabs)/index.tsx diff --git a/app/(tabs)/settings.tsx b/app/(app)/(tabs)/settings.tsx similarity index 100% rename from app/(tabs)/settings.tsx rename to app/(app)/(tabs)/settings.tsx diff --git a/app/(app)/_layout.tsx b/app/(app)/_layout.tsx new file mode 100644 index 0000000..2c82880 --- /dev/null +++ b/app/(app)/_layout.tsx @@ -0,0 +1,113 @@ +import { MaterialCommunityIcons } from '@expo/vector-icons' +import { + useFonts, + JetBrainsMono_400Regular, +} from '@expo-google-fonts/jetbrains-mono' +import { NotoSans_400Regular } from '@expo-google-fonts/noto-sans' +import { Redirect, SplashScreen, Stack, useRootNavigationState } from 'expo-router' +import * as SecureStore from 'expo-secure-store' +import React from 'react' +import { useColorScheme } from 'react-native' +import { PaperProvider } from 'react-native-paper' + +import { useAuth } from '@/lib/providers/auth' +import { Setting } from '@/lib/types' +import { StackHeader, Themes } from '@/lib/ui' + +export { + // Catch any errors thrown by the Layout component. + ErrorBoundary, +} from 'expo-router' + +export const unstable_settings = { + // Ensure that reloading on `/modal` keeps a back button present. + initialRouteName: '(root)/login', +} + +// Prevent the splash screen from auto-hiding before asset loading is complete. +SplashScreen.preventAutoHideAsync() + +const RootLayout = () => { + const { user } = useAuth() + const [loaded, error] = useFonts({ + NotoSans_400Regular, + JetBrainsMono_400Regular, + ...MaterialCommunityIcons.font, + }) + + // Get authentication state + const rootNavigationState = useRootNavigationState() + + // Expo Router uses Error Boundaries to catch errors in the navigation tree. + React.useEffect(() => { + if (error) throw error + }, [error]) + + React.useEffect(() => { + if (loaded) { + SplashScreen.hideAsync() + } + }, [loaded]) + // Make sure we have the navigation state before showing content + if (!loaded || !rootNavigationState) { + return null + } + if (!user) { + console.log('redirecting inside the root') + return + } + + return +} + +const RootLayoutNav = () => { + const colorScheme = useColorScheme() + const [settings, setSettings] = React.useState({ + theme: 'auto', + color: 'default', + }) + + // Load settings from the device + React.useEffect(() => { + SecureStore.getItemAsync('settings').then((result) => { + if (result === null) { + SecureStore.setItemAsync('settings', JSON.stringify(settings)).then( + (res) => console.log(res), + ) + } + + setSettings(JSON.parse(result ?? JSON.stringify(settings))) + }) + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []) + + return ( + + ( + + ), + }} + > + + + + + + + ) +} + +export default RootLayout diff --git a/app/drawer/_layout.tsx b/app/(app)/drawer/_layout.tsx similarity index 100% rename from app/drawer/_layout.tsx rename to app/(app)/drawer/_layout.tsx diff --git a/app/drawer/index.tsx b/app/(app)/drawer/index.tsx similarity index 100% rename from app/drawer/index.tsx rename to app/(app)/drawer/index.tsx diff --git a/app/drawer/settings.tsx b/app/(app)/drawer/settings.tsx similarity index 100% rename from app/drawer/settings.tsx rename to app/(app)/drawer/settings.tsx diff --git a/app/modal.tsx b/app/(app)/modal.tsx similarity index 100% rename from app/modal.tsx rename to app/(app)/modal.tsx diff --git a/app/search.tsx b/app/(app)/search.tsx similarity index 100% rename from app/search.tsx rename to app/(app)/search.tsx diff --git a/app/(auth)/login.tsx b/app/(auth)/login.tsx deleted file mode 100644 index c0c5b9e..0000000 --- a/app/(auth)/login.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { Text } from "react-native-paper"; - -export default function Login() { - return ( - Login please - ) -} \ No newline at end of file diff --git a/app/+html.tsx b/app/+html.tsx deleted file mode 100644 index 69c20c3..0000000 --- a/app/+html.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { ScrollViewStyleReset } from 'expo-router/html' -import React from 'react' - -// This file is web-only and used to configure the root HTML for every -// web page during static rendering. -// The contents of this function only run in Node.js environments and -// do not have access to the DOM or browser APIs. -export default function Root({ children }: { children: React.ReactNode }) { - return ( - - - - - - - {/* - Disable body scrolling on web. This makes ScrollView components work closer to how they do on native. - However, body scrolling is often nice to have for mobile web. If you want to enable it, remove this line. - */} - - - {/* Using raw CSS styles as an escape-hatch to ensure the background color never flickers in dark-mode. */} -