@vvedantb/native-ui 0.40.0 → 0.42.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/Slider.jsx +180 -0
- package/dist/UpdateChecker.jsx +181 -123
- package/dist/ai/icon-button.jsx +1 -1
- package/dist/index.js +1 -0
- package/dist/sliderMath.js +16 -0
- package/dist/updateCheck.js +34 -5
- package/package.json +1 -1
- package/src/Slider.tsx +208 -0
- package/src/UpdateChecker.tsx +23 -1
- package/src/ai/icon-button.tsx +1 -1
- package/src/index.ts +2 -0
- package/src/sliderMath.ts +18 -0
- package/src/updateCheck.ts +38 -6
package/dist/Slider.jsx
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { PanResponder, View } from "react-native";
|
|
3
|
+
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated";
|
|
4
|
+
import { cn } from "./cn";
|
|
5
|
+
import { useGlass } from "./glass";
|
|
6
|
+
import { selectionHaptic } from "./haptics";
|
|
7
|
+
import { palette } from "./palette";
|
|
8
|
+
import { useControllableState } from "./primitives/use-controllable-state";
|
|
9
|
+
import { snapSliderValue, sliderPercent, sliderValueFromOffset } from "./sliderMath";
|
|
10
|
+
import { useAccentColor } from "./theme";
|
|
11
|
+
import { tokens } from "./tokens";
|
|
12
|
+
import { useReduceMotion } from "./useReduceMotion";
|
|
13
|
+
import { useScheme } from "./useScheme";
|
|
14
|
+
const THUMB_LONG = 32;
|
|
15
|
+
const THUMB_SHORT = 20;
|
|
16
|
+
const DRAG_SCALE = 1.45;
|
|
17
|
+
|
|
18
|
+
/** Track 6 thick, glass pill thumb 32 × 20. The thumb grows to 1.45× and turns translucent while dragged. `surface="flat"` drops the glass shadow. */
|
|
19
|
+
export function Slider({
|
|
20
|
+
value,
|
|
21
|
+
defaultValue = 0,
|
|
22
|
+
onValueChange,
|
|
23
|
+
onSlidingComplete,
|
|
24
|
+
min = 0,
|
|
25
|
+
max = 100,
|
|
26
|
+
step = 1,
|
|
27
|
+
disabled = false,
|
|
28
|
+
orientation = "horizontal",
|
|
29
|
+
className,
|
|
30
|
+
style,
|
|
31
|
+
...props
|
|
32
|
+
}) {
|
|
33
|
+
"use no memo";
|
|
34
|
+
|
|
35
|
+
// PanResponder reads a mutable gesture box that the compiler cannot model.
|
|
36
|
+
const vertical = orientation === "vertical";
|
|
37
|
+
const scheme = useScheme();
|
|
38
|
+
const accent = useAccentColor();
|
|
39
|
+
const glass = useGlass("small");
|
|
40
|
+
const reduceMotion = useReduceMotion();
|
|
41
|
+
const [current, setCurrent] = useControllableState({
|
|
42
|
+
value,
|
|
43
|
+
defaultValue,
|
|
44
|
+
onChange: onValueChange
|
|
45
|
+
});
|
|
46
|
+
const [length, setLength] = useState(0);
|
|
47
|
+
const [dragging, setDragging] = useState(false);
|
|
48
|
+
const scale = useSharedValue(1);
|
|
49
|
+
const [box] = useState(() => ({
|
|
50
|
+
min,
|
|
51
|
+
max,
|
|
52
|
+
step,
|
|
53
|
+
vertical,
|
|
54
|
+
disabled,
|
|
55
|
+
value: current,
|
|
56
|
+
length: 0,
|
|
57
|
+
setValue: setCurrent,
|
|
58
|
+
onSlidingComplete
|
|
59
|
+
}));
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
box.min = min;
|
|
62
|
+
box.max = max;
|
|
63
|
+
box.step = step;
|
|
64
|
+
box.vertical = vertical;
|
|
65
|
+
box.disabled = disabled;
|
|
66
|
+
box.value = current;
|
|
67
|
+
box.setValue = setCurrent;
|
|
68
|
+
box.onSlidingComplete = onSlidingComplete;
|
|
69
|
+
});
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
const target = dragging ? DRAG_SCALE : 1;
|
|
72
|
+
scale.set(reduceMotion ? target : withTiming(target, {
|
|
73
|
+
duration: 200,
|
|
74
|
+
easing: Easing.bezier(0.22, 1, 0.36, 1)
|
|
75
|
+
}));
|
|
76
|
+
}, [dragging, reduceMotion, scale]);
|
|
77
|
+
const [responder] = useState(() => {
|
|
78
|
+
const commit = offset => {
|
|
79
|
+
const next = snapSliderValue(sliderValueFromOffset(offset, box.length, box.min, box.max, box.vertical), box.min, box.max, box.step);
|
|
80
|
+
if (next === box.value) return;
|
|
81
|
+
box.value = next;
|
|
82
|
+
selectionHaptic();
|
|
83
|
+
box.setValue(next);
|
|
84
|
+
};
|
|
85
|
+
const offsetOf = event => box.vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX;
|
|
86
|
+
const finish = () => {
|
|
87
|
+
setDragging(false);
|
|
88
|
+
box.onSlidingComplete?.(box.value);
|
|
89
|
+
};
|
|
90
|
+
return PanResponder.create({
|
|
91
|
+
onStartShouldSetPanResponder: () => !box.disabled,
|
|
92
|
+
onMoveShouldSetPanResponder: () => !box.disabled,
|
|
93
|
+
onPanResponderTerminationRequest: () => false,
|
|
94
|
+
onPanResponderGrant: event_0 => {
|
|
95
|
+
setDragging(true);
|
|
96
|
+
commit(offsetOf(event_0));
|
|
97
|
+
},
|
|
98
|
+
onPanResponderMove: event_1 => commit(offsetOf(event_1)),
|
|
99
|
+
onPanResponderRelease: finish,
|
|
100
|
+
onPanResponderTerminate: finish
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
const onLayout = event_2 => {
|
|
104
|
+
const next_0 = vertical ? event_2.nativeEvent.layout.height : event_2.nativeEvent.layout.width;
|
|
105
|
+
box.length = next_0;
|
|
106
|
+
setLength(next_0);
|
|
107
|
+
};
|
|
108
|
+
const onAccessibilityAction = event_3 => {
|
|
109
|
+
const direction = event_3.nativeEvent.actionName === "increment" ? 1 : -1;
|
|
110
|
+
const next_1 = snapSliderValue(box.value + direction * (step > 0 ? step : (max - min) / 10), min, max, step);
|
|
111
|
+
if (next_1 === box.value) return;
|
|
112
|
+
box.value = next_1;
|
|
113
|
+
setCurrent(next_1);
|
|
114
|
+
onSlidingComplete?.(next_1);
|
|
115
|
+
};
|
|
116
|
+
const percent = sliderPercent(current, min, max);
|
|
117
|
+
const travel = Math.max(0, length - THUMB_LONG);
|
|
118
|
+
const thumbOffset = percent / 100 * travel;
|
|
119
|
+
const thumbW = vertical ? THUMB_SHORT : THUMB_LONG;
|
|
120
|
+
const thumbH = vertical ? THUMB_LONG : THUMB_SHORT;
|
|
121
|
+
const thumbStyle = useAnimatedStyle(() => ({
|
|
122
|
+
transform: [{
|
|
123
|
+
scale: scale.get()
|
|
124
|
+
}],
|
|
125
|
+
opacity: 1 - (scale.get() - 1) / (DRAG_SCALE - 1) * 0.15
|
|
126
|
+
}));
|
|
127
|
+
const trackColor = palette.default[scheme];
|
|
128
|
+
const thumbColor = scheme === "dark" ? tokens.color.foreground.dark : tokens.color.surface.light;
|
|
129
|
+
return <View accessibilityRole="adjustable" accessibilityState={{
|
|
130
|
+
disabled
|
|
131
|
+
}} accessibilityValue={{
|
|
132
|
+
min,
|
|
133
|
+
max,
|
|
134
|
+
now: current
|
|
135
|
+
}} accessibilityActions={[{
|
|
136
|
+
name: "increment"
|
|
137
|
+
}, {
|
|
138
|
+
name: "decrement"
|
|
139
|
+
}]} onAccessibilityAction={onAccessibilityAction} onLayout={onLayout} className={cn(vertical ? "h-full min-h-40 w-8 items-center" : "h-8 w-full justify-center", disabled && "opacity-50", className)} style={style} {...responder.panHandlers} {...props}>
|
|
140
|
+
<View pointerEvents="none" className="overflow-hidden rounded-full" style={{
|
|
141
|
+
backgroundColor: trackColor,
|
|
142
|
+
...(vertical ? {
|
|
143
|
+
width: 6,
|
|
144
|
+
height: "100%"
|
|
145
|
+
} : {
|
|
146
|
+
height: 6,
|
|
147
|
+
width: "100%"
|
|
148
|
+
})
|
|
149
|
+
}}>
|
|
150
|
+
<View style={{
|
|
151
|
+
position: "absolute",
|
|
152
|
+
backgroundColor: accent,
|
|
153
|
+
...(vertical ? {
|
|
154
|
+
bottom: 0,
|
|
155
|
+
left: 0,
|
|
156
|
+
right: 0,
|
|
157
|
+
height: `${percent}%`
|
|
158
|
+
} : {
|
|
159
|
+
left: 0,
|
|
160
|
+
top: 0,
|
|
161
|
+
bottom: 0,
|
|
162
|
+
width: `${percent}%`
|
|
163
|
+
})
|
|
164
|
+
}} />
|
|
165
|
+
</View>
|
|
166
|
+
<Animated.View pointerEvents="none" style={[{
|
|
167
|
+
position: "absolute",
|
|
168
|
+
width: thumbW,
|
|
169
|
+
height: thumbH,
|
|
170
|
+
borderRadius: 999,
|
|
171
|
+
backgroundColor: thumbColor,
|
|
172
|
+
...(vertical ? {
|
|
173
|
+
bottom: thumbOffset,
|
|
174
|
+
alignSelf: "center"
|
|
175
|
+
} : {
|
|
176
|
+
left: thumbOffset
|
|
177
|
+
})
|
|
178
|
+
}, glass, thumbStyle]} />
|
|
179
|
+
</View>;
|
|
180
|
+
}
|
package/dist/UpdateChecker.jsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from "react";
|
|
3
|
-
import { Linking } from "react-native";
|
|
3
|
+
import { Linking, View } from "react-native";
|
|
4
4
|
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle } from "./AlertDialog";
|
|
5
|
-
import { fetchGitHubUpdate, fetchVStoreUpdate } from "./updateCheck";
|
|
5
|
+
import { fetchGitHubUpdate, fetchVStoreUpdate, visibleReleaseNotes } from "./updateCheck";
|
|
6
6
|
|
|
7
7
|
/** Opens the Updates tab of V Store, the Project V Android app store. */
|
|
8
8
|
export const V_STORE_UPDATES_URL = "vstore://updates";
|
|
@@ -18,12 +18,15 @@ export const V_STORE_UPDATES_URL = "vstore://updates";
|
|
|
18
18
|
* not hidden up front: Android 11+ only reports another app's link as
|
|
19
19
|
* openable to an app that declares it in its manifest `<queries>`.
|
|
20
20
|
*
|
|
21
|
+
* Release notes: when the update has `notes`, a "What's new" list shows the
|
|
22
|
+
* first `maxNotes` (default 5) titles, then "and N more".
|
|
23
|
+
*
|
|
21
24
|
* Controlled: it is open while `update` is set. `UpdateChecker` runs the
|
|
22
25
|
* check and holds that state. It adds no motion of its own; the dialog's
|
|
23
26
|
* follows Reduce Motion.
|
|
24
27
|
*/
|
|
25
28
|
export function UpdatePrompt(t0) {
|
|
26
|
-
const $ = _c(
|
|
29
|
+
const $ = _c(74);
|
|
27
30
|
const {
|
|
28
31
|
update,
|
|
29
32
|
appName,
|
|
@@ -33,14 +36,16 @@ export function UpdatePrompt(t0) {
|
|
|
33
36
|
downloadLabel: t3,
|
|
34
37
|
vStoreLabel: t4,
|
|
35
38
|
vStoreMissingText: t5,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
notesLabel: t6,
|
|
40
|
+
maxNotes: t7,
|
|
41
|
+
showDownload: t8,
|
|
42
|
+
showVStore: t9,
|
|
43
|
+
vStoreUrl: t10,
|
|
39
44
|
onLater,
|
|
40
45
|
onDownload,
|
|
41
46
|
onOpenVStore,
|
|
42
47
|
onVStoreMissing,
|
|
43
|
-
openUrl:
|
|
48
|
+
openUrl: t11,
|
|
44
49
|
testID
|
|
45
50
|
} = t0;
|
|
46
51
|
const title = t1 === undefined ? "Update available" : t1;
|
|
@@ -48,91 +53,139 @@ export function UpdatePrompt(t0) {
|
|
|
48
53
|
const downloadLabel = t3 === undefined ? "Download" : t3;
|
|
49
54
|
const vStoreLabel = t4 === undefined ? "Install from V Store" : t4;
|
|
50
55
|
const vStoreMissingText = t5 === undefined ? "V Store is not installed on this device." : t5;
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
56
|
+
const notesLabel = t6 === undefined ? "What's new" : t6;
|
|
57
|
+
const maxNotes = t7 === undefined ? 5 : t7;
|
|
58
|
+
const showDownload = t8 === undefined ? true : t8;
|
|
59
|
+
const showVStore = t9 === undefined ? true : t9;
|
|
60
|
+
const vStoreUrl = t10 === undefined ? V_STORE_UPDATES_URL : t10;
|
|
61
|
+
const openUrl = t11 === undefined ? Linking.openURL : t11;
|
|
55
62
|
const [missingFor, setMissingFor] = useState(null);
|
|
56
63
|
const [shown, setShown] = useState(update);
|
|
57
64
|
if (update && update !== shown) {
|
|
58
65
|
setShown(update);
|
|
59
66
|
}
|
|
60
67
|
const vStoreMissing = shown !== null && missingFor === shown.version;
|
|
61
|
-
let
|
|
68
|
+
let t12;
|
|
62
69
|
if ($[0] !== appName || $[1] !== description || $[2] !== shown) {
|
|
63
|
-
|
|
70
|
+
t12 = shown === null ? null : typeof description === "function" ? description(shown) : description ?? `${appName} ${shown.version} is ready to install.`;
|
|
64
71
|
$[0] = appName;
|
|
65
72
|
$[1] = description;
|
|
66
73
|
$[2] = shown;
|
|
67
|
-
$[3] =
|
|
68
|
-
} else {
|
|
69
|
-
t10 = $[3];
|
|
70
|
-
}
|
|
71
|
-
const body = t10;
|
|
72
|
-
const t11 = update !== null;
|
|
73
|
-
let t12;
|
|
74
|
-
if ($[4] !== onLater || $[5] !== update) {
|
|
75
|
-
t12 = next => {
|
|
76
|
-
if (!next && update) {
|
|
77
|
-
onLater?.(update);
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
$[4] = onLater;
|
|
81
|
-
$[5] = update;
|
|
82
|
-
$[6] = t12;
|
|
74
|
+
$[3] = t12;
|
|
83
75
|
} else {
|
|
84
|
-
t12 = $[
|
|
76
|
+
t12 = $[3];
|
|
85
77
|
}
|
|
78
|
+
const body = t12;
|
|
79
|
+
let T0;
|
|
80
|
+
let T1;
|
|
81
|
+
let T2;
|
|
86
82
|
let t13;
|
|
87
|
-
if ($[7] !== title) {
|
|
88
|
-
t13 = <AlertDialogTitle>{title}</AlertDialogTitle>;
|
|
89
|
-
$[7] = title;
|
|
90
|
-
$[8] = t13;
|
|
91
|
-
} else {
|
|
92
|
-
t13 = $[8];
|
|
93
|
-
}
|
|
94
83
|
let t14;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
84
|
+
let t15;
|
|
85
|
+
let t16;
|
|
86
|
+
let t17;
|
|
87
|
+
let t18;
|
|
88
|
+
if ($[4] !== body || $[5] !== maxNotes || $[6] !== notesLabel || $[7] !== onLater || $[8] !== shown || $[9] !== testID || $[10] !== title || $[11] !== update) {
|
|
89
|
+
const notes = shown === null ? {
|
|
90
|
+
notes: [],
|
|
91
|
+
more: 0
|
|
92
|
+
} : visibleReleaseNotes(shown, maxNotes);
|
|
93
|
+
T2 = AlertDialog;
|
|
94
|
+
t17 = update !== null;
|
|
95
|
+
if ($[21] !== onLater || $[22] !== update) {
|
|
96
|
+
t18 = next => {
|
|
97
|
+
if (!next && update) {
|
|
98
|
+
onLater?.(update);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
$[21] = onLater;
|
|
102
|
+
$[22] = update;
|
|
103
|
+
$[23] = t18;
|
|
104
|
+
} else {
|
|
105
|
+
t18 = $[23];
|
|
106
|
+
}
|
|
107
|
+
T1 = AlertDialogContent;
|
|
108
|
+
t16 = testID;
|
|
109
|
+
T0 = AlertDialogHeader;
|
|
110
|
+
if ($[24] !== title) {
|
|
111
|
+
t13 = <AlertDialogTitle>{title}</AlertDialogTitle>;
|
|
112
|
+
$[24] = title;
|
|
113
|
+
$[25] = t13;
|
|
114
|
+
} else {
|
|
115
|
+
t13 = $[25];
|
|
116
|
+
}
|
|
117
|
+
if ($[26] !== body) {
|
|
118
|
+
t14 = body != null ? <AlertDialogDescription>{body}</AlertDialogDescription> : null;
|
|
119
|
+
$[26] = body;
|
|
120
|
+
$[27] = t14;
|
|
121
|
+
} else {
|
|
122
|
+
t14 = $[27];
|
|
123
|
+
}
|
|
124
|
+
t15 = notes.notes.length > 0 ? <View testID={testID ? `${testID}-notes` : undefined} className="gap-1 pt-2"><AlertDialogDescription className="font-instrument-sans-medium">{notesLabel}</AlertDialogDescription>{notes.notes.map(_temp)}{notes.more > 0 ? <AlertDialogDescription>{`\u2022 and ${notes.more} more`}</AlertDialogDescription> : null}</View> : null;
|
|
125
|
+
$[4] = body;
|
|
126
|
+
$[5] = maxNotes;
|
|
127
|
+
$[6] = notesLabel;
|
|
128
|
+
$[7] = onLater;
|
|
129
|
+
$[8] = shown;
|
|
130
|
+
$[9] = testID;
|
|
131
|
+
$[10] = title;
|
|
132
|
+
$[11] = update;
|
|
133
|
+
$[12] = T0;
|
|
134
|
+
$[13] = T1;
|
|
135
|
+
$[14] = T2;
|
|
136
|
+
$[15] = t13;
|
|
137
|
+
$[16] = t14;
|
|
138
|
+
$[17] = t15;
|
|
139
|
+
$[18] = t16;
|
|
140
|
+
$[19] = t17;
|
|
141
|
+
$[20] = t18;
|
|
99
142
|
} else {
|
|
100
|
-
|
|
143
|
+
T0 = $[12];
|
|
144
|
+
T1 = $[13];
|
|
145
|
+
T2 = $[14];
|
|
146
|
+
t13 = $[15];
|
|
147
|
+
t14 = $[16];
|
|
148
|
+
t15 = $[17];
|
|
149
|
+
t16 = $[18];
|
|
150
|
+
t17 = $[19];
|
|
151
|
+
t18 = $[20];
|
|
101
152
|
}
|
|
102
|
-
let
|
|
103
|
-
if ($[
|
|
104
|
-
|
|
105
|
-
$[
|
|
106
|
-
$[
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
153
|
+
let t19;
|
|
154
|
+
if ($[28] !== showVStore || $[29] !== testID || $[30] !== vStoreMissing || $[31] !== vStoreMissingText) {
|
|
155
|
+
t19 = showVStore && vStoreMissing ? <AlertDialogDescription testID={testID ? `${testID}-vstore-missing` : undefined} accessibilityLiveRegion="polite">{vStoreMissingText}</AlertDialogDescription> : null;
|
|
156
|
+
$[28] = showVStore;
|
|
157
|
+
$[29] = testID;
|
|
158
|
+
$[30] = vStoreMissing;
|
|
159
|
+
$[31] = vStoreMissingText;
|
|
160
|
+
$[32] = t19;
|
|
110
161
|
} else {
|
|
111
|
-
|
|
162
|
+
t19 = $[32];
|
|
112
163
|
}
|
|
113
|
-
let
|
|
114
|
-
if ($[
|
|
115
|
-
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
$[
|
|
119
|
-
$[
|
|
164
|
+
let t20;
|
|
165
|
+
if ($[33] !== T0 || $[34] !== t13 || $[35] !== t14 || $[36] !== t15 || $[37] !== t19) {
|
|
166
|
+
t20 = <T0>{t13}{t14}{t15}{t19}</T0>;
|
|
167
|
+
$[33] = T0;
|
|
168
|
+
$[34] = t13;
|
|
169
|
+
$[35] = t14;
|
|
170
|
+
$[36] = t15;
|
|
171
|
+
$[37] = t19;
|
|
172
|
+
$[38] = t20;
|
|
120
173
|
} else {
|
|
121
|
-
|
|
174
|
+
t20 = $[38];
|
|
122
175
|
}
|
|
123
|
-
const
|
|
124
|
-
let
|
|
125
|
-
if ($[
|
|
126
|
-
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
176
|
+
const t21 = testID ? `${testID}-later` : undefined;
|
|
177
|
+
let t22;
|
|
178
|
+
if ($[39] !== laterLabel || $[40] !== t21) {
|
|
179
|
+
t22 = <AlertDialogCancel size="lg" testID={t21}>{laterLabel}</AlertDialogCancel>;
|
|
180
|
+
$[39] = laterLabel;
|
|
181
|
+
$[40] = t21;
|
|
182
|
+
$[41] = t22;
|
|
130
183
|
} else {
|
|
131
|
-
|
|
184
|
+
t22 = $[41];
|
|
132
185
|
}
|
|
133
|
-
let
|
|
134
|
-
if ($[
|
|
135
|
-
|
|
186
|
+
let t23;
|
|
187
|
+
if ($[42] !== onOpenVStore || $[43] !== onVStoreMissing || $[44] !== openUrl || $[45] !== showDownload || $[46] !== showVStore || $[47] !== testID || $[48] !== update || $[49] !== vStoreLabel || $[50] !== vStoreMissing || $[51] !== vStoreUrl) {
|
|
188
|
+
t23 = showVStore && !vStoreMissing ? <AlertDialogAction size="lg" variant={showDownload ? "secondary" : "default"} testID={testID ? `${testID}-vstore` : undefined} onPress={() => {
|
|
136
189
|
if (!update) {
|
|
137
190
|
return;
|
|
138
191
|
}
|
|
@@ -141,74 +194,79 @@ export function UpdatePrompt(t0) {
|
|
|
141
194
|
onVStoreMissing?.(update);
|
|
142
195
|
});
|
|
143
196
|
}}>{vStoreLabel}</AlertDialogAction> : null;
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
150
|
-
$[
|
|
151
|
-
$[
|
|
152
|
-
$[
|
|
153
|
-
$[
|
|
154
|
-
$[
|
|
197
|
+
$[42] = onOpenVStore;
|
|
198
|
+
$[43] = onVStoreMissing;
|
|
199
|
+
$[44] = openUrl;
|
|
200
|
+
$[45] = showDownload;
|
|
201
|
+
$[46] = showVStore;
|
|
202
|
+
$[47] = testID;
|
|
203
|
+
$[48] = update;
|
|
204
|
+
$[49] = vStoreLabel;
|
|
205
|
+
$[50] = vStoreMissing;
|
|
206
|
+
$[51] = vStoreUrl;
|
|
207
|
+
$[52] = t23;
|
|
155
208
|
} else {
|
|
156
|
-
|
|
209
|
+
t23 = $[52];
|
|
157
210
|
}
|
|
158
|
-
let
|
|
159
|
-
if ($[
|
|
160
|
-
|
|
211
|
+
let t24;
|
|
212
|
+
if ($[53] !== downloadLabel || $[54] !== onDownload || $[55] !== openUrl || $[56] !== showDownload || $[57] !== testID || $[58] !== update) {
|
|
213
|
+
t24 = showDownload ? <AlertDialogAction size="lg" testID={testID ? `${testID}-download` : undefined} onPress={() => {
|
|
161
214
|
if (!update) {
|
|
162
215
|
return;
|
|
163
216
|
}
|
|
164
|
-
openUrl(update.url).catch(
|
|
217
|
+
openUrl(update.url).catch(_temp2);
|
|
165
218
|
onDownload?.(update);
|
|
166
219
|
}}>{downloadLabel}</AlertDialogAction> : null;
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
220
|
+
$[53] = downloadLabel;
|
|
221
|
+
$[54] = onDownload;
|
|
222
|
+
$[55] = openUrl;
|
|
223
|
+
$[56] = showDownload;
|
|
224
|
+
$[57] = testID;
|
|
225
|
+
$[58] = update;
|
|
226
|
+
$[59] = t24;
|
|
174
227
|
} else {
|
|
175
|
-
|
|
228
|
+
t24 = $[59];
|
|
176
229
|
}
|
|
177
|
-
let
|
|
178
|
-
if ($[
|
|
179
|
-
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
230
|
+
let t25;
|
|
231
|
+
if ($[60] !== t22 || $[61] !== t23 || $[62] !== t24) {
|
|
232
|
+
t25 = <AlertDialogFooter>{t22}{t23}{t24}</AlertDialogFooter>;
|
|
233
|
+
$[60] = t22;
|
|
234
|
+
$[61] = t23;
|
|
235
|
+
$[62] = t24;
|
|
236
|
+
$[63] = t25;
|
|
184
237
|
} else {
|
|
185
|
-
|
|
238
|
+
t25 = $[63];
|
|
186
239
|
}
|
|
187
|
-
let
|
|
188
|
-
if ($[
|
|
189
|
-
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
240
|
+
let t26;
|
|
241
|
+
if ($[64] !== T1 || $[65] !== t16 || $[66] !== t20 || $[67] !== t25) {
|
|
242
|
+
t26 = <T1 testID={t16}>{t20}{t25}</T1>;
|
|
243
|
+
$[64] = T1;
|
|
244
|
+
$[65] = t16;
|
|
245
|
+
$[66] = t20;
|
|
246
|
+
$[67] = t25;
|
|
247
|
+
$[68] = t26;
|
|
194
248
|
} else {
|
|
195
|
-
|
|
249
|
+
t26 = $[68];
|
|
196
250
|
}
|
|
197
|
-
let
|
|
198
|
-
if ($[
|
|
199
|
-
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
$[
|
|
203
|
-
$[
|
|
251
|
+
let t27;
|
|
252
|
+
if ($[69] !== T2 || $[70] !== t17 || $[71] !== t18 || $[72] !== t26) {
|
|
253
|
+
t27 = <T2 open={t17} onOpenChange={t18}>{t26}</T2>;
|
|
254
|
+
$[69] = T2;
|
|
255
|
+
$[70] = t17;
|
|
256
|
+
$[71] = t18;
|
|
257
|
+
$[72] = t26;
|
|
258
|
+
$[73] = t27;
|
|
204
259
|
} else {
|
|
205
|
-
|
|
260
|
+
t27 = $[73];
|
|
206
261
|
}
|
|
207
|
-
return
|
|
262
|
+
return t27;
|
|
208
263
|
}
|
|
209
264
|
|
|
210
265
|
/** Where "Later" is remembered, for example `expo-secure-store` or AsyncStorage. */
|
|
211
|
-
function
|
|
266
|
+
function _temp2() {}
|
|
267
|
+
function _temp(note, index) {
|
|
268
|
+
return <AlertDialogDescription key={`${index}-${note}`}>{`\u2022 ${note}`}</AlertDialogDescription>;
|
|
269
|
+
}
|
|
212
270
|
async function readDismissed(storage, key) {
|
|
213
271
|
try {
|
|
214
272
|
return await storage.getItem(key);
|
|
@@ -352,7 +410,7 @@ export function UpdateChecker(t0) {
|
|
|
352
410
|
setUpdate(found);
|
|
353
411
|
}
|
|
354
412
|
};
|
|
355
|
-
run().catch(
|
|
413
|
+
run().catch(_temp3);
|
|
356
414
|
return () => {
|
|
357
415
|
cancelled = true;
|
|
358
416
|
};
|
|
@@ -392,7 +450,7 @@ export function UpdateChecker(t0) {
|
|
|
392
450
|
storageKey: key_0
|
|
393
451
|
} = latest.current;
|
|
394
452
|
if (store_0) {
|
|
395
|
-
Promise.resolve().then(() => store_0.setItem(key_0, current.version)).catch(
|
|
453
|
+
Promise.resolve().then(() => store_0.setItem(key_0, current.version)).catch(_temp4);
|
|
396
454
|
}
|
|
397
455
|
onLater?.(current);
|
|
398
456
|
};
|
|
@@ -438,5 +496,5 @@ export function UpdateChecker(t0) {
|
|
|
438
496
|
}
|
|
439
497
|
return t11;
|
|
440
498
|
}
|
|
499
|
+
function _temp4() {}
|
|
441
500
|
function _temp3() {}
|
|
442
|
-
function _temp2() {}
|
package/dist/ai/icon-button.jsx
CHANGED
|
@@ -8,7 +8,7 @@ import { tokens } from "../tokens";
|
|
|
8
8
|
import { useScheme } from "../useScheme";
|
|
9
9
|
|
|
10
10
|
/** The phone chat icon button: 40 square with an 18 icon (hit slop reaches 44). */
|
|
11
|
-
|
|
11
|
+
const CHAT_ICON_BUTTON_SIZE = 40;
|
|
12
12
|
const CHAT_ICON_BUTTON = {
|
|
13
13
|
xs: {
|
|
14
14
|
side: 36,
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,7 @@ export { Stepper } from "./Stepper";
|
|
|
40
40
|
export { CaptureButton } from "./CaptureButton";
|
|
41
41
|
export { Separator } from "./Separator";
|
|
42
42
|
export { Progress } from "./Progress";
|
|
43
|
+
export { Slider } from "./Slider";
|
|
43
44
|
export { Spinner, CenteredSpinner } from "./Spinner";
|
|
44
45
|
export { KeyboardAvoidingView } from "./primitives/keyboard-parts";
|
|
45
46
|
export { LoadingState } from "./LoadingState";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function snapSliderValue(raw, min, max, step) {
|
|
2
|
+
const clamped = Math.min(max, Math.max(min, raw));
|
|
3
|
+
if (step <= 0) return clamped;
|
|
4
|
+
const snapped = min + Math.round((clamped - min) / step) * step;
|
|
5
|
+
const decimals = (String(step).split(".")[1] ?? "").length;
|
|
6
|
+
return Math.min(max, Number(snapped.toFixed(decimals)));
|
|
7
|
+
}
|
|
8
|
+
export function sliderValueFromOffset(offset, length, min, max, vertical) {
|
|
9
|
+
if (length <= 0) return min;
|
|
10
|
+
const ratio = Math.min(1, Math.max(0, offset / length));
|
|
11
|
+
return min + (vertical ? 1 - ratio : ratio) * (max - min);
|
|
12
|
+
}
|
|
13
|
+
export function sliderPercent(value, min, max) {
|
|
14
|
+
if (max <= min) return 0;
|
|
15
|
+
return Math.min(100, Math.max(0, (value - min) / (max - min) * 100));
|
|
16
|
+
}
|
package/dist/updateCheck.js
CHANGED
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* A newer version to offer. `url` is what Download opens: the APK itself, else
|
|
3
|
+
* its release page. `notes` are the release's "What's changed" titles, and
|
|
4
|
+
* `moreNotes` the number of titles the source left out.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** At most `max` notes of `update`, and how many more there are. */
|
|
8
|
+
export function visibleReleaseNotes(update, max) {
|
|
9
|
+
const notes = update.notes ?? [];
|
|
10
|
+
const shown = notes.slice(0, Math.max(0, max));
|
|
11
|
+
return {
|
|
12
|
+
notes: shown,
|
|
13
|
+
more: notes.length - shown.length + (update.moreNotes ?? 0)
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function readNotes(body) {
|
|
17
|
+
const notes = Array.isArray(body.notes) ? body.notes.filter(note => typeof note === "string" && note.trim() !== "") : [];
|
|
18
|
+
const more = typeof body.moreNotes === "number" && body.moreNotes > 0 ? Math.floor(body.moreNotes) : 0;
|
|
19
|
+
return {
|
|
20
|
+
...(notes.length > 0 ? {
|
|
21
|
+
notes
|
|
22
|
+
} : {}),
|
|
23
|
+
...(more > 0 ? {
|
|
24
|
+
moreNotes: more
|
|
25
|
+
} : {})
|
|
26
|
+
};
|
|
27
|
+
}
|
|
2
28
|
|
|
3
29
|
/** The fields of a GitHub release the check reads (`GET /repos/{owner}/{repo}/releases`). */
|
|
4
30
|
|
|
@@ -74,7 +100,7 @@ export async function fetchGitHubUpdate(source, currentVersion) {
|
|
|
74
100
|
/**
|
|
75
101
|
* The HTTP host of V Store, the Project V Android app store. Its
|
|
76
102
|
* `GET /latest-version?package=<Android package>` answers
|
|
77
|
-
* `{ packageName, versionName }` for an app in its catalogue.
|
|
103
|
+
* `{ packageName, versionName, notes, moreNotes }` for an app in its catalogue.
|
|
78
104
|
*/
|
|
79
105
|
export const V_STORE_SITE_URL = "https://blessed-porcupine-303.eu-west-1.convex.site";
|
|
80
106
|
/**
|
|
@@ -83,7 +109,8 @@ export const V_STORE_SITE_URL = "https://blessed-porcupine-303.eu-west-1.convex.
|
|
|
83
109
|
* repositories too, so this works where `fetchGitHubUpdate` cannot. Null too
|
|
84
110
|
* when the app is not in the catalogue, the request fails, or the answer has
|
|
85
111
|
* another shape. A network error rejects. Without `downloadUrl`, `url` is
|
|
86
|
-
* `fallbackUrl`.
|
|
112
|
+
* `fallbackUrl`. `notes` and `moreNotes` come from the release's "What's
|
|
113
|
+
* changed" list, when V Store has one.
|
|
87
114
|
*/
|
|
88
115
|
export async function fetchVStoreUpdate(source, currentVersion, fallbackUrl) {
|
|
89
116
|
const site = source.siteUrl ?? V_STORE_SITE_URL;
|
|
@@ -95,10 +122,12 @@ export async function fetchVStoreUpdate(source, currentVersion, fallbackUrl) {
|
|
|
95
122
|
if (!response.ok) return null;
|
|
96
123
|
const body = await response.json();
|
|
97
124
|
if (!body || typeof body !== "object") return null;
|
|
98
|
-
const
|
|
125
|
+
const fields = body;
|
|
126
|
+
const version = fields.versionName;
|
|
99
127
|
if (typeof version !== "string" || !isNewerVersion(version, currentVersion)) return null;
|
|
100
128
|
return {
|
|
101
129
|
version,
|
|
102
|
-
url: source.downloadUrl?.(version) ?? fallbackUrl
|
|
130
|
+
url: source.downloadUrl?.(version) ?? fallbackUrl,
|
|
131
|
+
...readNotes(fields)
|
|
103
132
|
};
|
|
104
133
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.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, the app root shell helpers and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
package/src/Slider.tsx
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
PanResponder,
|
|
4
|
+
type GestureResponderEvent,
|
|
5
|
+
View,
|
|
6
|
+
type LayoutChangeEvent,
|
|
7
|
+
type ViewProps,
|
|
8
|
+
} from "react-native";
|
|
9
|
+
import Animated, {
|
|
10
|
+
Easing,
|
|
11
|
+
useAnimatedStyle,
|
|
12
|
+
useSharedValue,
|
|
13
|
+
withTiming,
|
|
14
|
+
} from "react-native-reanimated";
|
|
15
|
+
import { cn } from "./cn";
|
|
16
|
+
import { useGlass } from "./glass";
|
|
17
|
+
import { selectionHaptic } from "./haptics";
|
|
18
|
+
import { palette } from "./palette";
|
|
19
|
+
import { useControllableState } from "./primitives/use-controllable-state";
|
|
20
|
+
import { snapSliderValue, sliderPercent, sliderValueFromOffset } from "./sliderMath";
|
|
21
|
+
import { useAccentColor } from "./theme";
|
|
22
|
+
import { tokens } from "./tokens";
|
|
23
|
+
import { useReduceMotion } from "./useReduceMotion";
|
|
24
|
+
import { useScheme } from "./useScheme";
|
|
25
|
+
|
|
26
|
+
export type SliderProps = Omit<ViewProps, "children"> & {
|
|
27
|
+
value?: number;
|
|
28
|
+
defaultValue?: number;
|
|
29
|
+
onValueChange?: (value: number) => void;
|
|
30
|
+
onSlidingComplete?: (value: number) => void;
|
|
31
|
+
min?: number;
|
|
32
|
+
max?: number;
|
|
33
|
+
step?: number;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
orientation?: "horizontal" | "vertical";
|
|
36
|
+
className?: string;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const THUMB_LONG = 32;
|
|
40
|
+
const THUMB_SHORT = 20;
|
|
41
|
+
const DRAG_SCALE = 1.45;
|
|
42
|
+
|
|
43
|
+
/** Track 6 thick, glass pill thumb 32 × 20. The thumb grows to 1.45× and turns translucent while dragged. `surface="flat"` drops the glass shadow. */
|
|
44
|
+
export function Slider({
|
|
45
|
+
value,
|
|
46
|
+
defaultValue = 0,
|
|
47
|
+
onValueChange,
|
|
48
|
+
onSlidingComplete,
|
|
49
|
+
min = 0,
|
|
50
|
+
max = 100,
|
|
51
|
+
step = 1,
|
|
52
|
+
disabled = false,
|
|
53
|
+
orientation = "horizontal",
|
|
54
|
+
className,
|
|
55
|
+
style,
|
|
56
|
+
...props
|
|
57
|
+
}: SliderProps) {
|
|
58
|
+
"use no memo"; // PanResponder reads a mutable gesture box that the compiler cannot model.
|
|
59
|
+
const vertical = orientation === "vertical";
|
|
60
|
+
const scheme = useScheme();
|
|
61
|
+
const accent = useAccentColor();
|
|
62
|
+
const glass = useGlass("small");
|
|
63
|
+
const reduceMotion = useReduceMotion();
|
|
64
|
+
const [current, setCurrent] = useControllableState({ value, defaultValue, onChange: onValueChange });
|
|
65
|
+
const [length, setLength] = useState(0);
|
|
66
|
+
const [dragging, setDragging] = useState(false);
|
|
67
|
+
const scale = useSharedValue(1);
|
|
68
|
+
const [box] = useState(() => ({
|
|
69
|
+
min,
|
|
70
|
+
max,
|
|
71
|
+
step,
|
|
72
|
+
vertical,
|
|
73
|
+
disabled,
|
|
74
|
+
value: current,
|
|
75
|
+
length: 0,
|
|
76
|
+
setValue: setCurrent,
|
|
77
|
+
onSlidingComplete,
|
|
78
|
+
}));
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
box.min = min;
|
|
82
|
+
box.max = max;
|
|
83
|
+
box.step = step;
|
|
84
|
+
box.vertical = vertical;
|
|
85
|
+
box.disabled = disabled;
|
|
86
|
+
box.value = current;
|
|
87
|
+
box.setValue = setCurrent;
|
|
88
|
+
box.onSlidingComplete = onSlidingComplete;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const target = dragging ? DRAG_SCALE : 1;
|
|
93
|
+
scale.set(
|
|
94
|
+
reduceMotion ? target : withTiming(target, { duration: 200, easing: Easing.bezier(0.22, 1, 0.36, 1) }),
|
|
95
|
+
);
|
|
96
|
+
}, [dragging, reduceMotion, scale]);
|
|
97
|
+
|
|
98
|
+
const [responder] = useState(() => {
|
|
99
|
+
const commit = (offset: number) => {
|
|
100
|
+
const next = snapSliderValue(
|
|
101
|
+
sliderValueFromOffset(offset, box.length, box.min, box.max, box.vertical),
|
|
102
|
+
box.min,
|
|
103
|
+
box.max,
|
|
104
|
+
box.step,
|
|
105
|
+
);
|
|
106
|
+
if (next === box.value) return;
|
|
107
|
+
box.value = next;
|
|
108
|
+
selectionHaptic();
|
|
109
|
+
box.setValue(next);
|
|
110
|
+
};
|
|
111
|
+
const offsetOf = (event: GestureResponderEvent) =>
|
|
112
|
+
box.vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX;
|
|
113
|
+
const finish = () => {
|
|
114
|
+
setDragging(false);
|
|
115
|
+
box.onSlidingComplete?.(box.value);
|
|
116
|
+
};
|
|
117
|
+
return PanResponder.create({
|
|
118
|
+
onStartShouldSetPanResponder: () => !box.disabled,
|
|
119
|
+
onMoveShouldSetPanResponder: () => !box.disabled,
|
|
120
|
+
onPanResponderTerminationRequest: () => false,
|
|
121
|
+
onPanResponderGrant: (event) => {
|
|
122
|
+
setDragging(true);
|
|
123
|
+
commit(offsetOf(event));
|
|
124
|
+
},
|
|
125
|
+
onPanResponderMove: (event) => commit(offsetOf(event)),
|
|
126
|
+
onPanResponderRelease: finish,
|
|
127
|
+
onPanResponderTerminate: finish,
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const onLayout = (event: LayoutChangeEvent) => {
|
|
132
|
+
const next = vertical ? event.nativeEvent.layout.height : event.nativeEvent.layout.width;
|
|
133
|
+
box.length = next;
|
|
134
|
+
setLength(next);
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const onAccessibilityAction = (event: { nativeEvent: { actionName: string } }) => {
|
|
138
|
+
const direction = event.nativeEvent.actionName === "increment" ? 1 : -1;
|
|
139
|
+
const next = snapSliderValue(box.value + direction * (step > 0 ? step : (max - min) / 10), min, max, step);
|
|
140
|
+
if (next === box.value) return;
|
|
141
|
+
box.value = next;
|
|
142
|
+
setCurrent(next);
|
|
143
|
+
onSlidingComplete?.(next);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const percent = sliderPercent(current, min, max);
|
|
147
|
+
const travel = Math.max(0, length - THUMB_LONG);
|
|
148
|
+
const thumbOffset = (percent / 100) * travel;
|
|
149
|
+
const thumbW = vertical ? THUMB_SHORT : THUMB_LONG;
|
|
150
|
+
const thumbH = vertical ? THUMB_LONG : THUMB_SHORT;
|
|
151
|
+
|
|
152
|
+
const thumbStyle = useAnimatedStyle(() => ({
|
|
153
|
+
transform: [{ scale: scale.get() }],
|
|
154
|
+
opacity: 1 - ((scale.get() - 1) / (DRAG_SCALE - 1)) * 0.15,
|
|
155
|
+
}));
|
|
156
|
+
|
|
157
|
+
const trackColor = palette.default[scheme];
|
|
158
|
+
const thumbColor = scheme === "dark" ? tokens.color.foreground.dark : tokens.color.surface.light;
|
|
159
|
+
|
|
160
|
+
return (
|
|
161
|
+
<View
|
|
162
|
+
accessibilityRole="adjustable"
|
|
163
|
+
accessibilityState={{ disabled }}
|
|
164
|
+
accessibilityValue={{ min, max, now: current }}
|
|
165
|
+
accessibilityActions={[{ name: "increment" }, { name: "decrement" }]}
|
|
166
|
+
onAccessibilityAction={onAccessibilityAction}
|
|
167
|
+
onLayout={onLayout}
|
|
168
|
+
className={cn(vertical ? "h-full min-h-40 w-8 items-center" : "h-8 w-full justify-center", disabled && "opacity-50", className)}
|
|
169
|
+
style={style}
|
|
170
|
+
{...responder.panHandlers}
|
|
171
|
+
{...props}
|
|
172
|
+
>
|
|
173
|
+
<View
|
|
174
|
+
pointerEvents="none"
|
|
175
|
+
className="overflow-hidden rounded-full"
|
|
176
|
+
style={{
|
|
177
|
+
backgroundColor: trackColor,
|
|
178
|
+
...(vertical ? { width: 6, height: "100%" } : { height: 6, width: "100%" }),
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<View
|
|
182
|
+
style={{
|
|
183
|
+
position: "absolute",
|
|
184
|
+
backgroundColor: accent,
|
|
185
|
+
...(vertical
|
|
186
|
+
? { bottom: 0, left: 0, right: 0, height: `${percent}%` }
|
|
187
|
+
: { left: 0, top: 0, bottom: 0, width: `${percent}%` }),
|
|
188
|
+
}}
|
|
189
|
+
/>
|
|
190
|
+
</View>
|
|
191
|
+
<Animated.View
|
|
192
|
+
pointerEvents="none"
|
|
193
|
+
style={[
|
|
194
|
+
{
|
|
195
|
+
position: "absolute",
|
|
196
|
+
width: thumbW,
|
|
197
|
+
height: thumbH,
|
|
198
|
+
borderRadius: 999,
|
|
199
|
+
backgroundColor: thumbColor,
|
|
200
|
+
...(vertical ? { bottom: thumbOffset, alignSelf: "center" as const } : { left: thumbOffset }),
|
|
201
|
+
},
|
|
202
|
+
glass,
|
|
203
|
+
thumbStyle,
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
</View>
|
|
207
|
+
);
|
|
208
|
+
}
|
package/src/UpdateChecker.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
2
|
-
import { Linking } from "react-native";
|
|
2
|
+
import { Linking, View } from "react-native";
|
|
3
3
|
import {
|
|
4
4
|
AlertDialog,
|
|
5
5
|
AlertDialogAction,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
fetchGitHubUpdate,
|
|
15
15
|
fetchVStoreUpdate,
|
|
16
|
+
visibleReleaseNotes,
|
|
16
17
|
type AvailableUpdate,
|
|
17
18
|
type GitHubReleaseSource,
|
|
18
19
|
type VStoreSource,
|
|
@@ -32,6 +33,8 @@ export type UpdatePromptProps = {
|
|
|
32
33
|
downloadLabel?: ReactNode;
|
|
33
34
|
vStoreLabel?: ReactNode;
|
|
34
35
|
vStoreMissingText?: ReactNode;
|
|
36
|
+
notesLabel?: ReactNode;
|
|
37
|
+
maxNotes?: number;
|
|
35
38
|
showDownload?: boolean;
|
|
36
39
|
showVStore?: boolean;
|
|
37
40
|
vStoreUrl?: string;
|
|
@@ -55,6 +58,9 @@ export type UpdatePromptProps = {
|
|
|
55
58
|
* not hidden up front: Android 11+ only reports another app's link as
|
|
56
59
|
* openable to an app that declares it in its manifest `<queries>`.
|
|
57
60
|
*
|
|
61
|
+
* Release notes: when the update has `notes`, a "What's new" list shows the
|
|
62
|
+
* first `maxNotes` (default 5) titles, then "and N more".
|
|
63
|
+
*
|
|
58
64
|
* Controlled: it is open while `update` is set. `UpdateChecker` runs the
|
|
59
65
|
* check and holds that state. It adds no motion of its own; the dialog's
|
|
60
66
|
* follows Reduce Motion.
|
|
@@ -68,6 +74,8 @@ export function UpdatePrompt({
|
|
|
68
74
|
downloadLabel = "Download",
|
|
69
75
|
vStoreLabel = "Install from V Store",
|
|
70
76
|
vStoreMissingText = "V Store is not installed on this device.",
|
|
77
|
+
notesLabel = "What's new",
|
|
78
|
+
maxNotes = 5,
|
|
71
79
|
showDownload = true,
|
|
72
80
|
showVStore = true,
|
|
73
81
|
vStoreUrl = V_STORE_UPDATES_URL,
|
|
@@ -89,6 +97,7 @@ export function UpdatePrompt({
|
|
|
89
97
|
: typeof description === "function"
|
|
90
98
|
? description(shown)
|
|
91
99
|
: (description ?? `${appName} ${shown.version} is ready to install.`);
|
|
100
|
+
const notes = shown === null ? { notes: [], more: 0 } : visibleReleaseNotes(shown, maxNotes);
|
|
92
101
|
|
|
93
102
|
return (
|
|
94
103
|
<AlertDialog
|
|
@@ -101,6 +110,19 @@ export function UpdatePrompt({
|
|
|
101
110
|
<AlertDialogHeader>
|
|
102
111
|
<AlertDialogTitle>{title}</AlertDialogTitle>
|
|
103
112
|
{body != null ? <AlertDialogDescription>{body}</AlertDialogDescription> : null}
|
|
113
|
+
{notes.notes.length > 0 ? (
|
|
114
|
+
<View testID={testID ? `${testID}-notes` : undefined} className="gap-1 pt-2">
|
|
115
|
+
<AlertDialogDescription className="font-instrument-sans-medium">
|
|
116
|
+
{notesLabel}
|
|
117
|
+
</AlertDialogDescription>
|
|
118
|
+
{notes.notes.map((note, index) => (
|
|
119
|
+
<AlertDialogDescription key={`${index}-${note}`}>{`\u2022 ${note}`}</AlertDialogDescription>
|
|
120
|
+
))}
|
|
121
|
+
{notes.more > 0 ? (
|
|
122
|
+
<AlertDialogDescription>{`\u2022 and ${notes.more} more`}</AlertDialogDescription>
|
|
123
|
+
) : null}
|
|
124
|
+
</View>
|
|
125
|
+
) : null}
|
|
104
126
|
{showVStore && vStoreMissing ? (
|
|
105
127
|
<AlertDialogDescription
|
|
106
128
|
testID={testID ? `${testID}-vstore-missing` : undefined}
|
package/src/ai/icon-button.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { tokens } from "../tokens";
|
|
|
8
8
|
import { useScheme } from "../useScheme";
|
|
9
9
|
|
|
10
10
|
/** The phone chat icon button: 40 square with an 18 icon (hit slop reaches 44). */
|
|
11
|
-
|
|
11
|
+
const CHAT_ICON_BUTTON_SIZE = 40;
|
|
12
12
|
|
|
13
13
|
const CHAT_ICON_BUTTON = {
|
|
14
14
|
xs: { side: 36, icon: 16, className: "h-9 w-9" },
|
package/src/index.ts
CHANGED
|
@@ -110,6 +110,8 @@ export { Separator } from "./Separator";
|
|
|
110
110
|
export type { SeparatorProps } from "./Separator";
|
|
111
111
|
export { Progress } from "./Progress";
|
|
112
112
|
export type { ProgressProps } from "./Progress";
|
|
113
|
+
export { Slider } from "./Slider";
|
|
114
|
+
export type { SliderProps } from "./Slider";
|
|
113
115
|
export { Spinner, CenteredSpinner } from "./Spinner";
|
|
114
116
|
export { KeyboardAvoidingView } from "./primitives/keyboard-parts";
|
|
115
117
|
export type { KeyboardAvoidingViewProps } from "./primitives/keyboard-parts";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function snapSliderValue(raw: number, min: number, max: number, step: number) {
|
|
2
|
+
const clamped = Math.min(max, Math.max(min, raw));
|
|
3
|
+
if (step <= 0) return clamped;
|
|
4
|
+
const snapped = min + Math.round((clamped - min) / step) * step;
|
|
5
|
+
const decimals = (String(step).split(".")[1] ?? "").length;
|
|
6
|
+
return Math.min(max, Number(snapped.toFixed(decimals)));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function sliderValueFromOffset(offset: number, length: number, min: number, max: number, vertical: boolean) {
|
|
10
|
+
if (length <= 0) return min;
|
|
11
|
+
const ratio = Math.min(1, Math.max(0, offset / length));
|
|
12
|
+
return min + (vertical ? 1 - ratio : ratio) * (max - min);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function sliderPercent(value: number, min: number, max: number) {
|
|
16
|
+
if (max <= min) return 0;
|
|
17
|
+
return Math.min(100, Math.max(0, ((value - min) / (max - min)) * 100));
|
|
18
|
+
}
|
package/src/updateCheck.ts
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A newer version to offer. `url` is what Download opens: the APK itself, else
|
|
3
|
+
* its release page. `notes` are the release's "What's changed" titles, and
|
|
4
|
+
* `moreNotes` the number of titles the source left out.
|
|
5
|
+
*/
|
|
6
|
+
export type AvailableUpdate = {
|
|
7
|
+
version: string;
|
|
8
|
+
url: string;
|
|
9
|
+
notes?: string[];
|
|
10
|
+
moreNotes?: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/** At most `max` notes of `update`, and how many more there are. */
|
|
14
|
+
export function visibleReleaseNotes(
|
|
15
|
+
update: AvailableUpdate,
|
|
16
|
+
max: number,
|
|
17
|
+
): { notes: string[]; more: number } {
|
|
18
|
+
const notes = update.notes ?? [];
|
|
19
|
+
const shown = notes.slice(0, Math.max(0, max));
|
|
20
|
+
return { notes: shown, more: notes.length - shown.length + (update.moreNotes ?? 0) };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function readNotes(body: Record<string, unknown>): Pick<AvailableUpdate, "notes" | "moreNotes"> {
|
|
24
|
+
const notes = Array.isArray(body.notes)
|
|
25
|
+
? body.notes.filter((note): note is string => typeof note === "string" && note.trim() !== "")
|
|
26
|
+
: [];
|
|
27
|
+
const more = typeof body.moreNotes === "number" && body.moreNotes > 0 ? Math.floor(body.moreNotes) : 0;
|
|
28
|
+
return {
|
|
29
|
+
...(notes.length > 0 ? { notes } : {}),
|
|
30
|
+
...(more > 0 ? { moreNotes: more } : {}),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
3
33
|
|
|
4
34
|
/** The fields of a GitHub release the check reads (`GET /repos/{owner}/{repo}/releases`). */
|
|
5
35
|
export type GitHubRelease = {
|
|
@@ -97,7 +127,7 @@ export async function fetchGitHubUpdate(
|
|
|
97
127
|
/**
|
|
98
128
|
* The HTTP host of V Store, the Project V Android app store. Its
|
|
99
129
|
* `GET /latest-version?package=<Android package>` answers
|
|
100
|
-
* `{ packageName, versionName }` for an app in its catalogue.
|
|
130
|
+
* `{ packageName, versionName, notes, moreNotes }` for an app in its catalogue.
|
|
101
131
|
*/
|
|
102
132
|
export const V_STORE_SITE_URL = "https://blessed-porcupine-303.eu-west-1.convex.site";
|
|
103
133
|
|
|
@@ -113,7 +143,8 @@ export type VStoreSource = {
|
|
|
113
143
|
* repositories too, so this works where `fetchGitHubUpdate` cannot. Null too
|
|
114
144
|
* when the app is not in the catalogue, the request fails, or the answer has
|
|
115
145
|
* another shape. A network error rejects. Without `downloadUrl`, `url` is
|
|
116
|
-
* `fallbackUrl`.
|
|
146
|
+
* `fallbackUrl`. `notes` and `moreNotes` come from the release's "What's
|
|
147
|
+
* changed" list, when V Store has one.
|
|
117
148
|
*/
|
|
118
149
|
export async function fetchVStoreUpdate(
|
|
119
150
|
source: VStoreSource,
|
|
@@ -127,7 +158,8 @@ export async function fetchVStoreUpdate(
|
|
|
127
158
|
if (!response.ok) return null;
|
|
128
159
|
const body: unknown = await response.json();
|
|
129
160
|
if (!body || typeof body !== "object") return null;
|
|
130
|
-
const
|
|
161
|
+
const fields = body as Record<string, unknown>;
|
|
162
|
+
const version = fields.versionName;
|
|
131
163
|
if (typeof version !== "string" || !isNewerVersion(version, currentVersion)) return null;
|
|
132
|
-
return { version, url: source.downloadUrl?.(version) ?? fallbackUrl };
|
|
164
|
+
return { version, url: source.downloadUrl?.(version) ?? fallbackUrl, ...readNotes(fields) };
|
|
133
165
|
}
|