-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1deb222
commit af6cb40
Showing
7 changed files
with
175 additions
and
58 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
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; | ||
import { NavigationContainer } from '@react-navigation/native'; | ||
import { | ||
createNativeStackNavigator, | ||
type NativeStackScreenProps, | ||
} from '@react-navigation/native-stack'; | ||
import { Button, Text, View } from 'react-native'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
import { ToastDemo } from './ToastDemo'; | ||
|
||
function HomeScreen({ | ||
navigation, | ||
}: NativeStackScreenProps<HomeStackParamList, 'Home'>) { | ||
return ( | ||
<SafeAreaView style={{ flex: 1, backgroundColor: 'white' }}> | ||
<Button | ||
title="Show modal" | ||
onPress={() => { | ||
navigation.getParent()?.navigate('Modal'); | ||
}} | ||
/> | ||
<ToastDemo /> | ||
</SafeAreaView> | ||
); | ||
} | ||
|
||
function SettingsScreen() { | ||
return ( | ||
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}> | ||
<Text>Settings screen</Text> | ||
</View> | ||
); | ||
} | ||
|
||
type HomeStackParamList = { | ||
Home: undefined; | ||
}; | ||
|
||
const HomeStack = createNativeStackNavigator<HomeStackParamList>(); | ||
|
||
function HomeStackScreen() { | ||
return ( | ||
<HomeStack.Navigator> | ||
<HomeStack.Screen name="Home" component={HomeScreen} /> | ||
</HomeStack.Navigator> | ||
); | ||
} | ||
|
||
type SettingsStackParamList = { | ||
Settings: undefined; | ||
}; | ||
|
||
const SettingsStack = createNativeStackNavigator<SettingsStackParamList>(); | ||
|
||
function SettingsStackScreen() { | ||
return ( | ||
<SettingsStack.Navigator> | ||
<SettingsStack.Screen name="Settings" component={SettingsScreen} /> | ||
</SettingsStack.Navigator> | ||
); | ||
} | ||
|
||
type RootStackParamList = { | ||
Tab: undefined; | ||
Modal: undefined; | ||
}; | ||
|
||
const RootStack = createNativeStackNavigator<RootStackParamList>(); | ||
|
||
const Tab = createBottomTabNavigator(); | ||
|
||
const MainTab: React.FC = () => { | ||
return ( | ||
<Tab.Navigator screenOptions={{ headerShown: false }}> | ||
<Tab.Screen name="HomeStack" component={HomeStackScreen} /> | ||
<Tab.Screen name="SettingsStack" component={SettingsStackScreen} /> | ||
</Tab.Navigator> | ||
); | ||
}; | ||
|
||
const ToastDemoModal: React.FC = () => { | ||
return ( | ||
<SafeAreaView style={{ flex: 1, backgroundColor: 'white' }}> | ||
<ToastDemo /> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
export default function Navigator() { | ||
return ( | ||
<NavigationContainer> | ||
<RootStack.Navigator> | ||
<RootStack.Screen | ||
name="Tab" | ||
component={MainTab} | ||
options={{ | ||
headerShown: false, | ||
}} | ||
/> | ||
<RootStack.Screen | ||
name="Modal" | ||
component={ToastDemoModal} | ||
options={{ | ||
presentation: 'modal', | ||
headerShown: false, | ||
}} | ||
/> | ||
</RootStack.Navigator> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,4 +218,4 @@ | |
"type": "library", | ||
"version": "0.41.0" | ||
} | ||
} | ||
} |
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