This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
interaktive-systeme/app/(tabs)/_layout.tsx
2024-01-25 18:49:24 +01:00

62 lines
No EOL
2 KiB
TypeScript

import { Tabs } from "expo-router/tabs";
import { StyleSheet } from "react-native";
import { FontAwesome } from "@expo/vector-icons";
import { Redirect } from "expo-router";
import React from "react";
import { useAuth } from "../contexts/AuthContext";
import { useTheme } from "../contexts/ThemeContext";
export default function Layout() {
const {authState} = useAuth()
const {colors} = useTheme()
const styles = StyleSheet.create({
sceneContainer: {
backgroundColor: colors.containerColor,
},
tabBar: {
backgroundColor: colors.backgroundColor,
borderTopColor: colors.backgroundColor
}
});
const screenOptions = {
tabBarActiveTintColor: colors.tabIconSelected,
tabBarInactiveTintColor: colors.tabIconDefault,
headerShown: false,
tabBarStyle: styles.tabBar,
tabBarHideOnKeyboard: true
}
if(!authState?.authenticated){
return (
<Redirect href={"/"} />)
}
return (
<Tabs sceneContainerStyle={styles.sceneContainer} backBehavior="initialRoute" initialRouteName="(home)" screenOptions={screenOptions}>
<Tabs.Screen name="(budget)" options={
{
tabBarLabel: "Budget",
tabBarIcon: ({size, color}) => (
<FontAwesome name="money" size={size} color={color}/>),
}
}/>
<Tabs.Screen name="(home)" options={
{
tabBarLabel: "Home",
tabBarIcon: ({size, color}) => (
<FontAwesome name="home" size={size} color={color}/>),
}
}/>
<Tabs.Screen name="(stats)/index" options={
{
tabBarLabel: "Stats",
unmountOnBlur: true,
tabBarIcon: ({size, color}) => (
<FontAwesome name="bar-chart" size={size} color={color}/>),
}
}/>
</Tabs>
);
}