-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexplore.tsx
More file actions
242 lines (233 loc) · 7.59 KB
/
explore.tsx
File metadata and controls
242 lines (233 loc) · 7.59 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import { Link } from "expo-router";
import { SymbolView } from "expo-symbols";
import React from "react";
import { Platform, Pressable, ScrollView, StyleSheet, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { ThemedText } from "@/components/themed-text";
import { ThemedView } from "@/components/themed-view";
import { Collapsible } from "@/components/ui/collapsible";
import { WebBadge } from "@/components/web-badge";
import { BottomTabInset, MaxContentWidth, Spacing } from "@/constants/theme";
import { useTheme } from "@/hooks/use-theme";
import { ReactNativeGrabScreen } from "react-native-grab";
export default function TabTwoScreen() {
const safeAreaInsets = useSafeAreaInsets();
const insets = {
...safeAreaInsets,
bottom: safeAreaInsets.bottom + BottomTabInset + Spacing.three,
};
const theme = useTheme();
const contentPlatformStyle = Platform.select({
android: {
paddingTop: insets.top,
paddingLeft: insets.left,
paddingRight: insets.right,
paddingBottom: insets.bottom,
},
web: {
paddingTop: Spacing.six,
paddingBottom: Spacing.four,
},
});
return (
<ReactNativeGrabScreen>
<ScrollView
style={[styles.scrollView, { backgroundColor: theme.background }]}
contentInset={insets}
contentContainerStyle={[styles.contentContainer, contentPlatformStyle]}
>
<ThemedView style={styles.container}>
<ThemedView style={styles.titleContainer}>
<ThemedText type="subtitle">Selection playground</ThemedText>
<ThemedText style={styles.centerText} themeColor="textSecondary">
Tricky examples to try with React Native Grab.{"\n"}
Select overlays, absolute elements, and modal content.
</ThemedText>
</ThemedView>
<ThemedView style={styles.sectionsWrapper}>
<Collapsible title="Absolutely positioned elements">
<ThemedText type="small">
These cards use <ThemedText type="code">position: absolute</ThemedText> for badges
and overlapping layers. Try selecting the badge or the floating label.
</ThemedText>
<View style={styles.absoluteExamplesRow}>
<ThemedView type="backgroundElement" style={styles.absoluteCard}>
<View style={styles.absoluteFloatingLabel}>
<ThemedText
onPress={() => alert("hello")}
type="small"
style={styles.overlayLabelText}
>
Coming soon
</ThemedText>
</View>
<View style={styles.cardImagePlaceholder} />
<View style={styles.cardContent}>
<ThemedText type="default" style={styles.cardTitle}>
Beta access
</ThemedText>
<ThemedText
type="small"
themeColor="textSecondary"
style={styles.cardDescription}
>
Early access to experimental DOM traversal features.
</ThemedText>
</View>
</ThemedView>
</View>
</Collapsible>
<Collapsible title="Modal route">
<ThemedText type="small">
Content in a modal route is presented as a modal screen. Open the modal and try
selecting its title or link.
</ThemedText>
<Link href="/modal" asChild>
<Pressable
style={({ pressed }) => [styles.modalTrigger, pressed && styles.pressed]}
>
<ThemedView type="backgroundElement" style={styles.modalTriggerInner}>
<ThemedText type="link">Open modal</ThemedText>
<SymbolView
tintColor={theme.text}
name={{ ios: "rectangle.stack", android: "layers", web: "layers" }}
size={14}
/>
</ThemedView>
</Pressable>
</Link>
</Collapsible>
<Collapsible title="Grab context playground">
<ThemedText type="small">
Open a dedicated modal with nested grab context providers. Each nested element
displays the context object it contributes.
</ThemedText>
<Link href="/context-playground" asChild>
<Pressable
style={({ pressed }) => [styles.modalTrigger, pressed && styles.pressed]}
>
<ThemedView type="backgroundElement" style={styles.modalTriggerInner}>
<ThemedText type="link">Open context playground</ThemedText>
<SymbolView
tintColor={theme.text}
name={{
ios: "square.stack.3d.down.forward",
android: "layers",
web: "layers",
}}
size={14}
/>
</ThemedView>
</Pressable>
</Link>
</Collapsible>
</ThemedView>
{Platform.OS === "web" && <WebBadge />}
</ThemedView>
</ScrollView>
</ReactNativeGrabScreen>
);
}
const styles = StyleSheet.create({
scrollView: {
flex: 1,
},
contentContainer: {
flexDirection: "row",
justifyContent: "center",
},
container: {
maxWidth: MaxContentWidth,
flexGrow: 1,
},
titleContainer: {
gap: Spacing.three,
alignItems: "center",
paddingHorizontal: Spacing.four,
paddingVertical: Spacing.six,
},
centerText: {
textAlign: "center",
},
pressed: {
opacity: 0.7,
},
sectionsWrapper: {
gap: Spacing.five,
paddingHorizontal: Spacing.four,
paddingTop: Spacing.three,
},
absoluteExamplesRow: {
flexDirection: "row",
flexWrap: "wrap",
gap: Spacing.three,
marginTop: Spacing.two,
},
absoluteCard: {
flex: 1,
minWidth: 160,
maxWidth: 220,
borderRadius: Spacing.three,
overflow: "visible",
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.08,
shadowRadius: 8,
elevation: 3,
},
cardImagePlaceholder: {
height: 88,
backgroundColor: "rgba(0,0,0,0.06)",
borderTopLeftRadius: Spacing.three,
borderTopRightRadius: Spacing.three,
},
cardContent: {
padding: Spacing.three,
gap: Spacing.one,
},
cardTitle: {
fontWeight: 600,
},
cardDescription: {
lineHeight: 20,
},
absoluteBadge: {
position: "absolute",
top: -Spacing.one,
right: -Spacing.one,
paddingHorizontal: Spacing.two,
paddingVertical: Spacing.half,
borderRadius: Spacing.two,
backgroundColor: "#208AEF",
},
badgeText: {
color: "#fff",
},
absoluteFloatingLabel: {
position: "absolute",
top: 26,
left: Spacing.three,
right: Spacing.three,
paddingVertical: Spacing.one,
paddingHorizontal: Spacing.two,
borderRadius: Spacing.two,
backgroundColor: "rgba(0,0,0,0.6)",
alignItems: "center",
justifyContent: "center",
},
overlayLabelText: {
color: "#fff",
},
modalTrigger: {
marginTop: Spacing.two,
},
modalTriggerInner: {
flexDirection: "row",
paddingHorizontal: Spacing.four,
paddingVertical: Spacing.two,
borderRadius: Spacing.three,
justifyContent: "center",
gap: Spacing.one,
alignItems: "center",
},
});