Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[templates] Migrate React Navigation to 5.0 (#6974)
- Loading branch information
Showing
7 changed files
with
216 additions
and
195 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 was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
templates/expo-template-tabs/navigation/AppNavigator.web.js
This file was deleted.
Oops, something went wrong.
121 changes: 49 additions & 72 deletions
121
templates/expo-template-tabs/navigation/MainTabNavigator.js
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,79 +1,56 @@ | ||
import React from 'react'; | ||
import { Platform } from 'react-native'; | ||
import { createStackNavigator } from 'react-navigation-stack'; | ||
import { createBottomTabNavigator } from 'react-navigation-tabs'; | ||
|
||
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; | ||
import TabBarIcon from '../components/TabBarIcon'; | ||
import HomeScreen from '../screens/HomeScreen'; | ||
import LinksScreen from '../screens/LinksScreen'; | ||
import SettingsScreen from '../screens/SettingsScreen'; | ||
|
||
const config = Platform.select({ | ||
web: { headerMode: 'screen' }, | ||
default: {}, | ||
}); | ||
|
||
const HomeStack = createStackNavigator( | ||
{ | ||
Home: HomeScreen, | ||
}, | ||
config | ||
); | ||
|
||
HomeStack.navigationOptions = { | ||
tabBarLabel: 'Home', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
name={ | ||
Platform.OS === 'ios' | ||
? `ios-information-circle${focused ? '' : '-outline'}` | ||
: 'md-information-circle' | ||
} | ||
/> | ||
), | ||
}; | ||
|
||
HomeStack.path = ''; | ||
|
||
const LinksStack = createStackNavigator( | ||
{ | ||
Links: LinksScreen, | ||
}, | ||
config | ||
); | ||
|
||
LinksStack.navigationOptions = { | ||
tabBarLabel: 'Links', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon focused={focused} name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'} /> | ||
), | ||
}; | ||
|
||
LinksStack.path = ''; | ||
|
||
const SettingsStack = createStackNavigator( | ||
{ | ||
Settings: SettingsScreen, | ||
}, | ||
config | ||
); | ||
|
||
SettingsStack.navigationOptions = { | ||
tabBarLabel: 'Settings', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon focused={focused} name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'} /> | ||
), | ||
}; | ||
|
||
SettingsStack.path = ''; | ||
|
||
const tabNavigator = createBottomTabNavigator({ | ||
HomeStack, | ||
LinksStack, | ||
SettingsStack, | ||
}); | ||
|
||
tabNavigator.path = ''; | ||
|
||
export default tabNavigator; | ||
const BottomTab = createBottomTabNavigator(); | ||
|
||
export default function MainTabNavigator() { | ||
return ( | ||
<BottomTab.Navigator> | ||
<BottomTab.Screen | ||
name="Home" | ||
component={HomeScreen} | ||
options={{ | ||
title: 'Home', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
name={ | ||
Platform.OS === 'ios' | ||
? `ios-information-circle${focused ? '' : '-outline'}` | ||
: 'md-information-circle' | ||
} | ||
/> | ||
), | ||
}} | ||
/> | ||
<BottomTab.Screen | ||
name="Links" | ||
component={LinksScreen} | ||
options={{ | ||
title: 'Links', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon focused={focused} name={Platform.OS === 'ios' ? 'ios-link' : 'md-link'} /> | ||
), | ||
}} | ||
/> | ||
<BottomTab.Screen | ||
name="Settings" | ||
component={SettingsScreen} | ||
options={{ | ||
title: 'Settings', | ||
tabBarIcon: ({ focused }) => ( | ||
<TabBarIcon | ||
focused={focused} | ||
name={Platform.OS === 'ios' ? 'ios-options' : 'md-options'} | ||
/> | ||
), | ||
}} | ||
/> | ||
</BottomTab.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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useLinking } from '@react-navigation/native'; | ||
|
||
export default function(containerRef) { | ||
const { getInitialState } = useLinking(containerRef, { | ||
prefixes: [], | ||
config: { | ||
Root: { | ||
path: 'root', | ||
screens: { | ||
Home: 'home', | ||
Links: 'links', | ||
Settings: 'settings', | ||
}, | ||
}, | ||
}, | ||
}); | ||
return getInitialState(); | ||
} |
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
Oops, something went wrong.