Better route splitting

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

30
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 (
<>
<StatusBar style="light" />
<NavigationContainer> <NavigationContainer>
<Stack.Navigator> <Stack.Navigator>
<Stack.Screen <Stack.Screen
name="Home" name="Home"
component={HomeScreen} component={HomeScreen}
options={{ options={homeOptions}
/>
<Stack.Screen name="New" component={PostScreen} />
</Stack.Navigator>
</NavigationContainer>
</>
);
}
const homeOptions = {
headerStyle: style.header, headerStyle: style.header,
headerTitleStyle: style.headerTitle, headerTitleStyle: style.headerTitle,
headerTintColor: "#fff", headerTintColor: "#fff",
}} };
/>
</Stack.Navigator>
</NavigationContainer>
);
}
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>
);
}