@vvedantb/native-ui 0.24.0 → 0.24.1
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/CaptureButton.jsx +67 -46
- package/dist/Chip.jsx +42 -34
- package/dist/ColorSwatches.jsx +169 -45
- package/dist/Dialog.jsx +16 -3
- package/dist/FloatingFAB.jsx +71 -55
- package/dist/IconButton.jsx +62 -48
- package/dist/PinnedBotTile.jsx +87 -72
- package/dist/SearchInput.jsx +313 -50
- package/dist/ai/card-button.jsx +116 -147
- package/dist/ai/file-chip.jsx +46 -22
- package/dist/pressScale.js +131 -0
- package/dist/primitives/select.jsx +5 -1
- package/package.json +1 -1
- package/src/CaptureButton.tsx +15 -9
- package/src/Chip.tsx +9 -4
- package/src/ColorSwatches.tsx +74 -29
- package/src/Dialog.tsx +16 -7
- package/src/FloatingFAB.tsx +20 -13
- package/src/IconButton.tsx +8 -6
- package/src/PinnedBotTile.tsx +9 -5
- package/src/SearchInput.tsx +40 -12
- package/src/ai/card-button.tsx +17 -11
- package/src/ai/file-chip.tsx +13 -4
- package/src/pressScale.ts +72 -0
- package/src/primitives/select.tsx +7 -2
package/dist/ai/file-chip.jsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
3
|
import { IconFile } from "@tabler/icons-react-native";
|
|
4
4
|
import { cn } from "../cn";
|
|
5
5
|
import { MIN_TOUCH_TARGET, sizeStyle, textStyle, touchSlop } from "../controlStyles";
|
|
6
|
+
import { AnimatedPressable, usePressScale } from "../pressScale";
|
|
6
7
|
import { palette } from "../palette";
|
|
7
8
|
import { useLargerText } from "../theme";
|
|
8
9
|
import { tokens } from "../tokens";
|
|
@@ -142,7 +143,7 @@ function FileChipLabel(t0) {
|
|
|
142
143
|
* otherwise. Long names are cut in the middle, so the extension shows.
|
|
143
144
|
*/
|
|
144
145
|
export function FileChip(t0) {
|
|
145
|
-
const $ = _c(
|
|
146
|
+
const $ = _c(6);
|
|
146
147
|
const {
|
|
147
148
|
name,
|
|
148
149
|
path,
|
|
@@ -160,39 +161,62 @@ export function FileChip(t0) {
|
|
|
160
161
|
return t1;
|
|
161
162
|
}
|
|
162
163
|
let t1;
|
|
163
|
-
if ($[2]
|
|
164
|
+
if ($[2] !== name || $[3] !== onOpenFile || $[4] !== path) {
|
|
165
|
+
t1 = <FileChipButton name={name} path={path} onOpenFile={onOpenFile} />;
|
|
166
|
+
$[2] = name;
|
|
167
|
+
$[3] = onOpenFile;
|
|
168
|
+
$[4] = path;
|
|
169
|
+
$[5] = t1;
|
|
170
|
+
} else {
|
|
171
|
+
t1 = $[5];
|
|
172
|
+
}
|
|
173
|
+
return t1;
|
|
174
|
+
}
|
|
175
|
+
function FileChipButton(t0) {
|
|
176
|
+
const $ = _c(14);
|
|
177
|
+
const {
|
|
178
|
+
name,
|
|
179
|
+
path,
|
|
180
|
+
onOpenFile
|
|
181
|
+
} = t0;
|
|
182
|
+
const press = usePressScale();
|
|
183
|
+
let t1;
|
|
184
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
164
185
|
t1 = touchSlop(MIN_TOUCH_TARGET, CHIP_HEIGHT);
|
|
165
|
-
$[
|
|
186
|
+
$[0] = t1;
|
|
166
187
|
} else {
|
|
167
|
-
t1 = $[
|
|
188
|
+
t1 = $[0];
|
|
168
189
|
}
|
|
169
190
|
let t2;
|
|
170
|
-
if ($[
|
|
191
|
+
if ($[1] !== onOpenFile || $[2] !== path) {
|
|
171
192
|
t2 = () => onOpenFile(path);
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
193
|
+
$[1] = onOpenFile;
|
|
194
|
+
$[2] = path;
|
|
195
|
+
$[3] = t2;
|
|
175
196
|
} else {
|
|
176
|
-
t2 = $[
|
|
197
|
+
t2 = $[3];
|
|
177
198
|
}
|
|
178
199
|
let t3;
|
|
179
|
-
if ($[
|
|
200
|
+
if ($[4] !== name) {
|
|
180
201
|
t3 = <FileChipLabel name={name} />;
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
202
|
+
$[4] = name;
|
|
203
|
+
$[5] = t3;
|
|
183
204
|
} else {
|
|
184
|
-
t3 = $[
|
|
205
|
+
t3 = $[5];
|
|
185
206
|
}
|
|
186
207
|
let t4;
|
|
187
|
-
if ($[
|
|
188
|
-
t4 = <
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
208
|
+
if ($[6] !== name || $[7] !== path || $[8] !== press.onPressIn || $[9] !== press.onPressOut || $[10] !== press.style || $[11] !== t2 || $[12] !== t3) {
|
|
209
|
+
t4 = <AnimatedPressable accessibilityRole="button" accessibilityLabel={name} accessibilityHint={path} hitSlop={t1} onPress={t2} onPressIn={press.onPressIn} onPressOut={press.onPressOut} style={press.style} className="min-w-0 max-w-full">{t3}</AnimatedPressable>;
|
|
210
|
+
$[6] = name;
|
|
211
|
+
$[7] = path;
|
|
212
|
+
$[8] = press.onPressIn;
|
|
213
|
+
$[9] = press.onPressOut;
|
|
214
|
+
$[10] = press.style;
|
|
215
|
+
$[11] = t2;
|
|
216
|
+
$[12] = t3;
|
|
217
|
+
$[13] = t4;
|
|
194
218
|
} else {
|
|
195
|
-
t4 = $[
|
|
219
|
+
t4 = $[13];
|
|
196
220
|
}
|
|
197
221
|
return t4;
|
|
198
222
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { cssInterop } from "nativewind";
|
|
3
|
+
import { useCallback, useEffect } from "react";
|
|
4
|
+
import { Pressable } from "react-native";
|
|
5
|
+
import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
6
|
+
import { EASE_OUT } from "./motion";
|
|
7
|
+
import { useReduceMotion } from "./useReduceMotion";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A `Pressable` whose `style` can take the style from `usePressScale`.
|
|
11
|
+
* NativeWind maps `className` only for components it knows, so it is told
|
|
12
|
+
* about this one, or the classes would be dropped.
|
|
13
|
+
*/
|
|
14
|
+
export const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
15
|
+
cssInterop(AnimatedPressable, {
|
|
16
|
+
className: "style"
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Press feedback for a small control: a scale and a light dim that ease in on
|
|
20
|
+
* press-in and ease back on release. Pass `onPressIn` and `onPressOut` to the
|
|
21
|
+
* `Pressable` and `style` to the animated view that should scale (an
|
|
22
|
+
* `AnimatedPressable`, or an `Animated.View` inside the `Pressable`). One
|
|
23
|
+
* shared value on the UI thread drives transform and opacity only. A new press
|
|
24
|
+
* or release starts from the current value, so a fast tap never sticks. With
|
|
25
|
+
* Reduce Motion nothing animates and nothing scales: the dim switches on and
|
|
26
|
+
* off at once.
|
|
27
|
+
*/
|
|
28
|
+
export function usePressScale(t0) {
|
|
29
|
+
const $ = _c(18);
|
|
30
|
+
let t1;
|
|
31
|
+
if ($[0] !== t0) {
|
|
32
|
+
t1 = t0 === undefined ? {} : t0;
|
|
33
|
+
$[0] = t0;
|
|
34
|
+
$[1] = t1;
|
|
35
|
+
} else {
|
|
36
|
+
t1 = $[1];
|
|
37
|
+
}
|
|
38
|
+
const {
|
|
39
|
+
scale: t2,
|
|
40
|
+
dim: t3,
|
|
41
|
+
reducedDim: t4,
|
|
42
|
+
restOpacity: t5,
|
|
43
|
+
pressInMs: t6,
|
|
44
|
+
pressOutMs: t7,
|
|
45
|
+
disabled: t8
|
|
46
|
+
} = t1;
|
|
47
|
+
const scale = t2 === undefined ? 0.97 : t2;
|
|
48
|
+
const dim = t3 === undefined ? 0.7 : t3;
|
|
49
|
+
const reducedDim = t4 === undefined ? dim : t4;
|
|
50
|
+
const restOpacity = t5 === undefined ? 1 : t5;
|
|
51
|
+
const pressInMs = t6 === undefined ? 120 : t6;
|
|
52
|
+
const pressOutMs = t7 === undefined ? 160 : t7;
|
|
53
|
+
const disabled = t8 === undefined ? false : t8;
|
|
54
|
+
const reduceMotion = useReduceMotion();
|
|
55
|
+
const progress = useSharedValue(0);
|
|
56
|
+
const target = reduceMotion ? reducedDim : dim;
|
|
57
|
+
let t9;
|
|
58
|
+
if ($[2] !== pressInMs || $[3] !== progress || $[4] !== reduceMotion) {
|
|
59
|
+
t9 = () => {
|
|
60
|
+
progress.set(reduceMotion ? 1 : withTiming(1, {
|
|
61
|
+
duration: pressInMs,
|
|
62
|
+
easing: EASE_OUT
|
|
63
|
+
}));
|
|
64
|
+
};
|
|
65
|
+
$[2] = pressInMs;
|
|
66
|
+
$[3] = progress;
|
|
67
|
+
$[4] = reduceMotion;
|
|
68
|
+
$[5] = t9;
|
|
69
|
+
} else {
|
|
70
|
+
t9 = $[5];
|
|
71
|
+
}
|
|
72
|
+
const onPressIn = t9;
|
|
73
|
+
let t10;
|
|
74
|
+
if ($[6] !== pressOutMs || $[7] !== progress || $[8] !== reduceMotion) {
|
|
75
|
+
t10 = () => {
|
|
76
|
+
progress.set(reduceMotion ? 0 : withTiming(0, {
|
|
77
|
+
duration: pressOutMs,
|
|
78
|
+
easing: EASE_OUT
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
81
|
+
$[6] = pressOutMs;
|
|
82
|
+
$[7] = progress;
|
|
83
|
+
$[8] = reduceMotion;
|
|
84
|
+
$[9] = t10;
|
|
85
|
+
} else {
|
|
86
|
+
t10 = $[9];
|
|
87
|
+
}
|
|
88
|
+
const onPressOut = t10;
|
|
89
|
+
let t11;
|
|
90
|
+
let t12;
|
|
91
|
+
if ($[10] !== disabled || $[11] !== progress) {
|
|
92
|
+
t11 = () => {
|
|
93
|
+
if (disabled) {
|
|
94
|
+
progress.set(0);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
t12 = [disabled, progress];
|
|
98
|
+
$[10] = disabled;
|
|
99
|
+
$[11] = progress;
|
|
100
|
+
$[12] = t11;
|
|
101
|
+
$[13] = t12;
|
|
102
|
+
} else {
|
|
103
|
+
t11 = $[12];
|
|
104
|
+
t12 = $[13];
|
|
105
|
+
}
|
|
106
|
+
useEffect(t11, t12);
|
|
107
|
+
const style = useAnimatedStyle(() => {
|
|
108
|
+
const p = progress.get();
|
|
109
|
+
return {
|
|
110
|
+
opacity: restOpacity * (1 - p * (1 - target)),
|
|
111
|
+
transform: [{
|
|
112
|
+
scale: reduceMotion ? 1 : 1 - p * (1 - scale)
|
|
113
|
+
}]
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
let t13;
|
|
117
|
+
if ($[14] !== onPressIn || $[15] !== onPressOut || $[16] !== style) {
|
|
118
|
+
t13 = {
|
|
119
|
+
style,
|
|
120
|
+
onPressIn,
|
|
121
|
+
onPressOut
|
|
122
|
+
};
|
|
123
|
+
$[14] = onPressIn;
|
|
124
|
+
$[15] = onPressOut;
|
|
125
|
+
$[16] = style;
|
|
126
|
+
$[17] = t13;
|
|
127
|
+
} else {
|
|
128
|
+
t13 = $[17];
|
|
129
|
+
}
|
|
130
|
+
return t13;
|
|
131
|
+
}
|
|
@@ -6,6 +6,7 @@ import { IconCheck, IconChevronDown, IconChevronUp } from "@tabler/icons-react-n
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import { Platform, ScrollView, StyleSheet, Text, View } from "react-native";
|
|
8
8
|
import { FadeIn, FadeOut } from "react-native-reanimated";
|
|
9
|
+
import { EASE_OUT } from "../motion";
|
|
9
10
|
import { NativeOnlyAnimatedView } from "./native-only-animated-view";
|
|
10
11
|
import { SelectHost } from "./select-host";
|
|
11
12
|
import { TextClassContext } from "./text";
|
|
@@ -155,6 +156,9 @@ const SelectTrigger = React.forwardRef((t0, ref) => {
|
|
|
155
156
|
}
|
|
156
157
|
return t8;
|
|
157
158
|
});
|
|
159
|
+
/** The popover fades in and out on the strong ease-out. */
|
|
160
|
+
const SELECT_ENTER = FadeIn.duration(150).easing(EASE_OUT);
|
|
161
|
+
const SELECT_EXIT = FadeOut.duration(100).easing(EASE_OUT);
|
|
158
162
|
const SelectContent = React.forwardRef((t0, ref) => {
|
|
159
163
|
const $ = _c(31);
|
|
160
164
|
let children;
|
|
@@ -252,7 +256,7 @@ const SelectContent = React.forwardRef((t0, ref) => {
|
|
|
252
256
|
}
|
|
253
257
|
let t11;
|
|
254
258
|
if ($[18] !== position || $[19] !== props || $[20] !== ref || $[21] !== t4 || $[22] !== t9) {
|
|
255
|
-
t11 = <SelectPrimitive.Overlay style={overlayFill}><TextClassContext.Provider value="text-popover-foreground"><NativeOnlyAnimatedView entering={
|
|
259
|
+
t11 = <SelectPrimitive.Overlay style={overlayFill}><TextClassContext.Provider value="text-popover-foreground"><NativeOnlyAnimatedView entering={SELECT_ENTER} exiting={SELECT_EXIT} className="z-50" style={overlayFill} pointerEvents={t3}><SelectPrimitive.Content ref={ref} position={position} className={t4} {...props}>{t5}{t6}{t9}{t10}</SelectPrimitive.Content></NativeOnlyAnimatedView></TextClassContext.Provider></SelectPrimitive.Overlay>;
|
|
256
260
|
$[18] = position;
|
|
257
261
|
$[19] = props;
|
|
258
262
|
$[20] = ref;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.24.
|
|
3
|
+
"version": "0.24.1",
|
|
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",
|
package/src/CaptureButton.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { Pressable
|
|
1
|
+
import { Pressable } from "react-native";
|
|
2
|
+
import Animated from "react-native-reanimated";
|
|
2
3
|
import { cn } from "./cn";
|
|
4
|
+
import { usePressScale } from "./pressScale";
|
|
3
5
|
import { withAlpha } from "./palette";
|
|
4
6
|
import { tokens } from "./tokens";
|
|
5
7
|
|
|
@@ -16,7 +18,8 @@ export const CAPTURE_BUTTON = { size: 76, ring: 4, gap: 4 } as const;
|
|
|
16
18
|
|
|
17
19
|
/**
|
|
18
20
|
* A camera shutter: a 76 white ring around a white disc, for a live preview in
|
|
19
|
-
* light and dark alike. The disc
|
|
21
|
+
* light and dark alike. The disc eases down to 90% in 100 ms while pressed
|
|
22
|
+
* and back in 160 ms; with Reduce Motion it dims instead. Larger than the
|
|
20
23
|
* 44 target, so it needs no hit slop. A labelled button, dimmed and ignoring
|
|
21
24
|
* presses when `disabled`.
|
|
22
25
|
*/
|
|
@@ -28,6 +31,7 @@ export function CaptureButton({
|
|
|
28
31
|
}: CaptureButtonProps) {
|
|
29
32
|
const { size, ring, gap } = CAPTURE_BUTTON;
|
|
30
33
|
const inner = size - 2 * (ring + gap);
|
|
34
|
+
const press = usePressScale({ scale: 0.9, dim: 1, reducedDim: 0.7, pressInMs: 100, disabled });
|
|
31
35
|
return (
|
|
32
36
|
<Pressable
|
|
33
37
|
testID={testID}
|
|
@@ -36,6 +40,8 @@ export function CaptureButton({
|
|
|
36
40
|
accessibilityState={{ disabled }}
|
|
37
41
|
disabled={disabled}
|
|
38
42
|
onPress={onPress}
|
|
43
|
+
onPressIn={press.onPressIn}
|
|
44
|
+
onPressOut={press.onPressOut}
|
|
39
45
|
className={cn("items-center justify-center", disabled && "opacity-50")}
|
|
40
46
|
style={{
|
|
41
47
|
width: size,
|
|
@@ -46,17 +52,17 @@ export function CaptureButton({
|
|
|
46
52
|
backgroundColor: withAlpha(tokens.color.black, 0.15),
|
|
47
53
|
}}
|
|
48
54
|
>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
<Animated.View
|
|
56
|
+
style={[
|
|
57
|
+
{
|
|
52
58
|
width: inner,
|
|
53
59
|
height: inner,
|
|
54
60
|
borderRadius: inner / 2,
|
|
55
61
|
backgroundColor: tokens.color.white,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
},
|
|
63
|
+
press.style,
|
|
64
|
+
]}
|
|
65
|
+
/>
|
|
60
66
|
</Pressable>
|
|
61
67
|
);
|
|
62
68
|
}
|
package/src/Chip.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Text } from "react-native";
|
|
2
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
2
3
|
import { textStyle, typeStyle } from "./controlStyles";
|
|
3
4
|
import { useLargerText } from "./theme";
|
|
4
5
|
import { useScheme } from "./useScheme";
|
|
@@ -18,6 +19,7 @@ export function Chip({
|
|
|
18
19
|
}) {
|
|
19
20
|
const largerText = useLargerText();
|
|
20
21
|
const scheme = useScheme();
|
|
22
|
+
const press = usePressScale();
|
|
21
23
|
const size = round
|
|
22
24
|
? largerText
|
|
23
25
|
? "h-14 w-14"
|
|
@@ -26,13 +28,16 @@ export function Chip({
|
|
|
26
28
|
? "min-h-14 px-5 py-3"
|
|
27
29
|
: "min-h-12 px-4 py-2";
|
|
28
30
|
return (
|
|
29
|
-
<
|
|
31
|
+
<AnimatedPressable
|
|
30
32
|
testID={testID}
|
|
31
33
|
accessibilityRole="button"
|
|
32
34
|
accessibilityLabel={label}
|
|
33
35
|
accessibilityState={{ selected }}
|
|
34
36
|
onPress={onPress}
|
|
35
|
-
|
|
37
|
+
onPressIn={press.onPressIn}
|
|
38
|
+
onPressOut={press.onPressOut}
|
|
39
|
+
style={press.style}
|
|
40
|
+
className={`items-center justify-center rounded-full border border-white/40 dark:border-white/10 ${
|
|
36
41
|
size
|
|
37
42
|
} ${selected ? "bg-pink-100 dark:bg-pink-900/40" : "bg-secondary"}`}
|
|
38
43
|
>
|
|
@@ -46,6 +51,6 @@ export function Chip({
|
|
|
46
51
|
>
|
|
47
52
|
{label}
|
|
48
53
|
</Text>
|
|
49
|
-
</
|
|
54
|
+
</AnimatedPressable>
|
|
50
55
|
);
|
|
51
56
|
}
|
package/src/ColorSwatches.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { View } from "react-native";
|
|
2
2
|
import { IconCheck } from "@tabler/icons-react-native";
|
|
3
3
|
import { cn } from "./cn";
|
|
4
4
|
import { touchSlop } from "./controlStyles";
|
|
5
5
|
import { selectionHaptic } from "./haptics";
|
|
6
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
6
7
|
import { withAlpha } from "./palette";
|
|
7
8
|
import { useLargerText } from "./theme";
|
|
8
9
|
import { tokens } from "./tokens";
|
|
@@ -91,43 +92,87 @@ export function ColorSwatches({
|
|
|
91
92
|
const isSelected = color.toLowerCase() === selected;
|
|
92
93
|
const check = isSelected ? swatchCheckColor(color) : null;
|
|
93
94
|
return (
|
|
94
|
-
<
|
|
95
|
+
<Swatch
|
|
95
96
|
key={`${color}-${index}`}
|
|
96
97
|
testID={testID ? `${testID}-${index}` : undefined}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
label={labels?.[index] ?? color}
|
|
99
|
+
color={color}
|
|
100
|
+
selected={isSelected}
|
|
101
|
+
check={check}
|
|
101
102
|
disabled={disabled}
|
|
103
|
+
diameter={diameter}
|
|
104
|
+
outer={outer}
|
|
102
105
|
onPress={() => {
|
|
103
106
|
selectionHaptic();
|
|
104
107
|
onChange(color);
|
|
105
108
|
}}
|
|
106
|
-
|
|
107
|
-
style={{
|
|
108
|
-
width: outer,
|
|
109
|
-
height: outer,
|
|
110
|
-
borderRadius: outer / 2,
|
|
111
|
-
borderWidth: RING,
|
|
112
|
-
borderColor: isSelected ? tokens.color.foreground[scheme] : "transparent",
|
|
113
|
-
}}
|
|
114
|
-
>
|
|
115
|
-
<View
|
|
116
|
-
className="items-center justify-center"
|
|
117
|
-
style={{
|
|
118
|
-
width: diameter,
|
|
119
|
-
height: diameter,
|
|
120
|
-
borderRadius: diameter / 2,
|
|
121
|
-
backgroundColor: color,
|
|
122
|
-
borderWidth: 1,
|
|
123
|
-
borderColor: withAlpha(tokens.color.foreground[scheme], 0.12),
|
|
124
|
-
}}
|
|
125
|
-
>
|
|
126
|
-
{check ? <IconCheck size={Math.round(diameter / 2)} color={check} strokeWidth={2} /> : null}
|
|
127
|
-
</View>
|
|
128
|
-
</Pressable>
|
|
109
|
+
/>
|
|
129
110
|
);
|
|
130
111
|
})}
|
|
131
112
|
</View>
|
|
132
113
|
);
|
|
133
114
|
}
|
|
115
|
+
|
|
116
|
+
/** One swatch: a radio that scales a little on press. The slop does not scale. */
|
|
117
|
+
function Swatch({
|
|
118
|
+
testID,
|
|
119
|
+
label,
|
|
120
|
+
color,
|
|
121
|
+
selected,
|
|
122
|
+
check,
|
|
123
|
+
disabled,
|
|
124
|
+
diameter,
|
|
125
|
+
outer,
|
|
126
|
+
onPress,
|
|
127
|
+
}: {
|
|
128
|
+
testID?: string;
|
|
129
|
+
label: string;
|
|
130
|
+
color: string;
|
|
131
|
+
selected: boolean;
|
|
132
|
+
check: string | null;
|
|
133
|
+
disabled: boolean;
|
|
134
|
+
diameter: number;
|
|
135
|
+
outer: number;
|
|
136
|
+
onPress: () => void;
|
|
137
|
+
}) {
|
|
138
|
+
const scheme = useScheme();
|
|
139
|
+
const press = usePressScale({ disabled });
|
|
140
|
+
return (
|
|
141
|
+
<AnimatedPressable
|
|
142
|
+
testID={testID}
|
|
143
|
+
accessibilityRole="radio"
|
|
144
|
+
accessibilityLabel={label}
|
|
145
|
+
accessibilityState={{ checked: selected, disabled }}
|
|
146
|
+
hitSlop={touchSlop(outer)}
|
|
147
|
+
disabled={disabled}
|
|
148
|
+
onPress={onPress}
|
|
149
|
+
onPressIn={press.onPressIn}
|
|
150
|
+
onPressOut={press.onPressOut}
|
|
151
|
+
className="items-center justify-center"
|
|
152
|
+
style={[
|
|
153
|
+
{
|
|
154
|
+
width: outer,
|
|
155
|
+
height: outer,
|
|
156
|
+
borderRadius: outer / 2,
|
|
157
|
+
borderWidth: RING,
|
|
158
|
+
borderColor: selected ? tokens.color.foreground[scheme] : "transparent",
|
|
159
|
+
},
|
|
160
|
+
press.style,
|
|
161
|
+
]}
|
|
162
|
+
>
|
|
163
|
+
<View
|
|
164
|
+
className="items-center justify-center"
|
|
165
|
+
style={{
|
|
166
|
+
width: diameter,
|
|
167
|
+
height: diameter,
|
|
168
|
+
borderRadius: diameter / 2,
|
|
169
|
+
backgroundColor: color,
|
|
170
|
+
borderWidth: 1,
|
|
171
|
+
borderColor: withAlpha(tokens.color.foreground[scheme], 0.12),
|
|
172
|
+
}}
|
|
173
|
+
>
|
|
174
|
+
{check ? <IconCheck size={Math.round(diameter / 2)} color={check} strokeWidth={2} /> : null}
|
|
175
|
+
</View>
|
|
176
|
+
</AnimatedPressable>
|
|
177
|
+
);
|
|
178
|
+
}
|
package/src/Dialog.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
|
10
10
|
import { IconX } from "@tabler/icons-react-native";
|
|
11
11
|
import { FloatingSurface } from "./FloatingSurface";
|
|
12
12
|
import { cn } from "./cn";
|
|
13
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
13
14
|
import { isCompactOverlay, textStyle, typeStyle } from "./controlStyles";
|
|
14
15
|
import { DialogLayoutContext, useDialogLayout, type DialogLayout } from "./dialogLayout";
|
|
15
16
|
import { palette } from "./palette";
|
|
@@ -162,14 +163,22 @@ function DialogHandle() {
|
|
|
162
163
|
function DialogCloseButton() {
|
|
163
164
|
const largerText = useLargerText();
|
|
164
165
|
const scheme = useScheme();
|
|
166
|
+
const press = usePressScale();
|
|
167
|
+
// `asChild`: the close press goes into this animated `Pressable`, so the
|
|
168
|
+
// button scales while `overlay.tsx` stays as it is.
|
|
165
169
|
return (
|
|
166
|
-
<DialogClose
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
<DialogClose asChild>
|
|
171
|
+
<AnimatedPressable
|
|
172
|
+
testID="dialog-close"
|
|
173
|
+
accessibilityLabel="Close"
|
|
174
|
+
hitSlop={8}
|
|
175
|
+
onPressIn={press.onPressIn}
|
|
176
|
+
onPressOut={press.onPressOut}
|
|
177
|
+
style={press.style}
|
|
178
|
+
className="absolute right-2 top-2 h-11 w-11 items-center justify-center rounded-lg"
|
|
179
|
+
>
|
|
180
|
+
<IconX size={largerText ? 26 : 16} color={tokens.color.muted[scheme]} />
|
|
181
|
+
</AnimatedPressable>
|
|
173
182
|
</DialogClose>
|
|
174
183
|
);
|
|
175
184
|
}
|
package/src/FloatingFAB.tsx
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import { Platform,
|
|
2
|
+
import { Platform, View } from "react-native";
|
|
3
3
|
import { cn } from "./cn";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { FloatingSurface } from "./FloatingSurface";
|
|
6
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
6
7
|
import { useAccentColor, useLargerText } from "./theme";
|
|
7
8
|
import {
|
|
8
9
|
FLOATING_INSET,
|
|
@@ -24,6 +25,7 @@ export function FloatingFAB({
|
|
|
24
25
|
const insets = useSafeAreaInsets();
|
|
25
26
|
const largerText = useLargerText();
|
|
26
27
|
const accentColor = useAccentColor();
|
|
28
|
+
const press = usePressScale({ scale: 0.95 });
|
|
27
29
|
const size = largerText ? 64 : 56;
|
|
28
30
|
const tabBar = largerText
|
|
29
31
|
? FLOATING_TAB_BAR_HEIGHT_LARGE
|
|
@@ -39,24 +41,29 @@ export function FloatingFAB({
|
|
|
39
41
|
}}
|
|
40
42
|
>
|
|
41
43
|
<FloatingSurface radius={size / 2} blur={false}>
|
|
42
|
-
<
|
|
44
|
+
<AnimatedPressable
|
|
43
45
|
testID={testID}
|
|
44
46
|
accessibilityRole="button"
|
|
45
47
|
accessibilityLabel={label}
|
|
46
48
|
onPress={onPress}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
style
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
onPressIn={press.onPressIn}
|
|
50
|
+
onPressOut={press.onPressOut}
|
|
51
|
+
// Layout in `style` and no `className`: NativeWind drops a function
|
|
52
|
+
// `style` next to a `className`, and the press scale and dim come
|
|
53
|
+
// from the animated style, not a function style.
|
|
54
|
+
style={[
|
|
55
|
+
{
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
justifyContent: "center",
|
|
58
|
+
width: size,
|
|
59
|
+
height: size,
|
|
60
|
+
backgroundColor: accentColor,
|
|
61
|
+
},
|
|
62
|
+
press.style,
|
|
63
|
+
]}
|
|
57
64
|
>
|
|
58
65
|
{children}
|
|
59
|
-
</
|
|
66
|
+
</AnimatedPressable>
|
|
60
67
|
</FloatingSurface>
|
|
61
68
|
</View>
|
|
62
69
|
);
|
package/src/IconButton.tsx
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { ComponentType } from "react";
|
|
2
|
-
import { Pressable } from "react-native";
|
|
3
2
|
import type { IconProps } from "@tabler/icons-react-native";
|
|
4
|
-
import { cn } from "./cn";
|
|
5
3
|
import { touchSlop } from "./controlStyles";
|
|
4
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
6
5
|
import { withAlpha } from "./palette";
|
|
7
6
|
import { useLargerText } from "./theme";
|
|
8
7
|
import { tokens } from "./tokens";
|
|
@@ -69,8 +68,9 @@ export function IconButton({
|
|
|
69
68
|
const largerText = useLargerText();
|
|
70
69
|
const [diameter, iconSize] = METRICS[largerText ? "larger" : "regular"][size];
|
|
71
70
|
const { color, ...frame } = iconButtonColors(variant, scheme);
|
|
71
|
+
const press = usePressScale({ restOpacity: disabled ? 0.5 : 1, disabled });
|
|
72
72
|
return (
|
|
73
|
-
<
|
|
73
|
+
<AnimatedPressable
|
|
74
74
|
testID={testID}
|
|
75
75
|
accessibilityRole="button"
|
|
76
76
|
accessibilityLabel={label}
|
|
@@ -78,10 +78,12 @@ export function IconButton({
|
|
|
78
78
|
hitSlop={touchSlop(diameter)}
|
|
79
79
|
disabled={disabled}
|
|
80
80
|
onPress={onPress}
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
onPressIn={press.onPressIn}
|
|
82
|
+
onPressOut={press.onPressOut}
|
|
83
|
+
className="items-center justify-center"
|
|
84
|
+
style={[{ width: diameter, height: diameter, borderRadius: diameter / 2, borderWidth: 1, ...frame }, press.style]}
|
|
83
85
|
>
|
|
84
86
|
<Icon size={iconSize} color={iconColor ?? color} />
|
|
85
|
-
</
|
|
87
|
+
</AnimatedPressable>
|
|
86
88
|
);
|
|
87
89
|
}
|
package/src/PinnedBotTile.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Children, type ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { Text, View, type ViewProps } from "react-native";
|
|
3
3
|
import { cn } from "./cn";
|
|
4
4
|
import { cardStyle, textStyle, typeStyle } from "./controlStyles";
|
|
5
|
+
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
5
6
|
import { StatusDot } from "./StatusDot";
|
|
6
7
|
import { Spinner } from "./Spinner";
|
|
7
8
|
import { useLargerText } from "./theme";
|
|
@@ -31,16 +32,19 @@ export type PinnedBotTileProps = {
|
|
|
31
32
|
export function PinnedBotTile({ title, leading, unread = false, generating = false, onPress, onLongPress, testID }: PinnedBotTileProps) {
|
|
32
33
|
const scheme = useScheme();
|
|
33
34
|
const largerText = useLargerText();
|
|
35
|
+
const press = usePressScale();
|
|
34
36
|
const state = [unread ? "unread" : null, generating ? "generating" : null].filter(Boolean).join(", ");
|
|
35
37
|
return (
|
|
36
|
-
<
|
|
38
|
+
<AnimatedPressable
|
|
37
39
|
testID={testID}
|
|
38
40
|
accessibilityRole="button"
|
|
39
41
|
accessibilityLabel={state ? `${title}, ${state}` : title}
|
|
40
42
|
onPress={onPress}
|
|
41
43
|
onLongPress={onLongPress}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
onPressIn={press.onPressIn}
|
|
45
|
+
onPressOut={press.onPressOut}
|
|
46
|
+
className={cn("min-w-0 items-center justify-center gap-2 px-3 py-4", largerText ? "min-h-36" : "min-h-28")}
|
|
47
|
+
style={[cardStyle(scheme), press.style]}
|
|
44
48
|
>
|
|
45
49
|
{leading}
|
|
46
50
|
<Text
|
|
@@ -60,7 +64,7 @@ export function PinnedBotTile({ title, leading, unread = false, generating = fal
|
|
|
60
64
|
<Spinner size="sm" decorative />
|
|
61
65
|
</View>
|
|
62
66
|
) : null}
|
|
63
|
-
</
|
|
67
|
+
</AnimatedPressable>
|
|
64
68
|
);
|
|
65
69
|
}
|
|
66
70
|
|