@vvedantb/native-ui 0.21.1 → 0.23.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/dist/NativeBottomSheetContainer.jsx +303 -0
- package/dist/Stepper.jsx +142 -0
- package/dist/entries/native-bottom-sheet.js +4 -0
- package/dist/entries/primitives.js +1 -0
- package/dist/examples/ParityGallery.jsx +103 -66
- package/dist/index.js +1 -0
- package/package.json +10 -1
- package/src/NativeBottomSheetContainer.tsx +157 -0
- package/src/Stepper.tsx +67 -0
- package/src/entries/native-bottom-sheet.ts +4 -0
- package/src/entries/primitives.ts +2 -0
- package/src/examples/ParityGallery.tsx +20 -0
- package/src/index.ts +2 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { ModalBottomSheet } from "@swmansion/react-native-bottom-sheet";
|
|
3
|
+
import { IconX } from "@tabler/icons-react-native";
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
6
|
+
import { Colors } from "./colors";
|
|
7
|
+
import { textStyle, typeStyle } from "./controlStyles";
|
|
8
|
+
import { floatingSolidFill } from "./floating";
|
|
9
|
+
import { withAlpha } from "./palette";
|
|
10
|
+
import { useLargerText } from "./theme";
|
|
11
|
+
import { tokens } from "./tokens";
|
|
12
|
+
import { useScheme } from "./useScheme";
|
|
13
|
+
const SHEET_RADIUS = 20;
|
|
14
|
+
|
|
15
|
+
// A single open detent at 40%, so the default matches the gorhom container's one
|
|
16
|
+
// snap point. A caller can pass several detents to try the library's multi-detent
|
|
17
|
+
// sizing. The closed detent (0) is added by the component.
|
|
18
|
+
const DEFAULT_DETENTS = ["40%"];
|
|
19
|
+
|
|
20
|
+
// A dimming scrim like the gorhom backdrop's `opacity={0.5}`. The library scales
|
|
21
|
+
// this alpha to 0 at the closed detent and to full at an open one.
|
|
22
|
+
const SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* EXPERIMENTAL. A trial of Software Mansion's native `@swmansion/react-native-bottom-sheet`,
|
|
26
|
+
* next to the gorhom-based {@link BottomSheetContainer}. It mirrors that container's role
|
|
27
|
+
* and props: a controlled sheet over the screen, driven by `visible`/`onClose`, with a
|
|
28
|
+
* title and a close button in the same chrome.
|
|
29
|
+
*
|
|
30
|
+
* It is built on `ModalBottomSheet` in `windowOverlay` mode, so it needs no root
|
|
31
|
+
* `BottomSheetProvider` and nothing else in the app changes. The library is New
|
|
32
|
+
* Architecture only and ships native code, so it needs a native build (no Expo Go).
|
|
33
|
+
*
|
|
34
|
+
* Extra over the gorhom container: `detents`, the library's multi-detent sizing. Pass
|
|
35
|
+
* the open detents, shortest first; the default is a single 40% detent.
|
|
36
|
+
*/
|
|
37
|
+
export function NativeBottomSheetContainer(t0) {
|
|
38
|
+
const $ = _c(54);
|
|
39
|
+
const {
|
|
40
|
+
visible,
|
|
41
|
+
onClose,
|
|
42
|
+
title,
|
|
43
|
+
children,
|
|
44
|
+
closeTestID,
|
|
45
|
+
detents: t1
|
|
46
|
+
} = t0;
|
|
47
|
+
const detents = t1 === undefined ? DEFAULT_DETENTS : t1;
|
|
48
|
+
const largerText = useLargerText();
|
|
49
|
+
const scheme = useScheme();
|
|
50
|
+
const isDark = scheme === "dark";
|
|
51
|
+
let t2;
|
|
52
|
+
if ($[0] !== detents) {
|
|
53
|
+
t2 = [0, ...detents];
|
|
54
|
+
$[0] = detents;
|
|
55
|
+
$[1] = t2;
|
|
56
|
+
} else {
|
|
57
|
+
t2 = $[1];
|
|
58
|
+
}
|
|
59
|
+
const detentList = t2;
|
|
60
|
+
const [index, setIndex] = useState(0);
|
|
61
|
+
let t3;
|
|
62
|
+
let t4;
|
|
63
|
+
if ($[2] !== visible) {
|
|
64
|
+
t3 = () => {
|
|
65
|
+
setIndex(current => visible ? current === 0 ? 1 : current : 0);
|
|
66
|
+
};
|
|
67
|
+
t4 = [visible];
|
|
68
|
+
$[2] = visible;
|
|
69
|
+
$[3] = t3;
|
|
70
|
+
$[4] = t4;
|
|
71
|
+
} else {
|
|
72
|
+
t3 = $[3];
|
|
73
|
+
t4 = $[4];
|
|
74
|
+
}
|
|
75
|
+
useEffect(t3, t4);
|
|
76
|
+
let t5;
|
|
77
|
+
if ($[5] !== onClose) {
|
|
78
|
+
t5 = next => {
|
|
79
|
+
setIndex(next);
|
|
80
|
+
if (next === 0) {
|
|
81
|
+
onClose();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
$[5] = onClose;
|
|
85
|
+
$[6] = t5;
|
|
86
|
+
} else {
|
|
87
|
+
t5 = $[6];
|
|
88
|
+
}
|
|
89
|
+
const handleIndexChange = t5;
|
|
90
|
+
let t6;
|
|
91
|
+
if ($[7] !== onClose) {
|
|
92
|
+
t6 = () => {
|
|
93
|
+
setIndex(0);
|
|
94
|
+
onClose();
|
|
95
|
+
};
|
|
96
|
+
$[7] = onClose;
|
|
97
|
+
$[8] = t6;
|
|
98
|
+
} else {
|
|
99
|
+
t6 = $[8];
|
|
100
|
+
}
|
|
101
|
+
const handleCloseRequest = t6;
|
|
102
|
+
const t7 = floatingSolidFill[scheme];
|
|
103
|
+
let t8;
|
|
104
|
+
if ($[9] !== t7) {
|
|
105
|
+
t8 = <View style={[StyleSheet.absoluteFill, {
|
|
106
|
+
backgroundColor: t7
|
|
107
|
+
}]} />;
|
|
108
|
+
$[9] = t7;
|
|
109
|
+
$[10] = t8;
|
|
110
|
+
} else {
|
|
111
|
+
t8 = $[10];
|
|
112
|
+
}
|
|
113
|
+
const surface = t8;
|
|
114
|
+
let t9;
|
|
115
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
116
|
+
t9 = {
|
|
117
|
+
borderTopLeftRadius: SHEET_RADIUS,
|
|
118
|
+
borderTopRightRadius: SHEET_RADIUS
|
|
119
|
+
};
|
|
120
|
+
$[11] = t9;
|
|
121
|
+
} else {
|
|
122
|
+
t9 = $[11];
|
|
123
|
+
}
|
|
124
|
+
let t10;
|
|
125
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
126
|
+
t10 = {
|
|
127
|
+
flex: 1,
|
|
128
|
+
paddingTop: 12
|
|
129
|
+
};
|
|
130
|
+
$[12] = t10;
|
|
131
|
+
} else {
|
|
132
|
+
t10 = $[12];
|
|
133
|
+
}
|
|
134
|
+
const t11 = tokens.color.muted[scheme];
|
|
135
|
+
let t12;
|
|
136
|
+
if ($[13] !== t11) {
|
|
137
|
+
t12 = withAlpha(t11, 0.4);
|
|
138
|
+
$[13] = t11;
|
|
139
|
+
$[14] = t12;
|
|
140
|
+
} else {
|
|
141
|
+
t12 = $[14];
|
|
142
|
+
}
|
|
143
|
+
let t13;
|
|
144
|
+
if ($[15] !== t12) {
|
|
145
|
+
t13 = <View accessibilityElementsHidden={true} importantForAccessibility="no-hide-descendants" style={{
|
|
146
|
+
alignSelf: "center",
|
|
147
|
+
height: 6,
|
|
148
|
+
width: 40,
|
|
149
|
+
borderRadius: 999,
|
|
150
|
+
backgroundColor: t12
|
|
151
|
+
}} />;
|
|
152
|
+
$[15] = t12;
|
|
153
|
+
$[16] = t13;
|
|
154
|
+
} else {
|
|
155
|
+
t13 = $[16];
|
|
156
|
+
}
|
|
157
|
+
let t14;
|
|
158
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
159
|
+
t14 = {
|
|
160
|
+
flexDirection: "row",
|
|
161
|
+
alignItems: "center",
|
|
162
|
+
justifyContent: "space-between",
|
|
163
|
+
gap: 12,
|
|
164
|
+
paddingHorizontal: 20,
|
|
165
|
+
marginTop: 16,
|
|
166
|
+
marginBottom: 16
|
|
167
|
+
};
|
|
168
|
+
$[17] = t14;
|
|
169
|
+
} else {
|
|
170
|
+
t14 = $[17];
|
|
171
|
+
}
|
|
172
|
+
const t15 = largerText ? 24 : 20;
|
|
173
|
+
let t16;
|
|
174
|
+
if ($[18] !== t15) {
|
|
175
|
+
t16 = {
|
|
176
|
+
flex: 1,
|
|
177
|
+
fontSize: t15
|
|
178
|
+
};
|
|
179
|
+
$[18] = t15;
|
|
180
|
+
$[19] = t16;
|
|
181
|
+
} else {
|
|
182
|
+
t16 = $[19];
|
|
183
|
+
}
|
|
184
|
+
let t17;
|
|
185
|
+
if ($[20] !== scheme) {
|
|
186
|
+
t17 = textStyle("foreground", scheme);
|
|
187
|
+
$[20] = scheme;
|
|
188
|
+
$[21] = t17;
|
|
189
|
+
} else {
|
|
190
|
+
t17 = $[21];
|
|
191
|
+
}
|
|
192
|
+
let t18;
|
|
193
|
+
if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
|
|
194
|
+
t18 = typeStyle("semibold");
|
|
195
|
+
$[22] = t18;
|
|
196
|
+
} else {
|
|
197
|
+
t18 = $[22];
|
|
198
|
+
}
|
|
199
|
+
let t19;
|
|
200
|
+
if ($[23] !== t16 || $[24] !== t17) {
|
|
201
|
+
t19 = [t16, t17, t18];
|
|
202
|
+
$[23] = t16;
|
|
203
|
+
$[24] = t17;
|
|
204
|
+
$[25] = t19;
|
|
205
|
+
} else {
|
|
206
|
+
t19 = $[25];
|
|
207
|
+
}
|
|
208
|
+
let t20;
|
|
209
|
+
if ($[26] !== t19 || $[27] !== title) {
|
|
210
|
+
t20 = <Text accessibilityRole="header" style={t19}>{title}</Text>;
|
|
211
|
+
$[26] = t19;
|
|
212
|
+
$[27] = title;
|
|
213
|
+
$[28] = t20;
|
|
214
|
+
} else {
|
|
215
|
+
t20 = $[28];
|
|
216
|
+
}
|
|
217
|
+
let t21;
|
|
218
|
+
if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
|
|
219
|
+
t21 = {
|
|
220
|
+
marginRight: -8,
|
|
221
|
+
height: 48,
|
|
222
|
+
width: 48,
|
|
223
|
+
alignItems: "center",
|
|
224
|
+
justifyContent: "center"
|
|
225
|
+
};
|
|
226
|
+
$[29] = t21;
|
|
227
|
+
} else {
|
|
228
|
+
t21 = $[29];
|
|
229
|
+
}
|
|
230
|
+
const t22 = largerText ? 32 : 28;
|
|
231
|
+
const t23 = isDark ? Colors.white : Colors.black;
|
|
232
|
+
let t24;
|
|
233
|
+
if ($[30] !== t22 || $[31] !== t23) {
|
|
234
|
+
t24 = <IconX size={t22} color={t23} />;
|
|
235
|
+
$[30] = t22;
|
|
236
|
+
$[31] = t23;
|
|
237
|
+
$[32] = t24;
|
|
238
|
+
} else {
|
|
239
|
+
t24 = $[32];
|
|
240
|
+
}
|
|
241
|
+
let t25;
|
|
242
|
+
if ($[33] !== closeTestID || $[34] !== handleCloseRequest || $[35] !== t24) {
|
|
243
|
+
t25 = <TouchableOpacity testID={closeTestID} accessibilityRole="button" accessibilityLabel="Close" onPress={handleCloseRequest} style={t21} hitSlop={8} activeOpacity={0.7}>{t24}</TouchableOpacity>;
|
|
244
|
+
$[33] = closeTestID;
|
|
245
|
+
$[34] = handleCloseRequest;
|
|
246
|
+
$[35] = t24;
|
|
247
|
+
$[36] = t25;
|
|
248
|
+
} else {
|
|
249
|
+
t25 = $[36];
|
|
250
|
+
}
|
|
251
|
+
let t26;
|
|
252
|
+
if ($[37] !== t20 || $[38] !== t25) {
|
|
253
|
+
t26 = <View style={t14}>{t20}{t25}</View>;
|
|
254
|
+
$[37] = t20;
|
|
255
|
+
$[38] = t25;
|
|
256
|
+
$[39] = t26;
|
|
257
|
+
} else {
|
|
258
|
+
t26 = $[39];
|
|
259
|
+
}
|
|
260
|
+
let t27;
|
|
261
|
+
if ($[40] === Symbol.for("react.memo_cache_sentinel")) {
|
|
262
|
+
t27 = {
|
|
263
|
+
flex: 1,
|
|
264
|
+
paddingHorizontal: 20,
|
|
265
|
+
paddingBottom: 48
|
|
266
|
+
};
|
|
267
|
+
$[40] = t27;
|
|
268
|
+
} else {
|
|
269
|
+
t27 = $[40];
|
|
270
|
+
}
|
|
271
|
+
let t28;
|
|
272
|
+
if ($[41] !== children) {
|
|
273
|
+
t28 = <View style={t27}>{children}</View>;
|
|
274
|
+
$[41] = children;
|
|
275
|
+
$[42] = t28;
|
|
276
|
+
} else {
|
|
277
|
+
t28 = $[42];
|
|
278
|
+
}
|
|
279
|
+
let t29;
|
|
280
|
+
if ($[43] !== t13 || $[44] !== t26 || $[45] !== t28) {
|
|
281
|
+
t29 = <View style={t10}>{t13}{t26}{t28}</View>;
|
|
282
|
+
$[43] = t13;
|
|
283
|
+
$[44] = t26;
|
|
284
|
+
$[45] = t28;
|
|
285
|
+
$[46] = t29;
|
|
286
|
+
} else {
|
|
287
|
+
t29 = $[46];
|
|
288
|
+
}
|
|
289
|
+
let t30;
|
|
290
|
+
if ($[47] !== detentList || $[48] !== handleCloseRequest || $[49] !== handleIndexChange || $[50] !== index || $[51] !== surface || $[52] !== t29) {
|
|
291
|
+
t30 = <ModalBottomSheet index={index} detents={detentList} lazy={true} windowOverlay={true} scrimColor={SCRIM_COLOR} scrimAccessibilityLabel="Close" surface={surface} surfaceStyle={t9} onIndexChange={handleIndexChange} onCloseRequest={handleCloseRequest}>{t29}</ModalBottomSheet>;
|
|
292
|
+
$[47] = detentList;
|
|
293
|
+
$[48] = handleCloseRequest;
|
|
294
|
+
$[49] = handleIndexChange;
|
|
295
|
+
$[50] = index;
|
|
296
|
+
$[51] = surface;
|
|
297
|
+
$[52] = t29;
|
|
298
|
+
$[53] = t30;
|
|
299
|
+
} else {
|
|
300
|
+
t30 = $[53];
|
|
301
|
+
}
|
|
302
|
+
return t30;
|
|
303
|
+
}
|
package/dist/Stepper.jsx
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { IconMinus, IconPlus } from "@tabler/icons-react-native";
|
|
4
|
+
import { cn } from "./cn";
|
|
5
|
+
import { textStyle, typeStyle } from "./controlStyles";
|
|
6
|
+
import { IconButton } from "./IconButton";
|
|
7
|
+
import { useLargerText } from "./theme";
|
|
8
|
+
import { useScheme } from "./useScheme";
|
|
9
|
+
export function Stepper(t0) {
|
|
10
|
+
const $ = _c(40);
|
|
11
|
+
const {
|
|
12
|
+
value,
|
|
13
|
+
onChange,
|
|
14
|
+
min: t1,
|
|
15
|
+
max,
|
|
16
|
+
step: t2,
|
|
17
|
+
decrementLabel,
|
|
18
|
+
incrementLabel,
|
|
19
|
+
valueLabel,
|
|
20
|
+
testID
|
|
21
|
+
} = t0;
|
|
22
|
+
const min = t1 === undefined ? 1 : t1;
|
|
23
|
+
const step = t2 === undefined ? 1 : t2;
|
|
24
|
+
const scheme = useScheme();
|
|
25
|
+
const largerText = useLargerText();
|
|
26
|
+
let t3;
|
|
27
|
+
if ($[0] !== max || $[1] !== min) {
|
|
28
|
+
t3 = next => {
|
|
29
|
+
const floored = Math.max(min, next);
|
|
30
|
+
return max === undefined ? floored : Math.min(max, floored);
|
|
31
|
+
};
|
|
32
|
+
$[0] = max;
|
|
33
|
+
$[1] = min;
|
|
34
|
+
$[2] = t3;
|
|
35
|
+
} else {
|
|
36
|
+
t3 = $[2];
|
|
37
|
+
}
|
|
38
|
+
const clamp = t3;
|
|
39
|
+
const atMin = value <= min;
|
|
40
|
+
const atMax = max !== undefined && value >= max;
|
|
41
|
+
const t4 = testID === undefined ? undefined : `${testID}-less`;
|
|
42
|
+
let t5;
|
|
43
|
+
if ($[3] !== clamp || $[4] !== onChange || $[5] !== step || $[6] !== value) {
|
|
44
|
+
t5 = () => onChange(clamp(value - step));
|
|
45
|
+
$[3] = clamp;
|
|
46
|
+
$[4] = onChange;
|
|
47
|
+
$[5] = step;
|
|
48
|
+
$[6] = value;
|
|
49
|
+
$[7] = t5;
|
|
50
|
+
} else {
|
|
51
|
+
t5 = $[7];
|
|
52
|
+
}
|
|
53
|
+
let t6;
|
|
54
|
+
if ($[8] !== atMin || $[9] !== decrementLabel || $[10] !== t4 || $[11] !== t5) {
|
|
55
|
+
t6 = <IconButton testID={t4} icon={IconMinus} label={decrementLabel} size="lg" disabled={atMin} onPress={t5} />;
|
|
56
|
+
$[8] = atMin;
|
|
57
|
+
$[9] = decrementLabel;
|
|
58
|
+
$[10] = t4;
|
|
59
|
+
$[11] = t5;
|
|
60
|
+
$[12] = t6;
|
|
61
|
+
} else {
|
|
62
|
+
t6 = $[12];
|
|
63
|
+
}
|
|
64
|
+
const t7 = largerText ? "text-3xl" : "text-2xl";
|
|
65
|
+
let t8;
|
|
66
|
+
if ($[13] !== t7) {
|
|
67
|
+
t8 = cn("min-w-8 text-center font-instrument-sans-semibold", t7);
|
|
68
|
+
$[13] = t7;
|
|
69
|
+
$[14] = t8;
|
|
70
|
+
} else {
|
|
71
|
+
t8 = $[14];
|
|
72
|
+
}
|
|
73
|
+
let t9;
|
|
74
|
+
if ($[15] !== scheme) {
|
|
75
|
+
t9 = textStyle("foreground", scheme);
|
|
76
|
+
$[15] = scheme;
|
|
77
|
+
$[16] = t9;
|
|
78
|
+
} else {
|
|
79
|
+
t9 = $[16];
|
|
80
|
+
}
|
|
81
|
+
let t10;
|
|
82
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
83
|
+
t10 = typeStyle("semibold");
|
|
84
|
+
$[17] = t10;
|
|
85
|
+
} else {
|
|
86
|
+
t10 = $[17];
|
|
87
|
+
}
|
|
88
|
+
let t11;
|
|
89
|
+
if ($[18] !== t9) {
|
|
90
|
+
t11 = [t9, t10];
|
|
91
|
+
$[18] = t9;
|
|
92
|
+
$[19] = t11;
|
|
93
|
+
} else {
|
|
94
|
+
t11 = $[19];
|
|
95
|
+
}
|
|
96
|
+
let t12;
|
|
97
|
+
if ($[20] !== t11 || $[21] !== t8 || $[22] !== value || $[23] !== valueLabel) {
|
|
98
|
+
t12 = <Text accessibilityLabel={valueLabel} className={t8} style={t11}>{value}</Text>;
|
|
99
|
+
$[20] = t11;
|
|
100
|
+
$[21] = t8;
|
|
101
|
+
$[22] = value;
|
|
102
|
+
$[23] = valueLabel;
|
|
103
|
+
$[24] = t12;
|
|
104
|
+
} else {
|
|
105
|
+
t12 = $[24];
|
|
106
|
+
}
|
|
107
|
+
const t13 = testID === undefined ? undefined : `${testID}-more`;
|
|
108
|
+
let t14;
|
|
109
|
+
if ($[25] !== clamp || $[26] !== onChange || $[27] !== step || $[28] !== value) {
|
|
110
|
+
t14 = () => onChange(clamp(value + step));
|
|
111
|
+
$[25] = clamp;
|
|
112
|
+
$[26] = onChange;
|
|
113
|
+
$[27] = step;
|
|
114
|
+
$[28] = value;
|
|
115
|
+
$[29] = t14;
|
|
116
|
+
} else {
|
|
117
|
+
t14 = $[29];
|
|
118
|
+
}
|
|
119
|
+
let t15;
|
|
120
|
+
if ($[30] !== atMax || $[31] !== incrementLabel || $[32] !== t13 || $[33] !== t14) {
|
|
121
|
+
t15 = <IconButton testID={t13} icon={IconPlus} label={incrementLabel} size="lg" disabled={atMax} onPress={t14} />;
|
|
122
|
+
$[30] = atMax;
|
|
123
|
+
$[31] = incrementLabel;
|
|
124
|
+
$[32] = t13;
|
|
125
|
+
$[33] = t14;
|
|
126
|
+
$[34] = t15;
|
|
127
|
+
} else {
|
|
128
|
+
t15 = $[34];
|
|
129
|
+
}
|
|
130
|
+
let t16;
|
|
131
|
+
if ($[35] !== t12 || $[36] !== t15 || $[37] !== t6 || $[38] !== testID) {
|
|
132
|
+
t16 = <View testID={testID} className="flex-row items-center gap-1">{t6}{t12}{t15}</View>;
|
|
133
|
+
$[35] = t12;
|
|
134
|
+
$[36] = t15;
|
|
135
|
+
$[37] = t6;
|
|
136
|
+
$[38] = testID;
|
|
137
|
+
$[39] = t16;
|
|
138
|
+
} else {
|
|
139
|
+
t16 = $[39];
|
|
140
|
+
}
|
|
141
|
+
return t16;
|
|
142
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// `@vvedantb/native-ui/native-bottom-sheet`. Experimental: imports Software Mansion's
|
|
2
|
+
// native `@swmansion/react-native-bottom-sheet` (an optional peer). Kept separate from
|
|
3
|
+
// the gorhom `./bottom-sheet` entry so neither affects the other.
|
|
4
|
+
export { NativeBottomSheetContainer } from "../NativeBottomSheetContainer";
|
|
@@ -21,6 +21,7 @@ export { SectionLabel } from "../SectionLabel";
|
|
|
21
21
|
export { SheetRow } from "../SheetRow";
|
|
22
22
|
export { PageIndicator } from "../PageIndicator";
|
|
23
23
|
export { IconButton } from "../IconButton";
|
|
24
|
+
export { Stepper } from "../Stepper";
|
|
24
25
|
export { CaptureButton } from "../CaptureButton";
|
|
25
26
|
export { Separator } from "../Separator";
|
|
26
27
|
export { KeyboardAvoidingView } from "../primitives/keyboard-parts";
|
|
@@ -7,7 +7,7 @@ import { c as _c } from "react/compiler-runtime";
|
|
|
7
7
|
import { useState } from "react";
|
|
8
8
|
import { ScrollView, Text, View } from "react-native";
|
|
9
9
|
import { IconCopy, IconDots, IconInbox, IconPencil, IconPhoto, IconRefresh, IconTrash, IconX } from "@tabler/icons-react-native";
|
|
10
|
-
import { APP_ICONS, APP_NAMES, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AmbientBackground, AppMark, AppWordmark, BulkActionBar, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, Avatar, AvatarFallback, Badge, Button, CaptureButton, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CenteredSpinner, Checkbox, ColorSwatches, ConfirmDialog, DateTimeField, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EmptyState, FromProjectV, GoogleMark, IconButton, Input, Label, LabeledSwitchRow, ListRow, MoreFromProjectV, NEUTRAL_900, NativeUiProvider, PageHeader, PageIndicator, PageTitle, PricingModal, Progress, SearchInput, SectionLabel, Select, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetRow, SheetTitle, SheetTrigger, Skeleton, Spinner, StackPageHeader, StatGrid, StatusDot, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeToggle, Toaster, UpgradeToProCard, initials, palette, toast, tokens, useNativeUi } from "../index";
|
|
10
|
+
import { APP_ICONS, APP_NAMES, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, AmbientBackground, AppMark, AppWordmark, BulkActionBar, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuTrigger, Avatar, AvatarFallback, Badge, Button, CaptureButton, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CenteredSpinner, Checkbox, ColorSwatches, ConfirmDialog, DateTimeField, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, EmptyState, FromProjectV, GoogleMark, IconButton, Input, Label, LabeledSwitchRow, ListRow, MoreFromProjectV, NEUTRAL_900, NativeUiProvider, PageHeader, PageIndicator, PageTitle, PricingModal, Progress, SearchInput, SectionLabel, Select, Separator, Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetRow, SheetTitle, SheetTrigger, Skeleton, Spinner, StackPageHeader, StatGrid, StatusDot, Stepper, Switch, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, ThemeToggle, Toaster, UpgradeToProCard, initials, palette, toast, tokens, useNativeUi } from "../index";
|
|
11
11
|
import { typeStyle } from "../controlStyles";
|
|
12
12
|
import { useScheme } from "../useScheme";
|
|
13
13
|
import { ChainOfThought, ChainOfThoughtContent, ChainOfThoughtHeader, ChainOfThoughtSearchResult, ChainOfThoughtSearchResults, ChainOfThoughtStep, ConversationEmptyState, Suggestion, Suggestions } from "../ai";
|
|
@@ -153,7 +153,7 @@ export function ParityGallery() {
|
|
|
153
153
|
return t1;
|
|
154
154
|
}
|
|
155
155
|
function GalleryScreen() {
|
|
156
|
-
const $ = _c(
|
|
156
|
+
const $ = _c(201);
|
|
157
157
|
const [checked, setChecked] = useState("indeterminate");
|
|
158
158
|
const [switchOn, setSwitchOn] = useState(true);
|
|
159
159
|
const [colour, setColour] = useState(undefined);
|
|
@@ -170,6 +170,7 @@ function GalleryScreen() {
|
|
|
170
170
|
const [page, setPage] = useState(0);
|
|
171
171
|
const [menuSort, setMenuSort] = useState("newest");
|
|
172
172
|
const [picked, setPicked] = useState(2);
|
|
173
|
+
const [dose, setDose] = useState(1);
|
|
173
174
|
const scheme = useScheme();
|
|
174
175
|
let t0;
|
|
175
176
|
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -1073,95 +1074,131 @@ function GalleryScreen() {
|
|
|
1073
1074
|
}
|
|
1074
1075
|
let t128;
|
|
1075
1076
|
if ($[167] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1076
|
-
t128 = <
|
|
1077
|
+
t128 = <GalleryText>Tablets</GalleryText>;
|
|
1077
1078
|
$[167] = t128;
|
|
1078
1079
|
} else {
|
|
1079
1080
|
t128 = $[167];
|
|
1080
1081
|
}
|
|
1081
|
-
|
|
1082
|
-
if ($[168] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1083
|
-
t129 = <ChainOfThoughtHeader />;
|
|
1084
|
-
$[168] = t129;
|
|
1085
|
-
} else {
|
|
1086
|
-
t129 = $[168];
|
|
1087
|
-
}
|
|
1082
|
+
const t129 = `${dose} tablets`;
|
|
1088
1083
|
let t130;
|
|
1089
|
-
if ($[169]
|
|
1090
|
-
t130 = <
|
|
1091
|
-
$[
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
}
|
|
1095
|
-
let t131;
|
|
1096
|
-
if ($[170] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1097
|
-
t131 = <ChainOfThought defaultOpen={true}>{t129}<ChainOfThoughtContent>{t130}<ChainOfThoughtStep label="Search for sync options" status="active"><ChainOfThoughtSearchResults><ChainOfThoughtSearchResult>example.com</ChainOfThoughtSearchResult><ChainOfThoughtSearchResult>example.org</ChainOfThoughtSearchResult></ChainOfThoughtSearchResults></ChainOfThoughtStep><ChainOfThoughtStep label="Write the answer" status="pending" /></ChainOfThoughtContent></ChainOfThought>;
|
|
1098
|
-
$[170] = t131;
|
|
1084
|
+
if ($[168] !== dose || $[169] !== t129) {
|
|
1085
|
+
t130 = <View className="flex-row items-center justify-between rounded-lg bg-surface px-4 py-3">{t128}<Stepper testID="stepper-dose" value={dose} onChange={setDose} min={1} max={6} decrementLabel="Take one fewer" incrementLabel="Take one more" valueLabel={t129} /></View>;
|
|
1086
|
+
$[168] = dose;
|
|
1087
|
+
$[169] = t129;
|
|
1088
|
+
$[170] = t130;
|
|
1099
1089
|
} else {
|
|
1100
|
-
|
|
1090
|
+
t130 = $[170];
|
|
1101
1091
|
}
|
|
1092
|
+
const t131 = `Dose: ${dose}`;
|
|
1102
1093
|
let t132;
|
|
1103
|
-
if ($[171]
|
|
1104
|
-
t132 = <
|
|
1105
|
-
$[171] =
|
|
1094
|
+
if ($[171] !== t131) {
|
|
1095
|
+
t132 = <GalleryText testID="stepper-dose-value">{t131}</GalleryText>;
|
|
1096
|
+
$[171] = t131;
|
|
1097
|
+
$[172] = t132;
|
|
1106
1098
|
} else {
|
|
1107
|
-
t132 = $[
|
|
1099
|
+
t132 = $[172];
|
|
1108
1100
|
}
|
|
1109
1101
|
let t133;
|
|
1110
|
-
if ($[
|
|
1111
|
-
t133 = <
|
|
1112
|
-
$[
|
|
1113
|
-
$[
|
|
1114
|
-
$[
|
|
1115
|
-
|
|
1116
|
-
$[
|
|
1117
|
-
$[177] = t44;
|
|
1118
|
-
$[178] = t68;
|
|
1119
|
-
$[179] = t91;
|
|
1120
|
-
$[180] = t94;
|
|
1121
|
-
$[181] = t98;
|
|
1122
|
-
$[182] = t133;
|
|
1123
|
-
} else {
|
|
1124
|
-
t133 = $[182];
|
|
1102
|
+
if ($[173] !== t130 || $[174] !== t132) {
|
|
1103
|
+
t133 = <Section title="Stepper">{t130}{t132}</Section>;
|
|
1104
|
+
$[173] = t130;
|
|
1105
|
+
$[174] = t132;
|
|
1106
|
+
$[175] = t133;
|
|
1107
|
+
} else {
|
|
1108
|
+
t133 = $[175];
|
|
1125
1109
|
}
|
|
1126
1110
|
let t134;
|
|
1127
|
-
if ($[
|
|
1128
|
-
t134 =
|
|
1129
|
-
$[
|
|
1111
|
+
if ($[176] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1112
|
+
t134 = <AiChatSamples />;
|
|
1113
|
+
$[176] = t134;
|
|
1130
1114
|
} else {
|
|
1131
|
-
t134 = $[
|
|
1115
|
+
t134 = $[176];
|
|
1132
1116
|
}
|
|
1133
1117
|
let t135;
|
|
1134
|
-
if ($[
|
|
1135
|
-
t135 =
|
|
1136
|
-
$[
|
|
1118
|
+
if ($[177] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1119
|
+
t135 = <ChainOfThoughtHeader />;
|
|
1120
|
+
$[177] = t135;
|
|
1137
1121
|
} else {
|
|
1138
|
-
t135 = $[
|
|
1122
|
+
t135 = $[177];
|
|
1139
1123
|
}
|
|
1140
1124
|
let t136;
|
|
1141
|
-
if ($[
|
|
1142
|
-
t136 = <
|
|
1143
|
-
$[
|
|
1144
|
-
$[186] = t136;
|
|
1125
|
+
if ($[178] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1126
|
+
t136 = <ChainOfThoughtStep label="Read the question" />;
|
|
1127
|
+
$[178] = t136;
|
|
1145
1128
|
} else {
|
|
1146
|
-
t136 = $[
|
|
1129
|
+
t136 = $[178];
|
|
1147
1130
|
}
|
|
1148
1131
|
let t137;
|
|
1149
|
-
if ($[
|
|
1150
|
-
t137 = <
|
|
1151
|
-
$[
|
|
1132
|
+
if ($[179] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1133
|
+
t137 = <ChainOfThought defaultOpen={true}>{t135}<ChainOfThoughtContent>{t136}<ChainOfThoughtStep label="Search for sync options" status="active"><ChainOfThoughtSearchResults><ChainOfThoughtSearchResult>example.com</ChainOfThoughtSearchResult><ChainOfThoughtSearchResult>example.org</ChainOfThoughtSearchResult></ChainOfThoughtSearchResults></ChainOfThoughtStep><ChainOfThoughtStep label="Write the answer" status="pending" /></ChainOfThoughtContent></ChainOfThought>;
|
|
1134
|
+
$[179] = t137;
|
|
1152
1135
|
} else {
|
|
1153
|
-
t137 = $[
|
|
1136
|
+
t137 = $[179];
|
|
1154
1137
|
}
|
|
1155
1138
|
let t138;
|
|
1156
|
-
if ($[
|
|
1157
|
-
t138 = <
|
|
1158
|
-
$[
|
|
1159
|
-
|
|
1160
|
-
$[
|
|
1161
|
-
}
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1139
|
+
if ($[180] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1140
|
+
t138 = <Section title="AI chat">{t134}{t137}<Suggestions><Suggestion suggestion="Summarise this thread" onPress={_temp40} /><Suggestion suggestion="Draft a reply" onPress={_temp41} /></Suggestions><ConversationEmptyState className="flex-none" /></Section>;
|
|
1141
|
+
$[180] = t138;
|
|
1142
|
+
} else {
|
|
1143
|
+
t138 = $[180];
|
|
1144
|
+
}
|
|
1145
|
+
let t139;
|
|
1146
|
+
if ($[181] !== t100 || $[182] !== t117 || $[183] !== t118 || $[184] !== t133 || $[185] !== t19 || $[186] !== t33 || $[187] !== t44 || $[188] !== t68 || $[189] !== t91 || $[190] !== t94 || $[191] !== t98) {
|
|
1147
|
+
t139 = <ScrollView keyboardShouldPersistTaps="handled" contentContainerClassName="gap-8 px-4 pt-4" contentContainerStyle={t0}>{t3}{t7}{t19}{t20}{t21}{t33}{t36}{t44}{t49}{t51}{t68}{t91}{t93}{t94}{t98}{t100}{t104}{t117}{t118}{t120}{t121}{t127}{t133}{t138}</ScrollView>;
|
|
1148
|
+
$[181] = t100;
|
|
1149
|
+
$[182] = t117;
|
|
1150
|
+
$[183] = t118;
|
|
1151
|
+
$[184] = t133;
|
|
1152
|
+
$[185] = t19;
|
|
1153
|
+
$[186] = t33;
|
|
1154
|
+
$[187] = t44;
|
|
1155
|
+
$[188] = t68;
|
|
1156
|
+
$[189] = t91;
|
|
1157
|
+
$[190] = t94;
|
|
1158
|
+
$[191] = t98;
|
|
1159
|
+
$[192] = t139;
|
|
1160
|
+
} else {
|
|
1161
|
+
t139 = $[192];
|
|
1162
|
+
}
|
|
1163
|
+
let t140;
|
|
1164
|
+
if ($[193] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1165
|
+
t140 = () => setPricingOpen(false);
|
|
1166
|
+
$[193] = t140;
|
|
1167
|
+
} else {
|
|
1168
|
+
t140 = $[193];
|
|
1169
|
+
}
|
|
1170
|
+
let t141;
|
|
1171
|
+
if ($[194] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1172
|
+
t141 = ["vibot", "verve", "velth", "vmem", "vhub"];
|
|
1173
|
+
$[194] = t141;
|
|
1174
|
+
} else {
|
|
1175
|
+
t141 = $[194];
|
|
1176
|
+
}
|
|
1177
|
+
let t142;
|
|
1178
|
+
if ($[195] !== pricingOpen) {
|
|
1179
|
+
t142 = <PricingModal open={pricingOpen} onClose={t140} title="Upgrade to V Pro" apps={t141} currentApp="vibot" headline="One plan. Every V app." plans={PLANS} finePrint="Placeholder prices for the gallery." onCheckout={_temp42} />;
|
|
1180
|
+
$[195] = pricingOpen;
|
|
1181
|
+
$[196] = t142;
|
|
1182
|
+
} else {
|
|
1183
|
+
t142 = $[196];
|
|
1184
|
+
}
|
|
1185
|
+
let t143;
|
|
1186
|
+
if ($[197] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1187
|
+
t143 = <Toaster />;
|
|
1188
|
+
$[197] = t143;
|
|
1189
|
+
} else {
|
|
1190
|
+
t143 = $[197];
|
|
1191
|
+
}
|
|
1192
|
+
let t144;
|
|
1193
|
+
if ($[198] !== t139 || $[199] !== t142) {
|
|
1194
|
+
t144 = <View className="flex-1">{t139}{t142}{t143}</View>;
|
|
1195
|
+
$[198] = t139;
|
|
1196
|
+
$[199] = t142;
|
|
1197
|
+
$[200] = t144;
|
|
1198
|
+
} else {
|
|
1199
|
+
t144 = $[200];
|
|
1200
|
+
}
|
|
1201
|
+
return t144;
|
|
1165
1202
|
}
|
|
1166
1203
|
function _temp42(plan, period) {
|
|
1167
1204
|
return toast(`${plan.name} (${period})`);
|
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { SectionLabel } from "./SectionLabel";
|
|
|
29
29
|
export { SheetRow } from "./SheetRow";
|
|
30
30
|
export { PageIndicator } from "./PageIndicator";
|
|
31
31
|
export { IconButton } from "./IconButton";
|
|
32
|
+
export { Stepper } from "./Stepper";
|
|
32
33
|
export { CaptureButton } from "./CaptureButton";
|
|
33
34
|
export { Separator } from "./Separator";
|
|
34
35
|
export { Progress } from "./Progress";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
|
@@ -89,6 +89,11 @@
|
|
|
89
89
|
"source": "./src/entries/bottom-sheet.ts",
|
|
90
90
|
"default": "./dist/entries/bottom-sheet.js"
|
|
91
91
|
},
|
|
92
|
+
"./native-bottom-sheet": {
|
|
93
|
+
"types": "./src/entries/native-bottom-sheet.ts",
|
|
94
|
+
"source": "./src/entries/native-bottom-sheet.ts",
|
|
95
|
+
"default": "./dist/entries/native-bottom-sheet.js"
|
|
96
|
+
},
|
|
92
97
|
"./gesture-handler": {
|
|
93
98
|
"types": "./src/entries/gesture-handler.ts",
|
|
94
99
|
"source": "./src/entries/gesture-handler.ts",
|
|
@@ -193,6 +198,7 @@
|
|
|
193
198
|
"@rn-primitives/select": "*",
|
|
194
199
|
"@rn-primitives/slot": "*",
|
|
195
200
|
"@rn-primitives/switch": "*",
|
|
201
|
+
"@swmansion/react-native-bottom-sheet": ">=1.1.0",
|
|
196
202
|
"@tabler/icons-react-native": "*",
|
|
197
203
|
"@vvedantb/server": ">=0.17.1",
|
|
198
204
|
"class-variance-authority": ">=0.7.0",
|
|
@@ -231,6 +237,9 @@
|
|
|
231
237
|
"@gorhom/bottom-sheet": {
|
|
232
238
|
"optional": true
|
|
233
239
|
},
|
|
240
|
+
"@swmansion/react-native-bottom-sheet": {
|
|
241
|
+
"optional": true
|
|
242
|
+
},
|
|
234
243
|
"@json-render/core": {
|
|
235
244
|
"optional": true
|
|
236
245
|
},
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { ModalBottomSheet } from "@swmansion/react-native-bottom-sheet";
|
|
2
|
+
import type { ModalDetent } from "@swmansion/react-native-bottom-sheet";
|
|
3
|
+
import { IconX } from "@tabler/icons-react-native";
|
|
4
|
+
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
5
|
+
import { StyleSheet, Text, TouchableOpacity, View } from "react-native";
|
|
6
|
+
import { Colors } from "./colors";
|
|
7
|
+
import { textStyle, typeStyle } from "./controlStyles";
|
|
8
|
+
import { floatingSolidFill } from "./floating";
|
|
9
|
+
import { withAlpha } from "./palette";
|
|
10
|
+
import { useLargerText } from "./theme";
|
|
11
|
+
import { tokens } from "./tokens";
|
|
12
|
+
import { useScheme } from "./useScheme";
|
|
13
|
+
|
|
14
|
+
const SHEET_RADIUS = 20;
|
|
15
|
+
|
|
16
|
+
// A single open detent at 40%, so the default matches the gorhom container's one
|
|
17
|
+
// snap point. A caller can pass several detents to try the library's multi-detent
|
|
18
|
+
// sizing. The closed detent (0) is added by the component.
|
|
19
|
+
const DEFAULT_DETENTS: readonly ModalDetent[] = ["40%"];
|
|
20
|
+
|
|
21
|
+
// A dimming scrim like the gorhom backdrop's `opacity={0.5}`. The library scales
|
|
22
|
+
// this alpha to 0 at the closed detent and to full at an open one.
|
|
23
|
+
const SCRIM_COLOR = "rgba(0, 0, 0, 0.5)";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* EXPERIMENTAL. A trial of Software Mansion's native `@swmansion/react-native-bottom-sheet`,
|
|
27
|
+
* next to the gorhom-based {@link BottomSheetContainer}. It mirrors that container's role
|
|
28
|
+
* and props: a controlled sheet over the screen, driven by `visible`/`onClose`, with a
|
|
29
|
+
* title and a close button in the same chrome.
|
|
30
|
+
*
|
|
31
|
+
* It is built on `ModalBottomSheet` in `windowOverlay` mode, so it needs no root
|
|
32
|
+
* `BottomSheetProvider` and nothing else in the app changes. The library is New
|
|
33
|
+
* Architecture only and ships native code, so it needs a native build (no Expo Go).
|
|
34
|
+
*
|
|
35
|
+
* Extra over the gorhom container: `detents`, the library's multi-detent sizing. Pass
|
|
36
|
+
* the open detents, shortest first; the default is a single 40% detent.
|
|
37
|
+
*/
|
|
38
|
+
export function NativeBottomSheetContainer({
|
|
39
|
+
visible,
|
|
40
|
+
onClose,
|
|
41
|
+
title,
|
|
42
|
+
children,
|
|
43
|
+
closeTestID,
|
|
44
|
+
detents = DEFAULT_DETENTS,
|
|
45
|
+
}: {
|
|
46
|
+
visible: boolean;
|
|
47
|
+
onClose: () => void;
|
|
48
|
+
title: string;
|
|
49
|
+
children: React.ReactNode;
|
|
50
|
+
closeTestID?: string;
|
|
51
|
+
/** Open detents, shortest first. The closed detent is added automatically. */
|
|
52
|
+
detents?: readonly ModalDetent[];
|
|
53
|
+
}) {
|
|
54
|
+
const largerText = useLargerText();
|
|
55
|
+
const scheme = useScheme();
|
|
56
|
+
const isDark = scheme === "dark";
|
|
57
|
+
|
|
58
|
+
// The library sheet is controlled by a detent index. The first detent is the
|
|
59
|
+
// closed state (0); the open detents follow.
|
|
60
|
+
const detentList = useMemo<ModalDetent[]>(() => [0, ...detents], [detents]);
|
|
61
|
+
const [index, setIndex] = useState(0);
|
|
62
|
+
|
|
63
|
+
// Keep the index in step with `visible`: open to the first detent, close to 0.
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setIndex((current) => (visible ? (current === 0 ? 1 : current) : 0));
|
|
66
|
+
}, [visible]);
|
|
67
|
+
|
|
68
|
+
// A user-driven drag to the closed detent reports here; tell the parent.
|
|
69
|
+
const handleIndexChange = useCallback(
|
|
70
|
+
(next: number) => {
|
|
71
|
+
setIndex(next);
|
|
72
|
+
if (next === 0) onClose();
|
|
73
|
+
},
|
|
74
|
+
[onClose],
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// A scrim tap or system Back asks the sheet to close; close it and tell the parent.
|
|
78
|
+
const handleCloseRequest = useCallback(() => {
|
|
79
|
+
setIndex(0);
|
|
80
|
+
onClose();
|
|
81
|
+
}, [onClose]);
|
|
82
|
+
|
|
83
|
+
const surface = (
|
|
84
|
+
<View
|
|
85
|
+
style={[StyleSheet.absoluteFill, { backgroundColor: floatingSolidFill[scheme] }]}
|
|
86
|
+
/>
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<ModalBottomSheet
|
|
91
|
+
index={index}
|
|
92
|
+
detents={detentList}
|
|
93
|
+
// Unmount the content once the sheet settles closed, as the gorhom container does.
|
|
94
|
+
lazy
|
|
95
|
+
windowOverlay
|
|
96
|
+
scrimColor={SCRIM_COLOR}
|
|
97
|
+
scrimAccessibilityLabel="Close"
|
|
98
|
+
surface={surface}
|
|
99
|
+
surfaceStyle={{
|
|
100
|
+
borderTopLeftRadius: SHEET_RADIUS,
|
|
101
|
+
borderTopRightRadius: SHEET_RADIUS,
|
|
102
|
+
}}
|
|
103
|
+
onIndexChange={handleIndexChange}
|
|
104
|
+
onCloseRequest={handleCloseRequest}
|
|
105
|
+
>
|
|
106
|
+
<View style={{ flex: 1, paddingTop: 12 }}>
|
|
107
|
+
<View
|
|
108
|
+
accessibilityElementsHidden
|
|
109
|
+
importantForAccessibility="no-hide-descendants"
|
|
110
|
+
style={{
|
|
111
|
+
alignSelf: "center",
|
|
112
|
+
height: 6,
|
|
113
|
+
width: 40,
|
|
114
|
+
borderRadius: 999,
|
|
115
|
+
backgroundColor: withAlpha(tokens.color.muted[scheme], 0.4),
|
|
116
|
+
}}
|
|
117
|
+
/>
|
|
118
|
+
<View
|
|
119
|
+
style={{
|
|
120
|
+
flexDirection: "row",
|
|
121
|
+
alignItems: "center",
|
|
122
|
+
justifyContent: "space-between",
|
|
123
|
+
gap: 12,
|
|
124
|
+
paddingHorizontal: 20,
|
|
125
|
+
marginTop: 16,
|
|
126
|
+
marginBottom: 16,
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
<Text
|
|
130
|
+
accessibilityRole="header"
|
|
131
|
+
style={[
|
|
132
|
+
{ flex: 1, fontSize: largerText ? 24 : 20 },
|
|
133
|
+
textStyle("foreground", scheme),
|
|
134
|
+
typeStyle("semibold"),
|
|
135
|
+
]}
|
|
136
|
+
>
|
|
137
|
+
{title}
|
|
138
|
+
</Text>
|
|
139
|
+
<TouchableOpacity
|
|
140
|
+
testID={closeTestID}
|
|
141
|
+
accessibilityRole="button"
|
|
142
|
+
accessibilityLabel="Close"
|
|
143
|
+
onPress={handleCloseRequest}
|
|
144
|
+
style={{ marginRight: -8, height: 48, width: 48, alignItems: "center", justifyContent: "center" }}
|
|
145
|
+
hitSlop={8}
|
|
146
|
+
activeOpacity={0.7}
|
|
147
|
+
>
|
|
148
|
+
<IconX size={largerText ? 32 : 28} color={isDark ? Colors.white : Colors.black} />
|
|
149
|
+
</TouchableOpacity>
|
|
150
|
+
</View>
|
|
151
|
+
<View style={{ flex: 1, paddingHorizontal: 20, paddingBottom: 48 }}>
|
|
152
|
+
{children}
|
|
153
|
+
</View>
|
|
154
|
+
</View>
|
|
155
|
+
</ModalBottomSheet>
|
|
156
|
+
);
|
|
157
|
+
}
|
package/src/Stepper.tsx
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Text, View } from "react-native";
|
|
2
|
+
import { IconMinus, IconPlus } from "@tabler/icons-react-native";
|
|
3
|
+
import { cn } from "./cn";
|
|
4
|
+
import { textStyle, typeStyle } from "./controlStyles";
|
|
5
|
+
import { IconButton } from "./IconButton";
|
|
6
|
+
import { useLargerText } from "./theme";
|
|
7
|
+
import { useScheme } from "./useScheme";
|
|
8
|
+
|
|
9
|
+
export type StepperProps = {
|
|
10
|
+
value: number;
|
|
11
|
+
onChange: (value: number) => void;
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
decrementLabel: string;
|
|
16
|
+
incrementLabel: string;
|
|
17
|
+
valueLabel?: string;
|
|
18
|
+
testID?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function Stepper({
|
|
22
|
+
value,
|
|
23
|
+
onChange,
|
|
24
|
+
min = 1,
|
|
25
|
+
max,
|
|
26
|
+
step = 1,
|
|
27
|
+
decrementLabel,
|
|
28
|
+
incrementLabel,
|
|
29
|
+
valueLabel,
|
|
30
|
+
testID,
|
|
31
|
+
}: StepperProps) {
|
|
32
|
+
const scheme = useScheme();
|
|
33
|
+
const largerText = useLargerText();
|
|
34
|
+
const clamp = (next: number) => {
|
|
35
|
+
const floored = Math.max(min, next);
|
|
36
|
+
return max === undefined ? floored : Math.min(max, floored);
|
|
37
|
+
};
|
|
38
|
+
const atMin = value <= min;
|
|
39
|
+
const atMax = max !== undefined && value >= max;
|
|
40
|
+
return (
|
|
41
|
+
<View testID={testID} className="flex-row items-center gap-1">
|
|
42
|
+
<IconButton
|
|
43
|
+
testID={testID === undefined ? undefined : `${testID}-less`}
|
|
44
|
+
icon={IconMinus}
|
|
45
|
+
label={decrementLabel}
|
|
46
|
+
size="lg"
|
|
47
|
+
disabled={atMin}
|
|
48
|
+
onPress={() => onChange(clamp(value - step))}
|
|
49
|
+
/>
|
|
50
|
+
<Text
|
|
51
|
+
accessibilityLabel={valueLabel}
|
|
52
|
+
className={cn("min-w-8 text-center font-instrument-sans-semibold", largerText ? "text-3xl" : "text-2xl")}
|
|
53
|
+
style={[textStyle("foreground", scheme), typeStyle("semibold")]}
|
|
54
|
+
>
|
|
55
|
+
{value}
|
|
56
|
+
</Text>
|
|
57
|
+
<IconButton
|
|
58
|
+
testID={testID === undefined ? undefined : `${testID}-more`}
|
|
59
|
+
icon={IconPlus}
|
|
60
|
+
label={incrementLabel}
|
|
61
|
+
size="lg"
|
|
62
|
+
disabled={atMax}
|
|
63
|
+
onPress={() => onChange(clamp(value + step))}
|
|
64
|
+
/>
|
|
65
|
+
</View>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// `@vvedantb/native-ui/native-bottom-sheet`. Experimental: imports Software Mansion's
|
|
2
|
+
// native `@swmansion/react-native-bottom-sheet` (an optional peer). Kept separate from
|
|
3
|
+
// the gorhom `./bottom-sheet` entry so neither affects the other.
|
|
4
|
+
export { NativeBottomSheetContainer } from "../NativeBottomSheetContainer";
|
|
@@ -39,6 +39,8 @@ export { PageIndicator } from "../PageIndicator";
|
|
|
39
39
|
export type { PageIndicatorProps } from "../PageIndicator";
|
|
40
40
|
export { IconButton } from "../IconButton";
|
|
41
41
|
export type { IconButtonProps, IconButtonSize, IconButtonVariant } from "../IconButton";
|
|
42
|
+
export { Stepper } from "../Stepper";
|
|
43
|
+
export type { StepperProps } from "../Stepper";
|
|
42
44
|
export { CaptureButton } from "../CaptureButton";
|
|
43
45
|
export type { CaptureButtonProps } from "../CaptureButton";
|
|
44
46
|
export { Separator } from "../Separator";
|
|
@@ -96,6 +96,7 @@ import {
|
|
|
96
96
|
StackPageHeader,
|
|
97
97
|
StatGrid,
|
|
98
98
|
StatusDot,
|
|
99
|
+
Stepper,
|
|
99
100
|
Switch,
|
|
100
101
|
Tabs,
|
|
101
102
|
TabsContent,
|
|
@@ -238,6 +239,7 @@ function GalleryScreen() {
|
|
|
238
239
|
const [page, setPage] = useState(0);
|
|
239
240
|
const [menuSort, setMenuSort] = useState<"newest" | "oldest">("newest");
|
|
240
241
|
const [picked, setPicked] = useState(2);
|
|
242
|
+
const [dose, setDose] = useState(1);
|
|
241
243
|
const scheme = useScheme();
|
|
242
244
|
|
|
243
245
|
return (
|
|
@@ -770,6 +772,24 @@ function GalleryScreen() {
|
|
|
770
772
|
</View>
|
|
771
773
|
</Section>
|
|
772
774
|
|
|
775
|
+
<Section title="Stepper">
|
|
776
|
+
{/* Minus is disabled at `min` (1 here), plus at `max` (6). */}
|
|
777
|
+
<View className="flex-row items-center justify-between rounded-lg bg-surface px-4 py-3">
|
|
778
|
+
<GalleryText>Tablets</GalleryText>
|
|
779
|
+
<Stepper
|
|
780
|
+
testID="stepper-dose"
|
|
781
|
+
value={dose}
|
|
782
|
+
onChange={setDose}
|
|
783
|
+
min={1}
|
|
784
|
+
max={6}
|
|
785
|
+
decrementLabel="Take one fewer"
|
|
786
|
+
incrementLabel="Take one more"
|
|
787
|
+
valueLabel={`${dose} tablets`}
|
|
788
|
+
/>
|
|
789
|
+
</View>
|
|
790
|
+
<GalleryText testID="stepper-dose-value">{`Dose: ${dose}`}</GalleryText>
|
|
791
|
+
</Section>
|
|
792
|
+
|
|
773
793
|
{/* The full chat screen, with the composer and keyboard, is `AiChatGallery` (`@vvedantb/native-ui/ai-gallery`). */}
|
|
774
794
|
<Section title="AI chat">
|
|
775
795
|
<AiChatSamples />
|
package/src/index.ts
CHANGED
|
@@ -76,6 +76,8 @@ export { PageIndicator } from "./PageIndicator";
|
|
|
76
76
|
export type { PageIndicatorProps } from "./PageIndicator";
|
|
77
77
|
export { IconButton } from "./IconButton";
|
|
78
78
|
export type { IconButtonProps, IconButtonSize, IconButtonVariant } from "./IconButton";
|
|
79
|
+
export { Stepper } from "./Stepper";
|
|
80
|
+
export type { StepperProps } from "./Stepper";
|
|
79
81
|
export { CaptureButton } from "./CaptureButton";
|
|
80
82
|
export type { CaptureButtonProps } from "./CaptureButton";
|
|
81
83
|
export { Separator } from "./Separator";
|