-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
120 lines (114 loc) · 3.1 KB
/
App.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
111
112
113
114
115
116
117
118
119
120
import "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import {
createNativeStackNavigator,
NativeStackScreenProps,
} from "@react-navigation/native-stack";
import { FlatList, Pressable, Text } from "react-native";
import { Feather } from "@expo/vector-icons";
import {
LottieAnimationScreen,
LayoutAnimationScreen,
AnimatedScreen,
ReanimatedScreen,
NoAnimationScreen,
} from "./screens";
const screens = [
{
name: "NoAnimationScreen",
title: "👎 No animation",
},
{
name: "LottieAnimationScreen",
title: "⏱ Loading animation",
},
{
name: "LayoutAnimationScreen",
title: "🎊 Fade in",
},
{
name: "AnimatedScreen",
title: "💫 Sequenced layout",
},
{
name: "ReanimatedScreen",
title: "🔁 Rearrange list",
},
] as const;
export type StackParamList = {
NavigationScreen: undefined;
NoAnimationScreen: undefined;
LottieAnimationScreen: undefined;
LayoutAnimationScreen: undefined;
AnimatedScreen: undefined;
ReanimatedScreen: undefined;
};
const Stack = createNativeStackNavigator<StackParamList>();
export default function App() {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen
name="NavigationScreen"
component={NavigationScreen}
options={{ title: "🎄 My Animated Wishlist 🎄" }}
/>
<Stack.Screen
name="NoAnimationScreen"
component={NoAnimationScreen}
options={{ title: screens[0].title }}
/>
<Stack.Screen
name="LottieAnimationScreen"
component={LottieAnimationScreen}
options={{ title: screens[1].title }}
/>
<Stack.Screen
name="LayoutAnimationScreen"
component={LayoutAnimationScreen}
options={{ title: screens[2].title }}
/>
<Stack.Screen
name="AnimatedScreen"
component={AnimatedScreen}
options={{ title: screens[3].title }}
/>
<Stack.Screen
name="ReanimatedScreen"
component={ReanimatedScreen}
options={{ title: screens[4].title }}
/>
</Stack.Navigator>
</NavigationContainer>
);
}
type Props = NativeStackScreenProps<StackParamList, "NavigationScreen">;
function NavigationScreen({ navigation }: Props) {
return (
<FlatList
data={screens}
keyExtractor={(item) => item.name}
renderItem={({ item }) => (
<Pressable
style={(state) => {
return {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
height: 60,
marginTop: 18,
marginHorizontal: 18,
padding: 12,
borderRadius: 12,
backgroundColor: state.pressed ? "#ccc" : "#fff",
};
}}
onPress={() => navigation.navigate(item.name)}
>
<Text style={{ fontSize: 18 }}>{item.title}</Text>
<Feather name="chevron-right" size={30} color="black" />
</Pressable>
)}
/>
);
}