@myazahq/kyc-sdk-react-native 2.3.0 → 2.4.0
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/package.json +1 -2
- package/src/components/BrandBar.tsx +137 -0
- package/src/components/DialCodePicker.tsx +11 -17
- package/src/components/DocumentReviewSide.tsx +34 -14
- package/src/components/Icon.tsx +5 -0
- package/src/components/KycSheet.tsx +39 -140
- package/src/components/MediaSourceSheet.tsx +7 -37
- package/src/components/MyazaDateField.tsx +6 -20
- package/src/components/MyazaSelect.tsx +15 -39
- package/src/components/SandboxBanner.tsx +92 -0
- package/src/components/StepHeader.tsx +15 -2
- package/src/components/glass/ChromeGlass.tsx +65 -0
- package/src/components/glass/FloatingSheet.tsx +190 -0
- package/src/components/glass/GlassSheet.tsx +38 -0
- package/src/components/glass/GlassSurface.tsx +31 -3
- package/src/components/viewfinder/ImmersiveBottomBar.tsx +28 -17
- package/src/components/viewfinder/ImmersiveControls.tsx +26 -14
- package/src/components/viewfinder/ViewfinderControls.tsx +29 -7
- package/src/services/deviceMetadata.ts +1 -1
- package/src/types/config.ts +7 -2
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Pressable, ScrollView, TextInput, useWindowDimensions, View } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { radius, spacing } from '../config/theme';
|
|
5
5
|
import { useTheme } from './runtime';
|
|
6
6
|
import { useInputFontFamily } from './fonts';
|
|
7
7
|
import { MyazaText } from './Typography';
|
|
8
8
|
import { Icon } from './Icon';
|
|
9
|
+
import { FloatingSheet } from './glass/FloatingSheet';
|
|
9
10
|
|
|
10
11
|
// ---------------------------------------------------------------------------
|
|
11
12
|
// The select field — a collapsed value that opens a sheet of options.
|
|
@@ -131,45 +132,16 @@ export function MyazaSelect<T extends string | number>({
|
|
|
131
132
|
<Icon name="chevron-down" size={18} color={colors.textSecondary} />
|
|
132
133
|
</Pressable>
|
|
133
134
|
|
|
134
|
-
<
|
|
135
|
+
<FloatingSheet
|
|
135
136
|
visible={open}
|
|
136
|
-
|
|
137
|
-
animationType="slide"
|
|
138
|
-
onRequestClose={() => {
|
|
137
|
+
onClose={() => {
|
|
139
138
|
setOpen(false);
|
|
140
139
|
setQuery('');
|
|
141
140
|
}}
|
|
141
|
+
// Long option lists stay inside the sheet and scroll.
|
|
142
|
+
maxHeight={windowHeight * 0.6}
|
|
143
|
+
closeLabel={`Close ${sheetTitle ?? hint}`}
|
|
142
144
|
>
|
|
143
|
-
{/* Tapping the backdrop dismisses, matching the platform sheet. */}
|
|
144
|
-
<Pressable
|
|
145
|
-
onPress={() => {
|
|
146
|
-
setOpen(false);
|
|
147
|
-
setQuery('');
|
|
148
|
-
}}
|
|
149
|
-
style={{ flex: 1, backgroundColor: 'rgba(0,0,0,0.45)', justifyContent: 'flex-end' }}
|
|
150
|
-
>
|
|
151
|
-
{/* Stops a tap inside the sheet from closing it. */}
|
|
152
|
-
<Pressable
|
|
153
|
-
onPress={() => {}}
|
|
154
|
-
style={{
|
|
155
|
-
backgroundColor: colors.background,
|
|
156
|
-
borderTopLeftRadius: radius.lg,
|
|
157
|
-
borderTopRightRadius: radius.lg,
|
|
158
|
-
paddingBottom: spacing.lg,
|
|
159
|
-
// Long option lists stay inside the sheet and scroll.
|
|
160
|
-
maxHeight: windowHeight * 0.6,
|
|
161
|
-
}}
|
|
162
|
-
>
|
|
163
|
-
<View
|
|
164
|
-
style={{
|
|
165
|
-
alignSelf: 'center',
|
|
166
|
-
width: 36,
|
|
167
|
-
height: 4,
|
|
168
|
-
borderRadius: radius.full,
|
|
169
|
-
backgroundColor: colors.border,
|
|
170
|
-
marginTop: spacing.sm,
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
145
|
<MyazaText
|
|
174
146
|
variant="body"
|
|
175
147
|
style={{
|
|
@@ -222,7 +194,13 @@ export function MyazaSelect<T extends string | number>({
|
|
|
222
194
|
</View>
|
|
223
195
|
) : null}
|
|
224
196
|
|
|
225
|
-
<ScrollView
|
|
197
|
+
<ScrollView
|
|
198
|
+
bounces={false}
|
|
199
|
+
keyboardShouldPersistTaps="handled"
|
|
200
|
+
// The floating shell has no bottom padding of its own, so the
|
|
201
|
+
// last option must not sit flush against the rounded corner.
|
|
202
|
+
contentContainerStyle={{ paddingBottom: spacing.lg }}
|
|
203
|
+
>
|
|
226
204
|
{visible.length === 0 ? (
|
|
227
205
|
<MyazaText
|
|
228
206
|
variant="bodySmall"
|
|
@@ -280,9 +258,7 @@ export function MyazaSelect<T extends string | number>({
|
|
|
280
258
|
);
|
|
281
259
|
})}
|
|
282
260
|
</ScrollView>
|
|
283
|
-
|
|
284
|
-
</Pressable>
|
|
285
|
-
</Modal>
|
|
261
|
+
</FloatingSheet>
|
|
286
262
|
</>
|
|
287
263
|
);
|
|
288
264
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { spacing } from '../config/theme';
|
|
5
|
+
import type { KycState } from '../store/state';
|
|
6
|
+
import { useKyc } from './runtime';
|
|
7
|
+
import { Icon } from './Icon';
|
|
8
|
+
import { MyazaText } from './Typography';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* "You are not in production" strip, shown above the sheet's header.
|
|
12
|
+
*
|
|
13
|
+
* A sandbox flow is pixel-identical to a live one, which is the point — you are
|
|
14
|
+
* testing the real thing — and also the hazard: screenshots get mistaken for
|
|
15
|
+
* production incidents, testers wonder why a real passport was rejected, and a
|
|
16
|
+
* `pk_test_` key shipped to production looks like it works right up until
|
|
17
|
+
* nobody is actually verified.
|
|
18
|
+
*
|
|
19
|
+
* Environment comes from the SERVER (`/config`), not the API key prefix. Hosted
|
|
20
|
+
* sessions authenticate with an `hs_` handoff token that carries no environment
|
|
21
|
+
* slot, so key-sniffing would leave exactly the surface an end user sees
|
|
22
|
+
* unlabelled.
|
|
23
|
+
*
|
|
24
|
+
* DEVELOPMENT is labelled too, and differently: it runs the real pipeline
|
|
25
|
+
* against staging provider credentials, so "test data only" would be a lie
|
|
26
|
+
* there. 1:1 with the web and Flutter SDKs.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Whether the banner will render. The sheet needs this to decide who owns the
|
|
30
|
+
* safe-area top inset: the banner sits ABOVE the header, so when it shows it is
|
|
31
|
+
* the topmost element and must clear the status bar itself — otherwise the
|
|
32
|
+
* header pads for an inset the banner already crossed, and the strip is drawn
|
|
33
|
+
* under the clock on Android's edge-to-edge modals.
|
|
34
|
+
*/
|
|
35
|
+
export function useSandboxBannerVisible(): boolean {
|
|
36
|
+
const environment = useKyc((s: KycState) => s.serverConfig.environment);
|
|
37
|
+
return environment === 'SANDBOX' || environment === 'DEVELOPMENT';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function SandboxBanner({
|
|
41
|
+
topInset = 0,
|
|
42
|
+
}: {
|
|
43
|
+
/** Safe-area top inset to absorb, when the banner is the topmost element. */
|
|
44
|
+
topInset?: number;
|
|
45
|
+
}): React.ReactElement | null {
|
|
46
|
+
const environment = useKyc((s: KycState) => s.serverConfig.environment);
|
|
47
|
+
if (environment !== 'SANDBOX' && environment !== 'DEVELOPMENT') return null;
|
|
48
|
+
|
|
49
|
+
const sandbox = environment === 'SANDBOX';
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<View
|
|
53
|
+
accessibilityRole="alert"
|
|
54
|
+
style={{
|
|
55
|
+
flexDirection: 'row',
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
gap: spacing.xs + 2,
|
|
59
|
+
// Amber, not the brand colour: this is an out-of-band status about the
|
|
60
|
+
// session, and the org's palette would read as part of their flow.
|
|
61
|
+
backgroundColor: AMBER_TINT,
|
|
62
|
+
paddingHorizontal: spacing.md,
|
|
63
|
+
// The tint extends up through the status bar so the strip reads as one
|
|
64
|
+
// band rather than floating below a bare gap.
|
|
65
|
+
paddingTop: topInset + spacing.xs + 2,
|
|
66
|
+
paddingBottom: spacing.xs + 2,
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{/* Flask, not an alert mark: nothing is wrong — this is a statement about
|
|
70
|
+
WHICH environment you are in ("test environment", "test data only").
|
|
71
|
+
An alert glyph reads as a fault and sends testers hunting for one.
|
|
72
|
+
Same lucide icon the web SDK uses; Flutter mirrors it with
|
|
73
|
+
Icons.science_outlined. */}
|
|
74
|
+
<Icon name="flask" size={13} color={AMBER_INK} />
|
|
75
|
+
<MyazaText
|
|
76
|
+
variant="bodySmall"
|
|
77
|
+
color={AMBER_INK}
|
|
78
|
+
style={{ fontSize: 11, fontWeight: '700', letterSpacing: 1, textTransform: 'uppercase' }}
|
|
79
|
+
>
|
|
80
|
+
{sandbox ? 'Sandbox' : 'Development'}
|
|
81
|
+
</MyazaText>
|
|
82
|
+
<MyazaText variant="bodySmall" color={AMBER_INK} style={{ fontSize: 11, flexShrink: 1 }}>
|
|
83
|
+
{sandbox ? 'Test data only, no real checks run' : 'Test environment, results are not live'}
|
|
84
|
+
</MyazaText>
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Fixed rather than themed: the strip must read identically in light and dark,
|
|
90
|
+
// and it deliberately does not belong to the org's palette.
|
|
91
|
+
const AMBER_TINT = 'rgba(245, 158, 11, 0.18)';
|
|
92
|
+
const AMBER_INK = '#B45309';
|
|
@@ -12,7 +12,10 @@ import { CountryFlag } from './CountryFlag';
|
|
|
12
12
|
// title (heading2) + optional country flag, then an optional description below
|
|
13
13
|
// (indented to align under the title when a back button is present).
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// Back button width + gap. Kept in step with BACK_SIZE below: it indents the
|
|
16
|
+
// description so it starts under the title rather than under the button.
|
|
17
|
+
const BACK_SIZE = 40;
|
|
18
|
+
const BACK_FOOTPRINT = BACK_SIZE + spacing.sm;
|
|
16
19
|
|
|
17
20
|
export interface StepHeaderProps {
|
|
18
21
|
title: string;
|
|
@@ -28,7 +31,17 @@ export function StepHeader({ title, description, onBack, country }: StepHeaderPr
|
|
|
28
31
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
29
32
|
{onBack ? (
|
|
30
33
|
<View style={{ marginRight: spacing.sm }}>
|
|
31
|
-
|
|
34
|
+
{/* Same 40pt footprint as the theme/close chrome above it — a
|
|
35
|
+
smaller glass circle here read as a different class of control,
|
|
36
|
+
and 28pt was under the 44pt minimum touch target even with
|
|
37
|
+
hitSlop. */}
|
|
38
|
+
<GlassIconButton
|
|
39
|
+
icon="back"
|
|
40
|
+
onPress={onBack}
|
|
41
|
+
size={BACK_SIZE}
|
|
42
|
+
iconSize={22}
|
|
43
|
+
accessibilityLabel="Back"
|
|
44
|
+
/>
|
|
32
45
|
</View>
|
|
33
46
|
) : null}
|
|
34
47
|
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center' }}>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { GlassSurface } from './GlassSurface';
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// ChromeGlass — the surface behind controls that float over the LIVE CAMERA.
|
|
8
|
+
//
|
|
9
|
+
// This is the strongest case for Liquid Glass in the SDK: the chrome floats
|
|
10
|
+
// above content, it is interactive, and the background is a moving scene rather
|
|
11
|
+
// than a flat tint, which is exactly the condition the material was designed
|
|
12
|
+
// for (it is what the iOS Camera app does).
|
|
13
|
+
//
|
|
14
|
+
// Two properties are load-bearing, and both exist to protect the white glyphs:
|
|
15
|
+
//
|
|
16
|
+
// • `colorScheme: 'dark'` — forced, NOT the app theme. These icons are white
|
|
17
|
+
// against a camera feed, not against the app's background, so a light app
|
|
18
|
+
// theme would put pale glass under white icons.
|
|
19
|
+
//
|
|
20
|
+
// • `tintColor` — a dark bias over the glass. Plain glass is translucent, so
|
|
21
|
+
// a white passport page filling the frame would wash a white glyph out.
|
|
22
|
+
// The flat scrim this replaces guaranteed contrast; the tint is what buys
|
|
23
|
+
// that guarantee back while keeping the material's depth and adaptivity.
|
|
24
|
+
//
|
|
25
|
+
// Off iOS 26 it renders the ORIGINAL flat scrim, so Android and older iOS are
|
|
26
|
+
// pixel-identical to before. Glass stays purely additive.
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
|
|
29
|
+
/** The flat scrim used before glass, and still the fallback everywhere else. */
|
|
30
|
+
export const CHROME_SCRIM = 'rgba(0,0,0,0.55)';
|
|
31
|
+
|
|
32
|
+
/** Dark bias laid over the glass so white glyphs survive a bright scene. */
|
|
33
|
+
const CHROME_TINT = 'rgba(0,0,0,0.28)';
|
|
34
|
+
|
|
35
|
+
export interface ChromeGlassProps {
|
|
36
|
+
children?: React.ReactNode;
|
|
37
|
+
style?: StyleProp<ViewStyle>;
|
|
38
|
+
/** Whether the glass reacts to touch. True for buttons, false for pills. */
|
|
39
|
+
interactive?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Overrides the scrim on the fallback path. Pass the value the call site used
|
|
42
|
+
* before, so non-glass devices keep their exact previous appearance.
|
|
43
|
+
*/
|
|
44
|
+
scrim?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function ChromeGlass({
|
|
48
|
+
children,
|
|
49
|
+
style,
|
|
50
|
+
interactive = false,
|
|
51
|
+
scrim = CHROME_SCRIM,
|
|
52
|
+
}: ChromeGlassProps): React.ReactElement {
|
|
53
|
+
return (
|
|
54
|
+
<GlassSurface
|
|
55
|
+
glassStyle="regular"
|
|
56
|
+
colorScheme="dark"
|
|
57
|
+
tintColor={CHROME_TINT}
|
|
58
|
+
interactive={interactive}
|
|
59
|
+
fallbackColor={scrim}
|
|
60
|
+
style={style}
|
|
61
|
+
>
|
|
62
|
+
{children}
|
|
63
|
+
</GlassSurface>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Animated,
|
|
4
|
+
Easing,
|
|
5
|
+
Modal,
|
|
6
|
+
PanResponder,
|
|
7
|
+
Pressable,
|
|
8
|
+
View,
|
|
9
|
+
type ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import { initialWindowMetrics } from 'react-native-safe-area-context';
|
|
12
|
+
|
|
13
|
+
import { radius, spacing } from '../../config/theme';
|
|
14
|
+
import { useTheme } from '../runtime';
|
|
15
|
+
import { GlassIconButton } from '../GlassIconButton';
|
|
16
|
+
import { GlassSheet } from './GlassSheet';
|
|
17
|
+
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// FloatingSheet — the shell every bottom sheet in the SDK sits in.
|
|
20
|
+
//
|
|
21
|
+
// It floats: inset from all three edges and rounded on every corner, rather
|
|
22
|
+
// than welded to the bottom of the screen. That is what the glass is for. A
|
|
23
|
+
// panel flush to the edge reads as part of the screen, so seeing through it
|
|
24
|
+
// says nothing; a detached one reads as a layer that has risen above the flow.
|
|
25
|
+
//
|
|
26
|
+
// It offers three ways out, because a sheet that can only be dismissed one way
|
|
27
|
+
// is a trap for whichever user does not find that way:
|
|
28
|
+
// • swipe it down,
|
|
29
|
+
// • the close button,
|
|
30
|
+
// • tap the backdrop.
|
|
31
|
+
//
|
|
32
|
+
// Shared rather than copied into each sheet: swipe-to-dismiss is the kind of
|
|
33
|
+
// thing that rots when it exists in four places, and the sheets would drift
|
|
34
|
+
// apart on handle size, dismiss threshold and safe-area maths.
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
/** How far down a drag must travel before release dismisses instead of springing back. */
|
|
38
|
+
const DISMISS_DISTANCE = 90;
|
|
39
|
+
/** A flick dismisses at any distance — velocity is intent, distance is only evidence of it. */
|
|
40
|
+
const DISMISS_VELOCITY = 0.7;
|
|
41
|
+
|
|
42
|
+
export interface FloatingSheetProps {
|
|
43
|
+
visible: boolean;
|
|
44
|
+
onClose: () => void;
|
|
45
|
+
children?: React.ReactNode;
|
|
46
|
+
/** Extra bottom offset, e.g. a raised keyboard. */
|
|
47
|
+
bottomOffset?: number;
|
|
48
|
+
/** Caps the panel; the body owns its own scrolling. */
|
|
49
|
+
maxHeight?: number;
|
|
50
|
+
/** Accessible label for the close button. */
|
|
51
|
+
closeLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Fires once the modal has finished going away (iOS only, from `Modal`).
|
|
54
|
+
*
|
|
55
|
+
* Needed by callers that must wait for THIS sheet to be gone before opening
|
|
56
|
+
* another one — iOS refuses to present a second modal while the first is
|
|
57
|
+
* still on screen.
|
|
58
|
+
*/
|
|
59
|
+
onDismiss?: () => void;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function FloatingSheet({
|
|
63
|
+
visible,
|
|
64
|
+
onClose,
|
|
65
|
+
children,
|
|
66
|
+
bottomOffset = 0,
|
|
67
|
+
maxHeight,
|
|
68
|
+
closeLabel = 'Close',
|
|
69
|
+
onDismiss,
|
|
70
|
+
}: FloatingSheetProps): React.ReactElement {
|
|
71
|
+
const { colors } = useTheme();
|
|
72
|
+
const translateY = useRef(new Animated.Value(0)).current;
|
|
73
|
+
|
|
74
|
+
// The PanResponder is built once, so it would otherwise close over the FIRST
|
|
75
|
+
// onClose forever and stop dismissing after the parent re-renders.
|
|
76
|
+
const onCloseRef = useRef(onClose);
|
|
77
|
+
onCloseRef.current = onClose;
|
|
78
|
+
|
|
79
|
+
// A sheet reopened after being dragged away must not still be off-screen.
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (visible) translateY.setValue(0);
|
|
82
|
+
}, [visible, translateY]);
|
|
83
|
+
|
|
84
|
+
const pan = useRef(
|
|
85
|
+
PanResponder.create({
|
|
86
|
+
// Claim on touch START, not just on move.
|
|
87
|
+
//
|
|
88
|
+
// The panel is wrapped in a Pressable to swallow backdrop taps, and a
|
|
89
|
+
// Pressable takes the responder the instant a finger lands. Asking only
|
|
90
|
+
// on move meant that Pressable had already won and the drag never began.
|
|
91
|
+
// `onStartShouldSetResponder` bubbles from the deepest view up, and this
|
|
92
|
+
// header is deeper than that wrapper, so claiming here beats it — while
|
|
93
|
+
// the close button, deeper still, keeps winning its own taps.
|
|
94
|
+
onStartShouldSetPanResponder: () => true,
|
|
95
|
+
// Kept for the case where a touch begins as something else and turns
|
|
96
|
+
// into a drag. Downward only: stealing horizontal or upward gestures
|
|
97
|
+
// would make the scrollable bodies below feel broken.
|
|
98
|
+
onMoveShouldSetPanResponder: (_, g) => g.dy > 4 && Math.abs(g.dy) > Math.abs(g.dx),
|
|
99
|
+
// Once the drag owns the gesture, nothing may take it mid-pull.
|
|
100
|
+
onPanResponderTerminationRequest: () => false,
|
|
101
|
+
onPanResponderMove: (_, g) => {
|
|
102
|
+
// Downward only: dragging up must not detach the sheet from its corner.
|
|
103
|
+
if (g.dy > 0) translateY.setValue(g.dy);
|
|
104
|
+
},
|
|
105
|
+
onPanResponderRelease: (_, g) => {
|
|
106
|
+
if (g.dy > DISMISS_DISTANCE || g.vy > DISMISS_VELOCITY) {
|
|
107
|
+
Animated.timing(translateY, {
|
|
108
|
+
toValue: 700,
|
|
109
|
+
duration: 180,
|
|
110
|
+
easing: Easing.in(Easing.cubic),
|
|
111
|
+
useNativeDriver: true,
|
|
112
|
+
}).start(() => onCloseRef.current());
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
Animated.spring(translateY, {
|
|
116
|
+
toValue: 0,
|
|
117
|
+
useNativeDriver: true,
|
|
118
|
+
bounciness: 0,
|
|
119
|
+
}).start();
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
).current;
|
|
123
|
+
|
|
124
|
+
// Read once at module init like the rest of the SDK: these sheets are modal,
|
|
125
|
+
// so there is no provider above them to read live insets from.
|
|
126
|
+
const safeBottom = initialWindowMetrics?.insets?.bottom ?? 0;
|
|
127
|
+
|
|
128
|
+
const panel: ViewStyle = {
|
|
129
|
+
marginHorizontal: spacing.md,
|
|
130
|
+
// Clear the home indicator, and never sit flush even where there is none.
|
|
131
|
+
marginBottom: bottomOffset + Math.max(safeBottom, spacing.md),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<Modal
|
|
136
|
+
visible={visible}
|
|
137
|
+
transparent
|
|
138
|
+
animationType="slide"
|
|
139
|
+
onRequestClose={onClose}
|
|
140
|
+
onDismiss={onDismiss}
|
|
141
|
+
>
|
|
142
|
+
<Pressable
|
|
143
|
+
onPress={onClose}
|
|
144
|
+
accessibilityLabel="Dismiss"
|
|
145
|
+
style={{ flex: 1, justifyContent: 'flex-end', backgroundColor: 'rgba(0,0,0,0.5)' }}
|
|
146
|
+
>
|
|
147
|
+
<Animated.View style={[panel, { transform: [{ translateY }] }]}>
|
|
148
|
+
{/* Swallows taps so only the backdrop dismisses. */}
|
|
149
|
+
<Pressable onPress={() => undefined}>
|
|
150
|
+
<GlassSheet style={{ borderRadius: radius.xl, maxHeight, overflow: 'hidden' }}>
|
|
151
|
+
{/* The drag lives on the header, NOT the whole panel: bodies here
|
|
152
|
+
scroll, and a panel-wide responder fights the list for every
|
|
153
|
+
downward swipe. */}
|
|
154
|
+
<View
|
|
155
|
+
{...pan.panHandlers}
|
|
156
|
+
style={{
|
|
157
|
+
flexDirection: 'row',
|
|
158
|
+
alignItems: 'center',
|
|
159
|
+
paddingTop: spacing.sm,
|
|
160
|
+
paddingHorizontal: spacing.sm,
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<View style={{ flex: 1 }} />
|
|
164
|
+
{/* Grab handle — says "draggable" without a caption. */}
|
|
165
|
+
<View
|
|
166
|
+
style={{
|
|
167
|
+
width: 36,
|
|
168
|
+
height: 4,
|
|
169
|
+
borderRadius: 2,
|
|
170
|
+
backgroundColor: colors.border,
|
|
171
|
+
}}
|
|
172
|
+
/>
|
|
173
|
+
<View style={{ flex: 1, alignItems: 'flex-end' }}>
|
|
174
|
+
<GlassIconButton
|
|
175
|
+
icon="close"
|
|
176
|
+
onPress={onClose}
|
|
177
|
+
size={32}
|
|
178
|
+
iconSize={18}
|
|
179
|
+
accessibilityLabel={closeLabel}
|
|
180
|
+
/>
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
{children}
|
|
184
|
+
</GlassSheet>
|
|
185
|
+
</Pressable>
|
|
186
|
+
</Animated.View>
|
|
187
|
+
</Pressable>
|
|
188
|
+
</Modal>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useTheme } from '../runtime';
|
|
5
|
+
import { GlassSurface } from './GlassSurface';
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// GlassSheet — the panel of a bottom sheet that floats above the flow.
|
|
9
|
+
//
|
|
10
|
+
// A sheet is a surface, not a control, which is the one case where glass is
|
|
11
|
+
// right for something non-interactive: it is a layer that has risen above the
|
|
12
|
+
// content, and letting that content show through is what says so.
|
|
13
|
+
//
|
|
14
|
+
// `glassStyle: 'regular'` rather than `'clear'` on purpose. These panels are
|
|
15
|
+
// full of list text that has to stay readable, and `regular` is the frosted
|
|
16
|
+
// variant; `clear` is for chrome over imagery, where there is little to read.
|
|
17
|
+
//
|
|
18
|
+
// The colour scheme follows the APP theme (unlike the camera chrome, which is
|
|
19
|
+
// pinned dark) because a sheet sits over the SDK's own background, so its text
|
|
20
|
+
// is themed text on a themed surface.
|
|
21
|
+
//
|
|
22
|
+
// Off iOS 26 it is the opaque themed panel it has always been.
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
export interface GlassSheetProps {
|
|
26
|
+
children?: React.ReactNode;
|
|
27
|
+
/** Panel geometry — corner radii and padding. */
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function GlassSheet({ children, style }: GlassSheetProps): React.ReactElement {
|
|
32
|
+
const { colors } = useTheme();
|
|
33
|
+
return (
|
|
34
|
+
<GlassSurface glassStyle="regular" fallbackColor={colors.background} style={style}>
|
|
35
|
+
{children}
|
|
36
|
+
</GlassSurface>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Platform, View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
GlassView,
|
|
5
|
+
isLiquidGlassAvailable,
|
|
6
|
+
type GlassColorScheme,
|
|
7
|
+
type GlassStyle,
|
|
8
|
+
} from 'expo-glass-effect';
|
|
4
9
|
|
|
5
10
|
import { useTheme } from '../runtime';
|
|
6
11
|
|
|
@@ -10,7 +15,21 @@ import { useTheme } from '../runtime';
|
|
|
10
15
|
// On iOS 26+ (where `isLiquidGlassAvailable()` is true) it renders a native
|
|
11
16
|
// `GlassView`; everywhere else (Android, iOS < 26) it falls back to a plain
|
|
12
17
|
// token-styled surface. Glass is purely additive — every screen looks correct
|
|
13
|
-
// without it.
|
|
18
|
+
// without it.
|
|
19
|
+
//
|
|
20
|
+
// Where it is used, and the rule behind that: glass is for things that FLOAT
|
|
21
|
+
// above content — surfaces (the sheet shell + header, bottom sheets via
|
|
22
|
+
// `GlassSheet`) and interactive chrome (the header icon buttons, the camera
|
|
23
|
+
// controls via `ChromeGlass`).
|
|
24
|
+
//
|
|
25
|
+
// Deliberately NOT used for:
|
|
26
|
+
// • the primary CTA — it needs a solid brand fill to read as the one clear
|
|
27
|
+
// action, and a translucent one competes with everything behind it;
|
|
28
|
+
// • labels and status pills (the brand bar, capture hints, the sandbox
|
|
29
|
+
// strip) — at capsule scale glass reads as a control, so wrapping static
|
|
30
|
+
// text in it promises a tap that does nothing;
|
|
31
|
+
// • any "on" state (torch lit, toggle active) — a material that samples
|
|
32
|
+
// what is behind it cannot state a binary unambiguously.
|
|
14
33
|
// ---------------------------------------------------------------------------
|
|
15
34
|
|
|
16
35
|
const liquidGlass = Platform.OS === 'ios' && isLiquidGlassAvailable();
|
|
@@ -34,6 +53,14 @@ export interface GlassSurfaceProps {
|
|
|
34
53
|
* theme's elevated surface (`backgroundSecondary`).
|
|
35
54
|
*/
|
|
36
55
|
fallbackColor?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Forces the glass to render light or dark, overriding the app theme.
|
|
58
|
+
*
|
|
59
|
+
* Chrome that floats over the CAMERA needs this: its glyphs are white against
|
|
60
|
+
* a live scene, not against the app's background, so following a light app
|
|
61
|
+
* theme would render pale glass under white icons.
|
|
62
|
+
*/
|
|
63
|
+
colorScheme?: GlassColorScheme;
|
|
37
64
|
}
|
|
38
65
|
|
|
39
66
|
export function GlassSurface({
|
|
@@ -43,6 +70,7 @@ export function GlassSurface({
|
|
|
43
70
|
tintColor,
|
|
44
71
|
interactive = false,
|
|
45
72
|
fallbackColor,
|
|
73
|
+
colorScheme,
|
|
46
74
|
}: GlassSurfaceProps): React.ReactElement {
|
|
47
75
|
const { colors, mode } = useTheme();
|
|
48
76
|
|
|
@@ -53,7 +81,7 @@ export function GlassSurface({
|
|
|
53
81
|
glassEffectStyle={glassStyle}
|
|
54
82
|
tintColor={tintColor}
|
|
55
83
|
isInteractive={interactive}
|
|
56
|
-
colorScheme={mode}
|
|
84
|
+
colorScheme={colorScheme ?? mode}
|
|
57
85
|
>
|
|
58
86
|
{children}
|
|
59
87
|
</GlassView>
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ActivityIndicator, Pressable, View } from 'react-native';
|
|
2
|
+
import { ActivityIndicator, Pressable, View, type ViewStyle } from 'react-native';
|
|
3
3
|
import Svg, { Circle } from 'react-native-svg';
|
|
4
4
|
|
|
5
5
|
import { radius, spacing } from '../../config/theme';
|
|
6
6
|
import { useTheme } from '../runtime';
|
|
7
7
|
import { MyazaText } from '../Typography';
|
|
8
8
|
import { Icon } from '../Icon';
|
|
9
|
+
import { CHROME_SCRIM, ChromeGlass } from '../glass/ChromeGlass';
|
|
9
10
|
|
|
10
|
-
const SCRIM =
|
|
11
|
+
const SCRIM = CHROME_SCRIM;
|
|
12
|
+
|
|
13
|
+
/** The torch's own scrim, kept as-is so non-glass devices look unchanged. */
|
|
14
|
+
const TORCH_SCRIM = 'rgba(0,0,0,0.45)';
|
|
15
|
+
|
|
16
|
+
/** Fills a sized Pressable with a round surface. */
|
|
17
|
+
const ROUND_FILL: ViewStyle = {
|
|
18
|
+
flex: 1,
|
|
19
|
+
borderRadius: radius.full,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
justifyContent: 'center',
|
|
22
|
+
};
|
|
11
23
|
|
|
12
24
|
/**
|
|
13
25
|
* Fixed slots either side of the shutter.
|
|
@@ -147,22 +159,21 @@ export function BottomBar({
|
|
|
147
159
|
onPress={onToggleTorch}
|
|
148
160
|
accessibilityRole="button"
|
|
149
161
|
accessibilityLabel={torch ? 'Turn off the torch' : 'Turn on the torch'}
|
|
150
|
-
style={{
|
|
151
|
-
width: 36,
|
|
152
|
-
height: 36,
|
|
153
|
-
borderRadius: radius.full,
|
|
154
|
-
// Inverted when on, so "lit" reads at a glance rather than
|
|
155
|
-
// needing the icon to be decoded.
|
|
156
|
-
backgroundColor: torch ? '#FFFFFF' : 'rgba(0,0,0,0.45)',
|
|
157
|
-
alignItems: 'center',
|
|
158
|
-
justifyContent: 'center',
|
|
159
|
-
}}
|
|
162
|
+
style={{ width: 36, height: 36 }}
|
|
160
163
|
>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
164
|
+
{torch ? (
|
|
165
|
+
// Inverted when on, so "lit" reads at a glance rather than
|
|
166
|
+
// needing the icon to be decoded. Solid rather than glass: a
|
|
167
|
+
// translucent surface samples the scene behind it, so "on"
|
|
168
|
+
// would look different depending on where the camera points.
|
|
169
|
+
<View style={[ROUND_FILL, { backgroundColor: '#FFFFFF' }]}>
|
|
170
|
+
<Icon name="zap" size={18} color={colors.primary} />
|
|
171
|
+
</View>
|
|
172
|
+
) : (
|
|
173
|
+
<ChromeGlass interactive scrim={TORCH_SCRIM} style={ROUND_FILL}>
|
|
174
|
+
<Icon name="zap-off" size={18} color="#FFFFFF" />
|
|
175
|
+
</ChromeGlass>
|
|
176
|
+
)}
|
|
166
177
|
</Pressable>
|
|
167
178
|
) : null}
|
|
168
179
|
</View>
|