I created a footer for my app which let’s the user browse to different pages. However, there are too many screens to display so I wanted to create one button on the right which let’s the user see a list with additional screens that can be opened. I found this to be quite common in other apps, see below an example where the ‘more’-button would give that functionality (i.e., open list of other screens that user can choose):
How it should look like
I googled but could not find example code with this functionality. I read about ‘Modals’ but was not sure if this works in a footer and/or is the most simple solution.
This is the items in my footer that I would like to edit to show a list with additional screens instead of just linking to one screen:
<TouchableOpacity style={styles.innerBox} onPress={()=>navigation.navigate("TabsScreenD")}>
<Entypo name="dots-three-horizontal" size={40} color="white" />
<Text style={[Styles.text14L,{color:color.white, textAlign:"center"}]} >
More
</Text>
</TouchableOpacity>
Since I am very new to react-native I am looking for a simple solution.
Many thanks!
EDIT:
Unfortunately, I am not able to implement the solution proposed below. It seems not to fit with the current structure of my app or I am not editing the right parts of the code.
Here are additional details of what my app currently looks like:
App.js:
const App = props => {
return (
<Provider store={store}>
<AppNavigator />
</Provider>
);
};
AppNavigator.js:
export const AppNavigator = props => {
return (
<NavigationContainer>
<Stack.Navigator
screenOptions={{
headerShown: false,
}}
initialRouteName={"SplashScreen"}
>
<Stack.Screen name="SplashScreen" component={SplashScreen} />
<Stack.Screen name="LoginScreen" component={LoginScreen} />
<Stack.Screen name="HomeScreen" component={HomeScreen} />
</Stack.Navigator>
</NavigationContainer>
);
};
FooterTabs.js:
const FooterTabs = ({navigation}) => {
return (
<View style={styles.container}>
<TouchableOpacity style={styles.innerBox} onPress={()=>navigation.navigate("HomeScreen")}>
<AntDesign name="home" size={40} color="white" />
<Text style={[Styles.text14L,{color:color.white, textAlign:"center"}]}>
Home
</Text>
</TouchableOpacity>
<View style={styles.line} />
<TouchableOpacity style={styles.innerBox} onPress={()=>navigation.navigate("TabsScreenD")}>
<Entypo name="dots-three-horizontal" size={40} color="white" />
<Text style={[Styles.text14L,{color:color.white, textAlign:"center"}]} >
More
</Text>
</TouchableOpacity>
</View>
)
}
Sorry, this is kinda lengthy. I tried to shorten where possible. Can anyone give me advice on what I need to edit. Based on Nazir’s answer below I tried to replace ‘FooterTabs’ with a TabNavigator, but could not integrate it properly.
Thanks again!
2
Answers
you should use Tab Navigation for your footer and Stack Navigation for your screens.
and in
StackNavigator.js
file you have to create Stack Navigator which will have multiple screens as you want.if you want to hide Tabs when inner screen of more tab is visible you will have to change the structure of navigation.
To demo this, I have added the code below, also the tutorial I personally follow which helped me clear many crucial concepts like this is also mentioned below.
I have just displayed a full-screen view in the demo, but you can customize it accordingly since you want a list of screens to go into.
When the
+
tab is pressed, I am presenting a view with a red background color.Free course (Step by step guide on how to show a modal on tab press) – Here
Code – Here
Recording – Here
Kindly have a look and comment if you have further questions.