@plexui/react-native 0.2.4 → 0.2.6

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.
Files changed (40) hide show
  1. package/dist/es/components/Badge/Badge.js +10 -0
  2. package/dist/es/components/DatePicker/Calendar.js +112 -0
  3. package/dist/es/components/DatePicker/DatePicker.js +335 -0
  4. package/dist/es/components/DatePicker/TimeDial.js +123 -0
  5. package/dist/es/components/DatePicker/Wheel.js +164 -0
  6. package/dist/es/components/DatePicker/dates.js +147 -0
  7. package/dist/es/components/Dialog/Dialog.js +21 -0
  8. package/dist/es/components/Icon/material.js +16 -0
  9. package/dist/es/components/PageControl/PageControl.js +49 -22
  10. package/dist/es/components/ScrollEdge/ScrollEdge.js +27 -0
  11. package/dist/es/components/TabBar/TabBar.js +16 -13
  12. package/dist/es/index.js +2 -0
  13. package/dist/es/internal/BarBackdrop.js +54 -0
  14. package/dist/types/components/Badge/Badge.d.ts +1 -1
  15. package/dist/types/components/DatePicker/Calendar.d.ts +29 -0
  16. package/dist/types/components/DatePicker/DatePicker.d.ts +57 -0
  17. package/dist/types/components/DatePicker/TimeDial.d.ts +20 -0
  18. package/dist/types/components/DatePicker/Wheel.d.ts +40 -0
  19. package/dist/types/components/DatePicker/dates.d.ts +45 -0
  20. package/dist/types/components/Dialog/Dialog.d.ts +18 -0
  21. package/dist/types/components/Icon/material.d.ts +6 -0
  22. package/dist/types/components/PageControl/PageControl.d.ts +12 -1
  23. package/dist/types/components/ScrollEdge/ScrollEdge.d.ts +19 -0
  24. package/dist/types/components/TabBar/TabBar.d.ts +14 -4
  25. package/dist/types/index.d.ts +3 -1
  26. package/dist/types/internal/BarBackdrop.d.ts +9 -0
  27. package/package.json +1 -1
  28. package/src/components/Badge/Badge.tsx +9 -1
  29. package/src/components/DatePicker/Calendar.tsx +227 -0
  30. package/src/components/DatePicker/DatePicker.tsx +608 -0
  31. package/src/components/DatePicker/TimeDial.tsx +201 -0
  32. package/src/components/DatePicker/Wheel.tsx +247 -0
  33. package/src/components/DatePicker/dates.ts +161 -0
  34. package/src/components/Dialog/Dialog.tsx +46 -0
  35. package/src/components/Icon/material.ts +18 -0
  36. package/src/components/PageControl/PageControl.tsx +71 -24
  37. package/src/components/ScrollEdge/ScrollEdge.tsx +48 -0
  38. package/src/components/TabBar/TabBar.tsx +33 -15
  39. package/src/index.ts +3 -0
  40. package/src/internal/BarBackdrop.tsx +73 -0
@@ -40,3 +40,21 @@ export const MaterialCheckSymbol = createIcon("MaterialCheckSymbol", "0 -960 960
40
40
  * `abc_ic_ab_back_material` that Settings' toolbar shows); it is mirrored right to left.
41
41
  */
42
42
  export const MaterialArrowBack = createIcon("MaterialArrowBack", "0 0 24 24", [["path", { d: "M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z", fill: 0 }]])
43
+
44
+ /** Material Symbols' chevron_left and chevron_right (24, the outlined weight 400): a month's arrows in the date picker. */
45
+ export const MaterialChevronLeft = createIcon("MaterialChevronLeft", "0 -960 960 960", [["path", { d: "M560-240 320-480l240-240 56 56-184 184 184 184-56 56Z", fill: 0 }]])
46
+ export const MaterialChevronRight = createIcon("MaterialChevronRight", "0 -960 960 960", [["path", { d: "M504-480 320-664l56-56 240 240-240 240-56-56 184-184Z", fill: 0 }]])
47
+
48
+ /** Material Symbols' calendar_today and schedule (24, outlined weight 400): the trailing icons of a date and a time field. */
49
+ export const MaterialCalendarToday = createIcon("MaterialCalendarToday", "0 -960 960 960", [
50
+ ["path", { d: "M200-80q-33 0-56.5-23.5T120-160v-560q0-33 23.5-56.5T200-800h40v-80h80v80h320v-80h80v80h40q33 0 56.5 23.5T840-720v560q0 33-23.5 56.5T760-80H200Zm0-80h560v-400H200v400Zm0-480h560v-80H200v80Zm0 0v-80 80Z", fill: 0 }],
51
+ ])
52
+ export const MaterialSchedule = createIcon("MaterialSchedule", "0 -960 960 960", [
53
+ [
54
+ "path",
55
+ {
56
+ d: "m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z",
57
+ fill: 0,
58
+ },
59
+ ],
60
+ ])
@@ -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 dot = android ? ANDROID_DOT : theme.length("--page-control-dot-size", 8)
120
- const gap = android ? ANDROID_GAP : theme.length("--page-control-gap", 8)
121
- const padding = theme.length("--page-control-padding-inline", 12)
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
- const dotSize = (size: PageControlDotSize) =>
126
- size === "full" ? dot : android ? (size === "small" ? 4 : 3) : size === "small" ? theme.length("--page-control-dot-size-small", 6) : theme.length("--page-control-dot-size-smaller", 4)
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 wide
129
- const dotWidth = (size: PageControlDotSize, index: number) => (pill && index === current ? dot * 2.5 : dotSize(size))
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((size, index) => {
134
- if (size === "hidden") return
135
- if (index === current) currentCenter = x + dotWidth(size, index) / 2
136
- x += dotWidth(size, index) + gap
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) => setPress({ startX: event.nativeEvent.locationX, startIndex: current, scrubbing: false, rtl: isRTL(event.currentTarget) })}
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={[styles.target, { minHeight: target, marginVertical: -(target - capsuleHeight) / 2 }, 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) => setCapsule({ x: event.nativeEvent.layout.x, width: event.nativeEvent.layout.width })}
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
- { height: capsuleHeight, paddingHorizontal: padding, gap, borderRadius: capsuleHeight / 2 },
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 key={index} style={{ width: dotWidth(size, index), height: dotSize(size), borderRadius: dot / 2, backgroundColor: index === current && !worm ? on : off }} />
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={{ position: "absolute", top: "50%", marginTop: -ANDROID_DOT / 2, start: left, height: ANDROID_DOT, borderRadius: ANDROID_DOT / 2, backgroundColor: color, width: Animated.add(span, ANDROID_DOT) }}
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), `hard` an opaque bar, `glass` a translucent blurred one; the
70
- * lines and the glass show once `scrolled` says content is under it.
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
- backgroundColor: theme.color("--tab-bar-badge-background"),
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,8 @@ 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"
86
+ export { DatePicker, type DatePickerDisplay, type DatePickerMode, type DatePickerProps } from "./components/DatePicker/DatePicker"
84
87
  export { ActionSheet, type ActionSheetAction, type ActionSheetProps } from "./components/ActionSheet/ActionSheet"
85
88
  export { BottomSheet, type BottomSheetFooterProps, type BottomSheetProps } from "./components/BottomSheet/BottomSheet"
86
89
  export { Dialog, type DialogAction, type DialogProps } from "./components/Dialog/Dialog"
@@ -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
+ }