BottomTabNavigation

This commit is contained in:
aeroreyna
2022-03-06 22:09:01 -08:00
parent 8b1a52a3af
commit b01d437a73
6 changed files with 56 additions and 16 deletions

36
App.js
View File

@@ -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>
);
}