@plexui/react-native 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/README.md +34 -0
  2. package/dist/es/components/ActionSheet/ActionSheet.js +67 -19
  3. package/dist/es/components/Alert/Alert.js +163 -0
  4. package/dist/es/components/Avatar/Avatar.js +20 -8
  5. package/dist/es/components/BottomActions/BottomActions.js +34 -0
  6. package/dist/es/components/BottomSheet/BottomSheet.js +85 -17
  7. package/dist/es/components/Button/Button.js +108 -28
  8. package/dist/es/components/Card/Card.js +16 -8
  9. package/dist/es/components/Checkbox/Checkbox.js +67 -99
  10. package/dist/es/components/Chip/Chip.js +39 -19
  11. package/dist/es/components/Dialog/Dialog.js +38 -24
  12. package/dist/es/components/Field/Field.js +91 -0
  13. package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +59 -0
  14. package/dist/es/components/Icon/createIcon.js +13 -2
  15. package/dist/es/components/Indicator/CircularProgress.js +80 -0
  16. package/dist/es/components/Indicator/LoadingDots.js +46 -0
  17. package/dist/es/components/Indicator/LoadingIndicator.js +101 -0
  18. package/dist/es/components/Indicator/index.js +3 -0
  19. package/dist/es/components/Input/Input.js +69 -60
  20. package/dist/es/components/InputGroup/InputGroup.js +130 -0
  21. package/dist/es/components/List/List.js +175 -59
  22. package/dist/es/components/Menu/Menu.js +69 -40
  23. package/dist/es/components/NavigationButton/NavigationButton.js +20 -4
  24. package/dist/es/components/OTPInput/OTPInput.js +9 -3
  25. package/dist/es/components/PageControl/PageControl.js +13 -7
  26. package/dist/es/components/Popover/Popover.js +128 -0
  27. package/dist/es/components/Progress/Progress.js +142 -0
  28. package/dist/es/components/ProgressSteps/ProgressSteps.js +207 -0
  29. package/dist/es/components/RollingNumber/RollingNumber.js +125 -0
  30. package/dist/es/components/Select/Select.js +97 -34
  31. package/dist/es/components/Separator/Separator.js +31 -0
  32. package/dist/es/components/ShimmerText/ShimmerText.js +98 -0
  33. package/dist/es/components/Stepper/Stepper.js +219 -0
  34. package/dist/es/components/Switch/Switch.js +26 -12
  35. package/dist/es/components/TagInput/TagInput.js +121 -0
  36. package/dist/es/components/Text/Text.js +7 -4
  37. package/dist/es/components/TextLink/TextLink.js +42 -0
  38. package/dist/es/components/Textarea/Textarea.js +12 -0
  39. package/dist/es/components/Tip/Tip.js +193 -0
  40. package/dist/es/components/Toolbar/Toolbar.js +6 -2
  41. package/dist/es/components/Tooltip/Tooltip.js +272 -0
  42. package/dist/es/index.js +20 -2
  43. package/dist/es/internal/FloatingPanel.js +111 -0
  44. package/dist/es/internal/fieldStack.js +73 -0
  45. package/dist/es/internal/floating.js +97 -0
  46. package/dist/es/internal/ripple.js +119 -0
  47. package/dist/es/internal/row.js +2 -1
  48. package/dist/es/internal/transition.js +113 -0
  49. package/dist/es/theme/ThemeProvider.js +41 -9
  50. package/dist/es/theme/material.js +37 -7
  51. package/dist/types/components/ActionSheet/ActionSheet.d.ts +15 -7
  52. package/dist/types/components/Alert/Alert.d.ts +51 -0
  53. package/dist/types/components/Avatar/Avatar.d.ts +4 -2
  54. package/dist/types/components/BottomActions/BottomActions.d.ts +18 -0
  55. package/dist/types/components/BottomSheet/BottomSheet.d.ts +4 -2
  56. package/dist/types/components/Button/Button.d.ts +20 -5
  57. package/dist/types/components/Card/Card.d.ts +14 -1
  58. package/dist/types/components/Checkbox/Checkbox.d.ts +4 -3
  59. package/dist/types/components/Chip/Chip.d.ts +23 -4
  60. package/dist/types/components/Dialog/Dialog.d.ts +9 -5
  61. package/dist/types/components/Field/Field.d.ts +64 -0
  62. package/dist/types/components/FloatingLabelInput/FloatingLabelInput.d.ts +42 -0
  63. package/dist/types/components/Indicator/CircularProgress.d.ts +34 -0
  64. package/dist/types/components/Indicator/LoadingDots.d.ts +17 -0
  65. package/dist/types/components/Indicator/LoadingIndicator.d.ts +46 -0
  66. package/dist/types/components/Indicator/index.d.ts +3 -0
  67. package/dist/types/components/Input/Input.d.ts +13 -3
  68. package/dist/types/components/InputGroup/InputGroup.d.ts +71 -0
  69. package/dist/types/components/List/List.d.ts +57 -14
  70. package/dist/types/components/Menu/Menu.d.ts +4 -0
  71. package/dist/types/components/NavigationButton/NavigationButton.d.ts +11 -3
  72. package/dist/types/components/OTPInput/OTPInput.d.ts +10 -1
  73. package/dist/types/components/PageControl/PageControl.d.ts +11 -1
  74. package/dist/types/components/Popover/Popover.d.ts +86 -0
  75. package/dist/types/components/Progress/Progress.d.ts +56 -0
  76. package/dist/types/components/ProgressSteps/ProgressSteps.d.ts +61 -0
  77. package/dist/types/components/RollingNumber/RollingNumber.d.ts +36 -0
  78. package/dist/types/components/Select/Select.d.ts +36 -8
  79. package/dist/types/components/Separator/Separator.d.ts +19 -0
  80. package/dist/types/components/ShimmerText/ShimmerText.d.ts +28 -0
  81. package/dist/types/components/Stepper/Stepper.d.ts +61 -0
  82. package/dist/types/components/Switch/Switch.d.ts +5 -5
  83. package/dist/types/components/TagInput/TagInput.d.ts +44 -0
  84. package/dist/types/components/TextLink/TextLink.d.ts +30 -0
  85. package/dist/types/components/Textarea/Textarea.d.ts +19 -0
  86. package/dist/types/components/Tip/Tip.d.ts +71 -0
  87. package/dist/types/components/Toolbar/Toolbar.d.ts +9 -1
  88. package/dist/types/components/Tooltip/Tooltip.d.ts +84 -0
  89. package/dist/types/index.d.ts +20 -2
  90. package/dist/types/internal/FloatingPanel.d.ts +70 -0
  91. package/dist/types/internal/fieldStack.d.ts +48 -0
  92. package/dist/types/internal/floating.d.ts +71 -0
  93. package/dist/types/internal/ripple.d.ts +17 -0
  94. package/dist/types/internal/row.d.ts +15 -3
  95. package/dist/types/internal/transition.d.ts +37 -0
  96. package/dist/types/theme/ThemeProvider.d.ts +28 -4
  97. package/dist/types/theme/material.d.ts +20 -6
  98. package/dist/types/theme/types.d.ts +8 -0
  99. package/package.json +2 -2
  100. package/src/components/ActionSheet/ActionSheet.tsx +123 -38
  101. package/src/components/Alert/Alert.tsx +279 -0
  102. package/src/components/Avatar/Avatar.tsx +21 -9
  103. package/src/components/BottomActions/BottomActions.tsx +54 -0
  104. package/src/components/BottomSheet/BottomSheet.tsx +111 -25
  105. package/src/components/Button/Button.tsx +170 -35
  106. package/src/components/Card/Card.tsx +33 -9
  107. package/src/components/Checkbox/Checkbox.tsx +89 -124
  108. package/src/components/Chip/Chip.tsx +83 -20
  109. package/src/components/Dialog/Dialog.tsx +68 -37
  110. package/src/components/Field/Field.tsx +227 -0
  111. package/src/components/FloatingLabelInput/FloatingLabelInput.tsx +144 -0
  112. package/src/components/Icon/createIcon.tsx +16 -6
  113. package/src/components/Indicator/CircularProgress.tsx +141 -0
  114. package/src/components/Indicator/LoadingDots.tsx +79 -0
  115. package/src/components/Indicator/LoadingIndicator.tsx +166 -0
  116. package/src/components/Indicator/index.ts +3 -0
  117. package/src/components/Input/Input.tsx +126 -97
  118. package/src/components/InputGroup/InputGroup.tsx +261 -0
  119. package/src/components/List/List.tsx +345 -88
  120. package/src/components/Menu/Menu.tsx +83 -41
  121. package/src/components/NavigationButton/NavigationButton.tsx +35 -5
  122. package/src/components/OTPInput/OTPInput.tsx +21 -2
  123. package/src/components/PageControl/PageControl.tsx +36 -8
  124. package/src/components/Popover/Popover.tsx +261 -0
  125. package/src/components/Progress/Progress.tsx +255 -0
  126. package/src/components/ProgressSteps/ProgressSteps.tsx +415 -0
  127. package/src/components/RollingNumber/RollingNumber.tsx +189 -0
  128. package/src/components/Select/Select.tsx +175 -71
  129. package/src/components/Separator/Separator.tsx +51 -0
  130. package/src/components/ShimmerText/ShimmerText.tsx +144 -0
  131. package/src/components/Stepper/Stepper.tsx +386 -0
  132. package/src/components/Switch/Switch.tsx +26 -12
  133. package/src/components/TagInput/TagInput.tsx +227 -0
  134. package/src/components/Text/Text.tsx +8 -4
  135. package/src/components/TextLink/TextLink.tsx +77 -0
  136. package/src/components/Textarea/Textarea.tsx +23 -0
  137. package/src/components/Tip/Tip.tsx +410 -0
  138. package/src/components/Toolbar/Toolbar.tsx +27 -2
  139. package/src/components/Tooltip/Tooltip.tsx +478 -0
  140. package/src/index.ts +36 -2
  141. package/src/internal/FloatingPanel.tsx +199 -0
  142. package/src/internal/fieldStack.tsx +179 -0
  143. package/src/internal/floating.ts +131 -0
  144. package/src/internal/ripple.tsx +132 -0
  145. package/src/internal/row.ts +16 -3
  146. package/src/internal/transition.ts +124 -0
  147. package/src/theme/ThemeProvider.tsx +65 -15
  148. package/src/theme/material.ts +39 -7
  149. package/src/theme/types.ts +8 -0
@@ -1,8 +1,9 @@
1
1
  import { cloneElement, createContext, isValidElement, useCallback, useContext, useMemo, useRef, useState, type ComponentRef, type ReactElement, type ReactNode } from "react"
2
- import { Platform, Pressable, StyleSheet, View, type LayoutChangeEvent, type StyleProp, type TextStyle, type ViewStyle } from "react-native"
2
+ import { Platform, Pressable, StyleSheet, View, type GestureResponderEvent, type LayoutChangeEvent, type StyleProp, type TextStyle, type ViewStyle } from "react-native"
3
3
  import Disclosure from "../../icons/plex/Disclosure"
4
4
  import ExclamationMarkCircle from "../../icons/plex/ExclamationMarkCircle"
5
5
  import { spaceToggles, useDescription } from "../../internal/a11y"
6
+ import { useRipple } from "../../internal/ripple"
6
7
  import { flattenChildren, textOf } from "../../internal/children"
7
8
  import { cssBox } from "../../internal/cssBox"
8
9
  import { mirrored, useRTL } from "../../internal/direction"
@@ -10,6 +11,7 @@ import { RowEndContext, RowFrameContext, RowHoldContext, RowStartContext, type R
10
11
  import { accentText, controlHighlight, dangerText, divider, withAlpha } from "../../theme/material"
11
12
  import { useTheme } from "../../theme/ThemeProvider"
12
13
  import type { Theme } from "../../theme/types"
14
+ import { Button, ListActionContext } from "../Button/Button"
13
15
  import { Checkbox, type CheckboxProps } from "../Checkbox/Checkbox"
14
16
  import { IconDefaultsProvider } from "../Icon/createIcon"
15
17
  import { RadioContext, RadioGroup, type RadioGroupContext, type RadioGroupItemProps } from "../RadioGroup/RadioGroup"
@@ -25,8 +27,8 @@ export type ListProps = {
25
27
  /** A note under the section. */
26
28
  footer?: ReactNode
27
29
  /**
28
- * An error under the rows, as the web's FieldError in a group's footer: the danger color, 15/20, 4 lower than a
29
- * footer on iOS. It stands in place of the footer while it is set, and is announced when it appears.
30
+ * An error under the rows: it stands in the footer's place, in the footer's type (iOS 13/16, 8 under the section;
31
+ * Android 14sp), only in the danger color, while it is set, and is announced when it appears.
30
32
  */
31
33
  error?: ReactNode
32
34
  /**
@@ -36,33 +38,97 @@ export type ListProps = {
36
38
  * list at its edges) in the cards' color, the header a 32dp band of the grouped gray. @default "grouped"
37
39
  */
38
40
  surface?: "grouped" | "plain"
41
+ /**
42
+ * Content at the end of the header, as the web's FieldGroup `action`: a ghost Button there is the list header's text
43
+ * action (iOS: tinted 17/22 text on the title's line with a 44pt target; Android: 14sp Medium in its color). A string,
44
+ * a number or a Text (a count such as "2/3") takes the header's type in the secondary label, on the title's line. With
45
+ * no `header` the action stands alone at the header's end.
46
+ */
47
+ action?: ReactNode
48
+ /**
49
+ * How much the header stands out, as the web's FieldGroup `headerProminence`: `increased` is iOS's prominent list
50
+ * header (20/25 Semibold in the primary label, 10 above the rows), and on Android a 16sp Medium title in the text
51
+ * color in place of the accent's 14sp. @default "standard"
52
+ */
53
+ headerProminence?: "standard" | "increased"
54
+ /**
55
+ * Every row's value starts at one column, 40% into the row (`--field-row-column-width`), as the web's FieldGroup
56
+ * `columns`: a form of typed details. Off, values end at the row's edge.
57
+ */
58
+ columns?: boolean
39
59
  "aria-label"?: string
40
60
  testID?: string
41
61
  style?: StyleProp<ViewStyle>
42
62
  }
43
63
 
64
+ /** What a List tells its rows; null outside a List. */
65
+ const ListOptionsContext = createContext<{ columns: boolean } | null>(null)
66
+
67
+ /** Whether a control stands in a List's rows (a FloatingLabelInput is a row there, a List of its own elsewhere). */
68
+ export function useInList() {
69
+ return useContext(ListOptionsContext) != null
70
+ }
71
+
44
72
  /** The corners of Android's card of rows. */
45
73
  const ANDROID_CARD_RADIUS = 16
74
+ /** The start and end of an Android row's text, 21dp in from the card's edge (`--list-row-inset`). */
75
+ const ANDROID_INSET = 21
46
76
 
47
77
  /** A row's place in its section, and the radius of the corners it shares with the section's card (none in a plain list). */
48
78
  type RowPlace = { first: boolean; last: boolean; top: number; bottom: number }
49
79
  const PlaceContext = createContext<RowPlace>({ first: true, last: true, top: 0, bottom: 0 })
50
80
 
81
+ /**
82
+ * A header's action that is not a Button (a count such as "2/3") takes the header's type, so it stands on the title's
83
+ * line: iOS 17/22 on its last line, Android the header's 15sp on its 40dp row. Its own style still wins.
84
+ */
85
+ function headerAction(action: ReactNode, type: StyleProp<TextStyle>, color: string): ReactNode {
86
+ if (typeof action === "string" || typeof action === "number") {
87
+ return (
88
+ <Text color={color} tabularNums style={type}>
89
+ {action}
90
+ </Text>
91
+ )
92
+ }
93
+ if (isValidElement<{ style?: StyleProp<TextStyle> }>(action) && action.type === Text) {
94
+ return cloneElement(action, { style: [type, action.props.style] })
95
+ }
96
+ return action
97
+ }
98
+
51
99
  /**
52
100
  * A section of rows. iOS 26: a section of an inset grouped list, as @plexui/ui's FieldGroup on a phone
53
101
  * (`--field-group-radius` 26, the grouped secondary surface, rows 20 in from its edges, hairlines between rows from
54
102
  * the text's start; the header 17/22 at 590 in the secondary label over its description 15/20, the footer 13/16, an
55
- * error 15/20 in the danger color). Android: a section of a settings screen: one card of the section's rows,
56
- * 16dp round, a 1px divider between rows from the text's start; the header inside the card, a 40dp row of 14sp Medium
57
- * in the accent 20 in, its description 14sp in the secondary label under it; the footer under the card, 14sp in the
58
- * secondary label 12 in (24 from the screen's edge, as the screen insets the card 12), 10 above and 17 below, an
59
- * error the same in the error color. The screen sets the cards 12 from its edges and 12 apart. On a plain canvas
103
+ * error in its place and type in the danger color). Android: a section of a settings screen: one card of the section's rows,
104
+ * 16dp round, a 1px divider between rows from the text's start to the card's end; the header inside the card, a 40dp
105
+ * row of 15sp Medium in the accent 21 in (14 above it), its description 14sp in the secondary label under it; the
106
+ * footer under the card, 14sp in the secondary label 13 in (25 from the screen's edge, as the screen insets the card
107
+ * 12), 11 above and 17 below, an error the same in the error color (the web's FieldGroup on Android). The screen sets the cards 12 from its edges and 12 apart. On a plain canvas
60
108
  * Android draws a plain list: the rows across the screen with no card, the header a 32dp band of the grouped gray,
61
109
  * the footer on that gray.
62
110
  */
63
- export function List({ children, header, description, footer, error, surface = "grouped", "aria-label": ariaLabel, testID, style }: ListProps) {
111
+ export function List({
112
+ children,
113
+ header,
114
+ description,
115
+ footer,
116
+ error,
117
+ surface = "grouped",
118
+ action,
119
+ headerProminence = "standard",
120
+ columns = false,
121
+ "aria-label": ariaLabel,
122
+ testID,
123
+ style,
124
+ }: ListProps) {
64
125
  const theme = useTheme()
65
- const rows = flattenChildren(children).filter(isValidElement)
126
+ // A Button among the rows is an action row, as the web's ghost Button in a `[data-row]`
127
+ const rows = flattenChildren(children)
128
+ .filter(isValidElement)
129
+ .map((row) => (row.type === Button ? <ActionRow key={row.key ?? undefined}>{row}</ActionRow> : row))
130
+ const options = useMemo(() => ({ columns }), [columns])
131
+ const increased = headerProminence === "increased"
66
132
  const fill = surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface
67
133
  // The card's corners: Android's 16dp card (a header or description inside it stands over the first row), iOS's group
68
134
  const corner = surface === "plain" && theme.isAndroid ? 0 : theme.isAndroid ? ANDROID_CARD_RADIUS : theme.length("--field-group-radius", 26)
@@ -89,14 +155,30 @@ export function List({ children, header, description, footer, error, surface = "
89
155
  return (
90
156
  <View testID={testID} style={style}>
91
157
  <View style={plain ? { backgroundColor: theme.colors.groupedSurface } : [styles.androidCard, { backgroundColor: fill }]}>
92
- {header == null ? null : plain ? (
93
- <View style={[styles.androidBand, { backgroundColor: band }]}>
94
- <Text accessibilityRole="header" color={theme.colors.labelSecondary} weight="medium" numberOfLines={1} style={styles.androidBandText}>
95
- {header}
96
- </Text>
158
+ {header == null && action == null ? null : plain ? (
159
+ <View style={[styles.androidBand, action != null ? styles.androidBandRow : null, { backgroundColor: band }]}>
160
+ {header != null ? (
161
+ <Text accessibilityRole="header" color={theme.colors.labelSecondary} weight="medium" numberOfLines={1} style={[styles.androidBandText, action != null ? styles.grow : null]}>
162
+ {header}
163
+ </Text>
164
+ ) : (
165
+ <View style={styles.grow} />
166
+ )}
167
+ {action != null ? <ListActionContext.Provider value="header">{headerAction(action, styles.androidBandText, theme.colors.labelSecondary)}</ListActionContext.Provider> : null}
168
+ </View>
169
+ ) : action != null ? (
170
+ <View style={styles.androidHeaderRow}>
171
+ {header != null ? (
172
+ <Text accessibilityRole="header" color={increased ? theme.colors.text : accentText(theme)} weight="medium" style={[styles.androidHeaderTitle, increased ? styles.androidHeaderIncreased : null]}>
173
+ {header}
174
+ </Text>
175
+ ) : (
176
+ <View style={styles.grow} />
177
+ )}
178
+ <ListActionContext.Provider value="header">{headerAction(action, styles.androidHeaderTitleType, theme.colors.labelSecondary)}</ListActionContext.Provider>
97
179
  </View>
98
180
  ) : (
99
- <Text accessibilityRole="header" color={accentText(theme)} weight="medium" style={styles.androidHeader}>
181
+ <Text accessibilityRole="header" color={increased ? theme.colors.text : accentText(theme)} weight="medium" style={[styles.androidHeader, increased ? styles.androidHeaderIncreased : null]}>
100
182
  {header}
101
183
  </Text>
102
184
  )}
@@ -109,7 +191,7 @@ export function List({ children, header, description, footer, error, surface = "
109
191
  </Text>
110
192
  ) : null}
111
193
  <View accessibilityRole="list" aria-label={label}>
112
- {body}
194
+ <ListOptionsContext.Provider value={options}>{body}</ListOptionsContext.Provider>
113
195
  </View>
114
196
  </View>
115
197
  {error != null ? (
@@ -128,25 +210,43 @@ export function List({ children, header, description, footer, error, surface = "
128
210
  const footerBox = cssBox(theme, "--field-group-footer-padding", [8, inset, 6, inset])
129
211
  return (
130
212
  <View testID={testID} style={style}>
131
- {header != null || description != null ? (
213
+ {header != null || description != null || action != null ? (
132
214
  <View
133
215
  style={{
134
- minHeight: theme.length("--field-group-header-min-height", 39),
216
+ // The prominent header: 20/25 Semibold in the primary label, 10 above and below (45 at least), as the kit's
217
+ // Prominent list header
218
+ minHeight: increased ? 45 : theme.length("--field-group-header-min-height", 39),
135
219
  justifyContent: "flex-end",
136
- paddingTop: theme.length("--field-group-header-padding-top", 11),
137
- paddingBottom: theme.length("--field-group-header-padding-bottom", 6),
220
+ paddingTop: increased ? 10 : theme.length("--field-group-header-padding-top", 11),
221
+ paddingBottom: increased ? 10 : theme.length("--field-group-header-padding-bottom", 6),
138
222
  paddingHorizontal: theme.length("--field-group-title-padding-inline", inset),
139
223
  }}
140
224
  >
141
- {header != null ? (
142
- <Text
143
- accessibilityRole="header"
144
- weight="semibold"
145
- color={theme.colors.labelSecondary}
146
- style={{ fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) }}
147
- >
148
- {header}
149
- </Text>
225
+ {header != null || action != null ? (
226
+ <View style={action != null ? styles.iosHeaderRow : null}>
227
+ {header == null ? <View style={styles.grow} /> : null}
228
+ {header == null ? null : <Text
229
+ accessibilityRole="header"
230
+ weight="semibold"
231
+ color={increased ? theme.colors.text : theme.colors.labelSecondary}
232
+ style={[
233
+ increased ? { fontSize: 20, lineHeight: 25 } : { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
234
+ action != null ? styles.grow : null,
235
+ ]}
236
+ >
237
+ {header}
238
+ </Text>}
239
+ {/* On the title's last line, its target reaching over and under the line without making the header taller */}
240
+ {action != null ? (
241
+ <ListActionContext.Provider value="header">
242
+ {headerAction(
243
+ action,
244
+ { fontSize: theme.length("--field-group-title-font-size", 17), lineHeight: theme.length("--field-group-title-line-height", 22) },
245
+ theme.colors.labelSecondary,
246
+ )}
247
+ </ListActionContext.Provider>
248
+ ) : null}
249
+ </View>
150
250
  ) : null}
151
251
  {description != null ? (
152
252
  <Text
@@ -163,27 +263,13 @@ export function List({ children, header, description, footer, error, surface = "
163
263
  aria-label={label}
164
264
  style={[styles.iosGroup, { borderRadius: theme.length("--field-group-radius", 26), backgroundColor: surface === "plain" ? theme.color("--field-group-background", theme.colors.surfaceSecondary) : theme.colors.groupedSurface }]}
165
265
  >
166
- {body}
266
+ <ListOptionsContext.Provider value={options}>{body}</ListOptionsContext.Provider>
167
267
  </View>
168
- {error != null ? (
169
- // The web's FieldError in the footer: its 4 offset over the footer's padding
170
- <Text
171
- color={errorColor(theme)}
172
- accessibilityLiveRegion="polite"
173
- style={{
174
- fontSize: theme.length("--mobile-field-error-font-size", 15),
175
- lineHeight: theme.length("--mobile-field-error-line-height", 20),
176
- paddingTop: footerBox.top + theme.length("--mobile-field-error-offset", 4),
177
- paddingEnd: footerBox.right,
178
- paddingBottom: footerBox.bottom,
179
- paddingStart: footerBox.left,
180
- }}
181
- >
182
- {error}
183
- </Text>
184
- ) : footer != null ? (
268
+ {error != null || footer != null ? (
269
+ // An error takes the footer's place and type (13/16, 8 under the section), only in the danger color
185
270
  <Text
186
- color={theme.colors.labelSecondary}
271
+ color={error != null ? errorColor(theme) : theme.colors.labelSecondary}
272
+ accessibilityLiveRegion={error != null ? "polite" : undefined}
187
273
  style={{
188
274
  fontSize: theme.length("--field-group-footer-font-size", 13),
189
275
  lineHeight: theme.length("--field-group-footer-line-height", 16),
@@ -193,7 +279,7 @@ export function List({ children, header, description, footer, error, surface = "
193
279
  paddingStart: footerBox.left,
194
280
  }}
195
281
  >
196
- {footer}
282
+ {error ?? footer}
197
283
  </Text>
198
284
  ) : null}
199
285
  </View>
@@ -255,12 +341,13 @@ export type ListItemProps = {
255
341
  * A row of a List: the label (17/22, `--field-row-*`: 52 tall, 70 with a description, 12 above and below the text at
256
342
  * least) with a description, a leading symbol, a value (wrapping within 60% of the row, or under the label: `valuePlacement`) or a control, and the chevron
257
343
  * of a drill-in (`Disclosure`, in the tertiary label, turned over right to left). A row with `checked` is a switch
258
- * row. On Android a row of a settings screen: 50dp tall at least (60 with a description), the label 16sp, the
259
- * description 13sp in the secondary label under it, the value 16sp in the accent at the end, 17 from it (20 in a row
260
- * with a tile), no chevron; the text 20 in, or 71 after a 24dp symbol at 21, or 64 after a 28dp tile of
261
- * `leadingColor` at 18 with a 24dp symbol (the tile's corners 10), or 64 after a RadioGroup option's 20dp ring at 22
262
- * (the row 64dp with a description); a 1px divider from the text's start to the next row, none under a row with a
263
- * tile (a tiled row draws none).
344
+ * row. On Android a row of a settings screen: 50dp tall at least (64 with a description, its text 12 from the row's
345
+ * top and bottom), the label 16sp, the description 13sp in the secondary label under it, the value 16sp in the accent
346
+ * at the end, 17 from it (20 in a row with a tile), no chevron; the text 21 in, or 64 after a 24dp symbol at 20, or 64
347
+ * after a 28dp tile of `leadingColor` at 18 with a 24dp symbol (the tile's corners 10), or 64 after a RadioGroup
348
+ * option's 20dp ring at 22; a lone Checkbox at the end of a row with no `leading` leads it instead, its 20dp circle 22
349
+ * in (a multi-select list); a 1px divider from the text's start to the card's end, none under a row with a tile (a
350
+ * tiled row draws none).
264
351
  */
265
352
  export function ListItem({
266
353
  label,
@@ -305,6 +392,9 @@ export function ListItem({
305
392
  !switchRow && !onPress && !atEnd && radios != null && isValidElement(leading) && leading.type === RadioGroup.Item
306
393
  ? { kind: "radio" as const, element: leading as ReactElement<RadioGroupItemProps> }
307
394
  : null
395
+ // Android's multi-select row: a lone checkbox (no text of its own) at the end of a row with no symbol leads the row
396
+ const checkLeads =
397
+ theme.isAndroid && atEnd?.kind === "checkbox" && leading == null && atEnd.element.props.label == null && atEnd.element.props.description == null
308
398
  const found = atEnd ?? atStart
309
399
  const [controlOwn, setControlOwn] = useState<boolean | "indeterminate">(() => (found && found.kind !== "radio" ? (found.element.props.defaultChecked ?? false) : false))
310
400
  const rowName = textOf(label) || undefined
@@ -328,11 +418,20 @@ export function ListItem({
328
418
  theme.isAndroid ? styles.androidRow : iosRow(theme, pressed && lit, last, description != null || error != null)
329
419
  // A finger on the control at the end holds the row, as one on the row's text does
330
420
  const [held, setHeld] = useState(false)
421
+ // Android's press is the list selector's ripple from the touch point, clipped to the row (and the card's corners):
422
+ // the platform's on a device; drawn here on the web, and for a row held through the control at its end
423
+ const ripple = useRipple(controlHighlight(theme.scheme), theme.isAndroid, theme.reducedMotion)
424
+ const hold = (next: boolean, event?: GestureResponderEvent) => {
425
+ setHeld(next)
426
+ if (!theme.isAndroid) return
427
+ if (next) ripple.start(event)
428
+ else ripple.end()
429
+ }
331
430
  const content = (pressed: boolean) => {
332
431
  // The row's switch is drawn only: the row is the control
333
432
  const track = <SwitchTrack checked={checked} disabled={disabled} pressed={pressed} />
334
433
  const end = !switchRow ? (
335
- atStart ? trailing : (control?.node ?? trailing)
434
+ atStart ? trailing : checkLeads ? null : (control?.node ?? trailing)
336
435
  ) : trailing != null ? (
337
436
  <View style={[styles.pair, { gap: theme.isAndroid ? 16 : theme.length("--field-row-disclosure-gap", 8) }]}>
338
437
  {trailing}
@@ -341,21 +440,22 @@ export function ListItem({
341
440
  ) : (
342
441
  track
343
442
  )
344
- const start = atStart && control ? <RowStartContext.Provider value>{control.node}</RowStartContext.Provider> : leading
345
- const startColor = atStart ? undefined : leadingColor
443
+ const start = (atStart || checkLeads) && control ? <RowStartContext.Provider value>{control.node}</RowStartContext.Provider> : leading
444
+ const startColor = atStart || checkLeads ? undefined : leadingColor
346
445
  return (
347
446
  <RowFrameContext.Provider value={frame}>
348
447
  {theme.isAndroid ? (
349
- <AndroidContent handPress={handPress} theme={theme} label={label} description={description} descriptionId={described.id} leading={start} leadingColor={startColor} leadingMark={atStart != null} value={value} valuePlacement={valuePlacement} trailing={end} error={error} disabled={disabled} destructive={destructive} last={last} />
448
+ <AndroidContent handPress={handPress} theme={theme} label={label} description={description} descriptionId={described.id} leading={start} leadingColor={startColor} leadingMark={atStart != null || checkLeads} value={value} valuePlacement={valuePlacement} trailing={end} edgeControl={found != null || switchRow} error={error} disabled={disabled} destructive={destructive} last={last} />
350
449
  ) : (
351
- <IOSContent theme={theme} label={label} description={description} descriptionId={described.id} leading={start} leadingColor={startColor} value={value} valuePlacement={valuePlacement} trailing={end} error={error} chevron={chevron} disabled={disabled} destructive={destructive} last={last} />
450
+ <IOSContent theme={theme} label={label} description={description} descriptionId={described.id} leading={start} leadingColor={startColor} value={value} valuePlacement={valuePlacement} trailing={end} edgeControl={found != null || switchRow} error={error} chevron={chevron} disabled={disabled} destructive={destructive} last={last} />
352
451
  )}
353
452
  </RowFrameContext.Provider>
354
453
  )
355
454
  }
356
455
  if (press) {
357
- // Android's rows press in the list selector: the native ripple on a device, a layer on the web
456
+ // Android's rows press in the list selector: the native ripple on a device, the drawn one on the web
358
457
  const highlight = controlHighlight(theme.scheme)
458
+ const drawn = theme.isAndroid && !nativeRipple
359
459
  return (
360
460
  <Pressable
361
461
  ref={frameNode as never}
@@ -372,26 +472,146 @@ export function ListItem({
372
472
  aria-checked={switchRow ? checked : undefined}
373
473
  disabled={disabled}
374
474
  onPress={press}
475
+ onPressIn={drawn ? ripple.start : undefined}
476
+ onPressOut={drawn ? ripple.end : undefined}
375
477
  android_ripple={nativeRipple ? { color: highlight, foreground: true } : undefined}
376
478
  testID={testID}
377
479
  style={({ pressed }) => row(pressed || held)}
378
480
  >
379
481
  {({ pressed }) => (
380
- <RowHoldContext.Provider value={disabled ? null : setHeld}>
381
- {theme.isAndroid && ((!nativeRipple && pressed) || held) ? <View pointerEvents="none" style={[StyleSheet.absoluteFill, { backgroundColor: highlight }]} /> : null}
482
+ <RowHoldContext.Provider value={disabled ? null : theme.isAndroid ? hold : setHeld}>
483
+ {ripple.layer}
382
484
  {content(pressed || held)}
383
485
  </RowHoldContext.Provider>
384
486
  )}
385
487
  </Pressable>
386
488
  )
387
489
  }
490
+ // A row that only shows (a detail, a value) is one element named by `accessibilityLabel` when it has one; with a
491
+ // control at its end it stays a group, so the control is still reached
492
+ const named = accessibilityLabel != null && trailing == null && found == null
388
493
  return (
389
- <View ref={frameNode as never} collapsable={false} testID={testID} style={row(false)}>
494
+ <View
495
+ ref={frameNode as never}
496
+ collapsable={false}
497
+ testID={testID}
498
+ accessible={named || undefined}
499
+ accessibilityLabel={accessibilityLabel}
500
+ accessibilityRole={named && Platform.OS !== "web" ? "text" : undefined}
501
+ role={named && Platform.OS === "web" ? "group" : undefined}
502
+ style={row(false)}
503
+ >
390
504
  {content(false)}
391
505
  </View>
392
506
  )
393
507
  }
394
508
 
509
+ /** A Button among a List's rows: the row is the button (`ListActionContext`), the hairline under it from the text's start. */
510
+ function ActionRow({ children }: { children: ReactNode }) {
511
+ const theme = useTheme()
512
+ const { last } = useContext(PlaceContext)
513
+ return (
514
+ <View style={styles.actionRow}>
515
+ <ListActionContext.Provider value="row">{children}</ListActionContext.Provider>
516
+ {last ? null : (
517
+ <View
518
+ pointerEvents="none"
519
+ style={[styles.actionSeparator, { start: theme.isAndroid ? ANDROID_INSET : theme.length("--list-row-inset", 20), backgroundColor: theme.isAndroid ? divider(theme) : theme.colors.separator }]}
520
+ />
521
+ )}
522
+ </View>
523
+ )
524
+ }
525
+
526
+ export type StackedRowProps = {
527
+ /** The label over the value; none for a row whose placeholder names the field (`hideLabel`). */
528
+ label?: ReactNode
529
+ /** Words under the value (a label-hidden field's description). */
530
+ description?: ReactNode
531
+ error?: ReactNode
532
+ disabled?: boolean
533
+ /** A control at the end of the label's line. */
534
+ action?: ReactNode
535
+ /** The field: drawn bare, its text from the row's text start, as tall as its lines. */
536
+ children: ReactNode
537
+ testID?: string
538
+ }
539
+
540
+ /**
541
+ * A field row whose value is a line of its own, as the web's `Field row` with `orientation="vertical"` or `hideLabel`
542
+ * on a phone. iOS: the label 15/20 in the secondary label (`--field-row-above-*`), the value under it in the row's
543
+ * 17/22, 13 above and below (68 for one line); with no label the value alone, centred in the row's 52. The error 4
544
+ * under the value, as a row's. Android: the label 13sp in the secondary label, 4 over the bare value (17sp, as a card's
545
+ * text field), 10 above and below, 21 in; with no label the value alone 17 above and below and 22 in, a 54dp row (the
546
+ * reference's card input), the line above the row starting there too.
547
+ */
548
+ export function ListStackedRow({ label, description, error, disabled = false, action, children, testID }: StackedRowProps) {
549
+ const theme = useTheme()
550
+ const { last } = useContext(PlaceContext)
551
+ const rowEnd = useMemo<RowEnd>(() => ({ fill: () => {}, stacked: true }), [])
552
+ const android = theme.isAndroid
553
+ const hidden = label == null
554
+ const rowLine = theme.length("--field-row-label-line-height", 22)
555
+ // iOS: a row with words under its value (a description or an error) keeps the insets of a row with text, 12, as
556
+ // the web's phone rows do; an error stands 4 under the value and the value 4 under the label
557
+ const texted = description != null || error != null
558
+ // Android: a field alone in its row (no label, no words under it) is the reference's card input, 17 above and below
559
+ // and 22 in; with words under it 15 above and below
560
+ const alone = android && hidden && !texted
561
+ const inset = android ? (alone ? 22 : ANDROID_INSET) : theme.length("--list-row-inset", 20)
562
+ const padding = android
563
+ ? alone ? 17 : hidden ? 15 : 10
564
+ : texted ? theme.length("--field-row-text-padding-block", 12) : hidden ? (theme.length("--field-row-min-height", 52) - rowLine) / 2 : theme.length("--field-row-above-padding-block", 13)
565
+ const secondary = disabled ? (android ? withAlpha(theme.colors.labelSecondary, 0.5) : theme.colors.labelTertiary) : theme.colors.labelSecondary
566
+ const labelType = android
567
+ ? styles.androidDescription
568
+ : { fontSize: theme.length("--field-row-above-font-size", 15), lineHeight: theme.length("--field-row-above-line-height", 20) }
569
+ const labelText = hidden ? null : (
570
+ <Text color={secondary} style={[labelType, action != null ? styles.grow : null, !android && error != null && action == null ? { marginBottom: theme.length("--mobile-field-error-offset", 4) } : null]}>
571
+ {label}
572
+ </Text>
573
+ )
574
+ const errorOffset = theme.length("--mobile-field-error-offset", 4)
575
+ const errorLine = theme.length("--mobile-field-error-line-height", 20)
576
+ const iconSize = theme.length("--mobile-field-error-icon-size", 16)
577
+ return (
578
+ <View testID={testID} style={[styles.stackedRow, { paddingStart: inset }]}>
579
+ <View style={[styles.stackedColumn, { paddingEnd: inset, paddingVertical: padding, gap: android ? 4 : 0 }]}>
580
+ {last ? null : <View pointerEvents="none" style={[styles.iosSeparator, { backgroundColor: android ? divider(theme) : theme.colors.separator }]} />}
581
+ {labelText != null && action != null ? (
582
+ <View style={[styles.pair, { gap: 8 }, !android && error != null ? { marginBottom: theme.length("--mobile-field-error-offset", 4) } : null]}>
583
+ {labelText}
584
+ {action}
585
+ </View>
586
+ ) : (
587
+ labelText
588
+ )}
589
+ <RowEndContext.Provider value={rowEnd}>{children}</RowEndContext.Provider>
590
+ {description != null ? (
591
+ <Text
592
+ color={secondary}
593
+ style={android ? styles.androidDescription : { fontSize: theme.length("--field-row-description-font-size", 15), lineHeight: theme.length("--field-row-description-line-height", 20) }}
594
+ >
595
+ {description}
596
+ </Text>
597
+ ) : null}
598
+ {error == null ? null : android ? (
599
+ <Text color={dangerText(theme)} accessibilityLiveRegion="polite" style={styles.androidDescription}>
600
+ {error}
601
+ </Text>
602
+ ) : (
603
+ <View accessibilityLiveRegion="polite" style={[styles.iosError, { marginTop: errorOffset, gap: theme.length("--mobile-field-error-icon-gap", 4) }]}>
604
+ <ExclamationMarkCircle size={iconSize} color={errorColor(theme)} style={{ marginTop: (errorLine - iconSize) / 2 }} />
605
+ <Text color={errorColor(theme)} style={[styles.shrink, { fontSize: theme.length("--mobile-field-error-font-size", 15), lineHeight: errorLine }]}>
606
+ {error}
607
+ </Text>
608
+ </View>
609
+ )}
610
+ </View>
611
+ </View>
612
+ )
613
+ }
614
+
395
615
  type FoundControl =
396
616
  | { kind: "switch"; element: ReactElement<SwitchProps> }
397
617
  | { kind: "checkbox"; element: ReactElement<CheckboxProps> }
@@ -458,6 +678,8 @@ function iosRow(theme: Theme, pressed: boolean, last: boolean, described: boolea
458
678
 
459
679
  type ContentProps = Pick<ListItemProps, "label" | "description" | "leading" | "value" | "trailing" | "error"> & {
460
680
  theme: Theme
681
+ /** The end is a switch, a checkbox or a radio: with `columns` it stays at the row's edge. */
682
+ edgeControl?: boolean
461
683
  disabled: boolean
462
684
  destructive: boolean
463
685
  descriptionId?: string
@@ -498,7 +720,7 @@ function useValueBelow(
498
720
  return { below, probe, onRowLayout: auto ? measure("row") : undefined, onTrailingLayout: auto ? measure("trailing") : undefined }
499
721
  }
500
722
 
501
- function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, error, chevron, disabled, destructive, last }: ContentProps & { leadingColor?: string; chevron: boolean; last: boolean }) {
723
+ function IOSContent({ theme, label, description, descriptionId, leading, leadingColor, value, valuePlacement, trailing, edgeControl = false, error, chevron, disabled, destructive, last }: ContentProps & { leadingColor?: string; chevron: boolean; last: boolean }) {
502
724
  const inset = theme.length("--list-row-inset", 20)
503
725
  const tile = theme.length("--field-row-icon-size", 28)
504
726
  const gap = theme.length("--field-row-gap", 16)
@@ -526,7 +748,11 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
526
748
  )
527
749
  // A field at the end fills the room after the label (`RowEnd.fill`)
528
750
  const [fill, setFill] = useState(false)
529
- const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill }), [])
751
+ // In a List with `columns` a field's value starts at one column, 40% into the row (`--field-row-column-width`)
752
+ // A switch, a checkbox and a radio stay at the row's edge
753
+ const columns = useContext(ListOptionsContext)?.columns === true && trailing != null
754
+ const startsColumn = columns && !edgeControl
755
+ const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, align: startsColumn ? "start" : "end" }), [startsColumn])
530
756
  const errorOffset = theme.length("--mobile-field-error-offset", 4)
531
757
  const errorLine = theme.length("--mobile-field-error-line-height", 20)
532
758
  // With an error the label and the control stand on a line of their own over it
@@ -571,7 +797,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
571
797
  {probe}
572
798
  {line(
573
799
  <>
574
- <View style={[fill ? styles.iosTextHug : styles.iosText, { paddingVertical: error != null ? 0 : textPadding }, formRow && description == null && error == null ? { minHeight: target, justifyContent: "center" } : null]}>
800
+ <View style={[columns ? styles.column : fill ? styles.iosTextHug : styles.iosText, { paddingVertical: error != null ? 0 : textPadding }, formRow && description == null && error == null ? { minHeight: target, justifyContent: "center" } : null]}>
575
801
  <Text color={labelColor} style={labelType}>
576
802
  {label}
577
803
  </Text>
@@ -592,7 +818,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
592
818
  ) : null}
593
819
  </View>
594
820
  {(value != null && !below) || trailing != null || chevron ? (
595
- <View style={[fill ? styles.endFill : styles.end, { gap: disclosureGap }]}>
821
+ <View style={[fill || columns ? styles.endFill : styles.end, columns && !startsColumn ? styles.endAtEdge : null, { gap: disclosureGap }]}>
596
822
  {value != null && !below ? (
597
823
  // A long value wraps within the 60% the end takes, as the web's, rather than losing its end; set at the
598
824
  // row's end (a phone turns "right" over in a right-to-left layout itself, the web does not)
@@ -601,7 +827,7 @@ function IOSContent({ theme, label, description, descriptionId, leading, leading
601
827
  </Text>
602
828
  ) : null}
603
829
  {trailing != null ? (
604
- <View style={fill ? styles.grow : styles.keep} onLayout={onTrailingLayout}>
830
+ <View style={fill ? styles.grow : startsColumn ? styles.keepStart : styles.keep} onLayout={onTrailingLayout}>
605
831
  <RowEndContext.Provider value={rowEnd}>{trailing}</RowEndContext.Provider>
606
832
  </View>
607
833
  ) : null}
@@ -642,6 +868,7 @@ function AndroidContent({
642
868
  value,
643
869
  valuePlacement,
644
870
  trailing,
871
+ edgeControl = false,
645
872
  error,
646
873
  disabled,
647
874
  destructive,
@@ -654,18 +881,20 @@ function AndroidContent({
654
881
  // Android's row symbols are the text's ink over a light card and a gray over a dark one
655
882
  const symbol = dim(destructive ? danger : theme.scheme === "dark" ? theme.colors.labelSecondary : theme.colors.text)
656
883
  const tile = leading != null && !!leadingColor
657
- // A choice led by its mark: the 20dp ring 22 in, the text (and the divider) 64 in, 64dp tall with a description
658
- const textStart = leading == null ? 20 : tile || leadingMark ? 64 : 71
884
+ // The text (and the divider) 21 in, or 64 after a symbol, a tile or a choice's mark (its 20dp circle 22 in)
885
+ const textStart = leading == null ? ANDROID_INSET : 64
659
886
  // A value that ends the row stands 17 from the end (a value row), 20 in a row with a tile (a tiled row)
660
887
  const valueEnd = trailing == null && !tile ? 17 : 20
661
888
  // At the end the value takes half the row at most, 16 from the label and from a control
662
889
  const { below, probe, onRowLayout, onTrailingLayout } = useValueBelow(valuePlacement, label, value, { label: styles.androidLabel, value: styles.androidLabel }, (widths) => {
663
890
  const end = 16 + widths.value + (trailing != null ? 16 + widths.trailing : 0)
664
- return widths.value <= (widths.row - 40) * 0.5 + 0.5 && widths.label + end <= widths.row - textStart - valueEnd + 0.5
891
+ return widths.value <= (widths.row - 2 * ANDROID_INSET) * 0.5 + 0.5 && widths.label + end <= widths.row - textStart - valueEnd + 0.5
665
892
  })
666
893
  // A field at the end fills the room after the label, as on iOS; a select opens from the whole row
667
894
  const [fill, setFill] = useState(false)
668
- const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, press: handPress }), [handPress])
895
+ const columns = useContext(ListOptionsContext)?.columns === true && trailing != null
896
+ const startsColumn = columns && !edgeControl
897
+ const rowEnd = useMemo<RowEnd>(() => ({ fill: setFill, press: handPress, align: startsColumn ? "start" : "end" }), [handPress, startsColumn])
669
898
  const parts = (
670
899
  <>
671
900
  {leading == null ? null : leadingMark ? (
@@ -679,8 +908,10 @@ function AndroidContent({
679
908
  )}
680
909
  <View
681
910
  style={[
682
- fill ? styles.androidTextHug : styles.androidText,
683
- { paddingVertical: error != null ? 0 : description != null || below ? (leadingMark ? 12 : 10) : 15 },
911
+ columns ? [styles.androidTextHug, styles.column] : fill ? styles.androidTextHug : styles.androidText,
912
+ // One line centred in the 50dp row (54 beside a text field: a card's input row); with a second line 12 above
913
+ // and below (a 64dp row)
914
+ { paddingVertical: error != null ? 0 : description != null || below ? 12 : fill ? 17 : 15 },
684
915
  ]}
685
916
  >
686
917
  <Text color={ink} style={styles.androidLabel}>
@@ -699,12 +930,18 @@ function AndroidContent({
699
930
  ) : null}
700
931
  </View>
701
932
  {value != null && !below ? (
702
- <Text color={dim(accentText(theme))} numberOfLines={1} style={[styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - 20 }]}>
933
+ <Text color={dim(accentText(theme))} numberOfLines={1} style={[styles.androidLabel, styles.androidValue, { marginEnd: valueEnd - ANDROID_INSET }]}>
703
934
  {value}
704
935
  </Text>
705
936
  ) : null}
706
937
  {trailing != null ? (
707
- <View style={fill ? styles.androidEndFill : styles.androidEnd} onLayout={onTrailingLayout}>
938
+ <View
939
+ style={
940
+ // A switch or a checkbox stays at the row's edge after the label's column (it stretches in a column cell)
941
+ fill || startsColumn ? [styles.androidEndFill, startsColumn ? styles.androidEndStart : null] : columns ? [styles.androidEnd, styles.androidEndEdge] : styles.androidEnd
942
+ }
943
+ onLayout={onTrailingLayout}
944
+ >
708
945
  <RowEndContext.Provider value={rowEnd}>{trailing}</RowEndContext.Provider>
709
946
  </View>
710
947
  ) : null}
@@ -748,21 +985,22 @@ const styles = StyleSheet.create({
748
985
  // Android's section: one card, 16 round; the header a 40dp row inside it (a header row), the footer under it
749
986
  // (a footer: 24 from the screen's edge, 10 above, 17 below)
750
987
  androidCard: { borderRadius: ANDROID_CARD_RADIUS, overflow: "hidden" },
751
- androidHeader: { height: 40, paddingHorizontal: 20, paddingTop: 15, fontSize: 14, lineHeight: 18 },
752
- androidDescriptionLine: { paddingHorizontal: 20, paddingBottom: 6, fontSize: 14, lineHeight: 18 },
753
- androidDescriptionAlone: { paddingTop: 15 },
754
- androidFooter: { paddingHorizontal: 12, paddingTop: 10, paddingBottom: 17, fontSize: 14, lineHeight: 18 },
988
+ // The header: 15/20 Medium 14 under the card's top and 21 in, 6 under it to close its 40dp line
989
+ androidHeader: { minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, fontSize: 15, lineHeight: 20 },
990
+ androidDescriptionLine: { paddingHorizontal: ANDROID_INSET, paddingBottom: 6, fontSize: 14, lineHeight: 18 },
991
+ androidDescriptionAlone: { paddingTop: 14 },
992
+ androidFooter: { paddingHorizontal: 13, paddingTop: 11, paddingBottom: 17, fontSize: 14, lineHeight: 18 },
755
993
  // A plain list's header band (32dp, its text 16 in), its description and its footer 20 in as the rows' text, the
756
994
  // footer on the band's gray as the space between sections
757
995
  androidBand: { height: 32, justifyContent: "center", paddingHorizontal: 16 },
758
996
  androidBandText: { fontSize: 14, lineHeight: 18 },
759
997
  androidDescriptionPlain: { paddingTop: 10 },
760
- androidFooterPlain: { paddingHorizontal: 20 },
761
- androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: 20, paddingEnd: 20 },
762
- // A symbol at 21 and the text at 71; a 28dp tile at 18 with a 24dp symbol and the text at 64 (a tiled row)
763
- androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 26 },
764
- androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 2, marginEnd: 22 },
765
- androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -2, marginEnd: 18 },
998
+ androidFooterPlain: { paddingHorizontal: ANDROID_INSET },
999
+ androidRow: { flexDirection: "row", alignItems: "center", minHeight: 50, paddingStart: ANDROID_INSET, paddingEnd: ANDROID_INSET },
1000
+ // A 24dp symbol at 20, a 28dp tile at 18 with a 24dp symbol, or a choice's 20dp mark at 22: the text at 64
1001
+ androidIcon: { width: 24, height: 24, alignItems: "center", justifyContent: "center", marginStart: -1, marginEnd: 20 },
1002
+ androidMark: { width: 20, alignItems: "center", justifyContent: "center", marginStart: 1, marginEnd: 22 },
1003
+ androidTile: { width: 28, height: 28, borderRadius: 10, alignItems: "center", justifyContent: "center", marginStart: -3, marginEnd: 18 },
766
1004
  androidText: { flex: 1, minWidth: 0, gap: 4 },
767
1005
  androidTextHug: { flexShrink: 1, minWidth: 0, gap: 4 },
768
1006
  androidColumn: { flex: 1, minWidth: 0, paddingVertical: 10 },
@@ -782,4 +1020,23 @@ const styles = StyleSheet.create({
782
1020
  shrink: { flexShrink: 1 },
783
1021
  keep: { flexShrink: 0 },
784
1022
  grow: { flex: 1, minWidth: 0 },
1023
+ // The label's column of a List with `columns`, the value starting after it
1024
+ column: { width: "40%", flexGrow: 0, flexShrink: 0 },
1025
+ keepStart: { flexShrink: 1, minWidth: 0, alignItems: "flex-start" },
1026
+ androidEndStart: { alignItems: "flex-start" },
1027
+ androidEndEdge: { marginStart: "auto" },
1028
+ endAtEdge: { justifyContent: "flex-end" },
1029
+ iosHeaderRow: { flexDirection: "row", alignItems: "flex-end", gap: 16 },
1030
+ androidHeaderRow: { flexDirection: "row", alignItems: "flex-start", minHeight: 40, paddingHorizontal: ANDROID_INSET, paddingTop: 14, paddingBottom: 6, gap: 16 },
1031
+ androidHeaderTitle: { flex: 1, minWidth: 0, fontSize: 15, lineHeight: 20 },
1032
+ androidHeaderTitleType: { fontSize: 15, lineHeight: 20 },
1033
+ // A prominent header: the title 16sp in the text color
1034
+ androidHeaderIncreased: { fontSize: 16, lineHeight: 20 },
1035
+ androidBandRow: { flexDirection: "row", alignItems: "center", gap: 16 },
1036
+ // A row that is a Button: the button fills it, the hairline under it from the text's start
1037
+ actionRow: { alignSelf: "stretch" },
1038
+ actionSeparator: { position: "absolute", end: 0, bottom: 0, height: StyleSheet.hairlineWidth },
1039
+ // A field row whose value is a line of its own
1040
+ stackedRow: { alignSelf: "stretch", flexDirection: "row", alignItems: "center" },
1041
+ stackedColumn: { flex: 1, minWidth: 0, alignSelf: "stretch" },
785
1042
  })