@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.
- package/README.md +47 -47
- package/dist/index.d.mts +103 -2
- package/dist/index.d.ts +103 -2
- package/dist/index.js +2861 -2442
- package/dist/index.mjs +3651 -3227
- package/package.json +2 -2
- package/src/components/announcement-modal/AnnouncementModal.tsx +183 -183
- package/src/components/article/Article.tsx +21 -21
- package/src/components/article/ArticleCard.tsx +81 -81
- package/src/components/article/ArticleExcerpts.tsx +80 -80
- package/src/components/article/ArticleList.tsx +114 -114
- package/src/components/article/ArticleMarkdown.tsx +170 -170
- package/src/components/article/ArticleReaderModal.tsx +93 -93
- package/src/components/article/ArticleSingle.tsx +57 -57
- package/src/components/bottom-tab/BottomTab.tsx +392 -392
- package/src/components/button/Button.tsx +154 -154
- package/src/components/challenge/Badges.tsx +84 -84
- package/src/components/challenge/BadgesModal.tsx +166 -166
- package/src/components/challenge/Challenge.tsx +380 -380
- package/src/components/challenge/ChallengeModal.tsx +231 -231
- package/src/components/challenge/ChallengeVignette.tsx +249 -249
- package/src/components/challenge/ChallengesModal.tsx +243 -243
- package/src/components/challenge/QuizModal.tsx +381 -381
- package/src/components/challenge/ResultModal.tsx +144 -144
- package/src/components/chat/Chat.tsx +928 -928
- package/src/components/collection-calendar/CollectionCalendar.tsx +274 -274
- package/src/components/columns/Columns.tsx +33 -33
- package/src/components/consignes-modal/ConsignesModal.tsx +267 -267
- package/src/components/content-inset/ContentInset.tsx +33 -33
- package/src/components/header/Header.tsx +391 -391
- package/src/components/image/Image.tsx +15 -15
- package/src/components/image/ImageFrame.tsx +102 -102
- package/src/components/image/ImageMedia.tsx +31 -31
- package/src/components/image/ImageUrl.tsx +30 -30
- package/src/components/locations-map/LocationSheet.tsx +417 -417
- package/src/components/locations-map/LocationsMap.native.tsx +260 -260
- package/src/components/locations-map/LocationsMap.tsx +13 -13
- package/src/components/locations-map/LocationsMap.web.tsx +10 -10
- package/src/components/locations-map/LocationsMapShell.tsx +527 -527
- package/src/components/locations-map/LocationsMapView.tsx +108 -108
- package/src/components/locations-map/LocationsMapView.web.tsx +331 -331
- package/src/components/nav-button/NavButton.tsx +59 -59
- package/src/components/next-collection/NextCollection.tsx +636 -621
- package/src/components/notifications/NotificationsScreen.tsx +247 -247
- package/src/components/page/Page.tsx +102 -64
- package/src/components/parapraph/Paragraph.tsx +67 -67
- package/src/components/profile/ProfileScreen.tsx +236 -236
- package/src/components/recycling-info/RecyclingInfo.tsx +189 -189
- package/src/components/safe-area/OptionalSafeAreaProvider.tsx +17 -17
- package/src/components/search/Search.tsx +320 -320
- package/src/components/select-street-modal/SelectStreetModal.tsx +475 -475
- package/src/components/title/Title.tsx +100 -100
- package/src/components/vision/Vision.tsx +447 -447
- package/src/components/vision/VisionActionCard.tsx +117 -117
- package/src/components/vision/VisionCapture.tsx +30 -30
- package/src/components/vision/VisionTapOverlay.tsx +122 -122
- package/src/contexts/AnnouncementsContext.tsx +171 -171
- package/src/contexts/AppDataContext.tsx +458 -0
- package/src/contexts/ChallengesContext.tsx +182 -182
- package/src/contexts/LocalContext.tsx +227 -227
- package/src/contexts/ThemeContext.tsx +37 -37
- package/src/contexts/WastoContext.tsx +130 -127
- package/src/helpers/blogPost.ts +72 -72
- package/src/helpers/generateQuizQuestions.ts +247 -247
- package/src/helpers/getContrastColor.ts +18 -18
- package/src/helpers/haptics.ts +20 -20
- package/src/helpers/hoursSchedule.ts +230 -230
- package/src/helpers/htmlContentToMarkdown.ts +114 -114
- package/src/helpers/layout.ts +54 -54
- package/src/helpers/loadLinearGradient.ts +22 -22
- package/src/helpers/mapLocations.ts +170 -0
- package/src/helpers/maquetteTheme.ts +76 -76
- package/src/helpers/markdownUnderlinePlugin.ts +32 -32
- package/src/helpers/nextCollection.ts +122 -0
- package/src/helpers/normalizeWasteTypeRecyclingInfo.ts +80 -80
- package/src/helpers/publicMediaUrl.ts +8 -8
- package/src/helpers/resolveApiAssetUrl.ts +21 -21
- package/src/helpers/systemRoutes.ts +7 -7
- package/src/helpers/themeStyles.ts +114 -114
- package/src/helpers/ttlCache.ts +41 -0
- package/src/helpers/useSafeAreaPadding.ts +14 -14
- package/src/hooks/useBadges.ts +100 -100
- package/src/hooks/useBlogPosts.ts +109 -105
- package/src/hooks/useChallenges.ts +110 -110
- package/src/hooks/useCities.ts +56 -56
- package/src/hooks/useCityAnnouncements.ts +118 -118
- package/src/hooks/useCollectionCalendar.ts +421 -421
- package/src/hooks/useColumns.ts +19 -19
- package/src/hooks/useConsignes.ts +62 -62
- package/src/hooks/useLocations.ts +120 -248
- package/src/hooks/useNextCollection.ts +163 -238
- package/src/hooks/useRecyclingInfo.ts +90 -90
- package/src/hooks/useWastoClient.ts +16 -16
- package/src/index.ts +149 -142
- package/src/navigation/NavigationContext.tsx +56 -56
- package/src/sentry/initSentry.ts +120 -120
- package/src/types/Theme.ts +72 -72
- package/src/types/css-modules.d.ts +1 -1
|
@@ -1,67 +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
|
-
});
|
|
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
|
+
});
|
|
@@ -1,236 +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
|
-
});
|
|
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
|
+
});
|