BottomTabNavigation
This commit is contained in:
36
App.js
36
App.js
@@ -9,23 +9,37 @@ import { NavigationContainer } from '@react-navigation/native';
|
||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import Login from "./Views/Login.js"
|
||||
import Feed from "./Views/Feed.js"
|
||||
import { createMaterialBottomTabNavigator } from '@react-navigation/material-bottom-tabs';
|
||||
|
||||
const Tab = createMaterialBottomTabNavigator();
|
||||
|
||||
const Stack = createNativeStackNavigator();
|
||||
|
||||
export default function App() {
|
||||
let [isLoggedIn, setIsLoggedIn] = useState(false);
|
||||
|
||||
useEffect(async () => {
|
||||
let r = await API.isLoggedIn();
|
||||
setIsLoggedIn(r);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<NavigationContainer>
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen name="Feed" component={Feed} />
|
||||
<Stack.Screen name="Login" component={Login} />
|
||||
</Stack.Navigator>
|
||||
<Tab.Navigator initialRouteName="Home"
|
||||
activeColor="#f0edf6"
|
||||
inactiveColor="#3e2465"
|
||||
barStyle={{ backgroundColor: '#694fad' }}>
|
||||
<Tab.Screen
|
||||
name="Feed"
|
||||
component={Feed}
|
||||
options={{
|
||||
tabBarLabel: 'Home',
|
||||
tabBarIcon: ({ color }) => (
|
||||
<AwesomeIcon name="home" color={color} size={26} />
|
||||
),
|
||||
tabBarBadge: false
|
||||
}}
|
||||
listeners={({ navigation, route }) => ({
|
||||
tabPress: e => {
|
||||
navigation.navigate('Feed')
|
||||
},
|
||||
})}
|
||||
/>
|
||||
<Tab.Screen name="Login" component={Login} />
|
||||
</Tab.Navigator>
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user