From 01ca1efa321b3b293b61f7242c8c34d7877936c7 Mon Sep 17 00:00:00 2001 From: whysman Date: Sun, 9 Mar 2025 22:48:18 -0400 Subject: [PATCH] Fixed bottom nav, added layout.web --- app/_layout.web.tsx | 62 ++++++++++++++++++++++++++++++++++++++++ components/BottomNav.tsx | 17 +++++++---- 2 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 app/_layout.web.tsx diff --git a/app/_layout.web.tsx b/app/_layout.web.tsx new file mode 100644 index 0000000..6162f6c --- /dev/null +++ b/app/_layout.web.tsx @@ -0,0 +1,62 @@ +import { useFonts } from 'expo-font'; +import { Stack } from 'expo-router'; +import * as SplashScreen from 'expo-splash-screen'; +import { useEffect } from 'react'; +import 'react-native-reanimated'; +import { useColorScheme } from 'react-native'; +import { PaperProvider, Provider } from "react-native-paper"; +import { UserProvider, useUser } from "@/context/UserContext"; +import themes from '@/assets/themes' +import log from "@/util/log" + +// Prevent the splash screen from auto-hiding before asset loading is complete. +SplashScreen.preventAutoHideAsync(); + +export default function RootLayout() { + return ( + + + + ); +} + +function InnerRootLayout() { + const { currentTheme } = useUser(); // Access the currentTheme from UserContext + log.debug(currentTheme); + const colorScheme = useColorScheme(); + log.debug(colorScheme); + const [loaded] = useFonts({ + SpaceReg: require('../assets/fonts/SpaceMono-Regular.ttf'), + SpaceBold: require('../assets/fonts/SpaceMono-Bold.ttf'), + Light: require('../assets/fonts/font-light.otf'), + Medium: require('../assets/fonts/font-medium.otf'), + Heavy: require('../assets/fonts/font-heavy.otf'), + }); + useEffect(() => { + if (loaded) { + SplashScreen.hideAsync(); + } + }, [loaded]); + + if (!loaded) { + return null; + } + + // Ensure currentTheme is treated as a valid key, or fallback to 'blue' + //const themeKey: 'blue' | 'green' | 'red' | 'yellow' | 'orange' = (currentTheme as 'blue' | 'green' | 'red' | 'yellow' | 'orange') || 'blue'; + + // Use the themeKey to index into the themes object + + //const appTheme = themes[themeKey][colorScheme === 'dark' ? 'dark' : 'light']; + const appTheme = themes[currentTheme as keyof typeof themes][colorScheme === 'dark' ? 'dark' : 'light'] + + return ( + + + + + + + + ); +} diff --git a/components/BottomNav.tsx b/components/BottomNav.tsx index 65a535b..624da8d 100644 --- a/components/BottomNav.tsx +++ b/components/BottomNav.tsx @@ -1,15 +1,22 @@ -import {Appbar, Portal, Button, Dialog, Menu, Text, useTheme} from "react-native-paper"; -import {Image, useColorScheme, View} from "react-native"; +import {Appbar, Button, Text, useTheme} from "react-native-paper"; +import {View} from "react-native"; import styles from "@/assets/styles"; +import React from "react"; const BottomNav = () => { const theme = useTheme(); return ( - - Daisy Knight Dog Park - (change) + + Daisy Knight Dog Park +