-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
82 lines (73 loc) · 2.57 KB
/
App.js
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
72
73
74
75
76
77
78
79
80
81
82
import { StatusBar } from "expo-status-bar";
import * as React from "react";
import { NavigationContainer } from "@react-navigation/native";
import {
// CardStyleInterpolators,
createStackNavigator,
} from "@react-navigation/stack";
import { Appbar } from "react-native-paper";
import HomeScreen from "./src/screens/HomeScreen";
import AddEntryScreen from "./src/screens/AddEntryScreen";
import SummaryScreen from "./src/screens/SummaryScreen";
import CounterScreen from "./src/screens/CounterScreen";
import AboutScreen from "./src/screens/AboutScreen";
// import HelloScreen from "./src/screens/HelloScreen";
const Stack = createStackNavigator();
const CustomNavigationBar = ({ scene, previous, navigation }) => {
const { options } = scene.descriptor;
const title = options.headerTitle !== undefined ? options.headerTitle : options.title !== undefined ? options.title : scene.route.name;
const _goToAbout = () => navigation.navigate("About");
return (
<Appbar.Header>
{previous ? <Appbar.BackAction onPress={navigation.goBack} /> : null}
<Appbar.Content title={title}/>
{previous ? null : <Appbar.Action icon="information-outline" onPress={_goToAbout} />}
</Appbar.Header>
)
}
const App = () => {
return (
<NavigationContainer>
<StatusBar style="hidden" />
<Stack.Navigator
initialRouteName="Home"
screenOptions={{
// cardStyleInterpolator: CardStyleInterpolators.forHorizontalIOS,
header: (props) => <CustomNavigationBar {...props} />
}}
>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{headerTitle: "Life Tracker"}}
/>
<Stack.Screen
name="AddEntry"
component={AddEntryScreen}
options={{headerTitle: "New Item"}}
/>
<Stack.Screen
name="Summary"
component={SummaryScreen}
options={{headerTitle: "Summary"}}
/>
<Stack.Screen
name="Counter"
component={CounterScreen}
options={({ route }) => ({ headerTitle: "Counter for " + route.params.itemObject.title.charAt(0).toUpperCase() + route.params.itemObject.title.slice(1)})}
/>
<Stack.Screen
name="About"
component={AboutScreen}
options={{headerTitle: "About"}}
/>
{/* <Stack.Screen
name="Hello"
component={HelloScreen}
options={{headerTitle: "Dummy"}}
/> */}
</Stack.Navigator>
</NavigationContainer>
);
};
export default App;