@@ -6,16 +6,27 @@ import {useLingui} from '@lingui/react'
6
6
7
7
import { logger } from '#/logger'
8
8
import { isWeb } from '#/platform/detection'
9
+ import { useDeviceGeolocationApi } from '#/state/geolocation'
9
10
import { atoms as a , useBreakpoints , useTheme , web } from '#/alf'
11
+ import { Button , ButtonIcon , ButtonText } from '#/components/Button'
12
+ import * as Dialog from '#/components/Dialog'
13
+ import { DeviceLocationRequestDialog } from '#/components/dialogs/DeviceLocationRequestDialog'
14
+ import { Divider } from '#/components/Divider'
10
15
import { Full as Logo , Mark } from '#/components/icons/Logo'
16
+ import { PinLocation_Stroke2_Corner0_Rounded as LocationIcon } from '#/components/icons/PinLocation'
11
17
import { SimpleInlineLinkText as InlineLinkText } from '#/components/Link'
18
+ import { Outlet as PortalOutlet } from '#/components/Portal'
19
+ import * as Toast from '#/components/Toast'
12
20
import { Text } from '#/components/Typography'
21
+ import { BottomSheetOutlet } from '#/../modules/bottom-sheet'
13
22
14
23
export function BlockedGeoOverlay ( ) {
15
24
const t = useTheme ( )
16
25
const { _} = useLingui ( )
17
26
const { gtPhone} = useBreakpoints ( )
18
27
const insets = useSafeAreaInsets ( )
28
+ const geoDialog = Dialog . useDialogControl ( )
29
+ const { setDeviceGeolocation} = useDeviceGeolocationApi ( )
19
30
20
31
useEffect ( ( ) => {
21
32
// just counting overall hits here
@@ -51,59 +62,133 @@ export function BlockedGeoOverlay() {
51
62
]
52
63
53
64
return (
54
- < ScrollView
55
- contentContainerStyle = { [
56
- a . px_2xl ,
57
- {
58
- paddingTop : isWeb ? a . p_5xl . padding : insets . top + a . p_2xl . padding ,
59
- paddingBottom : 100 ,
60
- } ,
61
- ] } >
62
- < View
63
- style = { [
64
- a . mx_auto ,
65
- web ( {
66
- maxWidth : 440 ,
67
- paddingTop : gtPhone ? '8vh' : undefined ,
68
- } ) ,
65
+ < >
66
+ < ScrollView
67
+ contentContainerStyle = { [
68
+ a . px_2xl ,
69
+ {
70
+ paddingTop : isWeb ? a . p_5xl . padding : insets . top + a . p_2xl . padding ,
71
+ paddingBottom : 100 ,
72
+ } ,
69
73
] } >
70
- < View style = { [ a . align_start ] } >
71
- < View
72
- style = { [
73
- a . pl_md ,
74
- a . pr_lg ,
75
- a . py_sm ,
76
- a . rounded_full ,
77
- a . flex_row ,
78
- a . align_center ,
79
- a . gap_xs ,
80
- {
81
- backgroundColor : t . palette . primary_25 ,
82
- } ,
83
- ] } >
84
- < Mark fill = { t . palette . primary_600 } width = { 14 } />
85
- < Text
74
+ < View
75
+ style = { [
76
+ a . mx_auto ,
77
+ web ( {
78
+ maxWidth : 380 ,
79
+ paddingTop : gtPhone ? '8vh' : undefined ,
80
+ } ) ,
81
+ ] } >
82
+ < View style = { [ a . align_start ] } >
83
+ < View
86
84
style = { [
87
- a . font_bold ,
85
+ a . pl_md ,
86
+ a . pr_lg ,
87
+ a . py_sm ,
88
+ a . rounded_full ,
89
+ a . flex_row ,
90
+ a . align_center ,
91
+ a . gap_xs ,
88
92
{
89
- color : t . palette . primary_600 ,
93
+ backgroundColor : t . palette . primary_25 ,
90
94
} ,
91
95
] } >
92
- < Trans > Announcement</ Trans >
93
- </ Text >
96
+ < Mark fill = { t . palette . primary_600 } width = { 14 } />
97
+ < Text
98
+ style = { [
99
+ a . font_bold ,
100
+ {
101
+ color : t . palette . primary_600 ,
102
+ } ,
103
+ ] } >
104
+ < Trans > Announcement</ Trans >
105
+ </ Text >
106
+ </ View >
107
+ </ View >
108
+
109
+ < View style = { [ a . gap_lg , { paddingTop : 32 } ] } >
110
+ { blocks . map ( ( block , index ) => (
111
+ < Text key = { index } style = { [ textStyles ] } >
112
+ { block }
113
+ </ Text >
114
+ ) ) }
94
115
</ View >
95
- </ View >
96
116
97
- < View style = { [ a . gap_lg , { paddingTop : 32 , paddingBottom : 48 } ] } >
98
- { blocks . map ( ( block , index ) => (
99
- < Text key = { index } style = { [ textStyles ] } >
100
- { block }
101
- </ Text >
102
- ) ) }
117
+ { ! isWeb && (
118
+ < >
119
+ < View style = { [ a . pt_2xl ] } >
120
+ < Divider />
121
+ </ View >
122
+
123
+ < View style = { [ a . mt_xl , a . align_start ] } >
124
+ < Text
125
+ style = { [ a . text_lg , a . font_heavy , a . leading_snug , a . pb_xs ] } >
126
+ < Trans > Not in Mississippi?</ Trans >
127
+ </ Text >
128
+ < Text
129
+ style = { [
130
+ a . text_sm ,
131
+ a . leading_snug ,
132
+ t . atoms . text_contrast_medium ,
133
+ a . pb_md ,
134
+ ] } >
135
+ < Trans >
136
+ Confirm your location with GPS. Your location data is not
137
+ tracked and does not leave your device.
138
+ </ Trans >
139
+ </ Text >
140
+ < Button
141
+ label = { _ ( msg `Confirm your location` ) }
142
+ onPress = { ( ) => geoDialog . open ( ) }
143
+ size = "small"
144
+ color = "primary_subtle" >
145
+ < ButtonIcon icon = { LocationIcon } />
146
+ < ButtonText >
147
+ < Trans > Confirm your location</ Trans >
148
+ </ ButtonText >
149
+ </ Button >
150
+ </ View >
151
+
152
+ < DeviceLocationRequestDialog
153
+ control = { geoDialog }
154
+ onLocationAcquired = { props => {
155
+ if ( props . geolocationStatus . isAgeBlockedGeo ) {
156
+ props . disableDialogAction ( )
157
+ props . setDialogError (
158
+ _ (
159
+ msg `We're sorry, but based on your device's location, you are currently located in a region we cannot provide access at this time.` ,
160
+ ) ,
161
+ )
162
+ } else {
163
+ props . closeDialog ( ( ) => {
164
+ // set this after close!
165
+ setDeviceGeolocation ( {
166
+ countryCode : props . geolocationStatus . countryCode ,
167
+ regionCode : props . geolocationStatus . regionCode ,
168
+ } )
169
+ Toast . show ( _ ( msg `Thanks! You're all set.` ) , {
170
+ type : 'success' ,
171
+ } )
172
+ } )
173
+ }
174
+ } }
175
+ />
176
+ </ >
177
+ ) }
178
+
179
+ < View style = { [ { paddingTop : 48 } ] } >
180
+ < Logo width = { 120 } textFill = { t . atoms . text . color } />
181
+ </ View >
103
182
</ View >
183
+ </ ScrollView >
104
184
105
- < Logo width = { 120 } textFill = { t . atoms . text . color } />
106
- </ View >
107
- </ ScrollView >
185
+ { /*
186
+ * While this blocking overlay is up, other dialogs in the shell
187
+ * are not mounted, so it _should_ be safe to use these here
188
+ * without fear of other modals showing up.
189
+ */ }
190
+ < BottomSheetOutlet />
191
+ < PortalOutlet />
192
+ </ >
108
193
)
109
194
}
0 commit comments