Better route splitting

This commit is contained in:
Imbus 2023-12-15 01:31:02 +01:00
parent 1ec6a90ff9
commit 74a5b3930b

42
App.tsx
View file

@ -5,32 +5,46 @@ import { style } from "./src/util/style";
import { PostsContainer } from "./src/components/PostsContainer"; import { PostsContainer } from "./src/components/PostsContainer";
import { NavigationContainer } from "@react-navigation/native"; import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from "@react-navigation/native-stack"; import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { NewPostContainer } from "./src/components/NewPostContainer";
const Stack = createNativeStackNavigator(); const Stack = createNativeStackNavigator();
export default function App(): JSX.Element { export default function App(): JSX.Element {
return ( return (
<NavigationContainer> <>
<Stack.Navigator> <StatusBar style="light" />
<Stack.Screen <NavigationContainer>
name="Home" <Stack.Navigator>
component={HomeScreen} <Stack.Screen
options={{ name="Home"
headerStyle: style.header, component={HomeScreen}
headerTitleStyle: style.headerTitle, options={homeOptions}
headerTintColor: "#fff", />
}} <Stack.Screen name="New" component={PostScreen} />
/> </Stack.Navigator>
</Stack.Navigator> </NavigationContainer>
</NavigationContainer> </>
); );
} }
const homeOptions = {
headerStyle: style.header,
headerTitleStyle: style.headerTitle,
headerTintColor: "#fff",
};
function HomeScreen(): JSX.Element { function HomeScreen(): JSX.Element {
return ( return (
<View style={style.app}> <View style={style.app}>
<StatusBar style="light" />
<PostsContainer /> <PostsContainer />
</View> </View>
); );
} }
function PostScreen(): JSX.Element {
return (
<View style={style.app}>
<NewPostContainer />
</View>
);
}