@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,391 +1,391 @@
1
- import { Bell, ChevronLeftIcon, User } from "lucide-react-native";
2
- import {
3
- Image,
4
- Pressable,
5
- StyleSheet,
6
- View,
7
- type ImageStyle,
8
- } from "react-native";
9
- import { useTheme } from "../../contexts/ThemeContext";
10
- import { useWasto } from "../../contexts/WastoContext";
11
- import { useSafeAreaPadding } from "../../helpers/useSafeAreaPadding";
12
- import { Title } from "../title/Title";
13
- import { Theme } from "../../types/Theme";
14
- import { useMemo, type ReactNode } from "react";
15
- import { resolveTheme } from "../../helpers/themeStyles";
16
- import { useAnnouncements } from "../../contexts/AnnouncementsContext";
17
- import { hapticSelection } from "../../helpers/haptics";
18
- import { SPACE } from "../../helpers/layout";
19
- import { SYSTEM_ROUTES } from "../../helpers/systemRoutes";
20
- import { useAppNavigation } from "../../navigation/NavigationContext";
21
- import { publicMediaUrl } from "../../helpers/publicMediaUrl";
22
-
23
- export type AppHeaderSlot = "left" | "center" | "right";
24
-
25
- export type AppHeaderLogoElement = {
26
- id: string;
27
- type: "logo";
28
- slot: AppHeaderSlot;
29
- sourceType: "url" | "media";
30
- url?: string;
31
- mediaId?: string;
32
- };
33
-
34
- export type AppHeaderTitleElement = {
35
- id: string;
36
- type: "title";
37
- slot: AppHeaderSlot;
38
- useScreenTitle?: boolean;
39
- text?: string;
40
- };
41
-
42
- export type AppHeaderActionElement = {
43
- id: string;
44
- type: "action";
45
- slot: AppHeaderSlot;
46
- icon: string;
47
- label?: string;
48
- action: "navigate" | "back";
49
- href?: string;
50
- };
51
-
52
- export type AppHeaderElement =
53
- | AppHeaderLogoElement
54
- | AppHeaderTitleElement
55
- | AppHeaderActionElement;
56
-
57
- export type AppHeaderConfig = {
58
- elements: AppHeaderElement[];
59
- };
60
-
61
- export type HeaderProps = {
62
- readonly options: { title?: string; headerBackVisible?: boolean };
63
- readonly route: { name: string };
64
- readonly navigation: {
65
- canGoBack: () => boolean;
66
- goBack: () => void;
67
- };
68
- /** Flotte au-dessus du contenu (ex. carte) : fond transparent. */
69
- readonly overlay?: boolean;
70
- /** Config layout (`header.elements`) — logo / titre / actions. */
71
- readonly headerConfig?: AppHeaderConfig | null;
72
- };
73
-
74
- function resolveLogoUri(
75
- apiUrl: string,
76
- el: AppHeaderLogoElement,
77
- ): string | null {
78
- if (el.sourceType === "media") {
79
- return publicMediaUrl(apiUrl, el.mediaId);
80
- }
81
- const url = (el.url || "").trim();
82
- return url || null;
83
- }
84
-
85
- function HeaderLogo({
86
- element,
87
- }: {
88
- readonly element: AppHeaderLogoElement;
89
- }): ReactNode {
90
- const { apiUrl } = useWasto();
91
- const uri = resolveLogoUri(apiUrl, element);
92
- if (!uri) return null;
93
- return (
94
- <Image
95
- source={{ uri }}
96
- style={styles.logo as ImageStyle}
97
- resizeMode="contain"
98
- accessibilityLabel="Logo"
99
- />
100
- );
101
- }
102
-
103
- function HeaderActionButton({
104
- onPress,
105
- accessibilityLabel,
106
- children,
107
- themedStyles,
108
- borderRadius,
109
- }: {
110
- readonly onPress: () => void;
111
- readonly accessibilityLabel: string;
112
- readonly children: ReactNode;
113
- readonly themedStyles: ReturnType<typeof createThemedStyles>;
114
- readonly borderRadius: number;
115
- }): ReactNode {
116
- return (
117
- <Pressable
118
- onPress={onPress}
119
- style={[styles.iconBtn, themedStyles.iconBtn, { borderRadius }]}
120
- accessibilityLabel={accessibilityLabel}
121
- >
122
- {children}
123
- </Pressable>
124
- );
125
- }
126
-
127
- export function Header({
128
- options,
129
- route,
130
- navigation,
131
- overlay = false,
132
- headerConfig,
133
- }: HeaderProps): ReactNode {
134
- const { theme } = useTheme();
135
- const t = resolveTheme(theme);
136
- const themedStyles = createThemedStyles(theme);
137
- const topInset = useSafeAreaPadding(["top"]);
138
- const { hasUnread } = useAnnouncements();
139
- const { push } = useAppNavigation();
140
-
141
- const screenTitle = useMemo(
142
- () => options.title ?? route.name,
143
- [options.title, route.name],
144
- );
145
-
146
- const elements = headerConfig?.elements ?? [];
147
- const hasCustom = elements.length > 0;
148
- const hasCustomActions = elements.some((el) => el.type === "action");
149
-
150
- const bySlot = useMemo(() => {
151
- const left: AppHeaderElement[] = [];
152
- const center: AppHeaderElement[] = [];
153
- const right: AppHeaderElement[] = [];
154
- for (const el of elements) {
155
- if (el.slot === "center") center.push(el);
156
- else if (el.slot === "right") right.push(el);
157
- else left.push(el);
158
- }
159
- return { left, center, right };
160
- }, [elements]);
161
-
162
- const onBell = async () => {
163
- await hapticSelection();
164
- push(SYSTEM_ROUTES.notifications);
165
- };
166
-
167
- const onProfile = async () => {
168
- await hapticSelection();
169
- push(SYSTEM_ROUTES.profile);
170
- };
171
-
172
- const renderElement = (el: AppHeaderElement): ReactNode => {
173
- if (el.type === "logo") {
174
- return <HeaderLogo key={el.id} element={el} />;
175
- }
176
- if (el.type === "title") {
177
- const text =
178
- el.useScreenTitle !== false
179
- ? screenTitle
180
- : (el.text || "").trim() || screenTitle;
181
- return <Title key={el.id} text={text} level="1" />;
182
- }
183
- // action
184
- const onPress = async () => {
185
- await hapticSelection();
186
- if (el.action === "back") {
187
- if (navigation.canGoBack()) navigation.goBack();
188
- return;
189
- }
190
- const href = (el.href || "").trim();
191
- if (href) push(href);
192
- };
193
- const label = el.label?.trim() || el.icon || "Action";
194
- // Icônes système connues (bell / person) — le reste tombe sur Bell.
195
- const Icon =
196
- el.icon === "person" || el.icon === "users"
197
- ? User
198
- : Bell;
199
- return (
200
- <HeaderActionButton
201
- key={el.id}
202
- onPress={onPress}
203
- accessibilityLabel={label}
204
- themedStyles={themedStyles}
205
- borderRadius={t.radii.pill}
206
- >
207
- <Icon size={SPACE.iconGlyph} color={theme.colors.primary} />
208
- {el.icon === "bell" && hasUnread ? (
209
- <View
210
- style={[
211
- styles.badge,
212
- { backgroundColor: theme.colors.error },
213
- ]}
214
- />
215
- ) : null}
216
- </HeaderActionButton>
217
- );
218
- };
219
-
220
- const showBack =
221
- navigation.canGoBack() && options.headerBackVisible !== false;
222
-
223
- const defaultActions = (
224
- <>
225
- <HeaderActionButton
226
- onPress={onBell}
227
- accessibilityLabel="Notifications"
228
- themedStyles={themedStyles}
229
- borderRadius={t.radii.pill}
230
- >
231
- <Bell size={SPACE.iconGlyph} color={theme.colors.primary} />
232
- {hasUnread ? (
233
- <View
234
- style={[
235
- styles.badge,
236
- { backgroundColor: theme.colors.error },
237
- ]}
238
- />
239
- ) : null}
240
- </HeaderActionButton>
241
- <HeaderActionButton
242
- onPress={onProfile}
243
- accessibilityLabel="Profil"
244
- themedStyles={themedStyles}
245
- borderRadius={t.radii.pill}
246
- >
247
- <User size={SPACE.iconGlyph} color={theme.colors.primary} />
248
- </HeaderActionButton>
249
- </>
250
- );
251
-
252
- return (
253
- <View
254
- style={[
255
- styles.headerWrap,
256
- overlay ? undefined : themedStyles.headerWrap,
257
- topInset,
258
- ]}
259
- pointerEvents="box-none"
260
- >
261
- <View style={styles.header} pointerEvents="box-none">
262
- {hasCustom ? (
263
- <>
264
- <View style={styles.slotLeft} pointerEvents="box-none">
265
- {showBack ? (
266
- <HeaderActionButton
267
- onPress={() => navigation.goBack()}
268
- accessibilityLabel="Retour"
269
- themedStyles={themedStyles}
270
- borderRadius={t.radii.pill}
271
- >
272
- <ChevronLeftIcon
273
- size={SPACE.iconGlyph}
274
- color={theme.colors.onSurface}
275
- />
276
- </HeaderActionButton>
277
- ) : null}
278
- {bySlot.left.map(renderElement)}
279
- </View>
280
- <View
281
- style={styles.slotCenter}
282
- pointerEvents="box-none"
283
- >
284
- {bySlot.center.map(renderElement)}
285
- </View>
286
- <View style={styles.slotRight} pointerEvents="box-none">
287
- {bySlot.right.map(renderElement)}
288
- {!hasCustomActions ? defaultActions : null}
289
- </View>
290
- </>
291
- ) : (
292
- <>
293
- <View style={styles.left} pointerEvents="box-none">
294
- {showBack ? (
295
- <HeaderActionButton
296
- onPress={() => navigation.goBack()}
297
- accessibilityLabel="Retour"
298
- themedStyles={themedStyles}
299
- borderRadius={t.radii.pill}
300
- >
301
- <ChevronLeftIcon
302
- size={SPACE.iconGlyph}
303
- color={theme.colors.onSurface}
304
- />
305
- </HeaderActionButton>
306
- ) : null}
307
- <Title text={screenTitle} level="1" />
308
- </View>
309
- <View style={styles.actions}>{defaultActions}</View>
310
- </>
311
- )}
312
- </View>
313
- </View>
314
- );
315
- }
316
-
317
- const createThemedStyles = (theme: Theme) =>
318
- StyleSheet.create({
319
- headerWrap: {
320
- backgroundColor: theme.colors.background,
321
- },
322
- iconBtn: {
323
- backgroundColor: theme.colors.surface,
324
- borderWidth: 1,
325
- borderColor: theme.colors.border,
326
- },
327
- });
328
-
329
- const styles = StyleSheet.create({
330
- headerWrap: {},
331
- header: {
332
- flexDirection: "row",
333
- alignItems: "center",
334
- justifyContent: "space-between",
335
- paddingHorizontal: SPACE.pageX,
336
- paddingVertical: 12,
337
- gap: 10,
338
- minHeight: 56,
339
- },
340
- left: {
341
- flexDirection: "row",
342
- alignItems: "center",
343
- gap: 10,
344
- flex: 1,
345
- },
346
- slotLeft: {
347
- flexDirection: "row",
348
- alignItems: "center",
349
- gap: 10,
350
- flexShrink: 1,
351
- minWidth: 0,
352
- },
353
- slotCenter: {
354
- flex: 1,
355
- flexDirection: "row",
356
- alignItems: "center",
357
- justifyContent: "center",
358
- gap: 8,
359
- minWidth: 0,
360
- },
361
- slotRight: {
362
- flexDirection: "row",
363
- alignItems: "center",
364
- gap: 8,
365
- flexShrink: 0,
366
- },
367
- actions: {
368
- flexDirection: "row",
369
- alignItems: "center",
370
- gap: 8,
371
- },
372
- iconBtn: {
373
- width: SPACE.iconHit,
374
- height: SPACE.iconHit,
375
- alignItems: "center",
376
- justifyContent: "center",
377
- },
378
- badge: {
379
- position: "absolute",
380
- top: 4,
381
- right: 4,
382
- width: 12,
383
- height: 12,
384
- borderRadius: 6,
385
- },
386
- logo: {
387
- height: 32,
388
- width: 120,
389
- maxWidth: 160,
390
- },
391
- });
1
+ import { Bell, ChevronLeftIcon, User } from "lucide-react-native";
2
+ import {
3
+ Image,
4
+ Pressable,
5
+ StyleSheet,
6
+ View,
7
+ type ImageStyle,
8
+ } from "react-native";
9
+ import { useTheme } from "../../contexts/ThemeContext";
10
+ import { useWasto } from "../../contexts/WastoContext";
11
+ import { useSafeAreaPadding } from "../../helpers/useSafeAreaPadding";
12
+ import { Title } from "../title/Title";
13
+ import { Theme } from "../../types/Theme";
14
+ import { useMemo, type ReactNode } from "react";
15
+ import { resolveTheme } from "../../helpers/themeStyles";
16
+ import { useAnnouncements } from "../../contexts/AnnouncementsContext";
17
+ import { hapticSelection } from "../../helpers/haptics";
18
+ import { SPACE } from "../../helpers/layout";
19
+ import { SYSTEM_ROUTES } from "../../helpers/systemRoutes";
20
+ import { useAppNavigation } from "../../navigation/NavigationContext";
21
+ import { publicMediaUrl } from "../../helpers/publicMediaUrl";
22
+
23
+ export type AppHeaderSlot = "left" | "center" | "right";
24
+
25
+ export type AppHeaderLogoElement = {
26
+ id: string;
27
+ type: "logo";
28
+ slot: AppHeaderSlot;
29
+ sourceType: "url" | "media";
30
+ url?: string;
31
+ mediaId?: string;
32
+ };
33
+
34
+ export type AppHeaderTitleElement = {
35
+ id: string;
36
+ type: "title";
37
+ slot: AppHeaderSlot;
38
+ useScreenTitle?: boolean;
39
+ text?: string;
40
+ };
41
+
42
+ export type AppHeaderActionElement = {
43
+ id: string;
44
+ type: "action";
45
+ slot: AppHeaderSlot;
46
+ icon: string;
47
+ label?: string;
48
+ action: "navigate" | "back";
49
+ href?: string;
50
+ };
51
+
52
+ export type AppHeaderElement =
53
+ | AppHeaderLogoElement
54
+ | AppHeaderTitleElement
55
+ | AppHeaderActionElement;
56
+
57
+ export type AppHeaderConfig = {
58
+ elements: AppHeaderElement[];
59
+ };
60
+
61
+ export type HeaderProps = {
62
+ readonly options: { title?: string; headerBackVisible?: boolean };
63
+ readonly route: { name: string };
64
+ readonly navigation: {
65
+ canGoBack: () => boolean;
66
+ goBack: () => void;
67
+ };
68
+ /** Flotte au-dessus du contenu (ex. carte) : fond transparent. */
69
+ readonly overlay?: boolean;
70
+ /** Config layout (`header.elements`) — logo / titre / actions. */
71
+ readonly headerConfig?: AppHeaderConfig | null;
72
+ };
73
+
74
+ function resolveLogoUri(
75
+ apiUrl: string,
76
+ el: AppHeaderLogoElement,
77
+ ): string | null {
78
+ if (el.sourceType === "media") {
79
+ return publicMediaUrl(apiUrl, el.mediaId);
80
+ }
81
+ const url = (el.url || "").trim();
82
+ return url || null;
83
+ }
84
+
85
+ function HeaderLogo({
86
+ element,
87
+ }: {
88
+ readonly element: AppHeaderLogoElement;
89
+ }): ReactNode {
90
+ const { apiUrl } = useWasto();
91
+ const uri = resolveLogoUri(apiUrl, element);
92
+ if (!uri) return null;
93
+ return (
94
+ <Image
95
+ source={{ uri }}
96
+ style={styles.logo as ImageStyle}
97
+ resizeMode="contain"
98
+ accessibilityLabel="Logo"
99
+ />
100
+ );
101
+ }
102
+
103
+ function HeaderActionButton({
104
+ onPress,
105
+ accessibilityLabel,
106
+ children,
107
+ themedStyles,
108
+ borderRadius,
109
+ }: {
110
+ readonly onPress: () => void;
111
+ readonly accessibilityLabel: string;
112
+ readonly children: ReactNode;
113
+ readonly themedStyles: ReturnType<typeof createThemedStyles>;
114
+ readonly borderRadius: number;
115
+ }): ReactNode {
116
+ return (
117
+ <Pressable
118
+ onPress={onPress}
119
+ style={[styles.iconBtn, themedStyles.iconBtn, { borderRadius }]}
120
+ accessibilityLabel={accessibilityLabel}
121
+ >
122
+ {children}
123
+ </Pressable>
124
+ );
125
+ }
126
+
127
+ export function Header({
128
+ options,
129
+ route,
130
+ navigation,
131
+ overlay = false,
132
+ headerConfig,
133
+ }: HeaderProps): ReactNode {
134
+ const { theme } = useTheme();
135
+ const t = resolveTheme(theme);
136
+ const themedStyles = createThemedStyles(theme);
137
+ const topInset = useSafeAreaPadding(["top"]);
138
+ const { hasUnread } = useAnnouncements();
139
+ const { push } = useAppNavigation();
140
+
141
+ const screenTitle = useMemo(
142
+ () => options.title ?? route.name,
143
+ [options.title, route.name],
144
+ );
145
+
146
+ const elements = headerConfig?.elements ?? [];
147
+ const hasCustom = elements.length > 0;
148
+ const hasCustomActions = elements.some((el) => el.type === "action");
149
+
150
+ const bySlot = useMemo(() => {
151
+ const left: AppHeaderElement[] = [];
152
+ const center: AppHeaderElement[] = [];
153
+ const right: AppHeaderElement[] = [];
154
+ for (const el of elements) {
155
+ if (el.slot === "center") center.push(el);
156
+ else if (el.slot === "right") right.push(el);
157
+ else left.push(el);
158
+ }
159
+ return { left, center, right };
160
+ }, [elements]);
161
+
162
+ const onBell = async () => {
163
+ await hapticSelection();
164
+ push(SYSTEM_ROUTES.notifications);
165
+ };
166
+
167
+ const onProfile = async () => {
168
+ await hapticSelection();
169
+ push(SYSTEM_ROUTES.profile);
170
+ };
171
+
172
+ const renderElement = (el: AppHeaderElement): ReactNode => {
173
+ if (el.type === "logo") {
174
+ return <HeaderLogo key={el.id} element={el} />;
175
+ }
176
+ if (el.type === "title") {
177
+ const text =
178
+ el.useScreenTitle !== false
179
+ ? screenTitle
180
+ : (el.text || "").trim() || screenTitle;
181
+ return <Title key={el.id} text={text} level="1" />;
182
+ }
183
+ // action
184
+ const onPress = async () => {
185
+ await hapticSelection();
186
+ if (el.action === "back") {
187
+ if (navigation.canGoBack()) navigation.goBack();
188
+ return;
189
+ }
190
+ const href = (el.href || "").trim();
191
+ if (href) push(href);
192
+ };
193
+ const label = el.label?.trim() || el.icon || "Action";
194
+ // Icônes système connues (bell / person) — le reste tombe sur Bell.
195
+ const Icon =
196
+ el.icon === "person" || el.icon === "users"
197
+ ? User
198
+ : Bell;
199
+ return (
200
+ <HeaderActionButton
201
+ key={el.id}
202
+ onPress={onPress}
203
+ accessibilityLabel={label}
204
+ themedStyles={themedStyles}
205
+ borderRadius={t.radii.pill}
206
+ >
207
+ <Icon size={SPACE.iconGlyph} color={theme.colors.primary} />
208
+ {el.icon === "bell" && hasUnread ? (
209
+ <View
210
+ style={[
211
+ styles.badge,
212
+ { backgroundColor: theme.colors.error },
213
+ ]}
214
+ />
215
+ ) : null}
216
+ </HeaderActionButton>
217
+ );
218
+ };
219
+
220
+ const showBack =
221
+ navigation.canGoBack() && options.headerBackVisible !== false;
222
+
223
+ const defaultActions = (
224
+ <>
225
+ <HeaderActionButton
226
+ onPress={onBell}
227
+ accessibilityLabel="Notifications"
228
+ themedStyles={themedStyles}
229
+ borderRadius={t.radii.pill}
230
+ >
231
+ <Bell size={SPACE.iconGlyph} color={theme.colors.primary} />
232
+ {hasUnread ? (
233
+ <View
234
+ style={[
235
+ styles.badge,
236
+ { backgroundColor: theme.colors.error },
237
+ ]}
238
+ />
239
+ ) : null}
240
+ </HeaderActionButton>
241
+ <HeaderActionButton
242
+ onPress={onProfile}
243
+ accessibilityLabel="Profil"
244
+ themedStyles={themedStyles}
245
+ borderRadius={t.radii.pill}
246
+ >
247
+ <User size={SPACE.iconGlyph} color={theme.colors.primary} />
248
+ </HeaderActionButton>
249
+ </>
250
+ );
251
+
252
+ return (
253
+ <View
254
+ style={[
255
+ styles.headerWrap,
256
+ overlay ? undefined : themedStyles.headerWrap,
257
+ topInset,
258
+ ]}
259
+ pointerEvents="box-none"
260
+ >
261
+ <View style={styles.header} pointerEvents="box-none">
262
+ {hasCustom ? (
263
+ <>
264
+ <View style={styles.slotLeft} pointerEvents="box-none">
265
+ {showBack ? (
266
+ <HeaderActionButton
267
+ onPress={() => navigation.goBack()}
268
+ accessibilityLabel="Retour"
269
+ themedStyles={themedStyles}
270
+ borderRadius={t.radii.pill}
271
+ >
272
+ <ChevronLeftIcon
273
+ size={SPACE.iconGlyph}
274
+ color={theme.colors.onSurface}
275
+ />
276
+ </HeaderActionButton>
277
+ ) : null}
278
+ {bySlot.left.map(renderElement)}
279
+ </View>
280
+ <View
281
+ style={styles.slotCenter}
282
+ pointerEvents="box-none"
283
+ >
284
+ {bySlot.center.map(renderElement)}
285
+ </View>
286
+ <View style={styles.slotRight} pointerEvents="box-none">
287
+ {bySlot.right.map(renderElement)}
288
+ {!hasCustomActions ? defaultActions : null}
289
+ </View>
290
+ </>
291
+ ) : (
292
+ <>
293
+ <View style={styles.left} pointerEvents="box-none">
294
+ {showBack ? (
295
+ <HeaderActionButton
296
+ onPress={() => navigation.goBack()}
297
+ accessibilityLabel="Retour"
298
+ themedStyles={themedStyles}
299
+ borderRadius={t.radii.pill}
300
+ >
301
+ <ChevronLeftIcon
302
+ size={SPACE.iconGlyph}
303
+ color={theme.colors.onSurface}
304
+ />
305
+ </HeaderActionButton>
306
+ ) : null}
307
+ <Title text={screenTitle} level="1" />
308
+ </View>
309
+ <View style={styles.actions}>{defaultActions}</View>
310
+ </>
311
+ )}
312
+ </View>
313
+ </View>
314
+ );
315
+ }
316
+
317
+ const createThemedStyles = (theme: Theme) =>
318
+ StyleSheet.create({
319
+ headerWrap: {
320
+ backgroundColor: theme.colors.background,
321
+ },
322
+ iconBtn: {
323
+ backgroundColor: theme.colors.surface,
324
+ borderWidth: 1,
325
+ borderColor: theme.colors.border,
326
+ },
327
+ });
328
+
329
+ const styles = StyleSheet.create({
330
+ headerWrap: {},
331
+ header: {
332
+ flexDirection: "row",
333
+ alignItems: "center",
334
+ justifyContent: "space-between",
335
+ paddingHorizontal: SPACE.pageX,
336
+ paddingVertical: 12,
337
+ gap: 10,
338
+ minHeight: 56,
339
+ },
340
+ left: {
341
+ flexDirection: "row",
342
+ alignItems: "center",
343
+ gap: 10,
344
+ flex: 1,
345
+ },
346
+ slotLeft: {
347
+ flexDirection: "row",
348
+ alignItems: "center",
349
+ gap: 10,
350
+ flexShrink: 1,
351
+ minWidth: 0,
352
+ },
353
+ slotCenter: {
354
+ flex: 1,
355
+ flexDirection: "row",
356
+ alignItems: "center",
357
+ justifyContent: "center",
358
+ gap: 8,
359
+ minWidth: 0,
360
+ },
361
+ slotRight: {
362
+ flexDirection: "row",
363
+ alignItems: "center",
364
+ gap: 8,
365
+ flexShrink: 0,
366
+ },
367
+ actions: {
368
+ flexDirection: "row",
369
+ alignItems: "center",
370
+ gap: 8,
371
+ },
372
+ iconBtn: {
373
+ width: SPACE.iconHit,
374
+ height: SPACE.iconHit,
375
+ alignItems: "center",
376
+ justifyContent: "center",
377
+ },
378
+ badge: {
379
+ position: "absolute",
380
+ top: 4,
381
+ right: 4,
382
+ width: 12,
383
+ height: 12,
384
+ borderRadius: 6,
385
+ },
386
+ logo: {
387
+ height: 32,
388
+ width: 120,
389
+ maxWidth: 160,
390
+ },
391
+ });