-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathApp.js
More file actions
50 lines (45 loc) · 1.48 KB
/
App.js
File metadata and controls
50 lines (45 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React, { createContext, useState } from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import SplashScreen from 'react-native-splash-screen';
import { Icon } from 'native-base';
import ProductsComponent from './app/views/products';
import globalStyles from './app/styles';
console.disableYellowBox = true;
export const UserContext = createContext({
authtoken: '',
setAuthtoken: () => {
console.log('called');
}
});
console.disableYellowBox = true;
const Stack = createStackNavigator();
function App() {
const [authtoken, setAuthtoken] = useState('Bearer 6W9hcvwRvyyZgPu9Odq7ko8DSY8Nfm'); // Ideally, this will be set after making api call
SplashScreen.hide();
return (
<UserContext.Provider value={{ authtoken, setAuthtoken }}>
<NavigationContainer>
<Stack.Navigator
initialRouteName="Products"
screenOptions={{
headerLeft: ({ color, size }) => (
<Icon
name={'menu'}
type={'MaterialCommunityIcons'}
style={[globalStyles.headerLeft, { size }]}
onPress={() => alert('Hello, from header')}
/>
),
headerTitleAlign: 'center',
headerTitle: 'Products',
headerStyle: globalStyles.headerTitleStyle,
headerTitleStyle: { color: 'white' }
}}>
<Stack.Screen name="Products" component={ProductsComponent} />
</Stack.Navigator>
</NavigationContainer>
</UserContext.Provider>
);
}
export default App;