@wasto/cms-components 1.5.10
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.
- package/README.md +47 -0
- package/dist/index.d.mts +465 -0
- package/dist/index.d.ts +465 -0
- package/dist/index.js +10445 -0
- package/dist/index.mjs +10553 -0
- package/package.json +90 -0
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -0
- package/src/components/article/Article.tsx +22 -0
- package/src/components/article/ArticleCard.tsx +81 -0
- package/src/components/article/ArticleExcerpts.tsx +80 -0
- package/src/components/article/ArticleList.tsx +114 -0
- package/src/components/article/ArticleMarkdown.tsx +170 -0
- package/src/components/article/ArticleReaderModal.tsx +93 -0
- package/src/components/article/ArticleSingle.tsx +57 -0
- package/src/components/bottom-tab/BottomTab.tsx +392 -0
- package/src/components/button/Button.tsx +154 -0
- package/src/components/challenge/Badges.tsx +84 -0
- package/src/components/challenge/BadgesModal.tsx +166 -0
- package/src/components/challenge/Challenge.tsx +380 -0
- package/src/components/challenge/ChallengeModal.tsx +231 -0
- package/src/components/challenge/ChallengeVignette.tsx +249 -0
- package/src/components/challenge/ChallengesModal.tsx +243 -0
- package/src/components/challenge/QuizModal.tsx +381 -0
- package/src/components/challenge/ResultModal.tsx +144 -0
- package/src/components/chat/Chat.tsx +928 -0
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -0
- package/src/components/columns/Columns.tsx +34 -0
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -0
- package/src/components/content-inset/ContentInset.tsx +33 -0
- package/src/components/header/Header.tsx +391 -0
- package/src/components/image/Image.tsx +16 -0
- package/src/components/image/ImageFrame.tsx +102 -0
- package/src/components/image/ImageMedia.tsx +31 -0
- package/src/components/image/ImageUrl.tsx +30 -0
- package/src/components/locations-map/LocationSheet.tsx +417 -0
- package/src/components/locations-map/LocationsMap.native.tsx +260 -0
- package/src/components/locations-map/LocationsMap.tsx +13 -0
- package/src/components/locations-map/LocationsMap.web.tsx +10 -0
- package/src/components/locations-map/LocationsMapShell.tsx +527 -0
- package/src/components/locations-map/LocationsMapView.tsx +108 -0
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -0
- package/src/components/nav-button/NavButton.tsx +59 -0
- package/src/components/next-collection/NextCollection.tsx +621 -0
- package/src/components/notifications/NotificationsScreen.tsx +247 -0
- package/src/components/page/Page.tsx +64 -0
- package/src/components/parapraph/Paragraph.tsx +67 -0
- package/src/components/profile/ProfileScreen.tsx +236 -0
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -0
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -0
- package/src/components/search/Search.tsx +320 -0
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -0
- package/src/components/title/Title.tsx +100 -0
- package/src/components/vision/Vision.tsx +447 -0
- package/src/components/vision/VisionActionCard.tsx +117 -0
- package/src/components/vision/VisionCapture.tsx +30 -0
- package/src/components/vision/VisionTapOverlay.tsx +122 -0
- package/src/contexts/AnnouncementsContext.tsx +171 -0
- package/src/contexts/ChallengesContext.tsx +182 -0
- package/src/contexts/LocalContext.tsx +227 -0
- package/src/contexts/ThemeContext.tsx +37 -0
- package/src/contexts/WastoContext.tsx +127 -0
- package/src/helpers/blogPost.ts +72 -0
- package/src/helpers/generateQuizQuestions.ts +247 -0
- package/src/helpers/getContrastColor.ts +19 -0
- package/src/helpers/haptics.ts +20 -0
- package/src/helpers/hoursSchedule.ts +230 -0
- package/src/helpers/htmlContentToMarkdown.ts +114 -0
- package/src/helpers/layout.ts +54 -0
- package/src/helpers/loadLinearGradient.ts +22 -0
- package/src/helpers/maquetteTheme.ts +76 -0
- package/src/helpers/markdownUnderlinePlugin.ts +32 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -0
- package/src/helpers/publicMediaUrl.ts +8 -0
- package/src/helpers/resolveApiAssetUrl.ts +21 -0
- package/src/helpers/systemRoutes.ts +7 -0
- package/src/helpers/themeStyles.ts +114 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -0
- package/src/hooks/useBadges.ts +100 -0
- package/src/hooks/useBlogPosts.ts +105 -0
- package/src/hooks/useChallenges.ts +110 -0
- package/src/hooks/useCities.ts +56 -0
- package/src/hooks/useCityAnnouncements.ts +118 -0
- package/src/hooks/useCollectionCalendar.ts +421 -0
- package/src/hooks/useColumns.ts +20 -0
- package/src/hooks/useConsignes.ts +62 -0
- package/src/hooks/useLocations.ts +248 -0
- package/src/hooks/useNextCollection.ts +238 -0
- package/src/hooks/useRecyclingInfo.ts +90 -0
- package/src/hooks/useWastoClient.ts +16 -0
- package/src/index.ts +142 -0
- package/src/navigation/NavigationContext.tsx +56 -0
- package/src/sentry/initSentry.ts +120 -0
- package/src/types/Theme.ts +72 -0
- package/src/types/css-modules.d.ts +1 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { useCallback, type ReactNode } from "react";
|
|
2
|
+
import {
|
|
3
|
+
ActivityIndicator,
|
|
4
|
+
FlatList,
|
|
5
|
+
Pressable,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
Text,
|
|
8
|
+
View,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
11
|
+
import { resolveTheme, cardStyle } from "../../helpers/themeStyles";
|
|
12
|
+
import { SPACE } from "../../helpers/layout";
|
|
13
|
+
import {
|
|
14
|
+
useCityAnnouncements,
|
|
15
|
+
type CityAnnouncementItem,
|
|
16
|
+
} from "../../hooks/useCityAnnouncements";
|
|
17
|
+
import { Button } from "../button/Button";
|
|
18
|
+
|
|
19
|
+
function formatSentAt(value?: string | null) {
|
|
20
|
+
if (!value) return null;
|
|
21
|
+
const d = new Date(value);
|
|
22
|
+
if (Number.isNaN(d.getTime())) return null;
|
|
23
|
+
return d.toLocaleDateString("fr-FR", {
|
|
24
|
+
day: "numeric",
|
|
25
|
+
month: "short",
|
|
26
|
+
year: "numeric",
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function excerpt(body: string, max = 120) {
|
|
31
|
+
const t = body.trim().replace(/\s+/g, " ");
|
|
32
|
+
if (t.length <= max) return t;
|
|
33
|
+
return `${t.slice(0, max).trim()}…`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Inbox list — detail uses the shared AnnouncementModal (WastoProvider). */
|
|
37
|
+
export function NotificationsScreen(): ReactNode {
|
|
38
|
+
const { theme } = useTheme();
|
|
39
|
+
const t = resolveTheme(theme);
|
|
40
|
+
const {
|
|
41
|
+
items,
|
|
42
|
+
loading,
|
|
43
|
+
error,
|
|
44
|
+
hasMore,
|
|
45
|
+
loadMore,
|
|
46
|
+
reload,
|
|
47
|
+
openItem,
|
|
48
|
+
hasPlaceSelected,
|
|
49
|
+
totalCount,
|
|
50
|
+
} = useCityAnnouncements();
|
|
51
|
+
|
|
52
|
+
const renderItem = useCallback(
|
|
53
|
+
({ item }: { item: CityAnnouncementItem }) => {
|
|
54
|
+
const dateLabel = formatSentAt(item.sentAt);
|
|
55
|
+
return (
|
|
56
|
+
<Pressable
|
|
57
|
+
onPress={() => void openItem(item)}
|
|
58
|
+
style={[
|
|
59
|
+
styles.row,
|
|
60
|
+
cardStyle(theme),
|
|
61
|
+
{ borderRadius: t.radii.md },
|
|
62
|
+
]}
|
|
63
|
+
accessibilityRole="button"
|
|
64
|
+
accessibilityLabel={item.title}
|
|
65
|
+
>
|
|
66
|
+
<View style={styles.rowHeader}>
|
|
67
|
+
<Text
|
|
68
|
+
style={[styles.rowTitle, { color: theme.colors.onSurface }]}
|
|
69
|
+
numberOfLines={2}
|
|
70
|
+
>
|
|
71
|
+
{item.title}
|
|
72
|
+
</Text>
|
|
73
|
+
{item.unread ? (
|
|
74
|
+
<View
|
|
75
|
+
style={[
|
|
76
|
+
styles.unreadDot,
|
|
77
|
+
{ backgroundColor: theme.colors.primary },
|
|
78
|
+
]}
|
|
79
|
+
/>
|
|
80
|
+
) : null}
|
|
81
|
+
</View>
|
|
82
|
+
{dateLabel ? (
|
|
83
|
+
<Text style={[styles.rowMeta, { color: t.colors.muted }]}>
|
|
84
|
+
{dateLabel}
|
|
85
|
+
</Text>
|
|
86
|
+
) : null}
|
|
87
|
+
<Text
|
|
88
|
+
style={[styles.rowBody, { color: t.colors.muted }]}
|
|
89
|
+
numberOfLines={3}
|
|
90
|
+
>
|
|
91
|
+
{excerpt(item.body)}
|
|
92
|
+
</Text>
|
|
93
|
+
</Pressable>
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
[openItem, t.colors.muted, t.radii.md, theme],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
if (!hasPlaceSelected) {
|
|
100
|
+
return (
|
|
101
|
+
<View style={styles.center}>
|
|
102
|
+
<Text style={[styles.emptyTitle, { color: theme.colors.onSurface }]}>
|
|
103
|
+
Aucun secteur sélectionné
|
|
104
|
+
</Text>
|
|
105
|
+
<Text style={[styles.emptyText, { color: t.colors.muted }]}>
|
|
106
|
+
Choisissez votre rue pour voir les notifications de votre ville.
|
|
107
|
+
</Text>
|
|
108
|
+
</View>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (loading && items.length === 0) {
|
|
113
|
+
return (
|
|
114
|
+
<View style={styles.center}>
|
|
115
|
+
<ActivityIndicator color={theme.colors.primary} />
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (error && items.length === 0) {
|
|
121
|
+
return (
|
|
122
|
+
<View style={styles.center}>
|
|
123
|
+
<Text style={[styles.emptyTitle, { color: theme.colors.error }]}>
|
|
124
|
+
{error}
|
|
125
|
+
</Text>
|
|
126
|
+
<Button variant="secondary" onPress={() => void reload()} style={styles.retry}>
|
|
127
|
+
Réessayer
|
|
128
|
+
</Button>
|
|
129
|
+
</View>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<View style={styles.screen}>
|
|
135
|
+
<FlatList
|
|
136
|
+
data={items}
|
|
137
|
+
keyExtractor={(item) => item.id}
|
|
138
|
+
renderItem={renderItem}
|
|
139
|
+
contentContainerStyle={styles.list}
|
|
140
|
+
onEndReached={() => {
|
|
141
|
+
if (hasMore) loadMore();
|
|
142
|
+
}}
|
|
143
|
+
onEndReachedThreshold={0.4}
|
|
144
|
+
ListEmptyComponent={
|
|
145
|
+
<View style={styles.centerInline}>
|
|
146
|
+
<Text style={[styles.emptyTitle, { color: theme.colors.onSurface }]}>
|
|
147
|
+
Aucune notification
|
|
148
|
+
</Text>
|
|
149
|
+
<Text style={[styles.emptyText, { color: t.colors.muted }]}>
|
|
150
|
+
Les annonces de votre ville apparaîtront ici.
|
|
151
|
+
</Text>
|
|
152
|
+
</View>
|
|
153
|
+
}
|
|
154
|
+
ListFooterComponent={
|
|
155
|
+
hasMore ? (
|
|
156
|
+
<Button
|
|
157
|
+
variant="ghost"
|
|
158
|
+
onPress={loadMore}
|
|
159
|
+
style={styles.loadMore}
|
|
160
|
+
>
|
|
161
|
+
{`Voir plus (${items.length}/${totalCount})`}
|
|
162
|
+
</Button>
|
|
163
|
+
) : items.length > 0 ? (
|
|
164
|
+
<Text style={[styles.footerHint, { color: t.colors.muted }]}>
|
|
165
|
+
{totalCount} notification{totalCount > 1 ? "s" : ""}
|
|
166
|
+
</Text>
|
|
167
|
+
) : null
|
|
168
|
+
}
|
|
169
|
+
/>
|
|
170
|
+
</View>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const styles = StyleSheet.create({
|
|
175
|
+
screen: {
|
|
176
|
+
flex: 1,
|
|
177
|
+
},
|
|
178
|
+
list: {
|
|
179
|
+
paddingHorizontal: SPACE.pageX,
|
|
180
|
+
paddingVertical: SPACE.sectionY,
|
|
181
|
+
gap: SPACE.stack,
|
|
182
|
+
flexGrow: 1,
|
|
183
|
+
},
|
|
184
|
+
row: {
|
|
185
|
+
padding: SPACE.cardPad,
|
|
186
|
+
gap: 6,
|
|
187
|
+
},
|
|
188
|
+
rowHeader: {
|
|
189
|
+
flexDirection: "row",
|
|
190
|
+
alignItems: "flex-start",
|
|
191
|
+
gap: 8,
|
|
192
|
+
},
|
|
193
|
+
rowTitle: {
|
|
194
|
+
flex: 1,
|
|
195
|
+
fontSize: 16,
|
|
196
|
+
fontWeight: "700",
|
|
197
|
+
},
|
|
198
|
+
unreadDot: {
|
|
199
|
+
width: 10,
|
|
200
|
+
height: 10,
|
|
201
|
+
borderRadius: 5,
|
|
202
|
+
marginTop: 5,
|
|
203
|
+
},
|
|
204
|
+
rowMeta: {
|
|
205
|
+
fontSize: 12,
|
|
206
|
+
fontWeight: "600",
|
|
207
|
+
},
|
|
208
|
+
rowBody: {
|
|
209
|
+
fontSize: 14,
|
|
210
|
+
lineHeight: 20,
|
|
211
|
+
},
|
|
212
|
+
center: {
|
|
213
|
+
flex: 1,
|
|
214
|
+
alignItems: "center",
|
|
215
|
+
justifyContent: "center",
|
|
216
|
+
padding: SPACE.pageX,
|
|
217
|
+
gap: 8,
|
|
218
|
+
},
|
|
219
|
+
centerInline: {
|
|
220
|
+
paddingVertical: 48,
|
|
221
|
+
alignItems: "center",
|
|
222
|
+
gap: 8,
|
|
223
|
+
},
|
|
224
|
+
emptyTitle: {
|
|
225
|
+
fontSize: 17,
|
|
226
|
+
fontWeight: "700",
|
|
227
|
+
textAlign: "center",
|
|
228
|
+
},
|
|
229
|
+
emptyText: {
|
|
230
|
+
fontSize: 14,
|
|
231
|
+
textAlign: "center",
|
|
232
|
+
lineHeight: 20,
|
|
233
|
+
},
|
|
234
|
+
retry: {
|
|
235
|
+
marginTop: 12,
|
|
236
|
+
alignSelf: "stretch",
|
|
237
|
+
},
|
|
238
|
+
loadMore: {
|
|
239
|
+
marginTop: 8,
|
|
240
|
+
},
|
|
241
|
+
footerHint: {
|
|
242
|
+
textAlign: "center",
|
|
243
|
+
fontSize: 12,
|
|
244
|
+
marginTop: 8,
|
|
245
|
+
marginBottom: 16,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PropsWithChildren, type ReactNode } from "react";
|
|
2
|
+
import { ScrollView, StyleSheet, View } from "react-native";
|
|
3
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
4
|
+
import { useSafeAreaPadding } from "../../helpers/useSafeAreaPadding";
|
|
5
|
+
import { SPACE } from "../../helpers/layout";
|
|
6
|
+
import { Theme } from "../../types/Theme";
|
|
7
|
+
|
|
8
|
+
export type PageProps = PropsWithChildren & {
|
|
9
|
+
/** When false, content fills the screen without scrolling (e.g. fullScreen map). Default true. */
|
|
10
|
+
scroll?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Page shell: top safe area + optional vertical scroll.
|
|
15
|
+
* No global horizontal padding — each block uses ContentInset or is full-bleed
|
|
16
|
+
* (map, calendar grid). Bottom inset is handled by BottomTab when using tabs.
|
|
17
|
+
*/
|
|
18
|
+
export function Page({ children, scroll = true }: PageProps): ReactNode {
|
|
19
|
+
const { theme } = useTheme();
|
|
20
|
+
const themedStyles = createThemedStyles(theme);
|
|
21
|
+
const topInset = useSafeAreaPadding(["top"]);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<View style={[styles.root, themedStyles.root, topInset]}>
|
|
25
|
+
{scroll ? (
|
|
26
|
+
<ScrollView
|
|
27
|
+
style={styles.scroll}
|
|
28
|
+
contentContainerStyle={styles.scrollContent}
|
|
29
|
+
keyboardShouldPersistTaps="handled"
|
|
30
|
+
showsVerticalScrollIndicator={false}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
</ScrollView>
|
|
34
|
+
) : (
|
|
35
|
+
<View style={styles.fill}>{children}</View>
|
|
36
|
+
)}
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const createThemedStyles = (theme: Theme) =>
|
|
42
|
+
StyleSheet.create({
|
|
43
|
+
root: {
|
|
44
|
+
backgroundColor: theme.colors.background,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const styles = StyleSheet.create({
|
|
49
|
+
root: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
},
|
|
52
|
+
scroll: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
},
|
|
55
|
+
scrollContent: {
|
|
56
|
+
flexGrow: 1,
|
|
57
|
+
gap: SPACE.sectionY,
|
|
58
|
+
paddingBottom: 28,
|
|
59
|
+
},
|
|
60
|
+
fill: {
|
|
61
|
+
flex: 1,
|
|
62
|
+
gap: SPACE.sectionY,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { StyleProp, StyleSheet, Text, TextStyle, View } from "react-native";
|
|
3
|
+
import { Theme } from "../../types/Theme";
|
|
4
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
5
|
+
import type { TextAlignHorizontal, TextAlignVertical } from "../title/Title";
|
|
6
|
+
|
|
7
|
+
export type PararaphProps = {
|
|
8
|
+
text: string;
|
|
9
|
+
style?: StyleProp<TextStyle>;
|
|
10
|
+
alignHorizontal?: TextAlignHorizontal;
|
|
11
|
+
alignVertical?: TextAlignVertical;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function justifyForVertical(align: TextAlignVertical | undefined): "flex-start" | "center" | "flex-end" {
|
|
15
|
+
if (align === "middle") return "center";
|
|
16
|
+
if (align === "bottom") return "flex-end";
|
|
17
|
+
return "flex-start";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function textAlignFor(align: TextAlignHorizontal | undefined): "left" | "center" | "right" {
|
|
21
|
+
if (align === "center" || align === "right") return align;
|
|
22
|
+
return "left";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Paragraph({
|
|
26
|
+
text,
|
|
27
|
+
style,
|
|
28
|
+
alignHorizontal,
|
|
29
|
+
alignVertical,
|
|
30
|
+
}: PararaphProps): ReactNode {
|
|
31
|
+
const { theme } = useTheme();
|
|
32
|
+
const themedStyles = createThemedStyles(theme);
|
|
33
|
+
const textAlign = textAlignFor(alignHorizontal);
|
|
34
|
+
|
|
35
|
+
const content = (
|
|
36
|
+
<Text style={[styles.text, themedStyles.text, { textAlign }, style]}>
|
|
37
|
+
{text}
|
|
38
|
+
</Text>
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
if (!alignVertical || alignVertical === "top") {
|
|
42
|
+
return content;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<View style={[styles.alignWrap, { justifyContent: justifyForVertical(alignVertical) }]}>
|
|
47
|
+
{content}
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const createThemedStyles = (theme: Theme) => StyleSheet.create({
|
|
53
|
+
text: {
|
|
54
|
+
color: theme.colors.onSurface,
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
text: {
|
|
60
|
+
fontSize: 15,
|
|
61
|
+
lineHeight: 22,
|
|
62
|
+
},
|
|
63
|
+
alignWrap: {
|
|
64
|
+
minHeight: 22,
|
|
65
|
+
width: "100%",
|
|
66
|
+
},
|
|
67
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { Alert, StyleSheet, Text, View } from "react-native";
|
|
3
|
+
import { MapPin, Trash2 } from "lucide-react-native";
|
|
4
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
5
|
+
import { useLocal } from "../../contexts/LocalContext";
|
|
6
|
+
import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
|
|
7
|
+
import { SPACE } from "../../helpers/layout";
|
|
8
|
+
import { hapticSelection } from "../../helpers/haptics";
|
|
9
|
+
import { Button } from "../button/Button";
|
|
10
|
+
|
|
11
|
+
function RecapRow({
|
|
12
|
+
label,
|
|
13
|
+
value,
|
|
14
|
+
muted,
|
|
15
|
+
onSurface,
|
|
16
|
+
}: {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
muted: string;
|
|
20
|
+
onSurface: string;
|
|
21
|
+
}) {
|
|
22
|
+
return (
|
|
23
|
+
<View style={styles.recapRow}>
|
|
24
|
+
<Text style={[styles.recapLabel, { color: muted }]}>{label}</Text>
|
|
25
|
+
<Text style={[styles.recapValue, { color: onSurface }]} numberOfLines={2}>
|
|
26
|
+
{value}
|
|
27
|
+
</Text>
|
|
28
|
+
</View>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Profil local : récap secteur + actions changer / supprimer. */
|
|
33
|
+
export function ProfileScreen(): ReactNode {
|
|
34
|
+
const { theme } = useTheme();
|
|
35
|
+
const t = resolveTheme(theme);
|
|
36
|
+
const {
|
|
37
|
+
hasPlaceSelected,
|
|
38
|
+
placeMeta,
|
|
39
|
+
clearPlaceSelection,
|
|
40
|
+
clearLocalData,
|
|
41
|
+
isLoading,
|
|
42
|
+
} = useLocal();
|
|
43
|
+
|
|
44
|
+
const cityName = placeMeta?.cityName?.trim() || "—";
|
|
45
|
+
const streetName = placeMeta?.streetName?.trim() || "—";
|
|
46
|
+
const sectorName = placeMeta?.sectorName?.trim() || "—";
|
|
47
|
+
|
|
48
|
+
const onChangeSector = async () => {
|
|
49
|
+
await hapticSelection();
|
|
50
|
+
await clearPlaceSelection();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onDeleteData = () => {
|
|
54
|
+
Alert.alert(
|
|
55
|
+
"Supprimer mes données",
|
|
56
|
+
"Cela efface votre secteur, l’identifiant de cet appareil et les préférences locales. Les quiz déjà enregistrés côté serveur ne sont pas retirés ici.",
|
|
57
|
+
[
|
|
58
|
+
{ text: "Annuler", style: "cancel" },
|
|
59
|
+
{
|
|
60
|
+
text: "Supprimer",
|
|
61
|
+
style: "destructive",
|
|
62
|
+
onPress: () => {
|
|
63
|
+
void (async () => {
|
|
64
|
+
await hapticSelection();
|
|
65
|
+
await clearLocalData();
|
|
66
|
+
})();
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<View style={styles.screen}>
|
|
75
|
+
<View style={styles.section}>
|
|
76
|
+
<Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
|
|
77
|
+
MON SECTEUR
|
|
78
|
+
</Text>
|
|
79
|
+
<View
|
|
80
|
+
style={[
|
|
81
|
+
styles.recapCard,
|
|
82
|
+
cardStyle(theme),
|
|
83
|
+
{ borderRadius: t.radii.lg },
|
|
84
|
+
]}
|
|
85
|
+
>
|
|
86
|
+
<View style={styles.recapHead}>
|
|
87
|
+
<View
|
|
88
|
+
style={[
|
|
89
|
+
styles.recapIcon,
|
|
90
|
+
{
|
|
91
|
+
backgroundColor: theme.colors.primary,
|
|
92
|
+
borderRadius: t.radii.pill,
|
|
93
|
+
},
|
|
94
|
+
]}
|
|
95
|
+
>
|
|
96
|
+
<MapPin size={18} color={theme.colors.onPrimary} />
|
|
97
|
+
</View>
|
|
98
|
+
<Text
|
|
99
|
+
style={[styles.recapTitle, { color: theme.colors.onSurface }]}
|
|
100
|
+
>
|
|
101
|
+
{hasPlaceSelected ? "Zone de collecte" : "Aucune zone"}
|
|
102
|
+
</Text>
|
|
103
|
+
</View>
|
|
104
|
+
|
|
105
|
+
{hasPlaceSelected ? (
|
|
106
|
+
<View style={styles.recapList}>
|
|
107
|
+
<RecapRow
|
|
108
|
+
label="Ville"
|
|
109
|
+
value={cityName}
|
|
110
|
+
muted={t.colors.muted}
|
|
111
|
+
onSurface={theme.colors.onSurface}
|
|
112
|
+
/>
|
|
113
|
+
<View
|
|
114
|
+
style={[
|
|
115
|
+
styles.divider,
|
|
116
|
+
{ backgroundColor: theme.colors.border },
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
<RecapRow
|
|
120
|
+
label="Adresse"
|
|
121
|
+
value={streetName}
|
|
122
|
+
muted={t.colors.muted}
|
|
123
|
+
onSurface={theme.colors.onSurface}
|
|
124
|
+
/>
|
|
125
|
+
<View
|
|
126
|
+
style={[
|
|
127
|
+
styles.divider,
|
|
128
|
+
{ backgroundColor: theme.colors.border },
|
|
129
|
+
]}
|
|
130
|
+
/>
|
|
131
|
+
<RecapRow
|
|
132
|
+
label="Secteur"
|
|
133
|
+
value={sectorName}
|
|
134
|
+
muted={t.colors.muted}
|
|
135
|
+
onSurface={theme.colors.onSurface}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
) : (
|
|
139
|
+
<Text style={[styles.emptyHint, { color: t.colors.muted }]}>
|
|
140
|
+
Choisissez votre rue pour personnaliser les collectes et
|
|
141
|
+
notifications.
|
|
142
|
+
</Text>
|
|
143
|
+
)}
|
|
144
|
+
</View>
|
|
145
|
+
</View>
|
|
146
|
+
|
|
147
|
+
<View style={styles.section}>
|
|
148
|
+
<Text style={[styles.sectionLabel, { color: t.colors.muted }]}>
|
|
149
|
+
ACTIONS
|
|
150
|
+
</Text>
|
|
151
|
+
<View style={styles.actions}>
|
|
152
|
+
<Button
|
|
153
|
+
variant="secondary"
|
|
154
|
+
leftIcon={MapPin}
|
|
155
|
+
loading={isLoading}
|
|
156
|
+
onPress={() => void onChangeSector()}
|
|
157
|
+
>
|
|
158
|
+
Changer de secteur
|
|
159
|
+
</Button>
|
|
160
|
+
<Button
|
|
161
|
+
variant="ghost"
|
|
162
|
+
leftIcon={Trash2}
|
|
163
|
+
loading={isLoading}
|
|
164
|
+
onPress={onDeleteData}
|
|
165
|
+
textStyle={{ color: theme.colors.error }}
|
|
166
|
+
>
|
|
167
|
+
Supprimer mes données
|
|
168
|
+
</Button>
|
|
169
|
+
</View>
|
|
170
|
+
</View>
|
|
171
|
+
</View>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const styles = StyleSheet.create({
|
|
176
|
+
screen: {
|
|
177
|
+
flex: 1,
|
|
178
|
+
paddingHorizontal: SPACE.pageX,
|
|
179
|
+
paddingVertical: SPACE.sectionY,
|
|
180
|
+
gap: SPACE.sectionY,
|
|
181
|
+
},
|
|
182
|
+
section: {
|
|
183
|
+
gap: 10,
|
|
184
|
+
},
|
|
185
|
+
sectionLabel: {
|
|
186
|
+
fontSize: 12,
|
|
187
|
+
fontWeight: "700",
|
|
188
|
+
letterSpacing: 0.6,
|
|
189
|
+
},
|
|
190
|
+
recapCard: {
|
|
191
|
+
padding: SPACE.cardPad,
|
|
192
|
+
gap: 16,
|
|
193
|
+
},
|
|
194
|
+
recapHead: {
|
|
195
|
+
flexDirection: "row",
|
|
196
|
+
alignItems: "center",
|
|
197
|
+
gap: 12,
|
|
198
|
+
},
|
|
199
|
+
recapIcon: {
|
|
200
|
+
width: SPACE.iconHit,
|
|
201
|
+
height: SPACE.iconHit,
|
|
202
|
+
alignItems: "center",
|
|
203
|
+
justifyContent: "center",
|
|
204
|
+
},
|
|
205
|
+
recapTitle: {
|
|
206
|
+
flex: 1,
|
|
207
|
+
fontSize: 17,
|
|
208
|
+
fontWeight: "700",
|
|
209
|
+
},
|
|
210
|
+
recapList: {
|
|
211
|
+
gap: 0,
|
|
212
|
+
},
|
|
213
|
+
recapRow: {
|
|
214
|
+
gap: 4,
|
|
215
|
+
paddingVertical: 10,
|
|
216
|
+
},
|
|
217
|
+
recapLabel: {
|
|
218
|
+
fontSize: 12,
|
|
219
|
+
fontWeight: "600",
|
|
220
|
+
},
|
|
221
|
+
recapValue: {
|
|
222
|
+
fontSize: 16,
|
|
223
|
+
fontWeight: "700",
|
|
224
|
+
},
|
|
225
|
+
divider: {
|
|
226
|
+
height: StyleSheet.hairlineWidth,
|
|
227
|
+
width: "100%",
|
|
228
|
+
},
|
|
229
|
+
emptyHint: {
|
|
230
|
+
fontSize: 14,
|
|
231
|
+
lineHeight: 20,
|
|
232
|
+
},
|
|
233
|
+
actions: {
|
|
234
|
+
gap: SPACE.stack,
|
|
235
|
+
},
|
|
236
|
+
});
|