-
Notifications
You must be signed in to change notification settings - Fork 0
/
NativeNavigation.tsx
110 lines (100 loc) · 2.26 KB
/
NativeNavigation.tsx
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import { useNavigation } from "@react-navigation/native";
import React from "react";
import { ScrollView, StyleSheet, Text, View, Button } from "react-native";
import { createNativeStackNavigator } from "react-native-screens/native-stack";
import { Fade } from "../components/Fade";
const Stack = createNativeStackNavigator();
export default function NativeNavigation() {
const navigation = useNavigation();
return (
<Stack.Navigator
screenOptions={{
headerStyle: {
backgroundColor: "#fcfcfc"
}
}}
>
<Stack.Screen
name="NativeNavigation.Home"
component={Home}
options={{
headerTitle: "Home",
headerRight: () => (
<Button
title="Notifications"
onPress={() => {
navigation.navigate("NativeNavigation.Notifications");
}}
/>
)
}}
/>
<Stack.Screen
name="NativeNavigation.Notifications"
component={Notifications}
options={{
headerTitle: "Notifications"
}}
/>
</Stack.Navigator>
);
}
function Home() {
const navigation = useNavigation();
navigation.setOptions({
headerLargeTitle: true
});
return (
<ScrollView>
<Fade visible direction="down">
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
<ListItem />
</Fade>
</ScrollView>
);
}
function Notifications() {
const navigation = useNavigation();
navigation.setOptions({
headerLargeTitle: false
});
return (
<View style={styles.container}>
<Text>Notifications</Text>
</View>
);
}
function ListItem() {
return (
<View style={styles.listItem}>
<Text style={styles.listItemText}>List Item</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center"
},
listItem: {
padding: 20,
backgroundColor: "white",
marginBottom: 20,
justifyContent: "center",
alignContent: "center"
},
listItemText: {
fontSize: 28
}
});