@wasto/cms-components 1.5.10 → 1.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/README.md +47 -47
  2. package/dist/index.d.mts +103 -2
  3. package/dist/index.d.ts +103 -2
  4. package/dist/index.js +2861 -2442
  5. package/dist/index.mjs +3651 -3227
  6. package/package.json +2 -2
  7. package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
  8. package/src/components/article/Article.tsx +21 -21
  9. package/src/components/article/ArticleCard.tsx +81 -81
  10. package/src/components/article/ArticleExcerpts.tsx +80 -80
  11. package/src/components/article/ArticleList.tsx +114 -114
  12. package/src/components/article/ArticleMarkdown.tsx +170 -170
  13. package/src/components/article/ArticleReaderModal.tsx +93 -93
  14. package/src/components/article/ArticleSingle.tsx +57 -57
  15. package/src/components/bottom-tab/BottomTab.tsx +392 -392
  16. package/src/components/button/Button.tsx +154 -154
  17. package/src/components/challenge/Badges.tsx +84 -84
  18. package/src/components/challenge/BadgesModal.tsx +166 -166
  19. package/src/components/challenge/Challenge.tsx +380 -380
  20. package/src/components/challenge/ChallengeModal.tsx +231 -231
  21. package/src/components/challenge/ChallengeVignette.tsx +249 -249
  22. package/src/components/challenge/ChallengesModal.tsx +243 -243
  23. package/src/components/challenge/QuizModal.tsx +381 -381
  24. package/src/components/challenge/ResultModal.tsx +144 -144
  25. package/src/components/chat/Chat.tsx +928 -928
  26. package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
  27. package/src/components/columns/Columns.tsx +33 -33
  28. package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
  29. package/src/components/content-inset/ContentInset.tsx +33 -33
  30. package/src/components/header/Header.tsx +391 -391
  31. package/src/components/image/Image.tsx +15 -15
  32. package/src/components/image/ImageFrame.tsx +102 -102
  33. package/src/components/image/ImageMedia.tsx +31 -31
  34. package/src/components/image/ImageUrl.tsx +30 -30
  35. package/src/components/locations-map/LocationSheet.tsx +417 -417
  36. package/src/components/locations-map/LocationsMap.native.tsx +260 -260
  37. package/src/components/locations-map/LocationsMap.tsx +13 -13
  38. package/src/components/locations-map/LocationsMap.web.tsx +10 -10
  39. package/src/components/locations-map/LocationsMapShell.tsx +527 -527
  40. package/src/components/locations-map/LocationsMapView.tsx +108 -108
  41. package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
  42. package/src/components/nav-button/NavButton.tsx +59 -59
  43. package/src/components/next-collection/NextCollection.tsx +636 -621
  44. package/src/components/notifications/NotificationsScreen.tsx +247 -247
  45. package/src/components/page/Page.tsx +102 -64
  46. package/src/components/parapraph/Paragraph.tsx +67 -67
  47. package/src/components/profile/ProfileScreen.tsx +236 -236
  48. package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
  49. package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
  50. package/src/components/search/Search.tsx +320 -320
  51. package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
  52. package/src/components/title/Title.tsx +100 -100
  53. package/src/components/vision/Vision.tsx +447 -447
  54. package/src/components/vision/VisionActionCard.tsx +117 -117
  55. package/src/components/vision/VisionCapture.tsx +30 -30
  56. package/src/components/vision/VisionTapOverlay.tsx +122 -122
  57. package/src/contexts/AnnouncementsContext.tsx +171 -171
  58. package/src/contexts/AppDataContext.tsx +458 -0
  59. package/src/contexts/ChallengesContext.tsx +182 -182
  60. package/src/contexts/LocalContext.tsx +227 -227
  61. package/src/contexts/ThemeContext.tsx +37 -37
  62. package/src/contexts/WastoContext.tsx +130 -127
  63. package/src/helpers/blogPost.ts +72 -72
  64. package/src/helpers/generateQuizQuestions.ts +247 -247
  65. package/src/helpers/getContrastColor.ts +18 -18
  66. package/src/helpers/haptics.ts +20 -20
  67. package/src/helpers/hoursSchedule.ts +230 -230
  68. package/src/helpers/htmlContentToMarkdown.ts +114 -114
  69. package/src/helpers/layout.ts +54 -54
  70. package/src/helpers/loadLinearGradient.ts +22 -22
  71. package/src/helpers/mapLocations.ts +170 -0
  72. package/src/helpers/maquetteTheme.ts +76 -76
  73. package/src/helpers/markdownUnderlinePlugin.ts +32 -32
  74. package/src/helpers/nextCollection.ts +122 -0
  75. package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
  76. package/src/helpers/publicMediaUrl.ts +8 -8
  77. package/src/helpers/resolveApiAssetUrl.ts +21 -21
  78. package/src/helpers/systemRoutes.ts +7 -7
  79. package/src/helpers/themeStyles.ts +114 -114
  80. package/src/helpers/ttlCache.ts +41 -0
  81. package/src/helpers/useSafeAreaPadding.ts +14 -14
  82. package/src/hooks/useBadges.ts +100 -100
  83. package/src/hooks/useBlogPosts.ts +109 -105
  84. package/src/hooks/useChallenges.ts +110 -110
  85. package/src/hooks/useCities.ts +56 -56
  86. package/src/hooks/useCityAnnouncements.ts +118 -118
  87. package/src/hooks/useCollectionCalendar.ts +421 -421
  88. package/src/hooks/useColumns.ts +19 -19
  89. package/src/hooks/useConsignes.ts +62 -62
  90. package/src/hooks/useLocations.ts +120 -248
  91. package/src/hooks/useNextCollection.ts +163 -238
  92. package/src/hooks/useRecyclingInfo.ts +90 -90
  93. package/src/hooks/useWastoClient.ts +16 -16
  94. package/src/index.ts +149 -142
  95. package/src/navigation/NavigationContext.tsx +56 -56
  96. package/src/sentry/initSentry.ts +120 -120
  97. package/src/types/Theme.ts +72 -72
  98. package/src/types/css-modules.d.ts +1 -1
@@ -1,417 +1,417 @@
1
- import { Linking, Platform, Pressable, ScrollView, Share, StyleSheet, Text, View } from "react-native";
2
- import {
3
- ChevronUp,
4
- Clock,
5
- Copy,
6
- MapPin,
7
- Phone,
8
- X,
9
- } from "lucide-react-native";
10
- import { useEffect, useState, type ReactNode } from "react";
11
- import { Gesture, GestureDetector } from "react-native-gesture-handler";
12
- import Animated, {
13
- Easing,
14
- interpolate,
15
- runOnJS,
16
- useAnimatedStyle,
17
- useSharedValue,
18
- withTiming,
19
- } from "react-native-reanimated";
20
- import { useTheme } from "../../contexts/ThemeContext";
21
- import { Theme } from "../../types/Theme";
22
- import { Button } from "../button/Button";
23
- import {
24
- LOCATION_CATEGORY_META,
25
- type MapLocation,
26
- } from "../../hooks/useLocations";
27
- import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
28
- import { SPACE } from "../../helpers/layout";
29
-
30
- export type LocationSheetProps = {
31
- location: MapLocation;
32
- onClose: () => void;
33
- };
34
-
35
- const ENTER = { duration: 280, easing: Easing.out(Easing.cubic) };
36
- const HOURS_ANIM = { duration: 240, easing: Easing.out(Easing.cubic) };
37
- const DISMISS_Y = 96;
38
- const DISMISS_V = 900;
39
-
40
- async function copyText(value: string) {
41
- try {
42
- const webNav = (
43
- globalThis as {
44
- navigator?: { clipboard?: { writeText: (v: string) => Promise<void> } };
45
- }
46
- ).navigator;
47
- if (Platform.OS === "web" && webNav?.clipboard?.writeText) {
48
- await webNav.clipboard.writeText(value);
49
- return;
50
- }
51
- await Share.share({ message: value });
52
- } catch {
53
- // ignore copy failures
54
- }
55
- }
56
-
57
- export function LocationSheet({
58
- location,
59
- onClose,
60
- }: LocationSheetProps): ReactNode {
61
- const { theme } = useTheme();
62
- const t = resolveTheme(theme);
63
- const themedStyles = createThemedStyles(theme);
64
- const meta = LOCATION_CATEGORY_META[location.category];
65
- const [hoursOpen, setHoursOpen] = useState(false);
66
- const translateY = useSharedValue(48);
67
- const opacity = useSharedValue(0);
68
- const hoursProgress = useSharedValue(0);
69
- const hoursHeight = useSharedValue(0);
70
-
71
- useEffect(() => {
72
- setHoursOpen(false);
73
- hoursProgress.value = 0;
74
- translateY.value = 48;
75
- opacity.value = 0;
76
- translateY.value = withTiming(0, ENTER);
77
- opacity.value = withTiming(1, { duration: 220, easing: Easing.out(Easing.cubic) });
78
- }, [hoursProgress, location.id, opacity, translateY]);
79
-
80
- const closeSheet = () => {
81
- onClose();
82
- };
83
-
84
- const dismiss = () => {
85
- opacity.value = withTiming(0, { duration: 180, easing: Easing.out(Easing.cubic) });
86
- translateY.value = withTiming(420, { duration: 220, easing: Easing.in(Easing.cubic) }, (finished) => {
87
- if (finished) runOnJS(closeSheet)();
88
- });
89
- };
90
-
91
- const pan = Gesture.Pan()
92
- .activeOffsetY(16)
93
- .failOffsetX([-24, 24])
94
- .onUpdate((event) => {
95
- translateY.value = Math.max(0, event.translationY);
96
- })
97
- .onEnd((event) => {
98
- if (event.translationY > DISMISS_Y || event.velocityY > DISMISS_V) {
99
- runOnJS(dismiss)();
100
- return;
101
- }
102
- translateY.value = withTiming(0, ENTER);
103
- });
104
-
105
- const sheetStyle = useAnimatedStyle(() => ({
106
- transform: [{ translateY: translateY.value }],
107
- opacity: opacity.value,
108
- }), []);
109
-
110
- const chevronStyle = useAnimatedStyle(() => ({
111
- transform: [{ rotate: `${interpolate(hoursProgress.value, [0, 1], [180, 0])}deg` }],
112
- }), []);
113
-
114
- const hoursBodyStyle = useAnimatedStyle(() => ({
115
- height: hoursHeight.value * hoursProgress.value,
116
- opacity: hoursProgress.value,
117
- overflow: "hidden" as const,
118
- }), []);
119
-
120
- const toggleHours = () => {
121
- const next = !hoursOpen;
122
- setHoursOpen(next);
123
- hoursProgress.value = withTiming(next ? 1 : 0, HOURS_ANIM);
124
- };
125
-
126
- const openDirections = () => {
127
- const q = encodeURIComponent(
128
- location.address || `${location.lat},${location.lon}`,
129
- );
130
- void Linking.openURL(`https://maps.google.com/?q=${q}`);
131
- };
132
-
133
- const callPhone = () => {
134
- if (!location.phone) return;
135
- void Linking.openURL(`tel:${location.phone}`);
136
- };
137
-
138
- const hoursRows = location.hoursRows ?? [];
139
- const hasHours = hoursRows.length > 0 || Boolean(location.hoursDisplay);
140
- const status = location.hoursStatus;
141
-
142
- return (
143
- <GestureDetector gesture={pan}>
144
- <Animated.View style={[sheetStyle, styles.sheetAnim]}>
145
- <View
146
- style={[
147
- styles.sheet,
148
- cardStyle(theme),
149
- {
150
- borderTopLeftRadius: t.radii.lg,
151
- borderTopRightRadius: t.radii.lg,
152
- borderBottomLeftRadius: 0,
153
- borderBottomRightRadius: 0,
154
- },
155
- ]}
156
- >
157
- <View style={[styles.handle, { backgroundColor: theme.colors.border }]} />
158
-
159
- <View style={styles.head}>
160
- <View style={styles.headText}>
161
- <Text style={[styles.name, { color: theme.colors.onSurface }]}>
162
- {location.name}
163
- </Text>
164
- <Text style={themedStyles.meta}>{meta.label.toUpperCase()}</Text>
165
- </View>
166
- <Pressable
167
- onPress={dismiss}
168
- hitSlop={8}
169
- accessibilityLabel="Fermer"
170
- style={[
171
- styles.closeBtn,
172
- {
173
- backgroundColor: theme.colors.background,
174
- borderRadius: t.radii.pill,
175
- },
176
- ]}
177
- >
178
- <X size={16} color={theme.colors.onSurface} />
179
- </Pressable>
180
- </View>
181
-
182
- <ScrollView
183
- style={styles.bodyScroll}
184
- contentContainerStyle={styles.bodyContent}
185
- showsVerticalScrollIndicator={false}
186
- >
187
- {location.address ? (
188
- <View style={styles.row}>
189
- <MapPin size={16} color={t.colors.muted} />
190
- <Text style={themedStyles.address}>{location.address}</Text>
191
- <Pressable
192
- onPress={() => void copyText(location.address!)}
193
- hitSlop={8}
194
- accessibilityLabel="Copier l’adresse"
195
- >
196
- <Copy size={16} color={theme.colors.primary} />
197
- </Pressable>
198
- </View>
199
- ) : null}
200
-
201
- {location.phone ? (
202
- <View style={styles.row}>
203
- <Phone size={16} color={t.colors.muted} />
204
- <Text style={themedStyles.address}>{location.phone}</Text>
205
- <Pressable
206
- onPress={callPhone}
207
- hitSlop={8}
208
- accessibilityLabel="Appeler"
209
- >
210
- <Phone size={16} color={theme.colors.primary} />
211
- </Pressable>
212
- <Pressable
213
- onPress={() => void copyText(location.phone!)}
214
- hitSlop={8}
215
- accessibilityLabel="Copier le numéro"
216
- >
217
- <Copy size={16} color={theme.colors.primary} />
218
- </Pressable>
219
- </View>
220
- ) : null}
221
-
222
- {hasHours ? (
223
- <View
224
- style={[
225
- styles.hoursBox,
226
- {
227
- backgroundColor: theme.colors.background,
228
- borderRadius: t.radii.md,
229
- },
230
- ]}
231
- >
232
- <Pressable onPress={toggleHours} style={styles.hoursHeader}>
233
- <Clock size={16} color={t.colors.muted} />
234
- <Text style={[styles.hoursStatus, { color: t.colors.muted }]}>
235
- {status ? (
236
- <>
237
- <Text
238
- style={{
239
- color: status.open
240
- ? theme.colors.primary
241
- : theme.colors.error,
242
- fontWeight: "700",
243
- }}
244
- >
245
- {status.open ? "Ouvert" : "Fermé"}
246
- </Text>
247
- {status.text.includes(" - ")
248
- ? ` - ${status.text.split(" - ").slice(1).join(" - ")}`
249
- : ""}
250
- </>
251
- ) : (
252
- location.hoursDisplay ?? "Horaires"
253
- )}
254
- </Text>
255
- <Animated.View style={chevronStyle}>
256
- <ChevronUp size={16} color={theme.colors.primary} />
257
- </Animated.View>
258
- </Pressable>
259
- <Animated.View style={hoursBodyStyle}>
260
- <View
261
- style={styles.hoursMeasure}
262
- onLayout={(event) => {
263
- hoursHeight.value = event.nativeEvent.layout.height;
264
- }}
265
- >
266
- {hoursRows.length > 0 ? (
267
- <View style={styles.hoursList}>
268
- {hoursRows.map((row) => (
269
- <View key={row.label} style={styles.hoursRow}>
270
- <Text style={[styles.hoursDay, { color: t.colors.muted }]}>
271
- {row.label}
272
- </Text>
273
- <Text style={[styles.hoursValue, { color: t.colors.muted }]}>
274
- {row.hours}
275
- </Text>
276
- </View>
277
- ))}
278
- </View>
279
- ) : location.hoursDisplay ? (
280
- <Text style={[styles.hoursFallback, { color: t.colors.muted }]}>
281
- {location.hoursDisplay}
282
- </Text>
283
- ) : null}
284
- </View>
285
- </Animated.View>
286
- </View>
287
- ) : null}
288
- </ScrollView>
289
-
290
- <Button
291
- onPress={openDirections}
292
- rightIcon={MapPin}
293
- style={[styles.cta, { borderRadius: t.radii.md }]}
294
- >
295
- Afficher Itinéraire
296
- </Button>
297
- </View>
298
- </Animated.View>
299
- </GestureDetector>
300
- );
301
- }
302
-
303
- const createThemedStyles = (theme: Theme) =>
304
- StyleSheet.create({
305
- meta: {
306
- color: theme.colors.muted ?? theme.colors.onSurface,
307
- fontSize: 12,
308
- fontWeight: "700",
309
- letterSpacing: 0.4,
310
- marginTop: 4,
311
- },
312
- address: {
313
- color: theme.colors.onSurface,
314
- flex: 1,
315
- fontSize: 14,
316
- },
317
- });
318
-
319
- const styles = StyleSheet.create({
320
- sheetAnim: {
321
- maxHeight: "82%",
322
- },
323
- sheet: {
324
- paddingHorizontal: SPACE.pageX,
325
- paddingTop: 14,
326
- paddingBottom: SPACE.pageX,
327
- gap: 24,
328
- maxHeight: "100%",
329
- },
330
- handle: {
331
- alignSelf: "center",
332
- width: 40,
333
- height: 4,
334
- borderRadius: 2,
335
- marginBottom: 2,
336
- },
337
- head: {
338
- flexDirection: "row",
339
- alignItems: "flex-start",
340
- gap: 10,
341
- },
342
- headText: {
343
- flex: 1,
344
- },
345
- closeBtn: {
346
- width: 28,
347
- height: 28,
348
- alignItems: "center",
349
- justifyContent: "center",
350
- },
351
- name: {
352
- fontSize: 18,
353
- fontWeight: "800",
354
- },
355
- bodyScroll: {
356
- flexGrow: 0,
357
- flexShrink: 1,
358
- minHeight: 132,
359
- },
360
- bodyContent: {
361
- gap: 22,
362
- paddingBottom: 10,
363
- },
364
- row: {
365
- flexDirection: "row",
366
- alignItems: "center",
367
- gap: 10,
368
- },
369
- hoursBox: {
370
- padding: 12,
371
- paddingBottom: 4,
372
- },
373
- hoursHeader: {
374
- flexDirection: "row",
375
- alignItems: "center",
376
- gap: 8,
377
- paddingBottom: 8,
378
- },
379
- hoursStatus: {
380
- flex: 1,
381
- fontSize: 14,
382
- },
383
- hoursList: {
384
- gap: 6,
385
- paddingLeft: 24,
386
- paddingBottom: 8,
387
- },
388
- hoursMeasure: {
389
- position: "absolute",
390
- left: 0,
391
- right: 0,
392
- },
393
- hoursRow: {
394
- flexDirection: "row",
395
- justifyContent: "space-between",
396
- alignItems: "center",
397
- gap: 12,
398
- },
399
- hoursDay: {
400
- fontSize: 13,
401
- },
402
- hoursValue: {
403
- fontSize: 13,
404
- textAlign: "right",
405
- flex: 1,
406
- },
407
- hoursFallback: {
408
- fontSize: 13,
409
- lineHeight: 18,
410
- paddingLeft: 24,
411
- paddingBottom: 8,
412
- },
413
- cta: {
414
- height: SPACE.buttonH,
415
- marginTop: 12,
416
- },
417
- });
1
+ import { Linking, Platform, Pressable, ScrollView, Share, StyleSheet, Text, View } from "react-native";
2
+ import {
3
+ ChevronUp,
4
+ Clock,
5
+ Copy,
6
+ MapPin,
7
+ Phone,
8
+ X,
9
+ } from "lucide-react-native";
10
+ import { useEffect, useState, type ReactNode } from "react";
11
+ import { Gesture, GestureDetector } from "react-native-gesture-handler";
12
+ import Animated, {
13
+ Easing,
14
+ interpolate,
15
+ runOnJS,
16
+ useAnimatedStyle,
17
+ useSharedValue,
18
+ withTiming,
19
+ } from "react-native-reanimated";
20
+ import { useTheme } from "../../contexts/ThemeContext";
21
+ import { Theme } from "../../types/Theme";
22
+ import { Button } from "../button/Button";
23
+ import {
24
+ LOCATION_CATEGORY_META,
25
+ type MapLocation,
26
+ } from "../../hooks/useLocations";
27
+ import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
28
+ import { SPACE } from "../../helpers/layout";
29
+
30
+ export type LocationSheetProps = {
31
+ location: MapLocation;
32
+ onClose: () => void;
33
+ };
34
+
35
+ const ENTER = { duration: 280, easing: Easing.out(Easing.cubic) };
36
+ const HOURS_ANIM = { duration: 240, easing: Easing.out(Easing.cubic) };
37
+ const DISMISS_Y = 96;
38
+ const DISMISS_V = 900;
39
+
40
+ async function copyText(value: string) {
41
+ try {
42
+ const webNav = (
43
+ globalThis as {
44
+ navigator?: { clipboard?: { writeText: (v: string) => Promise<void> } };
45
+ }
46
+ ).navigator;
47
+ if (Platform.OS === "web" && webNav?.clipboard?.writeText) {
48
+ await webNav.clipboard.writeText(value);
49
+ return;
50
+ }
51
+ await Share.share({ message: value });
52
+ } catch {
53
+ // ignore copy failures
54
+ }
55
+ }
56
+
57
+ export function LocationSheet({
58
+ location,
59
+ onClose,
60
+ }: LocationSheetProps): ReactNode {
61
+ const { theme } = useTheme();
62
+ const t = resolveTheme(theme);
63
+ const themedStyles = createThemedStyles(theme);
64
+ const meta = LOCATION_CATEGORY_META[location.category];
65
+ const [hoursOpen, setHoursOpen] = useState(false);
66
+ const translateY = useSharedValue(48);
67
+ const opacity = useSharedValue(0);
68
+ const hoursProgress = useSharedValue(0);
69
+ const hoursHeight = useSharedValue(0);
70
+
71
+ useEffect(() => {
72
+ setHoursOpen(false);
73
+ hoursProgress.value = 0;
74
+ translateY.value = 48;
75
+ opacity.value = 0;
76
+ translateY.value = withTiming(0, ENTER);
77
+ opacity.value = withTiming(1, { duration: 220, easing: Easing.out(Easing.cubic) });
78
+ }, [hoursProgress, location.id, opacity, translateY]);
79
+
80
+ const closeSheet = () => {
81
+ onClose();
82
+ };
83
+
84
+ const dismiss = () => {
85
+ opacity.value = withTiming(0, { duration: 180, easing: Easing.out(Easing.cubic) });
86
+ translateY.value = withTiming(420, { duration: 220, easing: Easing.in(Easing.cubic) }, (finished) => {
87
+ if (finished) runOnJS(closeSheet)();
88
+ });
89
+ };
90
+
91
+ const pan = Gesture.Pan()
92
+ .activeOffsetY(16)
93
+ .failOffsetX([-24, 24])
94
+ .onUpdate((event) => {
95
+ translateY.value = Math.max(0, event.translationY);
96
+ })
97
+ .onEnd((event) => {
98
+ if (event.translationY > DISMISS_Y || event.velocityY > DISMISS_V) {
99
+ runOnJS(dismiss)();
100
+ return;
101
+ }
102
+ translateY.value = withTiming(0, ENTER);
103
+ });
104
+
105
+ const sheetStyle = useAnimatedStyle(() => ({
106
+ transform: [{ translateY: translateY.value }],
107
+ opacity: opacity.value,
108
+ }), []);
109
+
110
+ const chevronStyle = useAnimatedStyle(() => ({
111
+ transform: [{ rotate: `${interpolate(hoursProgress.value, [0, 1], [180, 0])}deg` }],
112
+ }), []);
113
+
114
+ const hoursBodyStyle = useAnimatedStyle(() => ({
115
+ height: hoursHeight.value * hoursProgress.value,
116
+ opacity: hoursProgress.value,
117
+ overflow: "hidden" as const,
118
+ }), []);
119
+
120
+ const toggleHours = () => {
121
+ const next = !hoursOpen;
122
+ setHoursOpen(next);
123
+ hoursProgress.value = withTiming(next ? 1 : 0, HOURS_ANIM);
124
+ };
125
+
126
+ const openDirections = () => {
127
+ const q = encodeURIComponent(
128
+ location.address || `${location.lat},${location.lon}`,
129
+ );
130
+ void Linking.openURL(`https://maps.google.com/?q=${q}`);
131
+ };
132
+
133
+ const callPhone = () => {
134
+ if (!location.phone) return;
135
+ void Linking.openURL(`tel:${location.phone}`);
136
+ };
137
+
138
+ const hoursRows = location.hoursRows ?? [];
139
+ const hasHours = hoursRows.length > 0 || Boolean(location.hoursDisplay);
140
+ const status = location.hoursStatus;
141
+
142
+ return (
143
+ <GestureDetector gesture={pan}>
144
+ <Animated.View style={[sheetStyle, styles.sheetAnim]}>
145
+ <View
146
+ style={[
147
+ styles.sheet,
148
+ cardStyle(theme),
149
+ {
150
+ borderTopLeftRadius: t.radii.lg,
151
+ borderTopRightRadius: t.radii.lg,
152
+ borderBottomLeftRadius: 0,
153
+ borderBottomRightRadius: 0,
154
+ },
155
+ ]}
156
+ >
157
+ <View style={[styles.handle, { backgroundColor: theme.colors.border }]} />
158
+
159
+ <View style={styles.head}>
160
+ <View style={styles.headText}>
161
+ <Text style={[styles.name, { color: theme.colors.onSurface }]}>
162
+ {location.name}
163
+ </Text>
164
+ <Text style={themedStyles.meta}>{meta.label.toUpperCase()}</Text>
165
+ </View>
166
+ <Pressable
167
+ onPress={dismiss}
168
+ hitSlop={8}
169
+ accessibilityLabel="Fermer"
170
+ style={[
171
+ styles.closeBtn,
172
+ {
173
+ backgroundColor: theme.colors.background,
174
+ borderRadius: t.radii.pill,
175
+ },
176
+ ]}
177
+ >
178
+ <X size={16} color={theme.colors.onSurface} />
179
+ </Pressable>
180
+ </View>
181
+
182
+ <ScrollView
183
+ style={styles.bodyScroll}
184
+ contentContainerStyle={styles.bodyContent}
185
+ showsVerticalScrollIndicator={false}
186
+ >
187
+ {location.address ? (
188
+ <View style={styles.row}>
189
+ <MapPin size={16} color={t.colors.muted} />
190
+ <Text style={themedStyles.address}>{location.address}</Text>
191
+ <Pressable
192
+ onPress={() => void copyText(location.address!)}
193
+ hitSlop={8}
194
+ accessibilityLabel="Copier l’adresse"
195
+ >
196
+ <Copy size={16} color={theme.colors.primary} />
197
+ </Pressable>
198
+ </View>
199
+ ) : null}
200
+
201
+ {location.phone ? (
202
+ <View style={styles.row}>
203
+ <Phone size={16} color={t.colors.muted} />
204
+ <Text style={themedStyles.address}>{location.phone}</Text>
205
+ <Pressable
206
+ onPress={callPhone}
207
+ hitSlop={8}
208
+ accessibilityLabel="Appeler"
209
+ >
210
+ <Phone size={16} color={theme.colors.primary} />
211
+ </Pressable>
212
+ <Pressable
213
+ onPress={() => void copyText(location.phone!)}
214
+ hitSlop={8}
215
+ accessibilityLabel="Copier le numéro"
216
+ >
217
+ <Copy size={16} color={theme.colors.primary} />
218
+ </Pressable>
219
+ </View>
220
+ ) : null}
221
+
222
+ {hasHours ? (
223
+ <View
224
+ style={[
225
+ styles.hoursBox,
226
+ {
227
+ backgroundColor: theme.colors.background,
228
+ borderRadius: t.radii.md,
229
+ },
230
+ ]}
231
+ >
232
+ <Pressable onPress={toggleHours} style={styles.hoursHeader}>
233
+ <Clock size={16} color={t.colors.muted} />
234
+ <Text style={[styles.hoursStatus, { color: t.colors.muted }]}>
235
+ {status ? (
236
+ <>
237
+ <Text
238
+ style={{
239
+ color: status.open
240
+ ? theme.colors.primary
241
+ : theme.colors.error,
242
+ fontWeight: "700",
243
+ }}
244
+ >
245
+ {status.open ? "Ouvert" : "Fermé"}
246
+ </Text>
247
+ {status.text.includes(" - ")
248
+ ? ` - ${status.text.split(" - ").slice(1).join(" - ")}`
249
+ : ""}
250
+ </>
251
+ ) : (
252
+ location.hoursDisplay ?? "Horaires"
253
+ )}
254
+ </Text>
255
+ <Animated.View style={chevronStyle}>
256
+ <ChevronUp size={16} color={theme.colors.primary} />
257
+ </Animated.View>
258
+ </Pressable>
259
+ <Animated.View style={hoursBodyStyle}>
260
+ <View
261
+ style={styles.hoursMeasure}
262
+ onLayout={(event) => {
263
+ hoursHeight.value = event.nativeEvent.layout.height;
264
+ }}
265
+ >
266
+ {hoursRows.length > 0 ? (
267
+ <View style={styles.hoursList}>
268
+ {hoursRows.map((row) => (
269
+ <View key={row.label} style={styles.hoursRow}>
270
+ <Text style={[styles.hoursDay, { color: t.colors.muted }]}>
271
+ {row.label}
272
+ </Text>
273
+ <Text style={[styles.hoursValue, { color: t.colors.muted }]}>
274
+ {row.hours}
275
+ </Text>
276
+ </View>
277
+ ))}
278
+ </View>
279
+ ) : location.hoursDisplay ? (
280
+ <Text style={[styles.hoursFallback, { color: t.colors.muted }]}>
281
+ {location.hoursDisplay}
282
+ </Text>
283
+ ) : null}
284
+ </View>
285
+ </Animated.View>
286
+ </View>
287
+ ) : null}
288
+ </ScrollView>
289
+
290
+ <Button
291
+ onPress={openDirections}
292
+ rightIcon={MapPin}
293
+ style={[styles.cta, { borderRadius: t.radii.md }]}
294
+ >
295
+ Afficher Itinéraire
296
+ </Button>
297
+ </View>
298
+ </Animated.View>
299
+ </GestureDetector>
300
+ );
301
+ }
302
+
303
+ const createThemedStyles = (theme: Theme) =>
304
+ StyleSheet.create({
305
+ meta: {
306
+ color: theme.colors.muted ?? theme.colors.onSurface,
307
+ fontSize: 12,
308
+ fontWeight: "700",
309
+ letterSpacing: 0.4,
310
+ marginTop: 4,
311
+ },
312
+ address: {
313
+ color: theme.colors.onSurface,
314
+ flex: 1,
315
+ fontSize: 14,
316
+ },
317
+ });
318
+
319
+ const styles = StyleSheet.create({
320
+ sheetAnim: {
321
+ maxHeight: "82%",
322
+ },
323
+ sheet: {
324
+ paddingHorizontal: SPACE.pageX,
325
+ paddingTop: 14,
326
+ paddingBottom: SPACE.pageX,
327
+ gap: 24,
328
+ maxHeight: "100%",
329
+ },
330
+ handle: {
331
+ alignSelf: "center",
332
+ width: 40,
333
+ height: 4,
334
+ borderRadius: 2,
335
+ marginBottom: 2,
336
+ },
337
+ head: {
338
+ flexDirection: "row",
339
+ alignItems: "flex-start",
340
+ gap: 10,
341
+ },
342
+ headText: {
343
+ flex: 1,
344
+ },
345
+ closeBtn: {
346
+ width: 28,
347
+ height: 28,
348
+ alignItems: "center",
349
+ justifyContent: "center",
350
+ },
351
+ name: {
352
+ fontSize: 18,
353
+ fontWeight: "800",
354
+ },
355
+ bodyScroll: {
356
+ flexGrow: 0,
357
+ flexShrink: 1,
358
+ minHeight: 132,
359
+ },
360
+ bodyContent: {
361
+ gap: 22,
362
+ paddingBottom: 10,
363
+ },
364
+ row: {
365
+ flexDirection: "row",
366
+ alignItems: "center",
367
+ gap: 10,
368
+ },
369
+ hoursBox: {
370
+ padding: 12,
371
+ paddingBottom: 4,
372
+ },
373
+ hoursHeader: {
374
+ flexDirection: "row",
375
+ alignItems: "center",
376
+ gap: 8,
377
+ paddingBottom: 8,
378
+ },
379
+ hoursStatus: {
380
+ flex: 1,
381
+ fontSize: 14,
382
+ },
383
+ hoursList: {
384
+ gap: 6,
385
+ paddingLeft: 24,
386
+ paddingBottom: 8,
387
+ },
388
+ hoursMeasure: {
389
+ position: "absolute",
390
+ left: 0,
391
+ right: 0,
392
+ },
393
+ hoursRow: {
394
+ flexDirection: "row",
395
+ justifyContent: "space-between",
396
+ alignItems: "center",
397
+ gap: 12,
398
+ },
399
+ hoursDay: {
400
+ fontSize: 13,
401
+ },
402
+ hoursValue: {
403
+ fontSize: 13,
404
+ textAlign: "right",
405
+ flex: 1,
406
+ },
407
+ hoursFallback: {
408
+ fontSize: 13,
409
+ lineHeight: 18,
410
+ paddingLeft: 24,
411
+ paddingBottom: 8,
412
+ },
413
+ cta: {
414
+ height: SPACE.buttonH,
415
+ marginTop: 12,
416
+ },
417
+ });