@velion-la/onboarding-sdk-react-native 1.0.0-beta.8 → 1.0.0-beta.9
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/lib/commonjs/camera/DocumentCapture.js +11 -3
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
- package/lib/commonjs/camera/LivenessCamera.js +18 -3
- package/lib/commonjs/camera/LivenessCamera.js.map +1 -1
- package/lib/commonjs/camera/MapAddressPicker.js +12 -22
- package/lib/commonjs/camera/MapAddressPicker.js.map +1 -1
- package/lib/commonjs/ui/StepShell.js +19 -4
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/VelionOnboardingScreen.js +52 -13
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/commonjs/utils/useSafeAreaInsets.js +41 -0
- package/lib/commonjs/utils/useSafeAreaInsets.js.map +1 -0
- package/lib/module/camera/DocumentCapture.js +11 -3
- package/lib/module/camera/DocumentCapture.js.map +1 -1
- package/lib/module/camera/LivenessCamera.js +18 -3
- package/lib/module/camera/LivenessCamera.js.map +1 -1
- package/lib/module/camera/MapAddressPicker.js +12 -23
- package/lib/module/camera/MapAddressPicker.js.map +1 -1
- package/lib/module/ui/StepShell.js +19 -4
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/VelionOnboardingScreen.js +55 -14
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/module/utils/useSafeAreaInsets.js +37 -0
- package/lib/module/utils/useSafeAreaInsets.js.map +1 -0
- package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -1
- package/lib/typescript/camera/LivenessCamera.d.ts.map +1 -1
- package/lib/typescript/camera/MapAddressPicker.d.ts.map +1 -1
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
- package/lib/typescript/utils/useSafeAreaInsets.d.ts +26 -0
- package/lib/typescript/utils/useSafeAreaInsets.d.ts.map +1 -0
- package/package.json +2 -1
- package/src/camera/DocumentCapture.tsx +12 -3
- package/src/camera/LivenessCamera.tsx +10 -3
- package/src/camera/MapAddressPicker.tsx +12 -18
- package/src/ui/StepShell.tsx +20 -3
- package/src/ui/VelionOnboardingScreen.tsx +53 -13
- package/src/utils/useSafeAreaInsets.ts +37 -0
|
@@ -31,6 +31,27 @@ import {
|
|
|
31
31
|
activateScreenKeepAwake,
|
|
32
32
|
deactivateScreenKeepAwake,
|
|
33
33
|
} from '../utils/keepAwake';
|
|
34
|
+
import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Mounts `react-native-safe-area-context`'s `SafeAreaProvider` so descendant
|
|
38
|
+
* `useSafeAreaInsets()` calls resolve real device insets (notch / nav bar). The
|
|
39
|
+
* library is loaded dynamically with a fail-safe: hosts that strip it (or that
|
|
40
|
+
* already mount their own provider higher up) still render — a nested provider
|
|
41
|
+
* returns correct insets, and a missing module degrades to zero insets.
|
|
42
|
+
*/
|
|
43
|
+
function SafeAreaBoundary({ children }: { children: ReactNode }) {
|
|
44
|
+
try {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
46
|
+
const mod = require('react-native-safe-area-context');
|
|
47
|
+
const Provider = mod.SafeAreaProvider;
|
|
48
|
+
return (
|
|
49
|
+
<Provider initialMetrics={mod.initialWindowMetrics}>{children}</Provider>
|
|
50
|
+
);
|
|
51
|
+
} catch {
|
|
52
|
+
return <>{children}</>;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
34
55
|
|
|
35
56
|
export interface VelionOnboardingScreenProps {
|
|
36
57
|
config: VelionConfig;
|
|
@@ -69,17 +90,19 @@ export function VelionOnboardingScreen({
|
|
|
69
90
|
onExit,
|
|
70
91
|
}: VelionOnboardingScreenProps) {
|
|
71
92
|
return (
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
<SafeAreaBoundary>
|
|
94
|
+
<ThemeProvider
|
|
95
|
+
themeOverrides={config.theme}
|
|
96
|
+
colorMode={config.colorMode ?? 'auto'}
|
|
97
|
+
>
|
|
98
|
+
<VelionOnboardingInner
|
|
99
|
+
config={config}
|
|
100
|
+
onComplete={onComplete}
|
|
101
|
+
onFail={onFail}
|
|
102
|
+
onExit={onExit}
|
|
103
|
+
/>
|
|
104
|
+
</ThemeProvider>
|
|
105
|
+
</SafeAreaBoundary>
|
|
83
106
|
);
|
|
84
107
|
}
|
|
85
108
|
|
|
@@ -90,6 +113,7 @@ function VelionOnboardingInner({
|
|
|
90
113
|
onExit,
|
|
91
114
|
}: VelionOnboardingScreenProps) {
|
|
92
115
|
const theme = useTheme();
|
|
116
|
+
const insets = useSafeAreaInsets();
|
|
93
117
|
const t = getStrings(config.locale);
|
|
94
118
|
const [state, setState] = useState<ViewState>(INITIAL_STATE);
|
|
95
119
|
const [progress, setProgress] = useState(0);
|
|
@@ -214,10 +238,20 @@ function VelionOnboardingInner({
|
|
|
214
238
|
|
|
215
239
|
return (
|
|
216
240
|
<View style={[styles.root, { backgroundColor: theme.backgroundColor }]}>
|
|
241
|
+
{/* Content fills the screen edge-to-edge so camera / map steps stay
|
|
242
|
+
full-bleed. The progress bar floats on top, pushed below the top
|
|
243
|
+
safe-area inset (status bar / notch / punch-hole). Form steps offset
|
|
244
|
+
their own header via StepShell, and camera steps offset their chrome
|
|
245
|
+
internally — so we never inset the content container here. */}
|
|
246
|
+
<View style={styles.content}>{renderBody()}</View>
|
|
217
247
|
{showProgress ? (
|
|
218
|
-
<
|
|
248
|
+
<View
|
|
249
|
+
pointerEvents="none"
|
|
250
|
+
style={[styles.progressOverlay, { paddingTop: insets.top }]}
|
|
251
|
+
>
|
|
252
|
+
<ProgressBar value={progress} hidden={progressHidden} />
|
|
253
|
+
</View>
|
|
219
254
|
) : null}
|
|
220
|
-
<View style={styles.content}>{renderBody()}</View>
|
|
221
255
|
{showLoadingOverlay ? <LoadingOverlay message={loadingText} /> : null}
|
|
222
256
|
</View>
|
|
223
257
|
);
|
|
@@ -231,6 +265,12 @@ const styles = StyleSheet.create({
|
|
|
231
265
|
flex: 1,
|
|
232
266
|
overflow: 'hidden',
|
|
233
267
|
},
|
|
268
|
+
progressOverlay: {
|
|
269
|
+
position: 'absolute',
|
|
270
|
+
top: 0,
|
|
271
|
+
left: 0,
|
|
272
|
+
right: 0,
|
|
273
|
+
},
|
|
234
274
|
message: {
|
|
235
275
|
flex: 1,
|
|
236
276
|
alignItems: 'center',
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared safe-area inset hook with a dynamic, fail-safe loader.
|
|
3
|
+
*
|
|
4
|
+
* `react-native-safe-area-context` is a transitive peer of Expo SDK 54+ (and is
|
|
5
|
+
* declared as a peerDependency of this SDK), but we never import it statically:
|
|
6
|
+
* hosts that strip optional native deps, or render the SDK outside a
|
|
7
|
+
* `SafeAreaProvider`, must still get a usable layout. So the hook is loaded with
|
|
8
|
+
* a `require` inside a try/catch and falls back to zero insets.
|
|
9
|
+
*
|
|
10
|
+
* The `require` result is deterministic for the lifetime of the bundle (the
|
|
11
|
+
* module is either installed or not), so the conditional hook call below does
|
|
12
|
+
* not change across renders — it does not violate the rules of hooks. Callers
|
|
13
|
+
* MUST still invoke this hook unconditionally (before any early return).
|
|
14
|
+
*
|
|
15
|
+
* Insets are applied to UI chrome (headers, CTAs, camera controls) — never to
|
|
16
|
+
* the full-bleed `<Camera>` / `<MapView>` preview, which must keep covering the
|
|
17
|
+
* whole screen so OCR / liveness framing is not cropped.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export interface EdgeInsets {
|
|
21
|
+
top: number;
|
|
22
|
+
bottom: number;
|
|
23
|
+
left: number;
|
|
24
|
+
right: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ZERO_INSETS: EdgeInsets = { top: 0, bottom: 0, left: 0, right: 0 };
|
|
28
|
+
|
|
29
|
+
export function useSafeAreaInsets(): EdgeInsets {
|
|
30
|
+
try {
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
|
|
32
|
+
const mod = require('react-native-safe-area-context');
|
|
33
|
+
return mod.useSafeAreaInsets() as EdgeInsets;
|
|
34
|
+
} catch {
|
|
35
|
+
return ZERO_INSETS;
|
|
36
|
+
}
|
|
37
|
+
}
|