@plexui/react-native 0.2.5 → 0.2.7
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/es/components/Badge/Badge.js +10 -0
- package/dist/es/components/PageControl/PageControl.js +49 -22
- package/dist/es/components/ScrollEdge/ScrollEdge.js +27 -0
- package/dist/es/components/TabBar/TabBar.js +16 -13
- package/dist/es/index.js +1 -0
- package/dist/es/internal/BarBackdrop.js +54 -0
- package/dist/es/theme/ThemeProvider.js +5 -2
- package/dist/types/components/Badge/Badge.d.ts +1 -1
- package/dist/types/components/PageControl/PageControl.d.ts +12 -1
- package/dist/types/components/ScrollEdge/ScrollEdge.d.ts +19 -0
- package/dist/types/components/TabBar/TabBar.d.ts +14 -4
- package/dist/types/index.d.ts +2 -1
- package/dist/types/internal/BarBackdrop.d.ts +9 -0
- package/package.json +2 -2
- package/src/components/Badge/Badge.tsx +9 -1
- package/src/components/PageControl/PageControl.tsx +71 -24
- package/src/components/ScrollEdge/ScrollEdge.tsx +48 -0
- package/src/components/TabBar/TabBar.tsx +33 -15
- package/src/index.ts +2 -0
- package/src/internal/BarBackdrop.tsx +73 -0
- package/src/theme/ThemeProvider.tsx +6 -2
|
@@ -19,6 +19,16 @@ export function counterBadgeColors(theme, color) {
|
|
|
19
19
|
export function badgeColors(theme, variant, color) {
|
|
20
20
|
if (variant === "counter")
|
|
21
21
|
return counterBadgeColors(theme, color);
|
|
22
|
+
// The accent has a solid and a soft step and one text color (styles' accent tokens): soft on the soft fill, the
|
|
23
|
+
// outline's text and line in that text color
|
|
24
|
+
if (color === "accent") {
|
|
25
|
+
const text = theme.color("--color-text-accent");
|
|
26
|
+
if (variant === "solid")
|
|
27
|
+
return { background: theme.color("--color-background-accent-solid"), text: theme.color("--color-text-accent-solid", "#FFFFFF"), border: undefined };
|
|
28
|
+
if (variant === "outline")
|
|
29
|
+
return { background: "transparent", text, border: text };
|
|
30
|
+
return { background: theme.color("--color-background-accent-soft"), text, border: undefined };
|
|
31
|
+
}
|
|
22
32
|
if (variant === "outline")
|
|
23
33
|
return { background: "transparent", text: theme.color(`--color-text-${color}-outline`), border: theme.color(`--color-border-${color}-outline`) };
|
|
24
34
|
if (variant === "solid")
|
|
@@ -46,7 +46,7 @@ const SCRUB_THRESHOLD = 8;
|
|
|
46
46
|
* page and back as it moves), in a 48dp target, with no capsule at all. For a screen reader it is adjustable: swipe
|
|
47
47
|
* up or down for the next or previous page.
|
|
48
48
|
*/
|
|
49
|
-
export function PageControl({ count, value: valueProp, defaultValue = 0, onChange, background = "automatic", indicator = "dots", tone = "default", valueText = defaultValueText, "aria-label": ariaLabel = "Pages", testID, style, }) {
|
|
49
|
+
export function PageControl({ count, value: valueProp, defaultValue = 0, onChange, background = "automatic", indicator = "dots", tone = "default", direction = "horizontal", size = "md", valueText = defaultValueText, "aria-label": ariaLabel = "Pages", testID, style, }) {
|
|
50
50
|
const theme = useTheme();
|
|
51
51
|
const [own, setOwn] = useState(defaultValue);
|
|
52
52
|
const current = clampIndex(valueProp ?? own, count);
|
|
@@ -62,25 +62,32 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, onChang
|
|
|
62
62
|
onChange?.(next, { scrubbing });
|
|
63
63
|
};
|
|
64
64
|
const android = theme.isAndroid;
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
const
|
|
65
|
+
const small = size === "sm";
|
|
66
|
+
const vertical = direction === "vertical";
|
|
67
|
+
const dot = small ? (android ? 4 : 5) : android ? ANDROID_DOT : theme.length("--page-control-dot-size", 8);
|
|
68
|
+
const gap = small ? 4 : android ? ANDROID_GAP : theme.length("--page-control-gap", 8);
|
|
69
|
+
const padding = small ? 6 : theme.length("--page-control-padding-inline", 12);
|
|
68
70
|
const pitch = dot + gap;
|
|
69
71
|
// Android draws every page's dot at full size; the iOS kit shrinks the ends from seven pages
|
|
70
72
|
const sizes = android ? Array.from({ length: Math.max(0, count) }, () => "full") : pageControlDots(count, current);
|
|
71
|
-
|
|
73
|
+
// The small and smaller ends keep their share of a full dot (6 and 4 of 8 on iOS)
|
|
74
|
+
const dotSize = (kind) => kind === "full"
|
|
75
|
+
? dot
|
|
76
|
+
: android
|
|
77
|
+
? Math.max(2, dot - (kind === "small" ? 1 : 2))
|
|
78
|
+
: (dot / 8) * (kind === "small" ? theme.length("--page-control-dot-size-small", 6) : theme.length("--page-control-dot-size-smaller", 4));
|
|
72
79
|
const pill = indicator === "pill";
|
|
73
|
-
// A pill: the current page two and a half dots
|
|
74
|
-
const dotWidth = (
|
|
80
|
+
// A pill: the current page two and a half dots long (18 at `sm`), along the direction
|
|
81
|
+
const dotWidth = (kind, index) => (pill && index === current ? (small ? 14 : dot * 2.5) : dotSize(kind));
|
|
75
82
|
// The center of the current dot, for a tap on either side of it
|
|
76
83
|
let x = padding;
|
|
77
84
|
let currentCenter = padding;
|
|
78
|
-
sizes.forEach((
|
|
79
|
-
if (
|
|
85
|
+
sizes.forEach((kind, index) => {
|
|
86
|
+
if (kind === "hidden")
|
|
80
87
|
return;
|
|
81
88
|
if (index === current)
|
|
82
|
-
currentCenter = x + dotWidth(
|
|
83
|
-
x += dotWidth(
|
|
89
|
+
currentCenter = x + dotWidth(kind, index) / 2;
|
|
90
|
+
x += dotWidth(kind, index) + gap;
|
|
84
91
|
});
|
|
85
92
|
const onColor = tone === "onColor";
|
|
86
93
|
const on = onColor ? "#FFFFFF" : android ? theme.material.primary : theme.color("--page-control-dot-color-current", theme.colors.text);
|
|
@@ -89,7 +96,7 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, onChang
|
|
|
89
96
|
// Android's current dot is drawn over the gray ones (it stretches between pages); a pill is a dot of its own
|
|
90
97
|
const worm = android && !pill;
|
|
91
98
|
// Android draws no capsule, not even for `prominent`
|
|
92
|
-
const capsuleHeight = theme.length("--page-control-height", 24);
|
|
99
|
+
const capsuleHeight = small ? 16 : theme.length("--page-control-height", 24);
|
|
93
100
|
const target = android ? 48 : theme.length("--page-control-target-size", 44);
|
|
94
101
|
const showBackground = !android && (background === "prominent" || (background === "automatic" && press != null));
|
|
95
102
|
const text = valueText(current, count);
|
|
@@ -99,7 +106,7 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, onChang
|
|
|
99
106
|
onKeyDown: (raw) => {
|
|
100
107
|
const event = raw;
|
|
101
108
|
// The dots run from the right in a right-to-left row: the left arrow goes on to the next page
|
|
102
|
-
const ahead = isRTL(event.currentTarget) ? -1 : 1;
|
|
109
|
+
const ahead = !vertical && isRTL(event.currentTarget) ? -1 : 1;
|
|
103
110
|
const to = { ArrowRight: current + ahead, ArrowDown: current + 1, ArrowLeft: current - ahead, ArrowUp: current - 1, Home: 0, End: count - 1 };
|
|
104
111
|
if (!(event.key in to))
|
|
105
112
|
return;
|
|
@@ -111,29 +118,46 @@ export function PageControl({ count, value: valueProp, defaultValue = 0, onChang
|
|
|
111
118
|
const onMove = (event) => {
|
|
112
119
|
if (!press || background === "minimal")
|
|
113
120
|
return;
|
|
114
|
-
const dx = (event.nativeEvent.locationX - press.startX) * (press.rtl ? -1 : 1);
|
|
121
|
+
const dx = ((vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX) - press.startX) * (press.rtl ? -1 : 1);
|
|
115
122
|
if (!press.scrubbing && Math.abs(dx) < SCRUB_THRESHOLD)
|
|
116
123
|
return;
|
|
117
124
|
if (!press.scrubbing)
|
|
118
125
|
setPress({ ...press, scrubbing: true });
|
|
119
126
|
go(press.startIndex + Math.round(dx / pitch), true);
|
|
120
127
|
};
|
|
121
|
-
return (_jsx(View, { ...keys, accessible: true, accessibilityRole: "adjustable", accessibilityLabel: ariaLabel, accessibilityValue: { min: 1, max: count, now: current + 1, text }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => go(current + (event.nativeEvent.actionName === "increment" ? 1 : -1)), "aria-valuemin": 1, "aria-valuemax": count, "aria-valuenow": current + 1, "aria-valuetext": text, onStartShouldSetResponder: () => count > 1, onResponderTerminationRequest: () => !press?.scrubbing, onResponderGrant: (event) => setPress({ startX: event.nativeEvent.locationX, startIndex: current, scrubbing: false, rtl: isRTL(event.currentTarget) }), onResponderMove: onMove, onResponderRelease: (event) => {
|
|
128
|
+
return (_jsx(View, { ...keys, accessible: true, accessibilityRole: "adjustable", accessibilityLabel: ariaLabel, accessibilityValue: { min: 1, max: count, now: current + 1, text }, accessibilityActions: [{ name: "increment" }, { name: "decrement" }], onAccessibilityAction: (event) => go(current + (event.nativeEvent.actionName === "increment" ? 1 : -1)), "aria-valuemin": 1, "aria-valuemax": count, "aria-valuenow": current + 1, "aria-valuetext": text, onStartShouldSetResponder: () => count > 1, onResponderTerminationRequest: () => !press?.scrubbing, onResponderGrant: (event) => setPress({ startX: vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX, startIndex: current, scrubbing: false, rtl: !vertical && isRTL(event.currentTarget) }), onResponderMove: onMove, onResponderRelease: (event) => {
|
|
122
129
|
// A tap on the leading side of the current dot goes back, on the trailing side forward; the dots are laid
|
|
123
130
|
// from the capsule's start, its right edge in a right-to-left row
|
|
124
|
-
const x = event.nativeEvent.locationX;
|
|
131
|
+
const x = vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX;
|
|
125
132
|
const fromStart = press?.rtl ? capsule.x + capsule.width - x : x - capsule.x;
|
|
126
133
|
if (press && !press.scrubbing)
|
|
127
134
|
go(current + (fromStart < currentCenter ? -1 : 1));
|
|
128
135
|
setPress(null);
|
|
129
136
|
}, onResponderTerminate: () => setPress(null), testID: testID,
|
|
130
137
|
// The target (44pt, 48dp on Android) reaches past the 24pt capsule without taking room, as the web's control
|
|
131
|
-
// lays out at the capsule's height
|
|
132
|
-
style: [
|
|
138
|
+
// lays out at the capsule's height,
|
|
139
|
+
style: [
|
|
140
|
+
styles.target,
|
|
141
|
+
// and is never shorter than that along the dots either (two small dots), the capsule centred in it
|
|
142
|
+
vertical
|
|
143
|
+
? { minWidth: target, minHeight: target, justifyContent: "center", marginHorizontal: -(target - capsuleHeight) / 2 }
|
|
144
|
+
: { minHeight: target, minWidth: target, justifyContent: "center", marginVertical: -(target - capsuleHeight) / 2 },
|
|
145
|
+
style,
|
|
146
|
+
], children: _jsxs(View, { pointerEvents: "none", onLayout: (event) => {
|
|
147
|
+
const { x: left, y: top, width, height } = event.nativeEvent.layout;
|
|
148
|
+
setCapsule(vertical ? { x: top, width: height } : { x: left, width });
|
|
149
|
+
}, style: [
|
|
133
150
|
styles.capsule,
|
|
134
|
-
|
|
151
|
+
vertical
|
|
152
|
+
? { flexDirection: "column", width: capsuleHeight, paddingVertical: padding, gap, borderRadius: capsuleHeight / 2 }
|
|
153
|
+
: { height: capsuleHeight, paddingHorizontal: padding, gap, borderRadius: capsuleHeight / 2 },
|
|
135
154
|
showBackground ? { backgroundColor: onColor ? "rgba(255, 255, 255, 0.2)" : theme.color("--page-control-background") } : null,
|
|
136
|
-
], children: [sizes.map((size, index) => size === "hidden" ? null : (_jsx(View, { style: {
|
|
155
|
+
], children: [sizes.map((size, index) => size === "hidden" ? null : (_jsx(View, { style: {
|
|
156
|
+
width: vertical ? dotSize(size) : dotWidth(size, index),
|
|
157
|
+
height: vertical ? dotWidth(size, index) : dotSize(size),
|
|
158
|
+
borderRadius: dot / 2,
|
|
159
|
+
backgroundColor: index === current && !worm ? on : off,
|
|
160
|
+
} }, index))), worm ? _jsx(AndroidCurrent, { start: currentCenter - dot / 2, color: on, reduced: theme.reducedMotion, dot: dot, vertical: vertical }) : null] }) }));
|
|
137
161
|
}
|
|
138
162
|
/** Android's page dots: 5dp, 11dp from one to the next. */
|
|
139
163
|
const ANDROID_DOT = 5;
|
|
@@ -148,7 +172,7 @@ const WORM_SETTLE = { duration: 200, easing: curves.easeOutQuint };
|
|
|
148
172
|
* one. On a change the far edge is on the new page at once and the near edge follows it through the settle, as when
|
|
149
173
|
* the pages' scroll draws the dot.
|
|
150
174
|
*/
|
|
151
|
-
function AndroidCurrent({ start, color, reduced }) {
|
|
175
|
+
function AndroidCurrent({ start, color, reduced, dot, vertical }) {
|
|
152
176
|
const [head] = useState(() => new Animated.Value(start));
|
|
153
177
|
const [tail] = useState(() => new Animated.Value(start));
|
|
154
178
|
const first = useRef(true);
|
|
@@ -168,7 +192,10 @@ function AndroidCurrent({ start, color, reduced }) {
|
|
|
168
192
|
// `start` keeps it on the dots' side in a right-to-left row
|
|
169
193
|
const span = Animated.subtract(head, tail).interpolate({ inputRange: [-1000, 0, 1000], outputRange: [1000, 0, 1000] });
|
|
170
194
|
const left = Animated.multiply(Animated.subtract(Animated.add(head, tail), span), 0.5);
|
|
171
|
-
|
|
195
|
+
const length = Animated.add(span, dot);
|
|
196
|
+
return (_jsx(Animated.View, { style: vertical
|
|
197
|
+
? { position: "absolute", left: "50%", marginLeft: -dot / 2, top: left, width: dot, borderRadius: dot / 2, backgroundColor: color, height: length }
|
|
198
|
+
: { position: "absolute", top: "50%", marginTop: -dot / 2, start: left, height: dot, borderRadius: dot / 2, backgroundColor: color, width: length } }));
|
|
172
199
|
}
|
|
173
200
|
const styles = StyleSheet.create({
|
|
174
201
|
target: { alignSelf: "center", alignItems: "center", justifyContent: "center" },
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Platform, View } from "react-native";
|
|
3
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
|
+
import { SoftBottomVeil, SoftTopEdge } from "../../internal/BarBackdrop";
|
|
5
|
+
import { useTheme } from "../../theme/ThemeProvider";
|
|
6
|
+
/**
|
|
7
|
+
* The soft scroll edge of a screen with no bar at that edge: content that scrolls up under the clock and the status
|
|
8
|
+
* icons, or down to the screen's bottom, is muted there. On iOS it is iOS 27.2's soft edge of a bottom bar (as
|
|
9
|
+
* TabBar's `fade`), turned over at the top: from the safe area's edge 34pt further in, a 10pt blur under a veil of
|
|
10
|
+
* the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
|
|
11
|
+
* over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
|
|
12
|
+
*/
|
|
13
|
+
export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID, style }) {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const insets = useSafeAreaInsets();
|
|
16
|
+
const canvas = canvasColor ?? theme.colors.background;
|
|
17
|
+
const top = edge === "top";
|
|
18
|
+
if (top && !scrolled)
|
|
19
|
+
return null;
|
|
20
|
+
if (theme.isAndroid) {
|
|
21
|
+
if (!top)
|
|
22
|
+
return null;
|
|
23
|
+
return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style], children: _jsx(SoftTopEdge, { fill: canvas, blur: Platform.OS === "web" ? 6 : 0 }) }));
|
|
24
|
+
}
|
|
25
|
+
// The safe area at that edge; the veil reaches 34 past it, into the screen
|
|
26
|
+
return (_jsx(View, { pointerEvents: "none", testID: testID, style: [{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style], children: top ? _jsx(SoftBottomVeil, { fill: canvas, bottom: insets.top }) : _jsx(SoftBottomVeil, { fill: canvas, top: 0 }) }));
|
|
27
|
+
}
|
|
@@ -3,7 +3,7 @@ import { createContext, useCallback, useContext, useEffect, useRef, useState } f
|
|
|
3
3
|
import { Animated, Easing, Pressable, StyleSheet, View, } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import Search from "../../icons/plex/Search";
|
|
6
|
-
import { BarBackdrop, SoftBottomEdge, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop";
|
|
6
|
+
import { BarBackdrop, SoftBottomEdge, TabBarFade, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop";
|
|
7
7
|
import { childrenOfType, textOf } from "../../internal/children";
|
|
8
8
|
import { physicalPadding } from "../../internal/direction";
|
|
9
9
|
import { Glass } from "../../internal/Glass";
|
|
@@ -40,7 +40,7 @@ function press(context, { value, disabled, onPress }, collapsed) {
|
|
|
40
40
|
onPress?.();
|
|
41
41
|
context.select(value);
|
|
42
42
|
}
|
|
43
|
-
function IOSTab({ value, label, icon, badge, disabled = false, onPress, testID, context, kind = "tab", hideLabel = false }) {
|
|
43
|
+
function IOSTab({ value, label, icon, badge, badgeColor, disabled = false, onPress, testID, context, kind = "tab", hideLabel = false }) {
|
|
44
44
|
const theme = useTheme();
|
|
45
45
|
const selected = context.value === value;
|
|
46
46
|
const circle = kind === "circle";
|
|
@@ -69,16 +69,17 @@ function IOSTab({ value, label, icon, badge, disabled = false, onPress, testID,
|
|
|
69
69
|
// A minimized tab takes the touches of its whole 48pt circle, not only its 40pt face
|
|
70
70
|
hitSlop: collapsed ? capsulePadding : undefined,
|
|
71
71
|
// A tab bar's labels keep their size, as UIKit's: a large text size shows the tab in the large content viewer
|
|
72
|
-
accessibilityShowsLargeContentViewer: true, accessibilityLargeContentTitle: textOf(label) || undefined, style: [styles.iosItem, size, circle ? null : { flexShrink: 1, minWidth: 0 }], children: [selected && !collapsed ? _jsx(View, { pointerEvents: "none", style: [styles.pill, pill, { backgroundColor: theme.color("--tab-bar-item-background-selected") }] }) : null, _jsx(View, { style: [styles.iosIcon, { height: theme.length("--tab-bar-icon-box", 28) }], children: _jsx(IconDefaultsProvider, { size: theme.length("--tab-bar-icon-size", 28), color: color, children: icon }) }), showLabel ? (_jsx(Text, { numberOfLines: 1, allowFontScaling: false, weight: "semibold", color: color, style: { fontSize: theme.length("--tab-bar-label-font-size", 10), lineHeight: theme.length("--tab-bar-label-line-height", 12), maxWidth: "100%" }, children: label })) : null, hasBadge(badge) && !circle ? (_jsx(View, { pointerEvents: "none", style: [styles.iosBadge, iosBadgeStyle(theme), { top: badgeTop, marginLeft: badgeStart }], children: badge === true ? null : (_jsx(Text, { color: theme.color("--tab-bar-badge-color"), style: iosBadgeText(theme), numberOfLines: 1, allowFontScaling: false, children: badge })) })) : null] }));
|
|
72
|
+
accessibilityShowsLargeContentViewer: true, accessibilityLargeContentTitle: textOf(label) || undefined, style: [styles.iosItem, size, circle ? null : { flexShrink: 1, minWidth: 0 }], children: [selected && !collapsed ? _jsx(View, { pointerEvents: "none", style: [styles.pill, pill, { backgroundColor: theme.color("--tab-bar-item-background-selected") }] }) : null, _jsx(View, { style: [styles.iosIcon, { height: theme.length("--tab-bar-icon-box", 28) }], children: _jsx(IconDefaultsProvider, { size: theme.length("--tab-bar-icon-size", 28), color: color, children: icon }) }), showLabel ? (_jsx(Text, { numberOfLines: 1, allowFontScaling: false, weight: "semibold", color: color, style: { fontSize: theme.length("--tab-bar-label-font-size", 10), lineHeight: theme.length("--tab-bar-label-line-height", 12), maxWidth: "100%" }, children: label })) : null, hasBadge(badge) && !circle ? (_jsx(View, { pointerEvents: "none", style: [styles.iosBadge, iosBadgeStyle(theme, badgeColor ?? context.badgeColor), { top: badgeTop, marginLeft: badgeStart }], children: badge === true ? null : (_jsx(Text, { color: (badgeColor ?? context.badgeColor) === "accent" ? theme.color("--color-text-accent-solid", "#FFFFFF") : theme.color("--tab-bar-badge-color"), style: iosBadgeText(theme), numberOfLines: 1, allowFontScaling: false, children: badge })) })) : null] }));
|
|
73
73
|
}
|
|
74
|
-
const iosBadgeStyle = (theme) => {
|
|
74
|
+
const iosBadgeStyle = (theme, color) => {
|
|
75
75
|
const size = theme.length("--tab-bar-badge-size", 18);
|
|
76
76
|
return {
|
|
77
77
|
minWidth: size,
|
|
78
78
|
height: size,
|
|
79
79
|
paddingHorizontal: theme.length("--tab-bar-badge-padding-inline", 5),
|
|
80
80
|
borderRadius: size / 2,
|
|
81
|
-
|
|
81
|
+
// iOS's own red, or the accent
|
|
82
|
+
backgroundColor: color === "accent" ? theme.color("--color-background-accent-solid") : theme.color("--tab-bar-badge-background"),
|
|
82
83
|
};
|
|
83
84
|
};
|
|
84
85
|
const iosBadgeText = (theme) => ({
|
|
@@ -99,7 +100,7 @@ const COUNT_SLIDE = 3;
|
|
|
99
100
|
* behind it). `true` draws a dot of the accent there. It scales in and out about that point (the center of a dot or a
|
|
100
101
|
* one-digit count), staying drawn as it shrinks away.
|
|
101
102
|
*/
|
|
102
|
-
function AndroidBadge({ badge, ring }) {
|
|
103
|
+
function AndroidBadge({ badge, ring, color }) {
|
|
103
104
|
const theme = useTheme();
|
|
104
105
|
const m = theme.material;
|
|
105
106
|
const reduced = theme.reducedMotion;
|
|
@@ -134,7 +135,7 @@ function AndroidBadge({ badge, ring }) {
|
|
|
134
135
|
return null;
|
|
135
136
|
const shown = visible ? badge : last;
|
|
136
137
|
const dot = shown === true;
|
|
137
|
-
return (_jsx(Animated.View, { pointerEvents: "none", style: [styles.androidBadgeFrame, { transform: [{ scale }] }], children: _jsx(Animated.View, { style: [dot ? styles.androidDot : styles.androidBadge, { backgroundColor: m.primary, borderColor: ring }], children: dot ? null : _jsx(BadgeCount, { value: shown, color: m.onPrimary, reduced: reduced }) }) }));
|
|
138
|
+
return (_jsx(Animated.View, { pointerEvents: "none", style: [styles.androidBadgeFrame, { transform: [{ scale }] }], children: _jsx(Animated.View, { style: [dot ? styles.androidDot : styles.androidBadge, { backgroundColor: color === "danger" ? m.error : m.primary, borderColor: ring }], children: dot ? null : _jsx(BadgeCount, { value: shown, color: color === "danger" ? m.onError : m.onPrimary, reduced: reduced }) }) }));
|
|
138
139
|
}
|
|
139
140
|
/**
|
|
140
141
|
* The text of an Android badge. When a count changes, the characters it shares with the last one (from either end)
|
|
@@ -209,7 +210,7 @@ function AndroidTabIcon({ icon, shown, selected, from, to }) {
|
|
|
209
210
|
* darker text, both blending there with the tab's own pill of the accent at 9%, which fades in and grows from 0.6
|
|
210
211
|
* over 320ms, decelerating. No ripple on a press, as the Android tab bar draws none.
|
|
211
212
|
*/
|
|
212
|
-
function AndroidTab({ value, label, icon, badge, disabled = false, onPress, testID, context, width, fontSize, }) {
|
|
213
|
+
function AndroidTab({ value, label, icon, badge, badgeColor, disabled = false, onPress, testID, context, width, fontSize, }) {
|
|
213
214
|
const theme = useTheme();
|
|
214
215
|
const m = theme.material;
|
|
215
216
|
const selected = context.value === value;
|
|
@@ -233,7 +234,7 @@ function AndroidTab({ value, label, icon, badge, disabled = false, onPress, test
|
|
|
233
234
|
opacity: shown.interpolate({ inputRange: [0, 1], outputRange: [0, 1], easing: DECELERATE }),
|
|
234
235
|
transform: [{ scale: shown.interpolate({ inputRange: [0, 1], outputRange: [0.6, 1] }) }],
|
|
235
236
|
},
|
|
236
|
-
] }), _jsx(AndroidTabIcon, { icon: icon, shown: shown, selected: selected, from: iconFrom, to: iconTo }), _jsx(Animated.Text, { numberOfLines: 1, style: [textStyle(theme, { weight: selected ? "bold" : "medium" }), { fontSize, lineHeight: 16, letterSpacing: theme.tracking(fontSize), maxWidth: "100%", color: text }], children: label }), _jsx(AndroidBadge, { badge: badge, ring: shown.interpolate({ inputRange: [0, 1], outputRange: [card, mix(m.primary, card, 0.09)], easing: DECELERATE }) })] }));
|
|
237
|
+
] }), _jsx(AndroidTabIcon, { icon: icon, shown: shown, selected: selected, from: iconFrom, to: iconTo }), _jsx(Animated.Text, { numberOfLines: 1, style: [textStyle(theme, { weight: selected ? "bold" : "medium" }), { fontSize, lineHeight: 16, letterSpacing: theme.tracking(fontSize), maxWidth: "100%", color: text }], children: label }), _jsx(AndroidBadge, { badge: badge, color: badgeColor ?? context.badgeColor, ring: shown.interpolate({ inputRange: [0, 1], outputRange: [card, mix(m.primary, card, 0.09)], easing: DECELERATE }) })] }));
|
|
237
238
|
}
|
|
238
239
|
/**
|
|
239
240
|
* The search or prominent tab of the bar, a 56dp circle of its own beside the capsule (ours: the Android bar has
|
|
@@ -296,7 +297,7 @@ function AndroidBar({ context, tabs, circle, accent, accessory, background, scro
|
|
|
296
297
|
// Android's fade under its tabs, from the bar's top (8 above the capsule): the
|
|
297
298
|
// screen's color fading in over 60dp in four even steps, then at 81% down to the edge; the other backgrounds show
|
|
298
299
|
// once content is under the bar
|
|
299
|
-
const backdrop = background === "soft" ? (_jsx(SoftBottomEdge, { fill: withAlpha(canvas, ANDROID_FADE_ALPHA), top: 60, tail: 60, blur: 0, stops: ANDROID_FADE_STOPS })) : background === "hard" ? (_jsx(BarBackdrop, { fill: canvas, line: scrolled ? m.outlineVariant : undefined, edge: "top" })) : background === "glass" && scrolled ? (_jsx(BarBackdrop, { fill: veil, blur: glassBarBlur(theme), line: m.outlineVariant, edge: "top" })) : null;
|
|
300
|
+
const backdrop = background === "soft" || background === "fade" ? (_jsx(SoftBottomEdge, { fill: withAlpha(canvas, ANDROID_FADE_ALPHA), top: 60, tail: 60, blur: 0, stops: ANDROID_FADE_STOPS })) : background === "hard" ? (_jsx(BarBackdrop, { fill: canvas, line: scrolled ? m.outlineVariant : undefined, edge: "top" })) : background === "glass" && scrolled ? (_jsx(BarBackdrop, { fill: veil, blur: glassBarBlur(theme), line: m.outlineVariant, edge: "top" })) : null;
|
|
300
301
|
return (_jsxs(View, { ...rest,
|
|
301
302
|
// Around the capsule the content shows and takes touches
|
|
302
303
|
pointerEvents: "box-none", onLayout: (event) => setWidth(event.nativeEvent.layout.width), style: [
|
|
@@ -316,7 +317,7 @@ const items = (children) => childrenOfType(children, TabBarItem);
|
|
|
316
317
|
* beside it.
|
|
317
318
|
* Props follow @plexui/ui.
|
|
318
319
|
*/
|
|
319
|
-
function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimized: minimizedProp, defaultMinimized = false, onMinimizedChange, background = "soft", scrolled = false, canvasColor, accessory, safeArea = true, "aria-label": ariaLabel = "Tabs", children, style, ...rest }) {
|
|
320
|
+
function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimized: minimizedProp, defaultMinimized = false, onMinimizedChange, background = "soft", scrolled = false, canvasColor, accessory, safeArea = true, badgeColor, "aria-label": ariaLabel = "Tabs", children, style, ...rest }) {
|
|
320
321
|
const theme = useTheme();
|
|
321
322
|
const insets = useSafeAreaInsets();
|
|
322
323
|
const tabs = items(children);
|
|
@@ -344,7 +345,7 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
344
345
|
const visible = shown.length ? shown : capsuleTabs.slice(0, 1);
|
|
345
346
|
const reachable = [...visible, ...(circle ? [circle] : [])];
|
|
346
347
|
const keys = useTabKeys(reachable, value, select);
|
|
347
|
-
const context = { value, minimized, select, expand, keys };
|
|
348
|
+
const context = { value, badgeColor, minimized, select, expand, keys };
|
|
348
349
|
if (theme.isAndroid) {
|
|
349
350
|
return (_jsx(TabBarContext.Provider, { value: context, children: _jsx(AndroidBar, { context: context, tabs: capsuleTabs, circle: circle, accent: !!prominentTab, accessory: accessory, background: background, scrolled: scrolled, canvasColor: canvasColor, safeArea: safeArea, ariaLabel: ariaLabel, rest: rest, style: style }) }));
|
|
350
351
|
}
|
|
@@ -360,7 +361,9 @@ function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, pro
|
|
|
360
361
|
const minimizedGap = theme.length("--tab-bar-minimized-accessory-gap", 13.33);
|
|
361
362
|
const canvas = canvasColor ?? theme.colors.background;
|
|
362
363
|
const veil = withAlpha(canvas, parseFloat(String(theme.token("--page-bar-veil-opacity") ?? "55")) / 100);
|
|
363
|
-
const backdrop = background === "hard" ? (_jsx(BarBackdrop, { fill: canvas, line: scrolled ? theme.color("--page-bar-hard-line") : undefined, edge: "top" })) : background === "glass" && scrolled ? (_jsx(BarBackdrop, { fill: veil, blur: glassBarBlur(theme), line: theme.color("--page-bar-line"), edge: "top" })) :
|
|
364
|
+
const backdrop = background === "hard" ? (_jsx(BarBackdrop, { fill: canvas, line: scrolled ? theme.color("--page-bar-hard-line") : undefined, edge: "top" })) : background === "glass" && scrolled ? (_jsx(BarBackdrop, { fill: veil, blur: glassBarBlur(theme), line: theme.color("--page-bar-line"), edge: "top" })) : background === "fade" ? (
|
|
365
|
+
// The screen's color coming in from the capsule's top (or the accessory's) down
|
|
366
|
+
_jsx(TabBarFade, { fill: canvas, top: padTop })) : null;
|
|
364
367
|
// The accessory keeps one place in the tree, so its state lives through a minimize: above the capsule, or between
|
|
365
368
|
// the two circles as tall as they are. The bar keeps its height either way, as TabBar.module.css
|
|
366
369
|
const sideLeft = gutter + (safeArea ? insets.left : 0);
|
package/dist/es/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export { OTPInput } from "./components/OTPInput/OTPInput";
|
|
|
26
26
|
export { Select } from "./components/Select/Select";
|
|
27
27
|
export { Menu } from "./components/Menu/Menu";
|
|
28
28
|
export { ContextMenu } from "./components/ContextMenu/ContextMenu";
|
|
29
|
+
export { ScrollEdge } from "./components/ScrollEdge/ScrollEdge";
|
|
29
30
|
export { DatePicker } from "./components/DatePicker/DatePicker";
|
|
30
31
|
export { ActionSheet } from "./components/ActionSheet/ActionSheet";
|
|
31
32
|
export { BottomSheet } from "./components/BottomSheet/BottomSheet";
|
|
@@ -177,3 +177,57 @@ export function SoftTopEdge({ fill, blur }) {
|
|
|
177
177
|
const stops = fadeStops(210 / 255, 48).map(([alpha, from]) => `${withAlpha(fill, alpha)} ${from}px`);
|
|
178
178
|
return (_jsxs(View, { pointerEvents: "none", style: StyleSheet.absoluteFill, children: [_jsx(View, { style: { flex: 1, backgroundColor: withAlpha(fill, 210 / 255) } }), _jsx(View, { style: { height: 48, backgroundImage: `linear-gradient(to bottom, ${stops.join(", ")})` } })] }));
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* iOS 27.2's soft scroll edge under a bottom bar (styles' --page-bar-soft-bottom-*, measured on a scrolled list,
|
|
182
|
+
* owner 13.11): from 34pt above the bar's items down to the screen's edge, a veil of the canvas color (8% 9 into the
|
|
183
|
+
* layer, 15% from 25 to 37, 23% at 45, 31% at 57, 46% from 77 down) over a 10pt blur that takes hold from 12 to 40
|
|
184
|
+
* into it. Over the canvas alone it draws nothing to see, so it stays drawn. Native draws the veil without the blur.
|
|
185
|
+
*/
|
|
186
|
+
const BOTTOM_REACH = 34;
|
|
187
|
+
const BOTTOM_VEIL = [
|
|
188
|
+
[0, 0],
|
|
189
|
+
[0.08, 9],
|
|
190
|
+
[0.15, 25],
|
|
191
|
+
[0.15, 37],
|
|
192
|
+
[0.23, 45],
|
|
193
|
+
[0.31, 57],
|
|
194
|
+
[0.46, 77],
|
|
195
|
+
];
|
|
196
|
+
export function SoftBottomVeil({ fill, top, bottom }) {
|
|
197
|
+
// `top`: under a bottom bar whose items start there; `bottom`: turned over, under the status bar `bottom` tall
|
|
198
|
+
const up = bottom != null;
|
|
199
|
+
const place = up
|
|
200
|
+
? { position: "absolute", top: 0, left: 0, right: 0, height: bottom + BOTTOM_REACH, overflow: "hidden", justifyContent: "flex-end" }
|
|
201
|
+
: { position: "absolute", top: (top ?? 0) - BOTTOM_REACH, left: 0, right: 0, bottom: 0 };
|
|
202
|
+
const way = up ? "to top" : "to bottom";
|
|
203
|
+
if (Platform.OS === "web") {
|
|
204
|
+
const veil = `linear-gradient(${way}, ${BOTTOM_VEIL.map(([alpha, at]) => `${black(alpha)} ${at}px`).join(", ")})`;
|
|
205
|
+
const blurMask = `linear-gradient(${way}, transparent 12px, #000 40px)`;
|
|
206
|
+
return (_jsxs(View, { pointerEvents: "none", style: place, children: [_jsx(View, { style: [StyleSheet.absoluteFill, { backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)", maskImage: blurMask, WebkitMaskImage: blurMask }] }), _jsx(View, { style: [StyleSheet.absoluteFill, { backgroundColor: fill, maskImage: veil, WebkitMaskImage: veil }] })] }));
|
|
207
|
+
}
|
|
208
|
+
const last = BOTTOM_VEIL[BOTTOM_VEIL.length - 1];
|
|
209
|
+
const gradient = `linear-gradient(${way}, ${BOTTOM_VEIL.map(([alpha, at]) => `${withAlpha(fill, alpha)} ${at}px`).join(", ")})`;
|
|
210
|
+
const ramp = _jsx(View, { style: { height: last[1], backgroundImage: gradient } });
|
|
211
|
+
const rest = _jsx(View, { style: { flex: 1, backgroundColor: withAlpha(fill, last[0]) } });
|
|
212
|
+
return (_jsxs(View, { pointerEvents: "none", style: place, children: [up ? rest : ramp, up ? ramp : rest] }));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The fade under a tab bar's capsule, as apps that mute the content under their tab bar draw it (measured on one at
|
|
216
|
+
* 3x): nothing above the capsule, so the rows over it stay clear; from the capsule's top the screen's color comes in
|
|
217
|
+
* over 60pt (6% 5 in, 25% 21 in, 37% 32 in, 56% 42 in, 69% 51 in, 85% from 60 in) and holds to the screen's edge,
|
|
218
|
+
* with no blur: the text under it stays sharp, only faint.
|
|
219
|
+
*/
|
|
220
|
+
const TAB_FADE = [
|
|
221
|
+
[0, 0],
|
|
222
|
+
[0.06, 5],
|
|
223
|
+
[0.25, 21],
|
|
224
|
+
[0.37, 32],
|
|
225
|
+
[0.56, 42],
|
|
226
|
+
[0.69, 51],
|
|
227
|
+
[0.85, 60],
|
|
228
|
+
];
|
|
229
|
+
export function TabBarFade({ fill, top }) {
|
|
230
|
+
const last = TAB_FADE[TAB_FADE.length - 1];
|
|
231
|
+
const gradient = `linear-gradient(to bottom, ${TAB_FADE.map(([alpha, at]) => `${withAlpha(fill, alpha)} ${at}px`).join(", ")})`;
|
|
232
|
+
return (_jsxs(View, { pointerEvents: "none", style: { position: "absolute", top, left: 0, right: 0, bottom: 0 }, children: [_jsx(View, { style: { height: last[1], backgroundImage: gradient } }), _jsx(View, { style: { flex: 1, backgroundColor: withAlpha(fill, last[0]) } })] }));
|
|
233
|
+
}
|
|
@@ -158,8 +158,11 @@ export function createTheme(options) {
|
|
|
158
158
|
success: color("--color-background-success-solid"),
|
|
159
159
|
onSuccess: color("--color-text-success-solid"),
|
|
160
160
|
danger: color("--color-background-danger-solid"),
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
// iOS's screens are black at night (systemBackground); Android's stay on the PlexUI canvas, as android.css
|
|
162
|
+
background: platform === "android" ? color("--gray-0", color("--color-surface")) : color("--mobile-surface-plain-primary", color("--color-surface")),
|
|
163
|
+
groupedBackground: platform === "android"
|
|
164
|
+
? color(scheme === "dark" ? "--gray-0" : "--gray-75", color("--color-surface-secondary"))
|
|
165
|
+
: color("--mobile-surface-grouped-primary", color("--color-surface-secondary")),
|
|
163
166
|
groupedSurface: color("--mobile-surface-grouped-secondary", color("--color-surface")),
|
|
164
167
|
surface: color("--color-surface"),
|
|
165
168
|
surfaceSecondary: color("--color-surface-secondary"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type StyleProp, type ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../../theme/types";
|
|
4
|
-
export type BadgeColor = "secondary" | "success" | "danger" | "warning" | "info" | "discovery" | "caution";
|
|
4
|
+
export type BadgeColor = "secondary" | "accent" | "success" | "danger" | "warning" | "info" | "discovery" | "caution";
|
|
5
5
|
export type BadgeVariant = "solid" | "soft" | "outline" | "counter";
|
|
6
6
|
export type BadgeSize = "sm" | "md" | "lg" | "xl";
|
|
7
7
|
export type BadgeProps = {
|
|
@@ -29,6 +29,17 @@ export type PageControlProps = {
|
|
|
29
29
|
* current white, the rest white at 40%), the capsule a white veil. @default "default"
|
|
30
30
|
*/
|
|
31
31
|
tone?: "default" | "onColor";
|
|
32
|
+
/**
|
|
33
|
+
* The way the pages run: `horizontal`, a row (mirrored in a right-to-left layout), or `vertical`, a column from top
|
|
34
|
+
* to bottom, as UIPageControl's `direction = .topToBottom` (never mirrored). @default "horizontal"
|
|
35
|
+
*/
|
|
36
|
+
direction?: "horizontal" | "vertical";
|
|
37
|
+
/**
|
|
38
|
+
* `md`, the platform's own dots (iOS 8pt 8 apart, Android 5dp 6 apart); `sm`, smaller dots for a control over a
|
|
39
|
+
* photo in a card: 5 apart 4 on iOS (the pill 14 long), 4dp 4 apart on Android, the capsule 16 thick. iOS has one size;
|
|
40
|
+
* `sm` is the kit's, as an app sets smaller indicator images. @default "md"
|
|
41
|
+
*/
|
|
42
|
+
size?: "sm" | "md";
|
|
32
43
|
/** @default (index, count) => `Page ${index + 1} of ${count}` */
|
|
33
44
|
valueText?: (index: number, count: number) => string;
|
|
34
45
|
/** @default "Pages" */
|
|
@@ -51,4 +62,4 @@ export declare const pageControlDots: (count: number, current: number) => PageCo
|
|
|
51
62
|
* page and back as it moves), in a 48dp target, with no capsule at all. For a screen reader it is adjustable: swipe
|
|
52
63
|
* up or down for the next or previous page.
|
|
53
64
|
*/
|
|
54
|
-
export declare function PageControl({ count, value: valueProp, defaultValue, onChange, background, indicator, tone, valueText, "aria-label": ariaLabel, testID, style, }: PageControlProps): import("react").JSX.Element;
|
|
65
|
+
export declare function PageControl({ count, value: valueProp, defaultValue, onChange, background, indicator, tone, direction, size, valueText, "aria-label": ariaLabel, testID, style, }: PageControlProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type StyleProp, type ViewStyle } from "react-native";
|
|
2
|
+
export type ScrollEdgeProps = {
|
|
3
|
+
/** The screen edge it stands at: under the status bar (`top`) or at the bottom of the screen. @default "top" */
|
|
4
|
+
edge?: "top" | "bottom";
|
|
5
|
+
/** Content is under the edge. The top edge shows only then; the bottom one stays, as iOS draws it. */
|
|
6
|
+
scrolled?: boolean;
|
|
7
|
+
/** The color of the screen it fades into (a grouped screen's canvas). @default the theme's background */
|
|
8
|
+
canvasColor?: string;
|
|
9
|
+
testID?: string;
|
|
10
|
+
style?: StyleProp<ViewStyle>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The soft scroll edge of a screen with no bar at that edge: content that scrolls up under the clock and the status
|
|
14
|
+
* icons, or down to the screen's bottom, is muted there. On iOS it is iOS 27.2's soft edge of a bottom bar (as
|
|
15
|
+
* TabBar's `fade`), turned over at the top: from the safe area's edge 34pt further in, a 10pt blur under a veil of
|
|
16
|
+
* the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
|
|
17
|
+
* over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ScrollEdge({ edge, scrolled, canvasColor, testID, style }: ScrollEdgeProps): import("react").JSX.Element | null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
import { type NativeScrollEvent, type NativeSyntheticEvent, type StyleProp, type ViewProps, type ViewStyle } from "react-native";
|
|
3
|
-
export type TabBarBackground = "soft" | "glass" | "hard" | "none";
|
|
3
|
+
export type TabBarBackground = "soft" | "fade" | "glass" | "hard" | "none";
|
|
4
4
|
export type TabBarSearch = {
|
|
5
5
|
/** The value of the search tab. */
|
|
6
6
|
value: string;
|
|
@@ -37,8 +37,10 @@ export type TabBarProps = Omit<ViewProps, "children"> & {
|
|
|
37
37
|
onMinimizedChange?: (minimized: boolean) => void;
|
|
38
38
|
/**
|
|
39
39
|
* How the bar meets content under it: `soft` and `none` let content run under the capsule (on Android `soft` fades
|
|
40
|
-
* the screen's color in under it, as the Android bar does),
|
|
41
|
-
*
|
|
40
|
+
* the screen's color in under it, as the Android bar does), as native iOS 26 tab bars do; `fade` mutes it, as many
|
|
41
|
+
* apps do on iOS: the rows over the capsule stay clear, and from its top the screen's color comes in over 60pt to
|
|
42
|
+
* 85%, held to the screen's edge, with no blur (on Android as `soft`); `hard` an opaque bar, `glass` a translucent
|
|
43
|
+
* blurred one. The lines and the glass show once `scrolled` says content is under it; the fade stays drawn.
|
|
42
44
|
* @default "soft"
|
|
43
45
|
*/
|
|
44
46
|
background?: TabBarBackground;
|
|
@@ -51,6 +53,11 @@ export type TabBarProps = Omit<ViewProps, "children"> & {
|
|
|
51
53
|
canvasColor?: string;
|
|
52
54
|
/** Content in a glass capsule above the tabs (iOS 26 bottom accessory); minimized, between the two circles. */
|
|
53
55
|
accessory?: ReactNode;
|
|
56
|
+
/**
|
|
57
|
+
* The badges' color: `danger`, the red of iOS's badges, or `accent`, the accent with its on color, as Android's
|
|
58
|
+
* badges are; a tab's own `badgeColor` wins. @default the platform's own: "danger" on iOS, "accent" on Android
|
|
59
|
+
*/
|
|
60
|
+
badgeColor?: TabBarBadgeColor;
|
|
54
61
|
/** Pads the bar for the home indicator. @default true */
|
|
55
62
|
safeArea?: boolean;
|
|
56
63
|
/** Accessible name of the navigation. @default "Tabs" */
|
|
@@ -71,12 +78,15 @@ export type TabBarItemProps = {
|
|
|
71
78
|
* count of 0 shows none, as on iOS. `true` draws a small dot on Android and an empty capsule on iOS.
|
|
72
79
|
*/
|
|
73
80
|
badge?: ReactNode;
|
|
81
|
+
/** The badge's color, over the bar's `badgeColor`. */
|
|
82
|
+
badgeColor?: TabBarBadgeColor;
|
|
74
83
|
/** When `true`, the tab cannot be selected. */
|
|
75
84
|
disabled?: boolean;
|
|
76
85
|
/** Called when the tab is pressed, before it is selected. */
|
|
77
86
|
onPress?: () => void;
|
|
78
87
|
testID?: string;
|
|
79
88
|
};
|
|
89
|
+
export type TabBarBadgeColor = "danger" | "accent";
|
|
80
90
|
/** One destination of the bar. */
|
|
81
91
|
declare function TabBarItem(props: TabBarItemProps): ReactElement | null;
|
|
82
92
|
declare namespace TabBarItem {
|
|
@@ -90,7 +100,7 @@ declare namespace TabBarItem {
|
|
|
90
100
|
* beside it.
|
|
91
101
|
* Props follow @plexui/ui.
|
|
92
102
|
*/
|
|
93
|
-
declare function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimized: minimizedProp, defaultMinimized, onMinimizedChange, background, scrolled, canvasColor, accessory, safeArea, "aria-label": ariaLabel, children, style, ...rest }: TabBarProps): import("react").JSX.Element;
|
|
103
|
+
declare function TabBarRoot({ value: valueProp, defaultValue, onValueChange, search, prominent, minimized: minimizedProp, defaultMinimized, onMinimizedChange, background, scrolled, canvasColor, accessory, safeArea, badgeColor, "aria-label": ariaLabel, children, style, ...rest }: TabBarProps): import("react").JSX.Element;
|
|
94
104
|
declare namespace TabBarRoot {
|
|
95
105
|
var displayName: string;
|
|
96
106
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export { Glass, type GlassProps } from "./internal/Glass";
|
|
|
10
10
|
export { BarItemContext, type BarItemStyle } from "./components/Button/Button";
|
|
11
11
|
export { NavigationButton, type NavigationAction, type NavigationButtonProps } from "./components/NavigationButton/NavigationButton";
|
|
12
12
|
export { Toolbar, type ToolbarBackground, type ToolbarContentProps, type ToolbarPlacement, type ToolbarProps, type ToolbarTitleAlign, type ToolbarTitleProps, type ToolbarTitleStyle, } from "./components/Toolbar/Toolbar";
|
|
13
|
-
export { TabBar, useTabBarMinimize, type TabBarBackground, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch, } from "./components/TabBar/TabBar";
|
|
13
|
+
export { TabBar, useTabBarMinimize, type TabBarBackground, type TabBarBadgeColor, type TabBarItemProps, type TabBarProminent, type TabBarProps, type TabBarSearch, } from "./components/TabBar/TabBar";
|
|
14
14
|
export { SegmentedControl, type SegmentedControlBadgeProp, type SegmentedControlOptionProps, type SegmentedControlProps, } from "./components/SegmentedControl/SegmentedControl";
|
|
15
15
|
export { Switch, type SwitchProps } from "./components/Switch/Switch";
|
|
16
16
|
export { Checkbox, type CheckboxProps } from "./components/Checkbox/Checkbox";
|
|
@@ -25,6 +25,7 @@ export { OTPInput, type OTPInputProps } from "./components/OTPInput/OTPInput";
|
|
|
25
25
|
export { Select, type SelectOption, type SelectProps } from "./components/Select/Select";
|
|
26
26
|
export { Menu, type MenuContentProps, type MenuItemProps, type MenuProps } from "./components/Menu/Menu";
|
|
27
27
|
export { ContextMenu, type ContextMenuContentProps, type ContextMenuProps } from "./components/ContextMenu/ContextMenu";
|
|
28
|
+
export { ScrollEdge, type ScrollEdgeProps } from "./components/ScrollEdge/ScrollEdge";
|
|
28
29
|
export { DatePicker, type DatePickerDisplay, type DatePickerMode, type DatePickerProps } from "./components/DatePicker/DatePicker";
|
|
29
30
|
export { ActionSheet, type ActionSheetAction, type ActionSheetProps } from "./components/ActionSheet/ActionSheet";
|
|
30
31
|
export { BottomSheet, type BottomSheetFooterProps, type BottomSheetProps } from "./components/BottomSheet/BottomSheet";
|
|
@@ -54,3 +54,12 @@ export declare function SoftTopEdge({ fill, blur }: {
|
|
|
54
54
|
fill: string;
|
|
55
55
|
blur: number;
|
|
56
56
|
}): import("react").JSX.Element;
|
|
57
|
+
export declare function SoftBottomVeil({ fill, top, bottom }: {
|
|
58
|
+
fill: string;
|
|
59
|
+
top?: number;
|
|
60
|
+
bottom?: number;
|
|
61
|
+
}): import("react").JSX.Element;
|
|
62
|
+
export declare function TabBarFade({ fill, top }: {
|
|
63
|
+
fill: string;
|
|
64
|
+
top: number;
|
|
65
|
+
}): import("react").JSX.Element;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/react-native",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Plex UI components for React Native and Expo: iOS 26 and Material 3, on the shared @plexui/styles tokens",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://plexui.com",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"test": "npm run typecheck && npm run lint && npm run test:web --prefix example"
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@plexui/styles": "^0.17.
|
|
87
|
+
"@plexui/styles": "^0.17.3"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
90
|
"expo-blur": ">=15",
|
|
@@ -8,7 +8,7 @@ import type { Theme } from "../../theme/types"
|
|
|
8
8
|
import { IconDefaultsProvider } from "../Icon/createIcon"
|
|
9
9
|
import { Text, TextColorProvider, type TextProps } from "../Text/Text"
|
|
10
10
|
|
|
11
|
-
export type BadgeColor = "secondary" | "success" | "danger" | "warning" | "info" | "discovery" | "caution"
|
|
11
|
+
export type BadgeColor = "secondary" | "accent" | "success" | "danger" | "warning" | "info" | "discovery" | "caution"
|
|
12
12
|
export type BadgeVariant = "solid" | "soft" | "outline" | "counter"
|
|
13
13
|
export type BadgeSize = "sm" | "md" | "lg" | "xl"
|
|
14
14
|
|
|
@@ -49,6 +49,14 @@ export function counterBadgeColors(theme: Theme, color: BadgeColor) {
|
|
|
49
49
|
|
|
50
50
|
export function badgeColors(theme: Theme, variant: BadgeVariant, color: BadgeColor) {
|
|
51
51
|
if (variant === "counter") return counterBadgeColors(theme, color)
|
|
52
|
+
// The accent has a solid and a soft step and one text color (styles' accent tokens): soft on the soft fill, the
|
|
53
|
+
// outline's text and line in that text color
|
|
54
|
+
if (color === "accent") {
|
|
55
|
+
const text = theme.color("--color-text-accent")
|
|
56
|
+
if (variant === "solid") return { background: theme.color("--color-background-accent-solid"), text: theme.color("--color-text-accent-solid", "#FFFFFF"), border: undefined }
|
|
57
|
+
if (variant === "outline") return { background: "transparent", text, border: text }
|
|
58
|
+
return { background: theme.color("--color-background-accent-soft"), text, border: undefined }
|
|
59
|
+
}
|
|
52
60
|
if (variant === "outline") return { background: "transparent", text: theme.color(`--color-text-${color}-outline`), border: theme.color(`--color-border-${color}-outline`) }
|
|
53
61
|
if (variant === "solid") return { background: theme.color(`--color-background-${color}-solid`), text: theme.color(`--color-text-${color}-solid`), border: undefined }
|
|
54
62
|
return { background: theme.color(`--color-background-${color}-soft-alpha`), text: theme.color(`--color-text-${color}-soft`), border: undefined }
|
|
@@ -36,6 +36,17 @@ export type PageControlProps = {
|
|
|
36
36
|
* current white, the rest white at 40%), the capsule a white veil. @default "default"
|
|
37
37
|
*/
|
|
38
38
|
tone?: "default" | "onColor"
|
|
39
|
+
/**
|
|
40
|
+
* The way the pages run: `horizontal`, a row (mirrored in a right-to-left layout), or `vertical`, a column from top
|
|
41
|
+
* to bottom, as UIPageControl's `direction = .topToBottom` (never mirrored). @default "horizontal"
|
|
42
|
+
*/
|
|
43
|
+
direction?: "horizontal" | "vertical"
|
|
44
|
+
/**
|
|
45
|
+
* `md`, the platform's own dots (iOS 8pt 8 apart, Android 5dp 6 apart); `sm`, smaller dots for a control over a
|
|
46
|
+
* photo in a card: 5 apart 4 on iOS (the pill 14 long), 4dp 4 apart on Android, the capsule 16 thick. iOS has one size;
|
|
47
|
+
* `sm` is the kit's, as an app sets smaller indicator images. @default "md"
|
|
48
|
+
*/
|
|
49
|
+
size?: "sm" | "md"
|
|
39
50
|
/** @default (index, count) => `Page ${index + 1} of ${count}` */
|
|
40
51
|
valueText?: (index: number, count: number) => string
|
|
41
52
|
/** @default "Pages" */
|
|
@@ -98,6 +109,8 @@ export function PageControl({
|
|
|
98
109
|
background = "automatic",
|
|
99
110
|
indicator = "dots",
|
|
100
111
|
tone = "default",
|
|
112
|
+
direction = "horizontal",
|
|
113
|
+
size = "md",
|
|
101
114
|
valueText = defaultValueText,
|
|
102
115
|
"aria-label": ariaLabel = "Pages",
|
|
103
116
|
testID,
|
|
@@ -116,24 +129,31 @@ export function PageControl({
|
|
|
116
129
|
onChange?.(next, { scrubbing })
|
|
117
130
|
}
|
|
118
131
|
const android = theme.isAndroid
|
|
119
|
-
const
|
|
120
|
-
const
|
|
121
|
-
const
|
|
132
|
+
const small = size === "sm"
|
|
133
|
+
const vertical = direction === "vertical"
|
|
134
|
+
const dot = small ? (android ? 4 : 5) : android ? ANDROID_DOT : theme.length("--page-control-dot-size", 8)
|
|
135
|
+
const gap = small ? 4 : android ? ANDROID_GAP : theme.length("--page-control-gap", 8)
|
|
136
|
+
const padding = small ? 6 : theme.length("--page-control-padding-inline", 12)
|
|
122
137
|
const pitch = dot + gap
|
|
123
138
|
// Android draws every page's dot at full size; the iOS kit shrinks the ends from seven pages
|
|
124
139
|
const sizes = android ? Array.from({ length: Math.max(0, count) }, (): PageControlDotSize => "full") : pageControlDots(count, current)
|
|
125
|
-
|
|
126
|
-
|
|
140
|
+
// The small and smaller ends keep their share of a full dot (6 and 4 of 8 on iOS)
|
|
141
|
+
const dotSize = (kind: PageControlDotSize) =>
|
|
142
|
+
kind === "full"
|
|
143
|
+
? dot
|
|
144
|
+
: android
|
|
145
|
+
? Math.max(2, dot - (kind === "small" ? 1 : 2))
|
|
146
|
+
: (dot / 8) * (kind === "small" ? theme.length("--page-control-dot-size-small", 6) : theme.length("--page-control-dot-size-smaller", 4))
|
|
127
147
|
const pill = indicator === "pill"
|
|
128
|
-
// A pill: the current page two and a half dots
|
|
129
|
-
const dotWidth = (
|
|
148
|
+
// A pill: the current page two and a half dots long (18 at `sm`), along the direction
|
|
149
|
+
const dotWidth = (kind: PageControlDotSize, index: number) => (pill && index === current ? (small ? 14 : dot * 2.5) : dotSize(kind))
|
|
130
150
|
// The center of the current dot, for a tap on either side of it
|
|
131
151
|
let x = padding
|
|
132
152
|
let currentCenter = padding
|
|
133
|
-
sizes.forEach((
|
|
134
|
-
if (
|
|
135
|
-
if (index === current) currentCenter = x + dotWidth(
|
|
136
|
-
x += dotWidth(
|
|
153
|
+
sizes.forEach((kind, index) => {
|
|
154
|
+
if (kind === "hidden") return
|
|
155
|
+
if (index === current) currentCenter = x + dotWidth(kind, index) / 2
|
|
156
|
+
x += dotWidth(kind, index) + gap
|
|
137
157
|
})
|
|
138
158
|
const onColor = tone === "onColor"
|
|
139
159
|
const on = onColor ? "#FFFFFF" : android ? theme.material.primary : theme.color("--page-control-dot-color-current", theme.colors.text)
|
|
@@ -142,7 +162,7 @@ export function PageControl({
|
|
|
142
162
|
// Android's current dot is drawn over the gray ones (it stretches between pages); a pill is a dot of its own
|
|
143
163
|
const worm = android && !pill
|
|
144
164
|
// Android draws no capsule, not even for `prominent`
|
|
145
|
-
const capsuleHeight = theme.length("--page-control-height", 24)
|
|
165
|
+
const capsuleHeight = small ? 16 : theme.length("--page-control-height", 24)
|
|
146
166
|
const target = android ? 48 : theme.length("--page-control-target-size", 44)
|
|
147
167
|
const showBackground = !android && (background === "prominent" || (background === "automatic" && press != null))
|
|
148
168
|
const text = valueText(current, count)
|
|
@@ -153,7 +173,7 @@ export function PageControl({
|
|
|
153
173
|
onKeyDown: (raw: unknown) => {
|
|
154
174
|
const event = raw as { key: string; preventDefault: () => void; currentTarget?: unknown }
|
|
155
175
|
// The dots run from the right in a right-to-left row: the left arrow goes on to the next page
|
|
156
|
-
const ahead = isRTL(event.currentTarget) ? -1 : 1
|
|
176
|
+
const ahead = !vertical && isRTL(event.currentTarget) ? -1 : 1
|
|
157
177
|
const to: Record<string, number> = { ArrowRight: current + ahead, ArrowDown: current + 1, ArrowLeft: current - ahead, ArrowUp: current - 1, Home: 0, End: count - 1 }
|
|
158
178
|
if (!(event.key in to)) return
|
|
159
179
|
event.preventDefault()
|
|
@@ -163,7 +183,7 @@ export function PageControl({
|
|
|
163
183
|
: {}
|
|
164
184
|
const onMove = (event: GestureResponderEvent) => {
|
|
165
185
|
if (!press || background === "minimal") return
|
|
166
|
-
const dx = (event.nativeEvent.locationX - press.startX) * (press.rtl ? -1 : 1)
|
|
186
|
+
const dx = ((vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX) - press.startX) * (press.rtl ? -1 : 1)
|
|
167
187
|
if (!press.scrubbing && Math.abs(dx) < SCRUB_THRESHOLD) return
|
|
168
188
|
if (!press.scrubbing) setPress({ ...press, scrubbing: true })
|
|
169
189
|
go(press.startIndex + Math.round(dx / pitch), true)
|
|
@@ -183,12 +203,14 @@ export function PageControl({
|
|
|
183
203
|
aria-valuetext={text}
|
|
184
204
|
onStartShouldSetResponder={() => count > 1}
|
|
185
205
|
onResponderTerminationRequest={() => !press?.scrubbing}
|
|
186
|
-
onResponderGrant={(event) =>
|
|
206
|
+
onResponderGrant={(event) =>
|
|
207
|
+
setPress({ startX: vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX, startIndex: current, scrubbing: false, rtl: !vertical && isRTL(event.currentTarget) })
|
|
208
|
+
}
|
|
187
209
|
onResponderMove={onMove}
|
|
188
210
|
onResponderRelease={(event) => {
|
|
189
211
|
// A tap on the leading side of the current dot goes back, on the trailing side forward; the dots are laid
|
|
190
212
|
// from the capsule's start, its right edge in a right-to-left row
|
|
191
|
-
const x = event.nativeEvent.locationX
|
|
213
|
+
const x = vertical ? event.nativeEvent.locationY : event.nativeEvent.locationX
|
|
192
214
|
const fromStart = press?.rtl ? capsule.x + capsule.width - x : x - capsule.x
|
|
193
215
|
if (press && !press.scrubbing) go(current + (fromStart < currentCenter ? -1 : 1))
|
|
194
216
|
setPress(null)
|
|
@@ -196,24 +218,44 @@ export function PageControl({
|
|
|
196
218
|
onResponderTerminate={() => setPress(null)}
|
|
197
219
|
testID={testID}
|
|
198
220
|
// The target (44pt, 48dp on Android) reaches past the 24pt capsule without taking room, as the web's control
|
|
199
|
-
// lays out at the capsule's height
|
|
200
|
-
style={[
|
|
221
|
+
// lays out at the capsule's height,
|
|
222
|
+
style={[
|
|
223
|
+
styles.target,
|
|
224
|
+
// and is never shorter than that along the dots either (two small dots), the capsule centred in it
|
|
225
|
+
vertical
|
|
226
|
+
? { minWidth: target, minHeight: target, justifyContent: "center", marginHorizontal: -(target - capsuleHeight) / 2 }
|
|
227
|
+
: { minHeight: target, minWidth: target, justifyContent: "center", marginVertical: -(target - capsuleHeight) / 2 },
|
|
228
|
+
style,
|
|
229
|
+
]}
|
|
201
230
|
>
|
|
202
231
|
<View
|
|
203
232
|
pointerEvents="none"
|
|
204
|
-
onLayout={(event) =>
|
|
233
|
+
onLayout={(event) => {
|
|
234
|
+
const { x: left, y: top, width, height } = event.nativeEvent.layout
|
|
235
|
+
setCapsule(vertical ? { x: top, width: height } : { x: left, width })
|
|
236
|
+
}}
|
|
205
237
|
style={[
|
|
206
238
|
styles.capsule,
|
|
207
|
-
|
|
239
|
+
vertical
|
|
240
|
+
? { flexDirection: "column", width: capsuleHeight, paddingVertical: padding, gap, borderRadius: capsuleHeight / 2 }
|
|
241
|
+
: { height: capsuleHeight, paddingHorizontal: padding, gap, borderRadius: capsuleHeight / 2 },
|
|
208
242
|
showBackground ? { backgroundColor: onColor ? "rgba(255, 255, 255, 0.2)" : theme.color("--page-control-background") } : null,
|
|
209
243
|
]}
|
|
210
244
|
>
|
|
211
245
|
{sizes.map((size, index) =>
|
|
212
246
|
size === "hidden" ? null : (
|
|
213
|
-
<View
|
|
247
|
+
<View
|
|
248
|
+
key={index}
|
|
249
|
+
style={{
|
|
250
|
+
width: vertical ? dotSize(size) : dotWidth(size, index),
|
|
251
|
+
height: vertical ? dotWidth(size, index) : dotSize(size),
|
|
252
|
+
borderRadius: dot / 2,
|
|
253
|
+
backgroundColor: index === current && !worm ? on : off,
|
|
254
|
+
}}
|
|
255
|
+
/>
|
|
214
256
|
),
|
|
215
257
|
)}
|
|
216
|
-
{worm ? <AndroidCurrent start={currentCenter - dot / 2} color={on} reduced={theme.reducedMotion} /> : null}
|
|
258
|
+
{worm ? <AndroidCurrent start={currentCenter - dot / 2} color={on} reduced={theme.reducedMotion} dot={dot} vertical={vertical} /> : null}
|
|
217
259
|
</View>
|
|
218
260
|
</View>
|
|
219
261
|
)
|
|
@@ -233,7 +275,7 @@ const WORM_SETTLE = { duration: 200, easing: curves.easeOutQuint }
|
|
|
233
275
|
* one. On a change the far edge is on the new page at once and the near edge follows it through the settle, as when
|
|
234
276
|
* the pages' scroll draws the dot.
|
|
235
277
|
*/
|
|
236
|
-
function AndroidCurrent({ start, color, reduced }: { start: number; color: string; reduced: boolean }) {
|
|
278
|
+
function AndroidCurrent({ start, color, reduced, dot, vertical }: { start: number; color: string; reduced: boolean; dot: number; vertical: boolean }) {
|
|
237
279
|
const [head] = useState(() => new Animated.Value(start))
|
|
238
280
|
const [tail] = useState(() => new Animated.Value(start))
|
|
239
281
|
const first = useRef(true)
|
|
@@ -253,9 +295,14 @@ function AndroidCurrent({ start, color, reduced }: { start: number; color: strin
|
|
|
253
295
|
// `start` keeps it on the dots' side in a right-to-left row
|
|
254
296
|
const span = Animated.subtract(head, tail).interpolate({ inputRange: [-1000, 0, 1000], outputRange: [1000, 0, 1000] })
|
|
255
297
|
const left = Animated.multiply(Animated.subtract(Animated.add(head, tail), span), 0.5)
|
|
298
|
+
const length = Animated.add(span, dot)
|
|
256
299
|
return (
|
|
257
300
|
<Animated.View
|
|
258
|
-
style={
|
|
301
|
+
style={
|
|
302
|
+
vertical
|
|
303
|
+
? { position: "absolute", left: "50%", marginLeft: -dot / 2, top: left, width: dot, borderRadius: dot / 2, backgroundColor: color, height: length }
|
|
304
|
+
: { position: "absolute", top: "50%", marginTop: -dot / 2, start: left, height: dot, borderRadius: dot / 2, backgroundColor: color, width: length }
|
|
305
|
+
}
|
|
259
306
|
/>
|
|
260
307
|
)
|
|
261
308
|
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Platform, View, type StyleProp, type ViewStyle } from "react-native"
|
|
2
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
3
|
+
import { SoftBottomVeil, SoftTopEdge } from "../../internal/BarBackdrop"
|
|
4
|
+
import { useTheme } from "../../theme/ThemeProvider"
|
|
5
|
+
|
|
6
|
+
export type ScrollEdgeProps = {
|
|
7
|
+
/** The screen edge it stands at: under the status bar (`top`) or at the bottom of the screen. @default "top" */
|
|
8
|
+
edge?: "top" | "bottom"
|
|
9
|
+
/** Content is under the edge. The top edge shows only then; the bottom one stays, as iOS draws it. */
|
|
10
|
+
scrolled?: boolean
|
|
11
|
+
/** The color of the screen it fades into (a grouped screen's canvas). @default the theme's background */
|
|
12
|
+
canvasColor?: string
|
|
13
|
+
testID?: string
|
|
14
|
+
style?: StyleProp<ViewStyle>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The soft scroll edge of a screen with no bar at that edge: content that scrolls up under the clock and the status
|
|
19
|
+
* icons, or down to the screen's bottom, is muted there. On iOS it is iOS 27.2's soft edge of a bottom bar (as
|
|
20
|
+
* TabBar's `fade`), turned over at the top: from the safe area's edge 34pt further in, a 10pt blur under a veil of
|
|
21
|
+
* the screen's color that grows to 46% at the screen's edge. On Android the top edge is the soft edge of its top bar
|
|
22
|
+
* over the status bar alone, the bottom one draws nothing. Lay it over the screen, after the scroll view.
|
|
23
|
+
*/
|
|
24
|
+
export function ScrollEdge({ edge = "top", scrolled = false, canvasColor, testID, style }: ScrollEdgeProps) {
|
|
25
|
+
const theme = useTheme()
|
|
26
|
+
const insets = useSafeAreaInsets()
|
|
27
|
+
const canvas = canvasColor ?? theme.colors.background
|
|
28
|
+
const top = edge === "top"
|
|
29
|
+
if (top && !scrolled) return null
|
|
30
|
+
if (theme.isAndroid) {
|
|
31
|
+
if (!top) return null
|
|
32
|
+
return (
|
|
33
|
+
<View pointerEvents="none" testID={testID} style={[{ position: "absolute", top: 0, left: 0, right: 0, height: insets.top }, style]}>
|
|
34
|
+
<SoftTopEdge fill={canvas} blur={Platform.OS === "web" ? 6 : 0} />
|
|
35
|
+
</View>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
// The safe area at that edge; the veil reaches 34 past it, into the screen
|
|
39
|
+
return (
|
|
40
|
+
<View
|
|
41
|
+
pointerEvents="none"
|
|
42
|
+
testID={testID}
|
|
43
|
+
style={[{ position: "absolute", left: 0, right: 0 }, top ? { top: 0, height: insets.top } : { bottom: 0, height: insets.bottom }, style]}
|
|
44
|
+
>
|
|
45
|
+
{top ? <SoftBottomVeil fill={canvas} bottom={insets.top} /> : <SoftBottomVeil fill={canvas} top={0} />}
|
|
46
|
+
</View>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from "react-native"
|
|
15
15
|
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
|
16
16
|
import Search from "../../icons/plex/Search"
|
|
17
|
-
import { BarBackdrop, SoftBottomEdge, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop"
|
|
17
|
+
import { BarBackdrop, SoftBottomEdge, TabBarFade, ANDROID_FADE_ALPHA, ANDROID_FADE_STOPS, glassBarBlur, useAndroidGlass } from "../../internal/BarBackdrop"
|
|
18
18
|
import { childrenOfType, textOf } from "../../internal/children"
|
|
19
19
|
import { physicalPadding } from "../../internal/direction"
|
|
20
20
|
import { Glass } from "../../internal/Glass"
|
|
@@ -26,7 +26,7 @@ import type { Theme } from "../../theme/types"
|
|
|
26
26
|
import { IconDefaultsProvider } from "../Icon/createIcon"
|
|
27
27
|
import { Text, textStyle } from "../Text/Text"
|
|
28
28
|
|
|
29
|
-
export type TabBarBackground = "soft" | "glass" | "hard" | "none"
|
|
29
|
+
export type TabBarBackground = "soft" | "fade" | "glass" | "hard" | "none"
|
|
30
30
|
|
|
31
31
|
export type TabBarSearch = {
|
|
32
32
|
/** The value of the search tab. */
|
|
@@ -66,8 +66,10 @@ export type TabBarProps = Omit<ViewProps, "children"> & {
|
|
|
66
66
|
onMinimizedChange?: (minimized: boolean) => void
|
|
67
67
|
/**
|
|
68
68
|
* How the bar meets content under it: `soft` and `none` let content run under the capsule (on Android `soft` fades
|
|
69
|
-
* the screen's color in under it, as the Android bar does),
|
|
70
|
-
*
|
|
69
|
+
* the screen's color in under it, as the Android bar does), as native iOS 26 tab bars do; `fade` mutes it, as many
|
|
70
|
+
* apps do on iOS: the rows over the capsule stay clear, and from its top the screen's color comes in over 60pt to
|
|
71
|
+
* 85%, held to the screen's edge, with no blur (on Android as `soft`); `hard` an opaque bar, `glass` a translucent
|
|
72
|
+
* blurred one. The lines and the glass show once `scrolled` says content is under it; the fade stays drawn.
|
|
71
73
|
* @default "soft"
|
|
72
74
|
*/
|
|
73
75
|
background?: TabBarBackground
|
|
@@ -80,6 +82,11 @@ export type TabBarProps = Omit<ViewProps, "children"> & {
|
|
|
80
82
|
canvasColor?: string
|
|
81
83
|
/** Content in a glass capsule above the tabs (iOS 26 bottom accessory); minimized, between the two circles. */
|
|
82
84
|
accessory?: ReactNode
|
|
85
|
+
/**
|
|
86
|
+
* The badges' color: `danger`, the red of iOS's badges, or `accent`, the accent with its on color, as Android's
|
|
87
|
+
* badges are; a tab's own `badgeColor` wins. @default the platform's own: "danger" on iOS, "accent" on Android
|
|
88
|
+
*/
|
|
89
|
+
badgeColor?: TabBarBadgeColor
|
|
83
90
|
/** Pads the bar for the home indicator. @default true */
|
|
84
91
|
safeArea?: boolean
|
|
85
92
|
/** Accessible name of the navigation. @default "Tabs" */
|
|
@@ -101,6 +108,8 @@ export type TabBarItemProps = {
|
|
|
101
108
|
* count of 0 shows none, as on iOS. `true` draws a small dot on Android and an empty capsule on iOS.
|
|
102
109
|
*/
|
|
103
110
|
badge?: ReactNode
|
|
111
|
+
/** The badge's color, over the bar's `badgeColor`. */
|
|
112
|
+
badgeColor?: TabBarBadgeColor
|
|
104
113
|
/** When `true`, the tab cannot be selected. */
|
|
105
114
|
disabled?: boolean
|
|
106
115
|
/** Called when the tab is pressed, before it is selected. */
|
|
@@ -108,8 +117,11 @@ export type TabBarItemProps = {
|
|
|
108
117
|
testID?: string
|
|
109
118
|
}
|
|
110
119
|
|
|
120
|
+
export type TabBarBadgeColor = "danger" | "accent"
|
|
121
|
+
|
|
111
122
|
type TabBarContextValue = {
|
|
112
123
|
value: string | undefined
|
|
124
|
+
badgeColor?: TabBarBadgeColor
|
|
113
125
|
minimized: boolean
|
|
114
126
|
select: (value: string) => void
|
|
115
127
|
expand: () => void
|
|
@@ -149,7 +161,7 @@ function press(context: TabBarContextValue, { value, disabled, onPress }: TabBar
|
|
|
149
161
|
context.select(value)
|
|
150
162
|
}
|
|
151
163
|
|
|
152
|
-
function IOSTab({ value, label, icon, badge, disabled = false, onPress, testID, context, kind = "tab", hideLabel = false }: TabProps) {
|
|
164
|
+
function IOSTab({ value, label, icon, badge, badgeColor, disabled = false, onPress, testID, context, kind = "tab", hideLabel = false }: TabProps) {
|
|
153
165
|
const theme = useTheme()
|
|
154
166
|
const selected = context.value === value
|
|
155
167
|
const circle = kind === "circle"
|
|
@@ -209,9 +221,9 @@ function IOSTab({ value, label, icon, badge, disabled = false, onPress, testID,
|
|
|
209
221
|
</Text>
|
|
210
222
|
) : null}
|
|
211
223
|
{hasBadge(badge) && !circle ? (
|
|
212
|
-
<View pointerEvents="none" style={[styles.iosBadge, iosBadgeStyle(theme), { top: badgeTop, marginLeft: badgeStart }]}>
|
|
224
|
+
<View pointerEvents="none" style={[styles.iosBadge, iosBadgeStyle(theme, badgeColor ?? context.badgeColor), { top: badgeTop, marginLeft: badgeStart }]}>
|
|
213
225
|
{badge === true ? null : (
|
|
214
|
-
<Text color={theme.color("--tab-bar-badge-color")} style={iosBadgeText(theme)} numberOfLines={1} allowFontScaling={false}>
|
|
226
|
+
<Text color={(badgeColor ?? context.badgeColor) === "accent" ? theme.color("--color-text-accent-solid", "#FFFFFF") : theme.color("--tab-bar-badge-color")} style={iosBadgeText(theme)} numberOfLines={1} allowFontScaling={false}>
|
|
215
227
|
{badge}
|
|
216
228
|
</Text>
|
|
217
229
|
)}
|
|
@@ -221,14 +233,15 @@ function IOSTab({ value, label, icon, badge, disabled = false, onPress, testID,
|
|
|
221
233
|
)
|
|
222
234
|
}
|
|
223
235
|
|
|
224
|
-
const iosBadgeStyle = (theme: Theme): ViewStyle => {
|
|
236
|
+
const iosBadgeStyle = (theme: Theme, color: TabBarBadgeColor | undefined): ViewStyle => {
|
|
225
237
|
const size = theme.length("--tab-bar-badge-size", 18)
|
|
226
238
|
return {
|
|
227
239
|
minWidth: size,
|
|
228
240
|
height: size,
|
|
229
241
|
paddingHorizontal: theme.length("--tab-bar-badge-padding-inline", 5),
|
|
230
242
|
borderRadius: size / 2,
|
|
231
|
-
|
|
243
|
+
// iOS's own red, or the accent
|
|
244
|
+
backgroundColor: color === "accent" ? theme.color("--color-background-accent-solid") : theme.color("--tab-bar-badge-background"),
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
247
|
|
|
@@ -252,7 +265,7 @@ const COUNT_SLIDE = 3
|
|
|
252
265
|
* behind it). `true` draws a dot of the accent there. It scales in and out about that point (the center of a dot or a
|
|
253
266
|
* one-digit count), staying drawn as it shrinks away.
|
|
254
267
|
*/
|
|
255
|
-
function AndroidBadge({ badge, ring }: { badge: ReactNode; ring: string | Animated.AnimatedInterpolation<string
|
|
268
|
+
function AndroidBadge({ badge, ring, color }: { badge: ReactNode; ring: string | Animated.AnimatedInterpolation<string>; color?: TabBarBadgeColor }) {
|
|
256
269
|
const theme = useTheme()
|
|
257
270
|
const m = theme.material
|
|
258
271
|
const reduced = theme.reducedMotion
|
|
@@ -285,8 +298,8 @@ function AndroidBadge({ badge, ring }: { badge: ReactNode; ring: string | Animat
|
|
|
285
298
|
const dot = shown === true
|
|
286
299
|
return (
|
|
287
300
|
<Animated.View pointerEvents="none" style={[styles.androidBadgeFrame, { transform: [{ scale }] }]}>
|
|
288
|
-
<Animated.View style={[dot ? styles.androidDot : styles.androidBadge, { backgroundColor: m.primary, borderColor: ring }]}>
|
|
289
|
-
{dot ? null : <BadgeCount value={shown} color={m.onPrimary} reduced={reduced} />}
|
|
301
|
+
<Animated.View style={[dot ? styles.androidDot : styles.androidBadge, { backgroundColor: color === "danger" ? m.error : m.primary, borderColor: ring }]}>
|
|
302
|
+
{dot ? null : <BadgeCount value={shown} color={color === "danger" ? m.onError : m.onPrimary} reduced={reduced} />}
|
|
290
303
|
</Animated.View>
|
|
291
304
|
</Animated.View>
|
|
292
305
|
)
|
|
@@ -410,6 +423,7 @@ function AndroidTab({
|
|
|
410
423
|
label,
|
|
411
424
|
icon,
|
|
412
425
|
badge,
|
|
426
|
+
badgeColor,
|
|
413
427
|
disabled = false,
|
|
414
428
|
onPress,
|
|
415
429
|
testID,
|
|
@@ -465,7 +479,7 @@ function AndroidTab({
|
|
|
465
479
|
{label}
|
|
466
480
|
</Animated.Text>
|
|
467
481
|
{/* The ring takes the pill's color as the pill fades in under it */}
|
|
468
|
-
<AndroidBadge badge={badge} ring={shown.interpolate({ inputRange: [0, 1], outputRange: [card, mix(m.primary, card, 0.09)], easing: DECELERATE })} />
|
|
482
|
+
<AndroidBadge badge={badge} color={badgeColor ?? context.badgeColor} ring={shown.interpolate({ inputRange: [0, 1], outputRange: [card, mix(m.primary, card, 0.09)], easing: DECELERATE })} />
|
|
469
483
|
</Pressable>
|
|
470
484
|
)
|
|
471
485
|
}
|
|
@@ -581,7 +595,7 @@ function AndroidBar({
|
|
|
581
595
|
// screen's color fading in over 60dp in four even steps, then at 81% down to the edge; the other backgrounds show
|
|
582
596
|
// once content is under the bar
|
|
583
597
|
const backdrop =
|
|
584
|
-
background === "soft" ? (
|
|
598
|
+
background === "soft" || background === "fade" ? (
|
|
585
599
|
<SoftBottomEdge fill={withAlpha(canvas, ANDROID_FADE_ALPHA)} top={60} tail={60} blur={0} stops={ANDROID_FADE_STOPS} />
|
|
586
600
|
) : background === "hard" ? (
|
|
587
601
|
<BarBackdrop fill={canvas} line={scrolled ? m.outlineVariant : undefined} edge="top" />
|
|
@@ -652,6 +666,7 @@ function TabBarRoot({
|
|
|
652
666
|
canvasColor,
|
|
653
667
|
accessory,
|
|
654
668
|
safeArea = true,
|
|
669
|
+
badgeColor,
|
|
655
670
|
"aria-label": ariaLabel = "Tabs",
|
|
656
671
|
children,
|
|
657
672
|
style,
|
|
@@ -682,7 +697,7 @@ function TabBarRoot({
|
|
|
682
697
|
const visible = shown.length ? shown : capsuleTabs.slice(0, 1)
|
|
683
698
|
const reachable = [...visible, ...(circle ? [circle] : [])]
|
|
684
699
|
const keys = useTabKeys(reachable, value, select)
|
|
685
|
-
const context: TabBarContextValue = { value, minimized, select, expand, keys }
|
|
700
|
+
const context: TabBarContextValue = { value, badgeColor, minimized, select, expand, keys }
|
|
686
701
|
|
|
687
702
|
if (theme.isAndroid) {
|
|
688
703
|
return (
|
|
@@ -722,6 +737,9 @@ function TabBarRoot({
|
|
|
722
737
|
<BarBackdrop fill={canvas} line={scrolled ? theme.color("--page-bar-hard-line") : undefined} edge="top" />
|
|
723
738
|
) : background === "glass" && scrolled ? (
|
|
724
739
|
<BarBackdrop fill={veil} blur={glassBarBlur(theme)} line={theme.color("--page-bar-line")} edge="top" />
|
|
740
|
+
) : background === "fade" ? (
|
|
741
|
+
// The screen's color coming in from the capsule's top (or the accessory's) down
|
|
742
|
+
<TabBarFade fill={canvas} top={padTop} />
|
|
725
743
|
) : null
|
|
726
744
|
// The accessory keeps one place in the tree, so its state lives through a minimize: above the capsule, or between
|
|
727
745
|
// the two circles as tall as they are. The bar keeps its height either way, as TabBar.module.css
|
package/src/index.ts
CHANGED
|
@@ -47,6 +47,7 @@ export {
|
|
|
47
47
|
TabBar,
|
|
48
48
|
useTabBarMinimize,
|
|
49
49
|
type TabBarBackground,
|
|
50
|
+
type TabBarBadgeColor,
|
|
50
51
|
type TabBarItemProps,
|
|
51
52
|
type TabBarProminent,
|
|
52
53
|
type TabBarProps,
|
|
@@ -81,6 +82,7 @@ export { OTPInput, type OTPInputProps } from "./components/OTPInput/OTPInput"
|
|
|
81
82
|
export { Select, type SelectOption, type SelectProps } from "./components/Select/Select"
|
|
82
83
|
export { Menu, type MenuContentProps, type MenuItemProps, type MenuProps } from "./components/Menu/Menu"
|
|
83
84
|
export { ContextMenu, type ContextMenuContentProps, type ContextMenuProps } from "./components/ContextMenu/ContextMenu"
|
|
85
|
+
export { ScrollEdge, type ScrollEdgeProps } from "./components/ScrollEdge/ScrollEdge"
|
|
84
86
|
export { DatePicker, type DatePickerDisplay, type DatePickerMode, type DatePickerProps } from "./components/DatePicker/DatePicker"
|
|
85
87
|
export { ActionSheet, type ActionSheetAction, type ActionSheetProps } from "./components/ActionSheet/ActionSheet"
|
|
86
88
|
export { BottomSheet, type BottomSheetFooterProps, type BottomSheetProps } from "./components/BottomSheet/BottomSheet"
|
|
@@ -251,3 +251,76 @@ export function SoftTopEdge({ fill, blur }: { fill: string; blur: number }) {
|
|
|
251
251
|
</View>
|
|
252
252
|
)
|
|
253
253
|
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* iOS 27.2's soft scroll edge under a bottom bar (styles' --page-bar-soft-bottom-*, measured on a scrolled list,
|
|
257
|
+
* owner 13.11): from 34pt above the bar's items down to the screen's edge, a veil of the canvas color (8% 9 into the
|
|
258
|
+
* layer, 15% from 25 to 37, 23% at 45, 31% at 57, 46% from 77 down) over a 10pt blur that takes hold from 12 to 40
|
|
259
|
+
* into it. Over the canvas alone it draws nothing to see, so it stays drawn. Native draws the veil without the blur.
|
|
260
|
+
*/
|
|
261
|
+
const BOTTOM_REACH = 34
|
|
262
|
+
const BOTTOM_VEIL: readonly [number, number][] = [
|
|
263
|
+
[0, 0],
|
|
264
|
+
[0.08, 9],
|
|
265
|
+
[0.15, 25],
|
|
266
|
+
[0.15, 37],
|
|
267
|
+
[0.23, 45],
|
|
268
|
+
[0.31, 57],
|
|
269
|
+
[0.46, 77],
|
|
270
|
+
]
|
|
271
|
+
|
|
272
|
+
export function SoftBottomVeil({ fill, top, bottom }: { fill: string; top?: number; bottom?: number }) {
|
|
273
|
+
// `top`: under a bottom bar whose items start there; `bottom`: turned over, under the status bar `bottom` tall
|
|
274
|
+
const up = bottom != null
|
|
275
|
+
const place: ViewStyle = up
|
|
276
|
+
? { position: "absolute", top: 0, left: 0, right: 0, height: bottom + BOTTOM_REACH, overflow: "hidden", justifyContent: "flex-end" }
|
|
277
|
+
: { position: "absolute", top: (top ?? 0) - BOTTOM_REACH, left: 0, right: 0, bottom: 0 }
|
|
278
|
+
const way = up ? "to top" : "to bottom"
|
|
279
|
+
if (Platform.OS === "web") {
|
|
280
|
+
const veil = `linear-gradient(${way}, ${BOTTOM_VEIL.map(([alpha, at]) => `${black(alpha)} ${at}px`).join(", ")})`
|
|
281
|
+
const blurMask = `linear-gradient(${way}, transparent 12px, #000 40px)`
|
|
282
|
+
return (
|
|
283
|
+
<View pointerEvents="none" style={place}>
|
|
284
|
+
<View style={[StyleSheet.absoluteFill, { backdropFilter: "blur(10px)", WebkitBackdropFilter: "blur(10px)", maskImage: blurMask, WebkitMaskImage: blurMask } as ViewStyle]} />
|
|
285
|
+
<View style={[StyleSheet.absoluteFill, { backgroundColor: fill, maskImage: veil, WebkitMaskImage: veil } as ViewStyle]} />
|
|
286
|
+
</View>
|
|
287
|
+
)
|
|
288
|
+
}
|
|
289
|
+
const last = BOTTOM_VEIL[BOTTOM_VEIL.length - 1]
|
|
290
|
+
const gradient = `linear-gradient(${way}, ${BOTTOM_VEIL.map(([alpha, at]) => `${withAlpha(fill, alpha)} ${at}px`).join(", ")})`
|
|
291
|
+
const ramp = <View style={{ height: last[1], backgroundImage: gradient } as ViewStyle} />
|
|
292
|
+
const rest = <View style={{ flex: 1, backgroundColor: withAlpha(fill, last[0]) }} />
|
|
293
|
+
return (
|
|
294
|
+
<View pointerEvents="none" style={place}>
|
|
295
|
+
{up ? rest : ramp}
|
|
296
|
+
{up ? ramp : rest}
|
|
297
|
+
</View>
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The fade under a tab bar's capsule, as apps that mute the content under their tab bar draw it (measured on one at
|
|
303
|
+
* 3x): nothing above the capsule, so the rows over it stay clear; from the capsule's top the screen's color comes in
|
|
304
|
+
* over 60pt (6% 5 in, 25% 21 in, 37% 32 in, 56% 42 in, 69% 51 in, 85% from 60 in) and holds to the screen's edge,
|
|
305
|
+
* with no blur: the text under it stays sharp, only faint.
|
|
306
|
+
*/
|
|
307
|
+
const TAB_FADE: readonly [number, number][] = [
|
|
308
|
+
[0, 0],
|
|
309
|
+
[0.06, 5],
|
|
310
|
+
[0.25, 21],
|
|
311
|
+
[0.37, 32],
|
|
312
|
+
[0.56, 42],
|
|
313
|
+
[0.69, 51],
|
|
314
|
+
[0.85, 60],
|
|
315
|
+
]
|
|
316
|
+
|
|
317
|
+
export function TabBarFade({ fill, top }: { fill: string; top: number }) {
|
|
318
|
+
const last = TAB_FADE[TAB_FADE.length - 1]
|
|
319
|
+
const gradient = `linear-gradient(to bottom, ${TAB_FADE.map(([alpha, at]) => `${withAlpha(fill, alpha)} ${at}px`).join(", ")})`
|
|
320
|
+
return (
|
|
321
|
+
<View pointerEvents="none" style={{ position: "absolute", top, left: 0, right: 0, bottom: 0 }}>
|
|
322
|
+
<View style={{ height: last[1], backgroundImage: gradient } as ViewStyle} />
|
|
323
|
+
<View style={{ flex: 1, backgroundColor: withAlpha(fill, last[0]) }} />
|
|
324
|
+
</View>
|
|
325
|
+
)
|
|
326
|
+
}
|
|
@@ -220,8 +220,12 @@ export function createTheme(options: {
|
|
|
220
220
|
success: color("--color-background-success-solid"),
|
|
221
221
|
onSuccess: color("--color-text-success-solid"),
|
|
222
222
|
danger: color("--color-background-danger-solid"),
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
// iOS's screens are black at night (systemBackground); Android's stay on the PlexUI canvas, as android.css
|
|
224
|
+
background: platform === "android" ? color("--gray-0", color("--color-surface")) : color("--mobile-surface-plain-primary", color("--color-surface")),
|
|
225
|
+
groupedBackground:
|
|
226
|
+
platform === "android"
|
|
227
|
+
? color(scheme === "dark" ? "--gray-0" : "--gray-75", color("--color-surface-secondary"))
|
|
228
|
+
: color("--mobile-surface-grouped-primary", color("--color-surface-secondary")),
|
|
225
229
|
groupedSurface: color("--mobile-surface-grouped-secondary", color("--color-surface")),
|
|
226
230
|
surface: color("--color-surface"),
|
|
227
231
|
surfaceSecondary: color("--color-surface-secondary"),
|