-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
71 lines (65 loc) · 2.26 KB
/
App.js
File metadata and controls
71 lines (65 loc) · 2.26 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as React from 'react';
import { View, Image, Dimensions } from 'react-native';
// import modules
import HomeScreen from './__routes/HomeScreen';
import BudgetScreen from './__routes/BudgetScreen';
import AnalyticsScreen from './__routes/AnalyticsScreen';
import AddItem from './__components/AddItem';
// import libraries
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator, HeaderBackButton } from '@react-navigation/stack';
// export reference for navigation from stack navigator
const navigationRef = React.createRef();
// function for navigating
const navigate = (name, params) => {
navigationRef.current && navigationRef.current.navigate(name, params);
}
// stack navigator
const Stack = createStackNavigator();
const App = () => {
return (
<NavigationContainer ref={ navigationRef }>
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
title: 'budgit',
headerStyle: {
backgroundColor: '#7DCCBE',
shadowColor: 'transparent',
},
headerTintColor: '#FFFFFF',
}}
>
<Stack.Screen
name='Home'
component={ HomeScreen }
options={{ headerShown: false }}
/>
<Stack.Screen
name='Budget'
component={ BudgetScreen }
options={{
}}
/>
<Stack.Screen
name='AddItem'
component={ AddItem }
options={{
headerLeft: () => (
<HeaderBackButton
onPress = {() => {
navigate('Home');
}}
/>
),
}}
/>
<Stack.Screen
name='Analytics'
component={ AnalyticsScreen }
/>
</Stack.Navigator>
</NavigationContainer>
);
}
export default App;