@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,189 +1,189 @@
|
|
|
1
|
-
import { StyleSheet, Text, View } from "react-native";
|
|
2
|
-
import { Image } from "expo-image";
|
|
3
|
-
import { useRecyclingInfo } from "../../hooks/useRecyclingInfo";
|
|
4
|
-
import { Theme } from "../../types/Theme";
|
|
5
|
-
import { useTheme } from "../../contexts/ThemeContext";
|
|
6
|
-
import { Title } from "../title/Title";
|
|
7
|
-
import { Paragraph } from "../parapraph/Paragraph";
|
|
8
|
-
import { getContrastColor } from "../../helpers/getContrastColor";
|
|
9
|
-
import { Button } from "../button/Button";
|
|
10
|
-
import { useState, type ReactNode } from "react";
|
|
11
|
-
import { ConsignesModal } from "../consignes-modal/ConsignesModal";
|
|
12
|
-
import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
|
|
13
|
-
import { resolveApiAssetUrl } from "../../helpers/resolveApiAssetUrl";
|
|
14
|
-
import { useWasto } from "../../contexts/WastoContext";
|
|
15
|
-
|
|
16
|
-
export type RecyclingInfoProps = {};
|
|
17
|
-
|
|
18
|
-
export function RecyclingInfo({ }: RecyclingInfoProps): ReactNode {
|
|
19
|
-
const { recyclingInfos } = useRecyclingInfo();
|
|
20
|
-
const { theme } = useTheme();
|
|
21
|
-
const { apiUrl } = useWasto();
|
|
22
|
-
const t = resolveTheme(theme);
|
|
23
|
-
const themedStyles = createThemedStyles(theme);
|
|
24
|
-
const [selectedWasteTypeId, setSelectedWasteTypeId] = useState<string | null>(null);
|
|
25
|
-
|
|
26
|
-
const handleOnWasteTypeSelected = (wasteTypeId: string) => {
|
|
27
|
-
return () => {
|
|
28
|
-
setSelectedWasteTypeId(wasteTypeId);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return <>
|
|
33
|
-
<View style={styles.container}>
|
|
34
|
-
{recyclingInfos.map((recyclingInfo) => {
|
|
35
|
-
const color = recyclingInfo.color ?? theme.colors.primary;
|
|
36
|
-
const illustration =
|
|
37
|
-
resolveApiAssetUrl(apiUrl, recyclingInfo.imageUrl) ||
|
|
38
|
-
(recyclingInfo.icon?.trim().startsWith("http") ? recyclingInfo.icon.trim() : null);
|
|
39
|
-
return (
|
|
40
|
-
<View
|
|
41
|
-
key={recyclingInfo.id}
|
|
42
|
-
style={[
|
|
43
|
-
styles.recyclingInfo,
|
|
44
|
-
cardStyle(theme),
|
|
45
|
-
]}
|
|
46
|
-
>
|
|
47
|
-
<View
|
|
48
|
-
style={[
|
|
49
|
-
styles.header,
|
|
50
|
-
{ backgroundColor: color },
|
|
51
|
-
]}
|
|
52
|
-
>
|
|
53
|
-
{illustration ? (
|
|
54
|
-
<Image
|
|
55
|
-
source={illustration}
|
|
56
|
-
style={styles.headerImage}
|
|
57
|
-
contentFit="contain"
|
|
58
|
-
/>
|
|
59
|
-
) : null}
|
|
60
|
-
<Title
|
|
61
|
-
text={recyclingInfo.name}
|
|
62
|
-
level="3"
|
|
63
|
-
style={{ color: getContrastColor(color), flex: 1 }}
|
|
64
|
-
/>
|
|
65
|
-
</View>
|
|
66
|
-
<View style={styles.body}>
|
|
67
|
-
{recyclingInfo.description && (
|
|
68
|
-
<Paragraph text={recyclingInfo.description} style={themedStyles.cardText} />
|
|
69
|
-
)}
|
|
70
|
-
<View
|
|
71
|
-
style={[
|
|
72
|
-
styles.details,
|
|
73
|
-
{
|
|
74
|
-
backgroundColor: recyclingInfo.colorLight ?? theme.colors.primarySoft,
|
|
75
|
-
borderRadius: t.radii.md,
|
|
76
|
-
},
|
|
77
|
-
]}
|
|
78
|
-
>
|
|
79
|
-
{recyclingInfo.details?.map((detail) => {
|
|
80
|
-
const detailImageUrl = resolveApiAssetUrl(
|
|
81
|
-
apiUrl,
|
|
82
|
-
detail.imageUrl,
|
|
83
|
-
);
|
|
84
|
-
return (
|
|
85
|
-
<View
|
|
86
|
-
key={detail.id}
|
|
87
|
-
style={[
|
|
88
|
-
styles.detail,
|
|
89
|
-
{
|
|
90
|
-
backgroundColor: "#ffffff55",
|
|
91
|
-
borderRadius: t.radii.sm,
|
|
92
|
-
},
|
|
93
|
-
]}
|
|
94
|
-
>
|
|
95
|
-
{detailImageUrl ? (
|
|
96
|
-
<Image
|
|
97
|
-
source={detailImageUrl}
|
|
98
|
-
style={styles.detailImage}
|
|
99
|
-
contentFit="contain"
|
|
100
|
-
/>
|
|
101
|
-
) : null}
|
|
102
|
-
<View style={styles.detailText}>
|
|
103
|
-
<Text
|
|
104
|
-
style={[
|
|
105
|
-
styles.detailMaterial,
|
|
106
|
-
{ color: getContrastColor(recyclingInfo.colorLight ?? "#FFFFFF") }
|
|
107
|
-
]}
|
|
108
|
-
>
|
|
109
|
-
{detail.material}
|
|
110
|
-
</Text>
|
|
111
|
-
<Text
|
|
112
|
-
style={{ color: getContrastColor(recyclingInfo.colorLight ?? "#FFFFFF") }}
|
|
113
|
-
>
|
|
114
|
-
{detail.description}
|
|
115
|
-
</Text>
|
|
116
|
-
</View>
|
|
117
|
-
</View>
|
|
118
|
-
);
|
|
119
|
-
})}
|
|
120
|
-
</View>
|
|
121
|
-
<Button
|
|
122
|
-
style={{ backgroundColor: color }}
|
|
123
|
-
textStyle={{ color: getContrastColor(color) }}
|
|
124
|
-
onPress={handleOnWasteTypeSelected(recyclingInfo.wasteTypeId)}
|
|
125
|
-
>
|
|
126
|
-
Voir les details
|
|
127
|
-
</Button>
|
|
128
|
-
</View>
|
|
129
|
-
</View>
|
|
130
|
-
);
|
|
131
|
-
})}
|
|
132
|
-
</View>
|
|
133
|
-
<ConsignesModal
|
|
134
|
-
visible={!!selectedWasteTypeId}
|
|
135
|
-
wasteTypeId={selectedWasteTypeId!}
|
|
136
|
-
onClose={() => setSelectedWasteTypeId(null)}
|
|
137
|
-
/>
|
|
138
|
-
</>
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const createThemedStyles = (theme: Theme) => StyleSheet.create({
|
|
142
|
-
cardText: {
|
|
143
|
-
color: theme.colors.onSurface,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const styles = StyleSheet.create({
|
|
148
|
-
container: {
|
|
149
|
-
gap: 16,
|
|
150
|
-
},
|
|
151
|
-
recyclingInfo: {
|
|
152
|
-
overflow: "hidden",
|
|
153
|
-
},
|
|
154
|
-
header: {
|
|
155
|
-
padding: 16,
|
|
156
|
-
flexDirection: "row",
|
|
157
|
-
alignItems: "center",
|
|
158
|
-
gap: 12,
|
|
159
|
-
},
|
|
160
|
-
headerImage: {
|
|
161
|
-
width: 56,
|
|
162
|
-
height: 56,
|
|
163
|
-
},
|
|
164
|
-
body: {
|
|
165
|
-
padding: 16,
|
|
166
|
-
gap: 16,
|
|
167
|
-
},
|
|
168
|
-
details: {
|
|
169
|
-
padding: 12,
|
|
170
|
-
gap: 10,
|
|
171
|
-
},
|
|
172
|
-
detail: {
|
|
173
|
-
flexDirection: "row",
|
|
174
|
-
alignItems: "center",
|
|
175
|
-
gap: 12,
|
|
176
|
-
padding: 12,
|
|
177
|
-
},
|
|
178
|
-
detailImage: {
|
|
179
|
-
width: 48,
|
|
180
|
-
height: 48,
|
|
181
|
-
},
|
|
182
|
-
detailText: {
|
|
183
|
-
flex: 1,
|
|
184
|
-
gap: 4,
|
|
185
|
-
},
|
|
186
|
-
detailMaterial: {
|
|
187
|
-
fontWeight: "700"
|
|
188
|
-
},
|
|
189
|
-
});
|
|
1
|
+
import { StyleSheet, Text, View } from "react-native";
|
|
2
|
+
import { Image } from "expo-image";
|
|
3
|
+
import { useRecyclingInfo } from "../../hooks/useRecyclingInfo";
|
|
4
|
+
import { Theme } from "../../types/Theme";
|
|
5
|
+
import { useTheme } from "../../contexts/ThemeContext";
|
|
6
|
+
import { Title } from "../title/Title";
|
|
7
|
+
import { Paragraph } from "../parapraph/Paragraph";
|
|
8
|
+
import { getContrastColor } from "../../helpers/getContrastColor";
|
|
9
|
+
import { Button } from "../button/Button";
|
|
10
|
+
import { useState, type ReactNode } from "react";
|
|
11
|
+
import { ConsignesModal } from "../consignes-modal/ConsignesModal";
|
|
12
|
+
import { cardStyle, resolveTheme } from "../../helpers/themeStyles";
|
|
13
|
+
import { resolveApiAssetUrl } from "../../helpers/resolveApiAssetUrl";
|
|
14
|
+
import { useWasto } from "../../contexts/WastoContext";
|
|
15
|
+
|
|
16
|
+
export type RecyclingInfoProps = {};
|
|
17
|
+
|
|
18
|
+
export function RecyclingInfo({ }: RecyclingInfoProps): ReactNode {
|
|
19
|
+
const { recyclingInfos } = useRecyclingInfo();
|
|
20
|
+
const { theme } = useTheme();
|
|
21
|
+
const { apiUrl } = useWasto();
|
|
22
|
+
const t = resolveTheme(theme);
|
|
23
|
+
const themedStyles = createThemedStyles(theme);
|
|
24
|
+
const [selectedWasteTypeId, setSelectedWasteTypeId] = useState<string | null>(null);
|
|
25
|
+
|
|
26
|
+
const handleOnWasteTypeSelected = (wasteTypeId: string) => {
|
|
27
|
+
return () => {
|
|
28
|
+
setSelectedWasteTypeId(wasteTypeId);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return <>
|
|
33
|
+
<View style={styles.container}>
|
|
34
|
+
{recyclingInfos.map((recyclingInfo) => {
|
|
35
|
+
const color = recyclingInfo.color ?? theme.colors.primary;
|
|
36
|
+
const illustration =
|
|
37
|
+
resolveApiAssetUrl(apiUrl, recyclingInfo.imageUrl) ||
|
|
38
|
+
(recyclingInfo.icon?.trim().startsWith("http") ? recyclingInfo.icon.trim() : null);
|
|
39
|
+
return (
|
|
40
|
+
<View
|
|
41
|
+
key={recyclingInfo.id}
|
|
42
|
+
style={[
|
|
43
|
+
styles.recyclingInfo,
|
|
44
|
+
cardStyle(theme),
|
|
45
|
+
]}
|
|
46
|
+
>
|
|
47
|
+
<View
|
|
48
|
+
style={[
|
|
49
|
+
styles.header,
|
|
50
|
+
{ backgroundColor: color },
|
|
51
|
+
]}
|
|
52
|
+
>
|
|
53
|
+
{illustration ? (
|
|
54
|
+
<Image
|
|
55
|
+
source={illustration}
|
|
56
|
+
style={styles.headerImage}
|
|
57
|
+
contentFit="contain"
|
|
58
|
+
/>
|
|
59
|
+
) : null}
|
|
60
|
+
<Title
|
|
61
|
+
text={recyclingInfo.name}
|
|
62
|
+
level="3"
|
|
63
|
+
style={{ color: getContrastColor(color), flex: 1 }}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
<View style={styles.body}>
|
|
67
|
+
{recyclingInfo.description && (
|
|
68
|
+
<Paragraph text={recyclingInfo.description} style={themedStyles.cardText} />
|
|
69
|
+
)}
|
|
70
|
+
<View
|
|
71
|
+
style={[
|
|
72
|
+
styles.details,
|
|
73
|
+
{
|
|
74
|
+
backgroundColor: recyclingInfo.colorLight ?? theme.colors.primarySoft,
|
|
75
|
+
borderRadius: t.radii.md,
|
|
76
|
+
},
|
|
77
|
+
]}
|
|
78
|
+
>
|
|
79
|
+
{recyclingInfo.details?.map((detail) => {
|
|
80
|
+
const detailImageUrl = resolveApiAssetUrl(
|
|
81
|
+
apiUrl,
|
|
82
|
+
detail.imageUrl,
|
|
83
|
+
);
|
|
84
|
+
return (
|
|
85
|
+
<View
|
|
86
|
+
key={detail.id}
|
|
87
|
+
style={[
|
|
88
|
+
styles.detail,
|
|
89
|
+
{
|
|
90
|
+
backgroundColor: "#ffffff55",
|
|
91
|
+
borderRadius: t.radii.sm,
|
|
92
|
+
},
|
|
93
|
+
]}
|
|
94
|
+
>
|
|
95
|
+
{detailImageUrl ? (
|
|
96
|
+
<Image
|
|
97
|
+
source={detailImageUrl}
|
|
98
|
+
style={styles.detailImage}
|
|
99
|
+
contentFit="contain"
|
|
100
|
+
/>
|
|
101
|
+
) : null}
|
|
102
|
+
<View style={styles.detailText}>
|
|
103
|
+
<Text
|
|
104
|
+
style={[
|
|
105
|
+
styles.detailMaterial,
|
|
106
|
+
{ color: getContrastColor(recyclingInfo.colorLight ?? "#FFFFFF") }
|
|
107
|
+
]}
|
|
108
|
+
>
|
|
109
|
+
{detail.material}
|
|
110
|
+
</Text>
|
|
111
|
+
<Text
|
|
112
|
+
style={{ color: getContrastColor(recyclingInfo.colorLight ?? "#FFFFFF") }}
|
|
113
|
+
>
|
|
114
|
+
{detail.description}
|
|
115
|
+
</Text>
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
);
|
|
119
|
+
})}
|
|
120
|
+
</View>
|
|
121
|
+
<Button
|
|
122
|
+
style={{ backgroundColor: color }}
|
|
123
|
+
textStyle={{ color: getContrastColor(color) }}
|
|
124
|
+
onPress={handleOnWasteTypeSelected(recyclingInfo.wasteTypeId)}
|
|
125
|
+
>
|
|
126
|
+
Voir les details
|
|
127
|
+
</Button>
|
|
128
|
+
</View>
|
|
129
|
+
</View>
|
|
130
|
+
);
|
|
131
|
+
})}
|
|
132
|
+
</View>
|
|
133
|
+
<ConsignesModal
|
|
134
|
+
visible={!!selectedWasteTypeId}
|
|
135
|
+
wasteTypeId={selectedWasteTypeId!}
|
|
136
|
+
onClose={() => setSelectedWasteTypeId(null)}
|
|
137
|
+
/>
|
|
138
|
+
</>
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const createThemedStyles = (theme: Theme) => StyleSheet.create({
|
|
142
|
+
cardText: {
|
|
143
|
+
color: theme.colors.onSurface,
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const styles = StyleSheet.create({
|
|
148
|
+
container: {
|
|
149
|
+
gap: 16,
|
|
150
|
+
},
|
|
151
|
+
recyclingInfo: {
|
|
152
|
+
overflow: "hidden",
|
|
153
|
+
},
|
|
154
|
+
header: {
|
|
155
|
+
padding: 16,
|
|
156
|
+
flexDirection: "row",
|
|
157
|
+
alignItems: "center",
|
|
158
|
+
gap: 12,
|
|
159
|
+
},
|
|
160
|
+
headerImage: {
|
|
161
|
+
width: 56,
|
|
162
|
+
height: 56,
|
|
163
|
+
},
|
|
164
|
+
body: {
|
|
165
|
+
padding: 16,
|
|
166
|
+
gap: 16,
|
|
167
|
+
},
|
|
168
|
+
details: {
|
|
169
|
+
padding: 12,
|
|
170
|
+
gap: 10,
|
|
171
|
+
},
|
|
172
|
+
detail: {
|
|
173
|
+
flexDirection: "row",
|
|
174
|
+
alignItems: "center",
|
|
175
|
+
gap: 12,
|
|
176
|
+
padding: 12,
|
|
177
|
+
},
|
|
178
|
+
detailImage: {
|
|
179
|
+
width: 48,
|
|
180
|
+
height: 48,
|
|
181
|
+
},
|
|
182
|
+
detailText: {
|
|
183
|
+
flex: 1,
|
|
184
|
+
gap: 4,
|
|
185
|
+
},
|
|
186
|
+
detailMaterial: {
|
|
187
|
+
fontWeight: "700"
|
|
188
|
+
},
|
|
189
|
+
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useContext, type PropsWithChildren } from "react";
|
|
2
|
-
import {
|
|
3
|
-
SafeAreaInsetsContext,
|
|
4
|
-
SafeAreaProvider,
|
|
5
|
-
} from "react-native-safe-area-context";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Reuses a parent Expo Router / React Navigation `SafeAreaProvider`.
|
|
9
|
-
* Mounts one only when the host has none (standalone / no navigation).
|
|
10
|
-
*/
|
|
11
|
-
export function OptionalSafeAreaProvider({ children }: PropsWithChildren) {
|
|
12
|
-
const parentInsets = useContext(SafeAreaInsetsContext);
|
|
13
|
-
if (parentInsets != null) {
|
|
14
|
-
return children;
|
|
15
|
-
}
|
|
16
|
-
return <SafeAreaProvider>{children}</SafeAreaProvider>;
|
|
17
|
-
}
|
|
1
|
+
import { useContext, type PropsWithChildren } from "react";
|
|
2
|
+
import {
|
|
3
|
+
SafeAreaInsetsContext,
|
|
4
|
+
SafeAreaProvider,
|
|
5
|
+
} from "react-native-safe-area-context";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Reuses a parent Expo Router / React Navigation `SafeAreaProvider`.
|
|
9
|
+
* Mounts one only when the host has none (standalone / no navigation).
|
|
10
|
+
*/
|
|
11
|
+
export function OptionalSafeAreaProvider({ children }: PropsWithChildren) {
|
|
12
|
+
const parentInsets = useContext(SafeAreaInsetsContext);
|
|
13
|
+
if (parentInsets != null) {
|
|
14
|
+
return children;
|
|
15
|
+
}
|
|
16
|
+
return <SafeAreaProvider>{children}</SafeAreaProvider>;
|
|
17
|
+
}
|