@velion-la/onboarding-sdk-react-native 1.1.0-beta.1 → 1.1.0-beta.3
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/CHANGELOG.md +16 -1
- package/README.md +40 -0
- package/lib/commonjs/camera/DocumentCapture.js +11 -0
- package/lib/commonjs/camera/DocumentCapture.js.map +1 -1
- package/lib/commonjs/steps/AddressInfoStep.js +41 -13
- package/lib/commonjs/steps/AddressInfoStep.js.map +1 -1
- package/lib/commonjs/steps/DocumentsOcrStep.js +115 -90
- package/lib/commonjs/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/commonjs/steps/EconomicActivityStep.js +53 -52
- package/lib/commonjs/steps/EconomicActivityStep.js.map +1 -1
- package/lib/commonjs/ui/ScreenScaffold.js +99 -0
- package/lib/commonjs/ui/ScreenScaffold.js.map +1 -0
- package/lib/commonjs/ui/StepShell.js +23 -42
- package/lib/commonjs/ui/StepShell.js.map +1 -1
- package/lib/commonjs/ui/VelionOnboardingScreen.js +13 -10
- package/lib/commonjs/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/commonjs/ui/forms/index.js +7 -0
- package/lib/commonjs/ui/forms/index.js.map +1 -1
- package/lib/commonjs/ui/forms/useFieldChain.js +56 -0
- package/lib/commonjs/ui/forms/useFieldChain.js.map +1 -0
- package/lib/commonjs/ui/keyboard.js +147 -0
- package/lib/commonjs/ui/keyboard.js.map +1 -0
- package/lib/commonjs/ui/screenInsets.js +67 -0
- package/lib/commonjs/ui/screenInsets.js.map +1 -0
- package/lib/commonjs/utils/documentCrop.js +21 -0
- package/lib/commonjs/utils/documentCrop.js.map +1 -1
- package/lib/module/camera/DocumentCapture.js +11 -0
- package/lib/module/camera/DocumentCapture.js.map +1 -1
- package/lib/module/steps/AddressInfoStep.js +41 -13
- package/lib/module/steps/AddressInfoStep.js.map +1 -1
- package/lib/module/steps/DocumentsOcrStep.js +116 -90
- package/lib/module/steps/DocumentsOcrStep.js.map +1 -1
- package/lib/module/steps/EconomicActivityStep.js +54 -53
- package/lib/module/steps/EconomicActivityStep.js.map +1 -1
- package/lib/module/ui/ScreenScaffold.js +94 -0
- package/lib/module/ui/ScreenScaffold.js.map +1 -0
- package/lib/module/ui/StepShell.js +24 -43
- package/lib/module/ui/StepShell.js.map +1 -1
- package/lib/module/ui/VelionOnboardingScreen.js +13 -10
- package/lib/module/ui/VelionOnboardingScreen.js.map +1 -1
- package/lib/module/ui/forms/index.js +1 -0
- package/lib/module/ui/forms/index.js.map +1 -1
- package/lib/module/ui/forms/useFieldChain.js +52 -0
- package/lib/module/ui/forms/useFieldChain.js.map +1 -0
- package/lib/module/ui/keyboard.js +143 -0
- package/lib/module/ui/keyboard.js.map +1 -0
- package/lib/module/ui/screenInsets.js +61 -0
- package/lib/module/ui/screenInsets.js.map +1 -0
- package/lib/module/utils/documentCrop.js +20 -0
- package/lib/module/utils/documentCrop.js.map +1 -1
- package/lib/typescript/camera/DocumentCapture.d.ts.map +1 -1
- package/lib/typescript/steps/AddressInfoStep.d.ts.map +1 -1
- package/lib/typescript/steps/DocumentsOcrStep.d.ts.map +1 -1
- package/lib/typescript/steps/EconomicActivityStep.d.ts.map +1 -1
- package/lib/typescript/ui/ScreenScaffold.d.ts +57 -0
- package/lib/typescript/ui/ScreenScaffold.d.ts.map +1 -0
- package/lib/typescript/ui/StepShell.d.ts +1 -3
- package/lib/typescript/ui/StepShell.d.ts.map +1 -1
- package/lib/typescript/ui/VelionOnboardingScreen.d.ts.map +1 -1
- package/lib/typescript/ui/forms/index.d.ts +1 -0
- package/lib/typescript/ui/forms/index.d.ts.map +1 -1
- package/lib/typescript/ui/forms/useFieldChain.d.ts +30 -0
- package/lib/typescript/ui/forms/useFieldChain.d.ts.map +1 -0
- package/lib/typescript/ui/keyboard.d.ts +69 -0
- package/lib/typescript/ui/keyboard.d.ts.map +1 -0
- package/lib/typescript/ui/screenInsets.d.ts +68 -0
- package/lib/typescript/ui/screenInsets.d.ts.map +1 -0
- package/lib/typescript/utils/documentCrop.d.ts +16 -0
- package/lib/typescript/utils/documentCrop.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/camera/DocumentCapture.tsx +10 -0
- package/src/steps/AddressInfoStep.tsx +37 -0
- package/src/steps/DocumentsOcrStep.tsx +138 -97
- package/src/steps/EconomicActivityStep.tsx +54 -44
- package/src/ui/ScreenScaffold.tsx +130 -0
- package/src/ui/StepShell.tsx +27 -56
- package/src/ui/VelionOnboardingScreen.tsx +16 -13
- package/src/ui/forms/index.ts +1 -0
- package/src/ui/forms/useFieldChain.ts +63 -0
- package/src/ui/keyboard.tsx +196 -0
- package/src/ui/screenInsets.ts +89 -0
- package/src/utils/documentCrop.ts +21 -0
|
@@ -25,7 +25,10 @@ import {
|
|
|
25
25
|
Text,
|
|
26
26
|
View,
|
|
27
27
|
} from 'react-native';
|
|
28
|
-
import
|
|
28
|
+
import {
|
|
29
|
+
ImageManipulator as ImageManipulatorModule,
|
|
30
|
+
SaveFormat,
|
|
31
|
+
} from 'expo-image-manipulator';
|
|
29
32
|
import type { PhotoFile } from 'react-native-vision-camera';
|
|
30
33
|
import {
|
|
31
34
|
SdkErrorCode,
|
|
@@ -39,6 +42,7 @@ import { Banner } from '../ui/primitives/Banner';
|
|
|
39
42
|
import { Button } from '../ui/primitives/Button';
|
|
40
43
|
import { LoadingOverlay } from '../ui/overlays/LoadingOverlay';
|
|
41
44
|
import { RetryDialog } from '../ui/overlays/RetryDialog';
|
|
45
|
+
import { ScreenScaffold } from '../ui/ScreenScaffold';
|
|
42
46
|
import { StepShell } from '../ui/StepShell';
|
|
43
47
|
import { StepIcon } from '../ui/icons/StepIcon';
|
|
44
48
|
import { useTheme, mixHex } from '../ui/theme';
|
|
@@ -46,7 +50,10 @@ import { getStrings } from '../i18n';
|
|
|
46
50
|
import { resolveCaptureModeFromStepConfig } from '../utils/stepConfig';
|
|
47
51
|
import { log } from '../utils/log';
|
|
48
52
|
import { DocumentCapture, type CaptureGuide } from '../camera/DocumentCapture';
|
|
49
|
-
import {
|
|
53
|
+
import {
|
|
54
|
+
computeGuideCropRect,
|
|
55
|
+
isGuideSpaceConsistent,
|
|
56
|
+
} from '../utils/documentCrop';
|
|
50
57
|
import type { ApiCaller } from '../transport/api';
|
|
51
58
|
import type { StepDeps, StepModule } from './types';
|
|
52
59
|
import { toSubmissionError } from './_shared';
|
|
@@ -274,11 +281,51 @@ function DocumentsOcrView({
|
|
|
274
281
|
setPhase(side === 'FRONT' ? 'captureFront' : 'captureBack');
|
|
275
282
|
return <View />;
|
|
276
283
|
}
|
|
284
|
+
// The actions live in the scaffold's footer so they always clear the
|
|
285
|
+
// Android navigation bar / iOS home indicator, and the title clears the
|
|
286
|
+
// status bar + ProgressBar (OSDKR-14).
|
|
277
287
|
return (
|
|
278
|
-
<
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
288
|
+
<ScreenScaffold
|
|
289
|
+
contentStyle={styles.reviewRoot}
|
|
290
|
+
header={
|
|
291
|
+
<Text style={[styles.reviewTitle, { color: theme.textColor }]}>
|
|
292
|
+
{side === 'FRONT'
|
|
293
|
+
? t.documents_ocr.frontTitle
|
|
294
|
+
: t.documents_ocr.backTitle}
|
|
295
|
+
</Text>
|
|
296
|
+
}
|
|
297
|
+
footer={
|
|
298
|
+
<View style={styles.reviewActions}>
|
|
299
|
+
<Button
|
|
300
|
+
variant="ghost"
|
|
301
|
+
label={t.documents_ocr.retakeBtn}
|
|
302
|
+
onPress={() =>
|
|
303
|
+
setPhase(side === 'FRONT' ? 'captureFront' : 'captureBack')
|
|
304
|
+
}
|
|
305
|
+
fullWidth={false}
|
|
306
|
+
style={styles.reviewBtn}
|
|
307
|
+
/>
|
|
308
|
+
<Button
|
|
309
|
+
label={
|
|
310
|
+
side === 'FRONT'
|
|
311
|
+
? t.documents_ocr.confirmFront
|
|
312
|
+
: t.documents_ocr.confirmBack
|
|
313
|
+
}
|
|
314
|
+
onPress={() => {
|
|
315
|
+
if (side === 'FRONT') {
|
|
316
|
+
setPhase('captureBack');
|
|
317
|
+
} else {
|
|
318
|
+
void submit();
|
|
319
|
+
}
|
|
320
|
+
}}
|
|
321
|
+
loading={Boolean(busyLabel)}
|
|
322
|
+
disabled={Boolean(busyLabel)}
|
|
323
|
+
fullWidth={false}
|
|
324
|
+
style={styles.reviewBtn}
|
|
325
|
+
/>
|
|
326
|
+
</View>
|
|
327
|
+
}
|
|
328
|
+
>
|
|
282
329
|
<View
|
|
283
330
|
style={styles.previewWrap}
|
|
284
331
|
onLayout={(e) =>
|
|
@@ -314,37 +361,8 @@ function DocumentsOcrView({
|
|
|
314
361
|
) : null}
|
|
315
362
|
</View>
|
|
316
363
|
{bannerError ? <Banner message={bannerError} /> : null}
|
|
317
|
-
<View style={styles.reviewActions}>
|
|
318
|
-
<Button
|
|
319
|
-
variant="ghost"
|
|
320
|
-
label={t.documents_ocr.retakeBtn}
|
|
321
|
-
onPress={() =>
|
|
322
|
-
setPhase(side === 'FRONT' ? 'captureFront' : 'captureBack')
|
|
323
|
-
}
|
|
324
|
-
fullWidth={false}
|
|
325
|
-
style={styles.reviewBtn}
|
|
326
|
-
/>
|
|
327
|
-
<Button
|
|
328
|
-
label={
|
|
329
|
-
side === 'FRONT'
|
|
330
|
-
? t.documents_ocr.confirmFront
|
|
331
|
-
: t.documents_ocr.confirmBack
|
|
332
|
-
}
|
|
333
|
-
onPress={() => {
|
|
334
|
-
if (side === 'FRONT') {
|
|
335
|
-
setPhase('captureBack');
|
|
336
|
-
} else {
|
|
337
|
-
void submit();
|
|
338
|
-
}
|
|
339
|
-
}}
|
|
340
|
-
loading={Boolean(busyLabel)}
|
|
341
|
-
disabled={Boolean(busyLabel)}
|
|
342
|
-
fullWidth={false}
|
|
343
|
-
style={styles.reviewBtn}
|
|
344
|
-
/>
|
|
345
|
-
</View>
|
|
346
364
|
{busyLabel ? <LoadingOverlay message={busyLabel} /> : null}
|
|
347
|
-
</
|
|
365
|
+
</ScreenScaffold>
|
|
348
366
|
);
|
|
349
367
|
}
|
|
350
368
|
|
|
@@ -412,72 +430,93 @@ async function compressJpeg(
|
|
|
412
430
|
): Promise<CapturedSide> {
|
|
413
431
|
const source = normalizeFileUri(uri);
|
|
414
432
|
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
//
|
|
418
|
-
//
|
|
419
|
-
//
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
433
|
+
// Load the photo once and take its dimensions from the *loaded* image, so
|
|
434
|
+
// the crop rectangle and the pixels it addresses come from the same decode
|
|
435
|
+
// with the EXIF orientation already applied (iOS fixes the orientation on
|
|
436
|
+
// load, Glide does on Android). Reading the size through a different API
|
|
437
|
+
// than the one that crops left room for the two to disagree.
|
|
438
|
+
//
|
|
439
|
+
// We crop strictly to the on-screen guide rectangle the user centred the
|
|
440
|
+
// document in; we never inspect pixels and we never rotate based on how the
|
|
441
|
+
// phone was held — `DocumentCapture` pins `outputOrientation="preview"` so
|
|
442
|
+
// the capture always comes back in the orientation the user framed.
|
|
443
|
+
const loadContext = ImageManipulatorModule.manipulate(source);
|
|
444
|
+
const loaded = await loadContext.renderAsync();
|
|
445
|
+
const context = ImageManipulatorModule.manipulate(loaded);
|
|
446
|
+
|
|
447
|
+
try {
|
|
448
|
+
// Sanity check before trusting the screen→photo mapping (OSDKR-13). If the
|
|
449
|
+
// photo came back in a different orientation than the screen the guide was
|
|
450
|
+
// drawn on, the mapping is meaningless: upload the full photo (the backend
|
|
451
|
+
// OCR handles an uncropped ID) instead of an arbitrary region.
|
|
452
|
+
const canCrop = isGuideSpaceConsistent({
|
|
453
|
+
screenW: guide.screenW,
|
|
454
|
+
screenH: guide.screenH,
|
|
455
|
+
imageW: loaded.width,
|
|
456
|
+
imageH: loaded.height,
|
|
457
|
+
});
|
|
458
|
+
if (!canCrop) {
|
|
459
|
+
log.info(
|
|
460
|
+
'[DocumentsOCR] guide/photo orientation mismatch — skipping crop',
|
|
461
|
+
{
|
|
462
|
+
screenW: guide.screenW,
|
|
463
|
+
screenH: guide.screenH,
|
|
464
|
+
imageW: loaded.width,
|
|
465
|
+
imageH: loaded.height,
|
|
466
|
+
},
|
|
467
|
+
);
|
|
468
|
+
}
|
|
429
469
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
470
|
+
// Crop to the guide, then resize the long edge to MAX_LONG_EDGE (never
|
|
471
|
+
// upscale — the crop can leave a small region) and recompress to ~78%.
|
|
472
|
+
let outW = loaded.width;
|
|
473
|
+
let outH = loaded.height;
|
|
474
|
+
if (canCrop) {
|
|
475
|
+
const crop = computeGuideCropRect({
|
|
476
|
+
screenW: guide.screenW,
|
|
477
|
+
screenH: guide.screenH,
|
|
478
|
+
imageW: loaded.width,
|
|
479
|
+
imageH: loaded.height,
|
|
480
|
+
cutout: guide.cutout,
|
|
481
|
+
});
|
|
482
|
+
context.crop({
|
|
435
483
|
originX: crop.x,
|
|
436
484
|
originY: crop.y,
|
|
437
485
|
width: crop.width,
|
|
438
486
|
height: crop.height,
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
if (longEdge > MAX_LONG_EDGE) {
|
|
444
|
-
actions.push({
|
|
445
|
-
resize:
|
|
446
|
-
crop.width >= crop.height
|
|
447
|
-
? { width: MAX_LONG_EDGE }
|
|
448
|
-
: { height: MAX_LONG_EDGE },
|
|
449
|
-
});
|
|
450
|
-
}
|
|
487
|
+
});
|
|
488
|
+
outW = crop.width;
|
|
489
|
+
outH = crop.height;
|
|
490
|
+
}
|
|
451
491
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
uri: result.uri,
|
|
459
|
-
width: result.width,
|
|
460
|
-
height: result.height,
|
|
461
|
-
byteLength,
|
|
462
|
-
};
|
|
463
|
-
}
|
|
492
|
+
const longEdge = Math.max(outW, outH);
|
|
493
|
+
if (longEdge > MAX_LONG_EDGE) {
|
|
494
|
+
context.resize(
|
|
495
|
+
outW >= outH ? { width: MAX_LONG_EDGE } : { height: MAX_LONG_EDGE },
|
|
496
|
+
);
|
|
497
|
+
}
|
|
464
498
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
499
|
+
const rendered = await context.renderAsync();
|
|
500
|
+
try {
|
|
501
|
+
const result = await rendered.saveAsync({
|
|
502
|
+
compress: COMPRESS_QUALITY,
|
|
503
|
+
format: SaveFormat.JPEG,
|
|
504
|
+
});
|
|
505
|
+
const byteLength = await fetchByteLength(result.uri);
|
|
506
|
+
return {
|
|
507
|
+
uri: result.uri,
|
|
508
|
+
width: result.width,
|
|
509
|
+
height: result.height,
|
|
510
|
+
byteLength,
|
|
511
|
+
};
|
|
512
|
+
} finally {
|
|
513
|
+
rendered.release();
|
|
514
|
+
}
|
|
515
|
+
} finally {
|
|
516
|
+
context.release();
|
|
517
|
+
loaded.release();
|
|
518
|
+
loadContext.release();
|
|
519
|
+
}
|
|
481
520
|
}
|
|
482
521
|
|
|
483
522
|
async function uploadJpeg(uri: string, signedUrl: string): Promise<void> {
|
|
@@ -563,9 +602,11 @@ const styles = StyleSheet.create({
|
|
|
563
602
|
fontSize: 14,
|
|
564
603
|
lineHeight: 20,
|
|
565
604
|
},
|
|
605
|
+
// Vertical rhythm only — the scaffold owns the safe-area padding, and its
|
|
606
|
+
// gutter aligns the title and the action row with this column.
|
|
566
607
|
reviewRoot: {
|
|
567
|
-
|
|
568
|
-
|
|
608
|
+
paddingHorizontal: 18,
|
|
609
|
+
paddingTop: 14,
|
|
569
610
|
gap: 14,
|
|
570
611
|
},
|
|
571
612
|
reviewTitle: {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { useCallback, useMemo, useState } from 'react';
|
|
21
|
-
import {
|
|
21
|
+
import { Keyboard, StyleSheet, Text, View } from 'react-native';
|
|
22
22
|
import {
|
|
23
23
|
SdkErrorCode,
|
|
24
24
|
type EconomicActivitySelectionPayload,
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
} from '../ui/primitives/SearchableSingleSelectList';
|
|
35
35
|
import { LoadingOverlay } from '../ui/overlays/LoadingOverlay';
|
|
36
36
|
import { RetryDialog } from '../ui/overlays/RetryDialog';
|
|
37
|
+
import { ScreenScaffold } from '../ui/ScreenScaffold';
|
|
37
38
|
import { useTheme } from '../ui/theme';
|
|
38
39
|
import { getStrings } from '../i18n';
|
|
39
40
|
import type { ApiCaller } from '../transport/api';
|
|
@@ -123,6 +124,14 @@ function EconomicActivityView({
|
|
|
123
124
|
const [submitting, setSubmitting] = useState(false);
|
|
124
125
|
const [retry, setRetry] = useState<{ message: string } | null>(null);
|
|
125
126
|
|
|
127
|
+
// Picking an activity ends the search, so drop the keyboard with it: the
|
|
128
|
+
// list collapses to the selection and "Continue" — the only thing left to do
|
|
129
|
+
// — comes back into reach without an extra tap to dismiss (OSDKR-14).
|
|
130
|
+
const handleSelect = useCallback((code: string) => {
|
|
131
|
+
setSelected(code);
|
|
132
|
+
Keyboard.dismiss();
|
|
133
|
+
}, []);
|
|
134
|
+
|
|
126
135
|
const handleSubmit = useCallback(async () => {
|
|
127
136
|
if (!selected) return;
|
|
128
137
|
setBannerError(null);
|
|
@@ -156,56 +165,60 @@ function EconomicActivityView({
|
|
|
156
165
|
);
|
|
157
166
|
}
|
|
158
167
|
|
|
168
|
+
// `ScreenScaffold` owns the safe-area chrome: the back control clears the
|
|
169
|
+
// status bar and the ProgressBar, and the "Continue" footer clears the
|
|
170
|
+
// Android navigation bar / iOS home indicator — and rides above the keyboard
|
|
171
|
+
// while the search field has focus (OSDKR-14).
|
|
159
172
|
return (
|
|
160
|
-
<
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
) : null}
|
|
168
|
-
<View style={styles.header}>
|
|
169
|
-
<Text style={[styles.title, { color: theme.textColor }]}>
|
|
170
|
-
{t.economic_activity.title}
|
|
171
|
-
</Text>
|
|
172
|
-
<Text style={[styles.subtitle, { color: theme.textSecondaryColor }]}>
|
|
173
|
-
{t.economic_activity.subtitle}
|
|
174
|
-
</Text>
|
|
175
|
-
</View>
|
|
176
|
-
<SearchableSingleSelectList
|
|
177
|
-
items={options}
|
|
178
|
-
value={selected}
|
|
179
|
-
onChange={setSelected}
|
|
180
|
-
searchPlaceholder={t.economic_activity.searchPlaceholder}
|
|
181
|
-
emptyText={t.economic_activity.empty}
|
|
182
|
-
disabled={submitting}
|
|
183
|
-
style={styles.list}
|
|
184
|
-
/>
|
|
185
|
-
{bannerError ? <Banner message={bannerError} /> : null}
|
|
186
|
-
<View style={styles.footer}>
|
|
187
|
-
<Button
|
|
188
|
-
label={t.common.continue}
|
|
189
|
-
onPress={handleSubmit}
|
|
190
|
-
loading={submitting}
|
|
191
|
-
disabled={submitting || !selected}
|
|
173
|
+
<ScreenScaffold
|
|
174
|
+
header={
|
|
175
|
+
onBack ? (
|
|
176
|
+
<BackButton
|
|
177
|
+
label={t.common.back}
|
|
178
|
+
onPress={onBack}
|
|
179
|
+
disabled={submitting}
|
|
192
180
|
/>
|
|
193
|
-
|
|
181
|
+
) : undefined
|
|
182
|
+
}
|
|
183
|
+
contentStyle={styles.content}
|
|
184
|
+
footer={
|
|
185
|
+
<Button
|
|
186
|
+
label={t.common.continue}
|
|
187
|
+
onPress={handleSubmit}
|
|
188
|
+
loading={submitting}
|
|
189
|
+
disabled={submitting || !selected}
|
|
190
|
+
/>
|
|
191
|
+
}
|
|
192
|
+
>
|
|
193
|
+
<View style={styles.header}>
|
|
194
|
+
<Text style={[styles.title, { color: theme.textColor }]}>
|
|
195
|
+
{t.economic_activity.title}
|
|
196
|
+
</Text>
|
|
197
|
+
<Text style={[styles.subtitle, { color: theme.textSecondaryColor }]}>
|
|
198
|
+
{t.economic_activity.subtitle}
|
|
199
|
+
</Text>
|
|
194
200
|
</View>
|
|
201
|
+
<SearchableSingleSelectList
|
|
202
|
+
items={options}
|
|
203
|
+
value={selected}
|
|
204
|
+
onChange={handleSelect}
|
|
205
|
+
searchPlaceholder={t.economic_activity.searchPlaceholder}
|
|
206
|
+
emptyText={t.economic_activity.empty}
|
|
207
|
+
disabled={submitting}
|
|
208
|
+
style={styles.list}
|
|
209
|
+
/>
|
|
210
|
+
{bannerError ? <Banner message={bannerError} /> : null}
|
|
195
211
|
{submitting ? <LoadingOverlay message={t.common.submitting} /> : null}
|
|
196
|
-
</
|
|
212
|
+
</ScreenScaffold>
|
|
197
213
|
);
|
|
198
214
|
}
|
|
199
215
|
|
|
200
216
|
const styles = StyleSheet.create({
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
body: {
|
|
205
|
-
flex: 1,
|
|
217
|
+
// Vertical padding only: the scaffold owns the safe-area chrome, and the
|
|
218
|
+
// horizontal gutter matches its header/footer so the three read as one column.
|
|
219
|
+
content: {
|
|
206
220
|
paddingHorizontal: 18,
|
|
207
221
|
paddingTop: 12,
|
|
208
|
-
paddingBottom: 16,
|
|
209
222
|
},
|
|
210
223
|
header: {
|
|
211
224
|
marginBottom: 12,
|
|
@@ -224,7 +237,4 @@ const styles = StyleSheet.create({
|
|
|
224
237
|
list: {
|
|
225
238
|
flex: 1,
|
|
226
239
|
},
|
|
227
|
-
footer: {
|
|
228
|
-
marginTop: 12,
|
|
229
|
-
},
|
|
230
240
|
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview The one place that owns safe-area chrome for a full-screen
|
|
3
|
+
* surface (OSDKR-14).
|
|
4
|
+
*
|
|
5
|
+
* Every screen in the flow is edge-to-edge: the content fills the window and
|
|
6
|
+
* the system bars are drawn over it. Getting that right means padding the
|
|
7
|
+
* chrome — never the content — by the device insets, and screens that rolled
|
|
8
|
+
* their own layout kept forgetting to (CTAs ended up under the Android
|
|
9
|
+
* navigation bar, "back" controls under the status bar and the ProgressBar).
|
|
10
|
+
*
|
|
11
|
+
* `ScreenScaffold` makes that structural instead of a thing to remember:
|
|
12
|
+
*
|
|
13
|
+
* ┌──────────────────────────┐
|
|
14
|
+
* │ header (padded by topChrome: status bar + ProgressBar)
|
|
15
|
+
* ├──────────────────────────┤
|
|
16
|
+
* │ children (flex, untouched — cameras/maps stay full-bleed)
|
|
17
|
+
* ├──────────────────────────┤
|
|
18
|
+
* │ footer (padded by the bottom inset, lifted over the keyboard)
|
|
19
|
+
* └──────────────────────────┘
|
|
20
|
+
*
|
|
21
|
+
* `StepShell` is the scrollable variant built on top of this — form steps go
|
|
22
|
+
* through it. Screens with a pinned CTA (a list plus "Continuar", a capture
|
|
23
|
+
* preview plus its actions) use the scaffold directly with a `footer`.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import type { ReactNode } from 'react';
|
|
27
|
+
import { StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
28
|
+
import { useTheme } from './theme';
|
|
29
|
+
import { PROGRESS_BAR_HEIGHT } from './overlays/ProgressBar';
|
|
30
|
+
import { useKeyboardHeight } from './keyboard';
|
|
31
|
+
import {
|
|
32
|
+
bottomChromeInset,
|
|
33
|
+
computeScreenInsets,
|
|
34
|
+
type ScreenInsets,
|
|
35
|
+
} from './screenInsets';
|
|
36
|
+
import { useSafeAreaInsets } from '../utils/useSafeAreaInsets';
|
|
37
|
+
|
|
38
|
+
/** Horizontal gutter shared by the header, footer and (by default) content. */
|
|
39
|
+
export const SCREEN_GUTTER = 18;
|
|
40
|
+
/** Gap between the content and a pinned footer. */
|
|
41
|
+
const FOOTER_TOP_GAP = 12;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Chrome insets for the current screen. Prefer `<ScreenScaffold>`; reach for
|
|
45
|
+
* the hook directly only when a screen positions chrome absolutely over a
|
|
46
|
+
* full-bleed surface (the camera overlays do).
|
|
47
|
+
*/
|
|
48
|
+
export function useScreenInsets(): ScreenInsets {
|
|
49
|
+
const raw = useSafeAreaInsets();
|
|
50
|
+
return computeScreenInsets(raw, PROGRESS_BAR_HEIGHT);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ScreenScaffoldProps {
|
|
54
|
+
children: ReactNode;
|
|
55
|
+
/**
|
|
56
|
+
* Chrome pinned to the top, below the ProgressBar — typically a back
|
|
57
|
+
* control. Padded so it can never overlap the status bar or the bar itself.
|
|
58
|
+
*/
|
|
59
|
+
header?: ReactNode | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Chrome pinned to the bottom — typically the step's CTA row. Padded clear
|
|
62
|
+
* of the navigation bar / home indicator, and lifted above the keyboard
|
|
63
|
+
* while it is open.
|
|
64
|
+
*/
|
|
65
|
+
footer?: ReactNode | undefined;
|
|
66
|
+
/** Horizontal padding for header, footer and content. Defaults to 18. */
|
|
67
|
+
gutter?: number | undefined;
|
|
68
|
+
/** Extra style for the content area (between header and footer). */
|
|
69
|
+
contentStyle?: StyleProp<ViewStyle> | undefined;
|
|
70
|
+
/** Paint the theme background behind the screen. Defaults to `true`. */
|
|
71
|
+
opaque?: boolean | undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function ScreenScaffold({
|
|
75
|
+
children,
|
|
76
|
+
header,
|
|
77
|
+
footer,
|
|
78
|
+
gutter = SCREEN_GUTTER,
|
|
79
|
+
contentStyle,
|
|
80
|
+
opaque = true,
|
|
81
|
+
}: ScreenScaffoldProps) {
|
|
82
|
+
const theme = useTheme();
|
|
83
|
+
const insets = useScreenInsets();
|
|
84
|
+
const keyboardHeight = useKeyboardHeight();
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<View
|
|
88
|
+
style={[
|
|
89
|
+
styles.root,
|
|
90
|
+
opaque ? { backgroundColor: theme.backgroundColor } : null,
|
|
91
|
+
]}
|
|
92
|
+
>
|
|
93
|
+
{header ? (
|
|
94
|
+
<View
|
|
95
|
+
style={{ paddingTop: insets.topChrome, paddingHorizontal: gutter }}
|
|
96
|
+
>
|
|
97
|
+
{header}
|
|
98
|
+
</View>
|
|
99
|
+
) : null}
|
|
100
|
+
|
|
101
|
+
<View style={[styles.content, contentStyle]}>{children}</View>
|
|
102
|
+
|
|
103
|
+
{footer ? (
|
|
104
|
+
<View
|
|
105
|
+
style={[
|
|
106
|
+
styles.footer,
|
|
107
|
+
{
|
|
108
|
+
paddingHorizontal: gutter,
|
|
109
|
+
paddingBottom: bottomChromeInset(insets, keyboardHeight),
|
|
110
|
+
},
|
|
111
|
+
]}
|
|
112
|
+
>
|
|
113
|
+
{footer}
|
|
114
|
+
</View>
|
|
115
|
+
) : null}
|
|
116
|
+
</View>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const styles = StyleSheet.create({
|
|
121
|
+
root: {
|
|
122
|
+
flex: 1,
|
|
123
|
+
},
|
|
124
|
+
content: {
|
|
125
|
+
flex: 1,
|
|
126
|
+
},
|
|
127
|
+
footer: {
|
|
128
|
+
paddingTop: FOOTER_TOP_GAP,
|
|
129
|
+
},
|
|
130
|
+
});
|