todosLists/Navigation/Navigation.js

37 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2022-02-11 08:58:55 +01:00
import React from 'react'
import { Text, View } from 'react-native'
import { NavigationContainer } from '@react-navigation/native'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import { TokenContext } from '../Context/Context'
import TodoListsScreen from '../Screen/TodoListsScreen'
import HomeScreen from '../Screen/HomeScreen'
import SignInScreen from '../Screen/SignInScreen'
import SignOutScreen from '../Screen/SignOutScreen'
import SignUpScreen from '../Screen/SignUpScreen'
const Tab = createBottomTabNavigator()
2022-02-24 12:55:27 +01:00
export default function Navigation() {
2022-02-11 08:58:55 +01:00
return (
<TokenContext.Consumer>
{([token, setToken]) => (
<NavigationContainer>
{token == null ? (
<Tab.Navigator>
<Tab.Screen name='SignIn' component={SignInScreen} />
<Tab.Screen name='SignUp' component={SignUpScreen} />
</Tab.Navigator>
) : (
<Tab.Navigator>
<Tab.Screen name='Home' component={HomeScreen} />
<Tab.Screen name='TodoLists' component={TodoListsScreen} />
<Tab.Screen name='SignOut' component={SignOutScreen} />
</Tab.Navigator>
)}
</NavigationContainer>
)}
</TokenContext.Consumer>
)
}