-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nav] Add MyContentStackNavigator and remove basic nav on HomeScreen #13
- Loading branch information
1 parent
41ea77a
commit 44a50ac
Showing
11 changed files
with
182 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,10 @@ | ||
import { Ionicons } from '@expo/vector-icons'; | ||
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import HomeScreen from './src/screens/HomeScreen'; | ||
import StoryScreen from './src/screens/StoryScreen'; | ||
import ToastScreen from './src/screens/ToastScreen'; | ||
import { RootStackParamsList } from './src/types/types'; | ||
|
||
const Tab = createMaterialBottomTabNavigator<RootStackParamsList>(); | ||
|
||
function HomeIcon({ color }: { color: string }) { | ||
return <Ionicons name="home-outline" color={color} size={26} />; | ||
} | ||
|
||
function StoryIcon({ color }: { color: string }) { | ||
return <Ionicons name="document-outline" color={color} size={26} />; | ||
} | ||
|
||
function ToastIcon({ color }: { color: string }) { | ||
return <Ionicons name="notifications-outline" color={color} size={26} />; | ||
} | ||
import TabNavigator from './src/navigation/TabNavigator'; | ||
|
||
export default function App() { | ||
return ( | ||
<NavigationContainer> | ||
<Tab.Navigator | ||
initialRouteName="Home" | ||
barStyle={{ backgroundColor: '#E5E4E2' }} | ||
> | ||
<Tab.Screen | ||
name="Home" | ||
component={HomeScreen} | ||
options={{ | ||
tabBarLabel: 'Home', | ||
tabBarIcon: HomeIcon, | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Story" | ||
component={StoryScreen} | ||
options={{ | ||
tabBarLabel: 'Story', | ||
tabBarIcon: StoryIcon, | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Toast" | ||
component={ToastScreen} | ||
options={{ | ||
tabBarLabel: 'Toast', | ||
tabBarIcon: ToastIcon, | ||
}} | ||
/> | ||
</Tab.Navigator> | ||
<TabNavigator /> | ||
</NavigationContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Ionicons } from '@expo/vector-icons'; | ||
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs'; | ||
import { ReactElement } from 'react'; | ||
import HomeScreen from '../screens/HomeScreen'; | ||
import SearchScreen from '../screens/SearchScreen'; | ||
import { RootStackParamsList } from '../types/navigation'; | ||
import MyContentStackNavigator from './stacks/MyContentStackNavigator'; | ||
|
||
function HomeIcon({ color }: { color: string }) { | ||
return <Ionicons name="home-outline" color={color} size={26} />; | ||
} | ||
|
||
function SearchIcon({ color }: { color: string }) { | ||
return <Ionicons name="search-outline" color={color} size={26} />; | ||
} | ||
|
||
function MyContentIcon({ color }: { color: string }) { | ||
return <Ionicons name="document-outline" color={color} size={26} />; | ||
} | ||
|
||
const Tab = createMaterialBottomTabNavigator<RootStackParamsList>(); | ||
|
||
function TabNavigator(): ReactElement { | ||
return ( | ||
<Tab.Navigator | ||
initialRouteName="Home" | ||
barStyle={{ backgroundColor: '#E5E4E2' }} | ||
> | ||
<Tab.Screen | ||
name="Home" | ||
component={HomeScreen} | ||
options={{ | ||
tabBarLabel: 'Home', | ||
tabBarIcon: HomeIcon, | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Search" | ||
component={SearchScreen} | ||
options={{ | ||
tabBarLabel: 'Search', | ||
tabBarIcon: SearchIcon, | ||
}} | ||
/> | ||
<Tab.Screen | ||
name="Content" | ||
component={MyContentStackNavigator} | ||
options={{ | ||
tabBarLabel: 'My Content', | ||
tabBarIcon: MyContentIcon, | ||
}} | ||
/> | ||
</Tab.Navigator> | ||
); | ||
} | ||
|
||
export default TabNavigator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createStackNavigator } from '@react-navigation/stack'; | ||
import React from 'react'; | ||
import MyContentScreen from '../../screens/MyContent'; | ||
import StoryScreen from '../../screens/StoryScreen'; | ||
import { MyContentStackParamList } from '../../types/navigation'; | ||
|
||
const MyContentStack = createStackNavigator<MyContentStackParamList>(); | ||
|
||
export default function MyContentStackNavigator() { | ||
return ( | ||
<MyContentStack.Navigator | ||
screenOptions={{ | ||
headerShown: false, | ||
}} | ||
> | ||
<MyContentStack.Screen name="MyContent" component={MyContentScreen} /> | ||
<MyContentStack.Screen name="Story" component={StoryScreen} /> | ||
</MyContentStack.Navigator> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,10 @@ | ||
import { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import React from 'react'; | ||
import { Button, Text, View } from 'react-native'; | ||
import { RootStackParamsList } from '../types/types'; | ||
import { Text, View } from 'react-native'; | ||
|
||
type HomeScreenProps = NativeStackScreenProps<RootStackParamsList, 'Home'>; | ||
|
||
export default function HomeScreen(props: HomeScreenProps) { | ||
const { navigation } = props; | ||
export default function HomeScreen() { | ||
return ( | ||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | ||
<Text>GIRLS WRITE NOW!</Text> | ||
<View style={{ padding: 20 }}> | ||
<Button title="Story Page" onPress={() => navigation.push('Story')} /> | ||
</View> | ||
<View style={{ padding: 20 }}> | ||
<Button title="Login Page" onPress={() => navigation.push('Login')} /> | ||
</View> | ||
<View style={{ padding: 20 }}> | ||
<Button title="Toast Page" onPress={() => navigation.push('Toast')} /> | ||
</View> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import React from 'react'; | ||
import { Button, Text, View } from 'react-native'; | ||
import { MyContentStackParamList } from '../types/navigation'; | ||
|
||
type MyContentScreenProps = NativeStackScreenProps< | ||
MyContentStackParamList, | ||
'MyContent' | ||
>; | ||
|
||
export default function MyContentScreen(props: MyContentScreenProps) { | ||
const { navigation } = props; | ||
return ( | ||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | ||
<Text>My Content</Text> | ||
<View style={{ padding: 20 }}> | ||
<Button | ||
title="Story Page" | ||
onPress={() => navigation.navigate('Story')} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
|
||
export default function SearchScreen() { | ||
return ( | ||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}> | ||
<Text>Search Screen</Text> | ||
</View> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type RootStackParamsList = { | ||
Home: undefined; | ||
Search: undefined; | ||
Content: undefined; | ||
}; | ||
|
||
export type MyContentStackParamList = { | ||
MyContent: undefined; | ||
Story: undefined; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
export type RootStackParamsList = { | ||
Home: undefined; | ||
Story: undefined; | ||
Login: undefined; | ||
Toast: undefined; | ||
}; | ||