@hzblj/kara-components 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +31 -3
- package/lib/module/atoms/checkbox/checkbox.android.js +7 -3
- package/lib/module/atoms/checkbox/checkbox.android.js.map +1 -1
- package/lib/module/atoms/date-picker/date-picker.ios.js +32 -11
- package/lib/module/atoms/date-picker/date-picker.ios.js.map +1 -1
- package/lib/module/atoms/index.js +0 -1
- package/lib/module/atoms/index.js.map +1 -1
- package/lib/module/atoms/rn-flat-list/rn-flat-list.js +10 -9
- package/lib/module/atoms/rn-flat-list/rn-flat-list.js.map +1 -1
- package/lib/module/atoms/rn-section-list/rn-section-list.js +5 -8
- package/lib/module/atoms/rn-section-list/rn-section-list.js.map +1 -1
- package/lib/module/atoms/segmented-control/index.js +1 -1
- package/lib/module/atoms/segmented-control/index.js.map +1 -1
- package/lib/module/atoms/segmented-control/segmented-control.android.js +74 -0
- package/lib/module/atoms/segmented-control/segmented-control.android.js.map +1 -0
- package/lib/module/atoms/segmented-control/segmented-control.ios.js +44 -0
- package/lib/module/atoms/segmented-control/segmented-control.ios.js.map +1 -0
- package/lib/module/atoms/switch/switch.android.js +4 -1
- package/lib/module/atoms/switch/switch.android.js.map +1 -1
- package/lib/module/molecules/search-bar/search-bar.js +15 -2
- package/lib/module/molecules/search-bar/search-bar.js.map +1 -1
- package/lib/module/molecules/tooltip/tooltip.android.js +16 -5
- package/lib/module/molecules/tooltip/tooltip.android.js.map +1 -1
- package/lib/module/organisms/action-sheet/action-sheet.android.js +41 -20
- package/lib/module/organisms/action-sheet/action-sheet.android.js.map +1 -1
- package/lib/module/organisms/action-sheet/action-sheet.ios.js +24 -8
- package/lib/module/organisms/action-sheet/action-sheet.ios.js.map +1 -1
- package/lib/module/organisms/alert/alert.ios.js +15 -2
- package/lib/module/organisms/alert/alert.ios.js.map +1 -1
- package/lib/module/organisms/form/form.android.js +22 -9
- package/lib/module/organisms/form/form.android.js.map +1 -1
- package/lib/module/organisms/swipe-actions/swipe-actions.android.js +125 -11
- package/lib/module/organisms/swipe-actions/swipe-actions.android.js.map +1 -1
- package/lib/module/organisms/swipe-actions/swipe-actions.ios.js +46 -18
- package/lib/module/organisms/swipe-actions/swipe-actions.ios.js.map +1 -1
- package/lib/module/templates/screen/screen.android.js +31 -10
- package/lib/module/templates/screen/screen.android.js.map +1 -1
- package/lib/typescript/atoms/avatar/avatar.types.d.ts +5 -0
- package/lib/typescript/atoms/badge/badge.types.d.ts +3 -0
- package/lib/typescript/atoms/button/button.types.d.ts +12 -0
- package/lib/typescript/atoms/card/card.types.d.ts +6 -0
- package/lib/typescript/atoms/checkbox/checkbox.types.d.ts +5 -0
- package/lib/typescript/atoms/chip/chip.types.d.ts +5 -0
- package/lib/typescript/atoms/color-picker/color-picker.types.d.ts +4 -0
- package/lib/typescript/atoms/date-picker/date-picker.ios.d.ts +6 -1
- package/lib/typescript/atoms/date-picker/date-picker.types.d.ts +14 -0
- package/lib/typescript/atoms/divider/divider.types.d.ts +3 -0
- package/lib/typescript/atoms/fab/fab.types.d.ts +7 -0
- package/lib/typescript/atoms/glass-view/glass-view.types.d.ts +1 -0
- package/lib/typescript/atoms/h-stack/h-stack.types.d.ts +6 -0
- package/lib/typescript/atoms/icon/icon.types.d.ts +8 -0
- package/lib/typescript/atoms/icon-button/icon-button.types.d.ts +5 -0
- package/lib/typescript/atoms/index.d.ts +0 -1
- package/lib/typescript/atoms/island/island.types.d.ts +4 -0
- package/lib/typescript/atoms/list/list.types.d.ts +2 -0
- package/lib/typescript/atoms/picker/picker.types.d.ts +12 -0
- package/lib/typescript/atoms/pressable/pressable.types.d.ts +8 -0
- package/lib/typescript/atoms/progress/progress.types.d.ts +6 -0
- package/lib/typescript/atoms/rn-flat-list/rn-flat-list.d.ts +5 -8
- package/lib/typescript/atoms/rn-flat-list/rn-flat-list.types.d.ts +3 -1
- package/lib/typescript/atoms/rn-scroll-view/rn-scroll-view.types.d.ts +4 -0
- package/lib/typescript/atoms/rn-section-list/rn-section-list.d.ts +2 -8
- package/lib/typescript/atoms/rn-section-list/rn-section-list.types.d.ts +3 -1
- package/lib/typescript/atoms/rn-text/rn-text.types.d.ts +4 -0
- package/lib/typescript/atoms/rn-view/rn-view.types.d.ts +2 -0
- package/lib/typescript/atoms/scroll-view/scroll-view.types.d.ts +4 -0
- package/lib/typescript/atoms/segmented-control/segmented-control.d.ts +1 -6
- package/lib/typescript/atoms/segmented-control/segmented-control.ios.d.ts +7 -0
- package/lib/typescript/atoms/segmented-control/segmented-control.types.d.ts +13 -0
- package/lib/typescript/atoms/skeleton/skeleton.types.d.ts +5 -0
- package/lib/typescript/atoms/slider/slider.types.d.ts +7 -0
- package/lib/typescript/atoms/spacer/spacer.types.d.ts +3 -0
- package/lib/typescript/atoms/surface/surface.types.d.ts +7 -0
- package/lib/typescript/atoms/switch/switch.types.d.ts +8 -0
- package/lib/typescript/atoms/text/text.types.d.ts +12 -0
- package/lib/typescript/atoms/text-field/text-field.types.d.ts +12 -0
- package/lib/typescript/atoms/v-stack/v-stack.types.d.ts +9 -0
- package/lib/typescript/atoms/z-stack/z-stack.types.d.ts +8 -0
- package/lib/typescript/molecules/collapsible/collapsible.types.d.ts +8 -0
- package/lib/typescript/molecules/empty-state/empty-state.types.d.ts +5 -0
- package/lib/typescript/molecules/label/label.types.d.ts +6 -0
- package/lib/typescript/molecules/labeled-content/labeled-content.types.d.ts +6 -0
- package/lib/typescript/molecules/link/link.types.d.ts +6 -0
- package/lib/typescript/molecules/list-item/list-item.types.d.ts +9 -0
- package/lib/typescript/molecules/navigation-bar/navigation-bar.types.d.ts +8 -0
- package/lib/typescript/molecules/pager/pager.types.d.ts +2 -0
- package/lib/typescript/molecules/radio-group/radio-group.types.d.ts +10 -0
- package/lib/typescript/molecules/rn-list-item/rn-list-item.types.d.ts +1 -1
- package/lib/typescript/molecules/rn-tooltip/rn-tooltip.types.d.ts +11 -0
- package/lib/typescript/molecules/scroll-edge-container/scroll-edge-container.types.d.ts +3 -0
- package/lib/typescript/molecules/search-bar/search-bar.types.d.ts +8 -0
- package/lib/typescript/molecules/stepper/stepper.types.d.ts +13 -0
- package/lib/typescript/molecules/tooltip/tooltip.types.d.ts +12 -0
- package/lib/typescript/organisms/action-sheet/action-sheet.types.d.ts +8 -0
- package/lib/typescript/organisms/alert/alert.types.d.ts +11 -0
- package/lib/typescript/organisms/context-menu/context-menu.types.d.ts +4 -0
- package/lib/typescript/organisms/fab-menu/fab-menu.types.d.ts +2 -0
- package/lib/typescript/organisms/form/form.types.d.ts +6 -0
- package/lib/typescript/organisms/menu/menu.types.d.ts +17 -0
- package/lib/typescript/organisms/sheet/sheet.types.d.ts +19 -0
- package/lib/typescript/organisms/snackbar/snackbar.types.d.ts +8 -0
- package/lib/typescript/organisms/swipe-actions/swipe-actions.types.d.ts +36 -13
- package/lib/typescript/templates/screen/screen.types.d.ts +9 -0
- package/package.json +5 -7
- package/src/atoms/avatar/avatar.types.ts +5 -0
- package/src/atoms/badge/badge.types.ts +3 -0
- package/src/atoms/button/button.types.ts +12 -0
- package/src/atoms/card/card.types.ts +6 -0
- package/src/atoms/checkbox/checkbox.android.tsx +7 -3
- package/src/atoms/checkbox/checkbox.types.ts +5 -0
- package/src/atoms/chip/chip.types.ts +5 -0
- package/src/atoms/color-picker/color-picker.types.ts +4 -0
- package/src/atoms/date-picker/date-picker.ios.tsx +33 -13
- package/src/atoms/date-picker/date-picker.types.ts +14 -0
- package/src/atoms/divider/divider.types.ts +3 -0
- package/src/atoms/fab/fab.types.ts +7 -0
- package/src/atoms/glass-view/glass-view.types.ts +1 -0
- package/src/atoms/h-stack/h-stack.types.ts +6 -0
- package/src/atoms/icon/icon.types.ts +8 -0
- package/src/atoms/icon-button/icon-button.types.ts +5 -0
- package/src/atoms/index.ts +0 -1
- package/src/atoms/island/island.types.ts +4 -0
- package/src/atoms/list/list.types.ts +2 -0
- package/src/atoms/picker/picker.types.ts +12 -0
- package/src/atoms/pressable/pressable.types.ts +8 -0
- package/src/atoms/progress/progress.types.ts +6 -0
- package/src/atoms/rn-flat-list/rn-flat-list.tsx +8 -8
- package/src/atoms/rn-flat-list/rn-flat-list.types.ts +3 -1
- package/src/atoms/rn-scroll-view/rn-scroll-view.types.ts +4 -0
- package/src/atoms/rn-section-list/rn-section-list.tsx +5 -8
- package/src/atoms/rn-section-list/rn-section-list.types.ts +3 -1
- package/src/atoms/rn-text/rn-text.types.ts +4 -0
- package/src/atoms/rn-view/rn-view.types.ts +2 -0
- package/src/atoms/scroll-view/scroll-view.types.ts +4 -0
- package/src/atoms/segmented-control/segmented-control.android.tsx +79 -0
- package/src/atoms/segmented-control/segmented-control.ios.tsx +47 -0
- package/src/atoms/segmented-control/segmented-control.types.ts +13 -0
- package/src/atoms/skeleton/skeleton.types.ts +5 -0
- package/src/atoms/slider/slider.types.ts +7 -0
- package/src/atoms/spacer/spacer.types.ts +3 -0
- package/src/atoms/surface/surface.types.ts +7 -0
- package/src/atoms/switch/switch.android.tsx +4 -1
- package/src/atoms/switch/switch.types.ts +8 -0
- package/src/atoms/text/text.types.ts +12 -0
- package/src/atoms/text-field/text-field.types.ts +12 -0
- package/src/atoms/v-stack/v-stack.types.ts +9 -0
- package/src/atoms/z-stack/z-stack.types.ts +8 -0
- package/src/molecules/collapsible/collapsible.types.ts +8 -0
- package/src/molecules/empty-state/empty-state.types.ts +5 -0
- package/src/molecules/label/label.types.ts +6 -0
- package/src/molecules/labeled-content/labeled-content.types.ts +6 -0
- package/src/molecules/link/link.types.ts +6 -0
- package/src/molecules/list-item/list-item.types.ts +9 -0
- package/src/molecules/navigation-bar/navigation-bar.types.ts +8 -0
- package/src/molecules/pager/pager.types.ts +2 -0
- package/src/molecules/radio-group/radio-group.types.ts +10 -0
- package/src/molecules/rn-list-item/rn-list-item.types.ts +1 -1
- package/src/molecules/rn-tooltip/rn-tooltip.types.ts +11 -0
- package/src/molecules/scroll-edge-container/scroll-edge-container.types.ts +3 -0
- package/src/molecules/search-bar/search-bar.tsx +9 -2
- package/src/molecules/search-bar/search-bar.types.ts +8 -0
- package/src/molecules/stepper/stepper.types.ts +13 -0
- package/src/molecules/tooltip/tooltip.android.tsx +17 -9
- package/src/molecules/tooltip/tooltip.types.ts +12 -0
- package/src/organisms/action-sheet/action-sheet.android.tsx +37 -19
- package/src/organisms/action-sheet/action-sheet.ios.tsx +22 -9
- package/src/organisms/action-sheet/action-sheet.types.ts +8 -0
- package/src/organisms/alert/alert.ios.tsx +11 -1
- package/src/organisms/alert/alert.types.ts +11 -0
- package/src/organisms/context-menu/context-menu.types.ts +4 -0
- package/src/organisms/fab-menu/fab-menu.types.ts +2 -0
- package/src/organisms/form/form.android.tsx +15 -7
- package/src/organisms/form/form.types.ts +6 -0
- package/src/organisms/menu/menu.types.ts +17 -0
- package/src/organisms/sheet/sheet.types.ts +19 -0
- package/src/organisms/snackbar/snackbar.types.ts +8 -0
- package/src/organisms/swipe-actions/swipe-actions.android.tsx +129 -9
- package/src/organisms/swipe-actions/swipe-actions.ios.tsx +45 -11
- package/src/organisms/swipe-actions/swipe-actions.types.ts +37 -14
- package/src/templates/screen/screen.android.tsx +33 -12
- package/src/templates/screen/screen.types.ts +9 -0
- package/lib/module/atoms/flash-list/flash-list.js +0 -31
- package/lib/module/atoms/flash-list/flash-list.js.map +0 -1
- package/lib/module/atoms/flash-list/flash-list.types.js +0 -4
- package/lib/module/atoms/flash-list/flash-list.types.js.map +0 -1
- package/lib/module/atoms/flash-list/index.js +0 -5
- package/lib/module/atoms/flash-list/index.js.map +0 -1
- package/lib/module/atoms/segmented-control/segmented-control.js +0 -40
- package/lib/module/atoms/segmented-control/segmented-control.js.map +0 -1
- package/lib/typescript/atoms/flash-list/flash-list.d.ts +0 -8
- package/lib/typescript/atoms/flash-list/flash-list.types.d.ts +0 -18
- package/lib/typescript/atoms/flash-list/index.d.ts +0 -2
- package/src/atoms/flash-list/flash-list.tsx +0 -28
- package/src/atoms/flash-list/flash-list.types.ts +0 -20
- package/src/atoms/flash-list/index.ts +0 -2
- package/src/atoms/segmented-control/segmented-control.tsx +0 -47
|
@@ -7,14 +7,8 @@ import type {RnSectionListProps} from './rn-section-list.types'
|
|
|
7
7
|
const NO_SX = {}
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* FlashList is the default for lists in this codebase and should stay that way for data rows. This
|
|
13
|
-
* exists for the case it cannot serve: content that hosts native views. FlashList positions its rows
|
|
14
|
-
* absolutely and recycles their cells, and an `@expo/ui` host does not survive either — the hosted
|
|
15
|
-
* view ends up drawn where the layout no longer is. `VirtualizedList` renders its cells in normal flow
|
|
16
|
-
* inside a scroll view, using blank spacers for the range it has not rendered, so a hosted view stays
|
|
17
|
-
* exactly where the layout put it.
|
|
10
|
+
* `RnFlatList` with sections: React Native's own `VirtualizedList`, cells in normal flow inside a scroll view, so a
|
|
11
|
+
* row that hosts native views keeps them where the layout put it.
|
|
18
12
|
*
|
|
19
13
|
* Sticky headers default off, unlike React Native, where they are on for vertical lists. A header that
|
|
20
14
|
* detaches and floats over the content is a deliberate effect, not something a list should do unasked.
|
|
@@ -30,6 +24,9 @@ export const RnSectionList = <TItem, TSection = DefaultSectionT>({
|
|
|
30
24
|
|
|
31
25
|
return (
|
|
32
26
|
<RNSectionList<TItem, TSection>
|
|
27
|
+
// Android clips by default, and a host is measured after its first layout — at zero height it counts as
|
|
28
|
+
// off-screen, is detached, and its native view never comes back.
|
|
29
|
+
removeClippedSubviews={false}
|
|
33
30
|
sections={sections}
|
|
34
31
|
{...rest}
|
|
35
32
|
contentContainerStyle={content === undefined ? undefined : contentStyle}
|
|
@@ -3,9 +3,11 @@ import type {DefaultSectionT, SectionListProps as RNSectionListProps} from 'reac
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Top-level `sx` styles the viewport; `content` styles the scrolling content container, so padding and
|
|
6
|
-
* gap belong there — the same split as `RnScrollView` and `RnFlatList`.
|
|
6
|
+
* gap belong there — the same split as `RnScrollView` and `RnFlatList`. `removeClippedSubviews` is off unless
|
|
7
|
+
* you turn it on, as in `RnFlatList`: Android's default would leave rows with hosts in them empty.
|
|
7
8
|
*/
|
|
8
9
|
export type RnSectionListProps<TItem, TSection = DefaultSectionT> = ResponsiveViewSx &
|
|
9
10
|
Omit<RNSectionListProps<TItem, TSection>, 'contentContainerStyle' | 'style'> & {
|
|
11
|
+
/** Styles the scrolling content container — padding and gap belong here. */
|
|
10
12
|
content?: ResponsiveViewSx
|
|
11
13
|
}
|
|
@@ -2,9 +2,13 @@ import type {ColorToken, TextVariant} from '@hzblj/kara-theme'
|
|
|
2
2
|
import type {ReactNode} from 'react'
|
|
3
3
|
import type {TextProps as RNTextProps} from 'react-native'
|
|
4
4
|
|
|
5
|
+
/** React Native's `Text` in a theme typography variant — the React Native tier, for text outside a native host. */
|
|
5
6
|
export type RnTextProps = Omit<RNTextProps, 'style'> & {
|
|
7
|
+
/** Horizontal alignment, as React Native's `textAlign`. */
|
|
6
8
|
align?: 'center' | 'left' | 'right'
|
|
9
|
+
/** The text's colour. `content.primary` by default. */
|
|
7
10
|
color?: ColorToken
|
|
11
|
+
/** The typography variant. `body` by default. */
|
|
8
12
|
variant?: TextVariant
|
|
9
13
|
}
|
|
10
14
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {ReactElement, ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/** Carries a React Native view into a SwiftUI or Compose tree — `@expo/ui`'s `RNHostView` on both platforms. */
|
|
3
4
|
export type RnViewProps = {
|
|
4
5
|
/**
|
|
5
6
|
* A single React Native *view*. It may not contain React Native text: a bare string becomes a
|
|
@@ -15,6 +16,7 @@ export type RnViewProps = {
|
|
|
15
16
|
* intrinsic size and would otherwise stretch to fill the SwiftUI parent.
|
|
16
17
|
*/
|
|
17
18
|
matchContents?: boolean
|
|
19
|
+
/** Not forwarded on either platform — give the child its own `testID`. */
|
|
18
20
|
testID?: string
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -9,7 +9,9 @@ export type ScrollViewAxis = 'horizontal' | 'vertical'
|
|
|
9
9
|
* like React Native's `contentContainerStyle` padding and scrolls with the content.
|
|
10
10
|
*/
|
|
11
11
|
export type ScrollViewProps = ResponsiveSx & {
|
|
12
|
+
/** The scroll direction. `vertical` by default. */
|
|
12
13
|
axis?: ScrollViewAxis
|
|
14
|
+
/** Laid out in a stack along `axis`. */
|
|
13
15
|
children?: ReactNode
|
|
14
16
|
/**
|
|
15
17
|
* Enables pull-to-refresh. Async on purpose: the spinner runs until the promise settles, which is
|
|
@@ -21,7 +23,9 @@ export type ScrollViewProps = ResponsiveSx & {
|
|
|
21
23
|
onRefresh?: () => Promise<void>
|
|
22
24
|
/** iOS only — Compose exposes no indicator toggle, so Android always shows the native one. */
|
|
23
25
|
showsIndicators?: boolean
|
|
26
|
+
/** The space between children. */
|
|
24
27
|
spacing?: SpaceSize
|
|
28
|
+
/** Test identifier, forwarded to the native view. */
|
|
25
29
|
testID?: string
|
|
26
30
|
}
|
|
27
31
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {Host, SegmentedButton, SingleChoiceSegmentedButtonRow, Text} from '@expo/ui/jetpack-compose'
|
|
2
|
+
import {fillMaxWidth, testID as testIdModifier, weight} from '@expo/ui/jetpack-compose/modifiers'
|
|
3
|
+
import {useAppTheme} from '@hzblj/kara-theme'
|
|
4
|
+
import {useCallback, useMemo} from 'react'
|
|
5
|
+
|
|
6
|
+
import {haptics} from '../../haptics'
|
|
7
|
+
import type {SegmentedControlComponent, SegmentedControlProps} from './segmented-control.types'
|
|
8
|
+
|
|
9
|
+
const MATCH_HEIGHT_ONLY = {horizontal: false, vertical: true}
|
|
10
|
+
|
|
11
|
+
/** Every segment the same width, like UIKit's: Material's would size each to its label. */
|
|
12
|
+
const SEGMENT = [weight(1)]
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Material's single-choice segmented buttons, the selected one filled with the accent like a checked `Switch`. Its own
|
|
16
|
+
* host, themed like an `Island`, so it drops into React Native layout the way the iOS control does. Material plays
|
|
17
|
+
* nothing on a new segment, so this plays `selection`.
|
|
18
|
+
*/
|
|
19
|
+
export const SegmentedControl: SegmentedControlComponent = ({
|
|
20
|
+
disabled = false,
|
|
21
|
+
onChange,
|
|
22
|
+
selectedIndex,
|
|
23
|
+
testID,
|
|
24
|
+
values,
|
|
25
|
+
}: SegmentedControlProps) => {
|
|
26
|
+
const theme = useAppTheme()
|
|
27
|
+
|
|
28
|
+
const colors = useMemo(
|
|
29
|
+
() => ({
|
|
30
|
+
activeBorderColor: theme.color('fill.accent.primary'),
|
|
31
|
+
activeContainerColor: theme.color('fill.accent.primary'),
|
|
32
|
+
activeContentColor: theme.color('content.on.bg'),
|
|
33
|
+
disabledActiveBorderColor: theme.color('fill.accent.disabled'),
|
|
34
|
+
disabledActiveContainerColor: theme.color('fill.accent.disabled'),
|
|
35
|
+
disabledActiveContentColor: theme.color('btn.content.disabled'),
|
|
36
|
+
disabledInactiveBorderColor: theme.color('border.tertiary'),
|
|
37
|
+
disabledInactiveContentColor: theme.color('btn.content.disabled'),
|
|
38
|
+
inactiveBorderColor: theme.color('border.secondary.base'),
|
|
39
|
+
inactiveContentColor: theme.color('content.primary'),
|
|
40
|
+
}),
|
|
41
|
+
[theme]
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
const rowModifiers = useMemo(() => (testID ? [fillMaxWidth(), testIdModifier(testID)] : [fillMaxWidth()]), [testID])
|
|
45
|
+
|
|
46
|
+
// Material reports a tap on the segment that is already selected too; iOS does not, and neither does this.
|
|
47
|
+
const select = useCallback(
|
|
48
|
+
(index: number) => {
|
|
49
|
+
if (index === selectedIndex) {
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
haptics.selection()
|
|
54
|
+
onChange?.(index, values[index] ?? '')
|
|
55
|
+
},
|
|
56
|
+
[onChange, selectedIndex, values]
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Host colorScheme={theme.dark ? 'dark' : 'light'} matchContents={MATCH_HEIGHT_ONLY} seedColor={theme.materialSeed}>
|
|
61
|
+
<SingleChoiceSegmentedButtonRow modifiers={rowModifiers}>
|
|
62
|
+
{values.map((label, index) => (
|
|
63
|
+
<SegmentedButton
|
|
64
|
+
colors={colors}
|
|
65
|
+
enabled={!disabled}
|
|
66
|
+
key={index}
|
|
67
|
+
modifiers={SEGMENT}
|
|
68
|
+
onClick={() => select(index)}
|
|
69
|
+
selected={index === selectedIndex}
|
|
70
|
+
>
|
|
71
|
+
<SegmentedButton.Label>
|
|
72
|
+
<Text style={theme.typography.subheadlineMedium}>{label}</Text>
|
|
73
|
+
</SegmentedButton.Label>
|
|
74
|
+
</SegmentedButton>
|
|
75
|
+
))}
|
|
76
|
+
</SingleChoiceSegmentedButtonRow>
|
|
77
|
+
</Host>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {SegmentedControl as NativeSegmentedControl} from '@hzblj/kara-native/swift-ui'
|
|
2
|
+
import {useAppTheme} from '@hzblj/kara-theme'
|
|
3
|
+
import {useCallback, useMemo} from 'react'
|
|
4
|
+
|
|
5
|
+
import type {SegmentedControlComponent, SegmentedControlProps} from './segmented-control.types'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* kara's own `UISegmentedControl`, with the pill in the accent and white text on it — the system control tints only the
|
|
9
|
+
* pill, and SwiftUI's segmented picker not even that. A plain `UIView` in React Native layout: it needs no host, takes
|
|
10
|
+
* the width it is given and UIKit's height. UIKit plays the control's own feedback.
|
|
11
|
+
*/
|
|
12
|
+
export const SegmentedControl: SegmentedControlComponent = ({
|
|
13
|
+
disabled = false,
|
|
14
|
+
onChange,
|
|
15
|
+
selectedIndex,
|
|
16
|
+
testID,
|
|
17
|
+
values,
|
|
18
|
+
}: SegmentedControlProps) => {
|
|
19
|
+
const theme = useAppTheme()
|
|
20
|
+
const face = theme.typography.footnoteMedium
|
|
21
|
+
|
|
22
|
+
// The native control speaks in values; a segment's is its index, so two labels may read the same.
|
|
23
|
+
const options = useMemo(() => values.map((label, index) => ({label, value: String(index)})), [values])
|
|
24
|
+
|
|
25
|
+
const onValueChange = useCallback(
|
|
26
|
+
(value: string) => {
|
|
27
|
+
const index = Number(value)
|
|
28
|
+
onChange?.(index, values[index] ?? '')
|
|
29
|
+
},
|
|
30
|
+
[onChange, values]
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<NativeSegmentedControl
|
|
35
|
+
activePillColor={theme.color('fill.accent.primary')}
|
|
36
|
+
activeTextColor={theme.color('content.on.bg')}
|
|
37
|
+
disabled={disabled}
|
|
38
|
+
fontFamily={face.fontFamily}
|
|
39
|
+
fontSize={face.fontSize}
|
|
40
|
+
inactiveTextColor={theme.color('content.primary')}
|
|
41
|
+
onValueChange={onValueChange}
|
|
42
|
+
options={options}
|
|
43
|
+
selectedValue={String(selectedIndex)}
|
|
44
|
+
testID={testID}
|
|
45
|
+
/>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A row of mutually exclusive segments, the selected one in the accent — kara's own `UISegmentedControl` on iOS,
|
|
5
|
+
* Material's single-choice segmented buttons on Android. It needs no `Screen` or `Island`: iOS is a plain view, Android
|
|
6
|
+
* brings its own host. It takes the width it is given; the height is the platform's.
|
|
7
|
+
*/
|
|
3
8
|
export type SegmentedControlProps = {
|
|
9
|
+
/** Stops the user changing the segment, and dims the control. */
|
|
4
10
|
disabled?: boolean
|
|
11
|
+
/**
|
|
12
|
+
* Called with the index and label of the segment the user picked — never for a tap on the one already selected.
|
|
13
|
+
* Android plays `selection`; iOS's control plays its own feedback.
|
|
14
|
+
*/
|
|
5
15
|
onChange?: (index: number, value: string) => void
|
|
16
|
+
/** The selected segment. Controlled: pass back what `onChange` reports. */
|
|
6
17
|
selectedIndex: number
|
|
18
|
+
/** Test identifier, on the whole control — reach a segment by its label. */
|
|
7
19
|
testID?: string
|
|
20
|
+
/** The segments' labels, in order. */
|
|
8
21
|
values: string[]
|
|
9
22
|
}
|
|
10
23
|
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type {RadiiSize} from '@hzblj/kara-theme'
|
|
2
2
|
import type {ReactNode} from 'react'
|
|
3
3
|
|
|
4
|
+
/** A loading placeholder that pulses in `fill.quaternary` — a React Native view, so it needs no host. */
|
|
4
5
|
export type SkeletonProps = {
|
|
6
|
+
/** The corner radius. `small` by default. */
|
|
5
7
|
borderRadius?: RadiiSize
|
|
8
|
+
/** In points. */
|
|
6
9
|
height: number
|
|
10
|
+
/** Test identifier, forwarded to the view. */
|
|
7
11
|
testID?: string
|
|
12
|
+
/** In points. Leave it unset and it fills the available width. */
|
|
8
13
|
width?: number
|
|
9
14
|
}
|
|
10
15
|
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/** SwiftUI `Slider` / Compose's Material `Slider`, tinted `fill.accent.primary`. */
|
|
3
4
|
export type SliderProps = {
|
|
5
|
+
/** Stops the user moving the thumb, and dims the slider. */
|
|
4
6
|
disabled?: boolean
|
|
7
|
+
/** The upper end. `1` by default. */
|
|
5
8
|
max?: number
|
|
9
|
+
/** The lower end. `0` by default. */
|
|
6
10
|
min?: number
|
|
11
|
+
/** Called with the new value as the thumb moves. */
|
|
7
12
|
onValueChange?: (value: number) => void
|
|
13
|
+
/** The increment between stops; leave it unset for a continuous slider. On Android every stop plays a `tick`. */
|
|
8
14
|
step?: number
|
|
15
|
+
/** Between `min` and `max`. Controlled: pass back what `onValueChange` reports. */
|
|
9
16
|
value: number
|
|
10
17
|
}
|
|
11
18
|
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type {SpaceSize} from '@hzblj/kara-theme'
|
|
2
2
|
import type {ReactNode} from 'react'
|
|
3
3
|
|
|
4
|
+
/** Takes up the free space in a stack — SwiftUI `Spacer` / Compose `Spacer` with `weight(1)`. */
|
|
4
5
|
export type SpacerProps = {
|
|
6
|
+
/** The least room it takes. iOS holds it along the stack's axis; Android as a minimum height only. */
|
|
5
7
|
min?: SpaceSize
|
|
8
|
+
/** iOS: forwarded to the native view. Android ignores it. */
|
|
6
9
|
testID?: string
|
|
7
10
|
}
|
|
8
11
|
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import type {ResponsiveSx} from '@hzblj/kara-sx'
|
|
2
2
|
import type {ReactNode} from 'react'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A container padded `s16` and rounded `large` unless told otherwise — a SwiftUI `VStack` on iOS, Material's
|
|
6
|
+
* `Surface` around a `Column` on Android.
|
|
7
|
+
*/
|
|
4
8
|
export type SurfaceProps = ResponsiveSx & {
|
|
9
|
+
/** Stacked vertically, from the leading edge. */
|
|
5
10
|
children?: ReactNode
|
|
11
|
+
/** iOS wraps the content in a `GlassEffectContainer`; Android raises it to a tonal elevation of `3`. */
|
|
6
12
|
glass?: boolean
|
|
13
|
+
/** Test identifier, forwarded to the native view. */
|
|
7
14
|
testID?: string
|
|
8
15
|
}
|
|
9
16
|
|
|
@@ -7,6 +7,9 @@ import {haptics} from '../../haptics'
|
|
|
7
7
|
import {useHostGuard} from '../../host-context'
|
|
8
8
|
import type {SwitchComponent, SwitchProps} from './switch.types'
|
|
9
9
|
|
|
10
|
+
/** Stands in for a missing handler: Material drops its 48dp touch target without one, and the switch moves. */
|
|
11
|
+
const NOOP = () => undefined
|
|
12
|
+
|
|
10
13
|
/**
|
|
11
14
|
* Material's switch, tinted with the accent like SwiftUI's toggle. With a label it is a full-width row — label at the
|
|
12
15
|
* start, switch at the end — and the whole row toggles, the way a Material settings row does. A flip plays
|
|
@@ -35,7 +38,7 @@ export const Switch: SwitchComponent = ({disabled = false, label, onValueChange,
|
|
|
35
38
|
checkedTrackColor: theme.color('fill.accent.primary'),
|
|
36
39
|
}}
|
|
37
40
|
enabled={!disabled}
|
|
38
|
-
onCheckedChange={onValueChange ? toggle :
|
|
41
|
+
onCheckedChange={onValueChange ? toggle : NOOP}
|
|
39
42
|
value={value}
|
|
40
43
|
/>
|
|
41
44
|
)
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/** SwiftUI `Toggle` / Compose `Switch`, tinted `fill.accent.primary`. */
|
|
3
4
|
export type SwitchProps = {
|
|
5
|
+
/** Stops the user flipping it, and dims it. */
|
|
4
6
|
disabled?: boolean
|
|
7
|
+
/**
|
|
8
|
+
* Shown beside the switch. On Android it makes a full-width row — label at the start, switch at the end — that
|
|
9
|
+
* toggles wherever it is tapped.
|
|
10
|
+
*/
|
|
5
11
|
label?: string
|
|
12
|
+
/** Called with the new value when the user flips it. On Android a flip plays `toggleOn` / `toggleOff`. */
|
|
6
13
|
onValueChange?: (value: boolean) => void
|
|
14
|
+
/** Whether it is on. Controlled: pass back what `onValueChange` reports. */
|
|
7
15
|
value: boolean
|
|
8
16
|
}
|
|
9
17
|
|
|
@@ -7,14 +7,26 @@ export type TextDecoration = 'none' | 'strikethrough' | 'underline'
|
|
|
7
7
|
|
|
8
8
|
export type TextTransform = 'lowercase' | 'uppercase'
|
|
9
9
|
|
|
10
|
+
/** SwiftUI `Text` / Compose `Text` in a theme typography variant — a native atom; outside a host, use `RnText`. */
|
|
10
11
|
export type TextProps = {
|
|
12
|
+
/**
|
|
13
|
+
* How its lines align. iOS reads `left` and `right` as leading and trailing, so they flip in a right-to-left
|
|
14
|
+
* layout; Android keeps them as they are.
|
|
15
|
+
*/
|
|
11
16
|
align?: TextAlign
|
|
17
|
+
/** The text. */
|
|
12
18
|
children?: ReactNode
|
|
19
|
+
/** The text's colour. `content.primary` by default. */
|
|
13
20
|
color?: ColorToken
|
|
21
|
+
/** An underline or a strikethrough. */
|
|
14
22
|
decoration?: TextDecoration
|
|
23
|
+
/** The most lines it wraps to. iOS truncates the last with an ellipsis; Android clips it. */
|
|
15
24
|
numberOfLines?: number
|
|
25
|
+
/** Test identifier, forwarded to the native view. */
|
|
16
26
|
testID?: string
|
|
27
|
+
/** Upper- or lower-cases the text. Android applies it only when `children` is a plain string. */
|
|
17
28
|
transform?: TextTransform
|
|
29
|
+
/** The typography variant. `body` by default. */
|
|
18
30
|
variant?: TextVariant
|
|
19
31
|
}
|
|
20
32
|
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* An uncontrolled text field with an optional label above it — SwiftUI `TextField` (`SecureField` when `secure`) /
|
|
5
|
+
* Compose `OutlinedTextField`.
|
|
6
|
+
*/
|
|
3
7
|
export type TextFieldProps = {
|
|
8
|
+
/** The text it starts with. Read once, on mount — the field is uncontrolled. */
|
|
4
9
|
defaultValue?: string
|
|
10
|
+
/** Stops editing and dims the field. On iOS it outranks `error`. */
|
|
5
11
|
disabled?: boolean
|
|
12
|
+
/** Marks the field invalid: a destructive outline and label. */
|
|
6
13
|
error?: boolean
|
|
14
|
+
/** Shown above the field, in `labelMedium`. */
|
|
7
15
|
label?: string
|
|
16
|
+
/** Wraps the text and grows the field to fit it. iOS ignores it when `secure`. */
|
|
8
17
|
multiline?: boolean
|
|
18
|
+
/** Called with the whole text after every change. */
|
|
9
19
|
onChangeText?: (text: string) => void
|
|
20
|
+
/** Masks the text, for a password. */
|
|
10
21
|
secure?: boolean
|
|
22
|
+
/** iOS: forwarded to the native field. Android ignores it. */
|
|
11
23
|
testID?: string
|
|
12
24
|
}
|
|
13
25
|
|
|
@@ -4,11 +4,20 @@ import type {ReactNode} from 'react'
|
|
|
4
4
|
|
|
5
5
|
export type VStackAlign = 'center' | 'end' | 'start'
|
|
6
6
|
|
|
7
|
+
/** Stacks its children top to bottom — SwiftUI `VStack` / Compose `Column`. */
|
|
7
8
|
export type VStackProps = ResponsiveSx & {
|
|
9
|
+
/** The children's horizontal alignment. `start` by default. */
|
|
8
10
|
align?: VStackAlign
|
|
11
|
+
/** Laid out top to bottom, `spacing` apart. */
|
|
9
12
|
children?: ReactNode
|
|
13
|
+
/**
|
|
14
|
+
* Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a `clickable` whose ripple
|
|
15
|
+
* fills the stack's shape.
|
|
16
|
+
*/
|
|
10
17
|
onPress?: () => void
|
|
18
|
+
/** The space between children. */
|
|
11
19
|
spacing?: SpaceSize
|
|
20
|
+
/** Test identifier, forwarded to the native view. */
|
|
12
21
|
testID?: string
|
|
13
22
|
}
|
|
14
23
|
|
|
@@ -3,10 +3,18 @@ import type {ReactNode} from 'react'
|
|
|
3
3
|
|
|
4
4
|
export type ZStackAlign = 'bottom' | 'center' | 'top'
|
|
5
5
|
|
|
6
|
+
/** Layers its children on one another — SwiftUI `ZStack` / Compose `Box`. */
|
|
6
7
|
export type ZStackProps = ResponsiveSx & {
|
|
8
|
+
/** Where the children sit vertically; they are always centred horizontally. `center` by default. */
|
|
7
9
|
align?: ZStackAlign
|
|
10
|
+
/** Drawn in order, the last on top. */
|
|
8
11
|
children?: ReactNode
|
|
12
|
+
/**
|
|
13
|
+
* Makes the whole stack pressable. iOS adds a tap gesture with no press feedback; Android a `clickable` whose ripple
|
|
14
|
+
* fills the stack's shape.
|
|
15
|
+
*/
|
|
9
16
|
onPress?: () => void
|
|
17
|
+
/** Test identifier, forwarded to the native view. */
|
|
10
18
|
testID?: string
|
|
11
19
|
}
|
|
12
20
|
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A row that shows and hides its content: SwiftUI's `DisclosureGroup` on iOS; on Android a pressable row with a
|
|
5
|
+
* chevron over an animated reveal. A native atom — it renders inside `<Screen>` or `<Island>`.
|
|
6
|
+
*/
|
|
3
7
|
export type CollapsibleProps = {
|
|
8
|
+
/** Shown while `expanded`. */
|
|
4
9
|
children: ReactNode
|
|
10
|
+
/** Whether the content is shown. Update it from `onExpandedChange`. */
|
|
5
11
|
expanded: boolean
|
|
12
|
+
/** The row's text. */
|
|
6
13
|
label: string
|
|
14
|
+
/** The user pressed the row; it passes the state the row asks for. */
|
|
7
15
|
onExpandedChange: (expanded: boolean) => void
|
|
8
16
|
}
|
|
9
17
|
|
|
@@ -6,10 +6,15 @@ import type {IconName} from '../../atoms/icon'
|
|
|
6
6
|
* `action` takes a `Button` so the state can offer a way out.
|
|
7
7
|
*/
|
|
8
8
|
export type EmptyStateProps = {
|
|
9
|
+
/** Under the text — a `Button`, say. */
|
|
9
10
|
action?: ReactNode
|
|
11
|
+
/** A second line under the title, in the secondary colour. */
|
|
10
12
|
description?: string
|
|
13
|
+
/** One of the app's icons, large and muted above the title. */
|
|
11
14
|
icon?: IconName
|
|
15
|
+
/** Test identifier, forwarded to the native view. */
|
|
12
16
|
testID?: string
|
|
17
|
+
/** The headline. */
|
|
13
18
|
title: string
|
|
14
19
|
}
|
|
15
20
|
|
|
@@ -8,11 +8,17 @@ import type {IconName} from '../../atoms/icon'
|
|
|
8
8
|
* header. For a full tappable row with a subtitle and chevron, use `ListItem`.
|
|
9
9
|
*/
|
|
10
10
|
export type LabelProps = {
|
|
11
|
+
/** Colours the icon and the title alike. `content.primary` by default. */
|
|
11
12
|
color?: ColorToken
|
|
13
|
+
/** One of the app's icons, before the title. */
|
|
12
14
|
icon: IconName
|
|
15
|
+
/** The icon's size. `s20` by default. */
|
|
13
16
|
iconSize?: SpaceSize
|
|
17
|
+
/** Test identifier, forwarded to the native view. */
|
|
14
18
|
testID?: string
|
|
19
|
+
/** The text beside the icon. */
|
|
15
20
|
title: string
|
|
21
|
+
/** The title's text style. `body` by default. */
|
|
16
22
|
variant?: TextVariant
|
|
17
23
|
}
|
|
18
24
|
|
|
@@ -7,13 +7,19 @@ import type {IconName} from '../../atoms/icon'
|
|
|
7
7
|
* Pass `children` instead of `value` when the trailing side is a control rather than text.
|
|
8
8
|
*/
|
|
9
9
|
export type LabeledContentProps = {
|
|
10
|
+
/** The trailing side when it is a control, in place of `value`. */
|
|
10
11
|
children?: ReactNode
|
|
12
|
+
/** One of the app's icons, before the label, in the secondary colour. */
|
|
11
13
|
icon?: IconName
|
|
14
|
+
/** The leading text. */
|
|
12
15
|
label: string
|
|
16
|
+
/** Makes the row pressable and adds a chevron on the trailing edge. */
|
|
13
17
|
onPress?: () => void
|
|
14
18
|
/** Horizontal padding inside the row — inside its press area too, so Android's ripple reaches the card's edges. */
|
|
15
19
|
px?: SpaceSize
|
|
20
|
+
/** Test identifier, forwarded to the native view. */
|
|
16
21
|
testID?: string
|
|
22
|
+
/** The trailing text, in the secondary colour. Ignored when `children` is given. */
|
|
17
23
|
value?: string
|
|
18
24
|
}
|
|
19
25
|
|
|
@@ -5,11 +5,17 @@ import type {IconName} from '../../atoms/icon'
|
|
|
5
5
|
|
|
6
6
|
/** Opens an external URL in the platform browser or the app that claims the scheme. */
|
|
7
7
|
export type LinkProps = {
|
|
8
|
+
/** Colours the label and the icon. `content.accent` by default. */
|
|
8
9
|
color?: ColorToken
|
|
10
|
+
/** One of the app's icons, before the label. */
|
|
9
11
|
icon?: IconName
|
|
12
|
+
/** The link's text. */
|
|
10
13
|
label: string
|
|
14
|
+
/** Test identifier, forwarded to the native view. */
|
|
11
15
|
testID?: string
|
|
16
|
+
/** Opened through React Native's `Linking` on press. A URL nothing can open fails silently. */
|
|
12
17
|
url: string
|
|
18
|
+
/** The label's text style. `body` by default. */
|
|
13
19
|
variant?: TextVariant
|
|
14
20
|
}
|
|
15
21
|
|
|
@@ -3,16 +3,25 @@ import type {ReactNode} from 'react'
|
|
|
3
3
|
|
|
4
4
|
import type {IconName} from '../../atoms/icon'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* A row with an optional icon, a title and subtitle, and a chevron when it can be pressed. A native atom — it renders
|
|
8
|
+
* inside `<Screen>` or `<Island>`; `RnListItem` is the same row without a host.
|
|
9
|
+
*/
|
|
6
10
|
export type ListItemProps = {
|
|
11
|
+
/** One of the app's icons, before the title, in the secondary colour. */
|
|
7
12
|
icon?: IconName
|
|
13
|
+
/** Makes the row pressable and adds a chevron on the trailing edge. */
|
|
8
14
|
onPress?: () => void
|
|
9
15
|
/**
|
|
10
16
|
* Horizontal padding inside the row — inside its press area too, so Android's ripple reaches the card's edges. For
|
|
11
17
|
* rows in a card of your own; a `List` insets its rows by itself.
|
|
12
18
|
*/
|
|
13
19
|
px?: SpaceSize
|
|
20
|
+
/** A second line under the title, smaller and in the secondary colour. */
|
|
14
21
|
subtitle?: string
|
|
22
|
+
/** Test identifier, forwarded to the row's view. */
|
|
15
23
|
testID?: string
|
|
24
|
+
/** The row's main text. */
|
|
16
25
|
title: string
|
|
17
26
|
}
|
|
18
27
|
|
|
@@ -3,6 +3,7 @@ import type {ReactNode, Ref} from 'react'
|
|
|
3
3
|
import type {IconName} from '../../atoms/icon'
|
|
4
4
|
|
|
5
5
|
type NavigationBarItemBase = {
|
|
6
|
+
/** Called when the item is pressed. */
|
|
6
7
|
onPress: () => void
|
|
7
8
|
/**
|
|
8
9
|
* iOS 26: neighbouring items on one side share a glass capsule; this gives the item its own. A close next to
|
|
@@ -29,10 +30,15 @@ export type NavigationBarSearchRef = {
|
|
|
29
30
|
|
|
30
31
|
/** A search field in place of the title — iOS only for now; Android keeps the title. */
|
|
31
32
|
export type NavigationBarSearch = {
|
|
33
|
+
/** Every edit of the field's text. */
|
|
32
34
|
onChangeText: (text: string) => void
|
|
35
|
+
/** The field gained or lost focus. */
|
|
33
36
|
onFocusChange?: (focused: boolean) => void
|
|
37
|
+
/** Shown while the field is empty. */
|
|
34
38
|
placeholder: string
|
|
39
|
+
/** Imperative `clear`. */
|
|
35
40
|
ref?: Ref<NavigationBarSearchRef>
|
|
41
|
+
/** Test identifier, forwarded to the native search field. */
|
|
36
42
|
testID?: string
|
|
37
43
|
}
|
|
38
44
|
|
|
@@ -52,7 +58,9 @@ export type NavigationBarProps = {
|
|
|
52
58
|
leadingItems?: NavigationBarItem[]
|
|
53
59
|
/** Replaces the title with a search field (iOS). */
|
|
54
60
|
search?: NavigationBarSearch
|
|
61
|
+
/** Test identifier, forwarded to the native bar. iOS only — Android ignores it. */
|
|
55
62
|
testID?: string
|
|
63
|
+
/** The bar's title. */
|
|
56
64
|
title?: string
|
|
57
65
|
/** `center` by default — iOS's own; `leading` is Material's top app bar. */
|
|
58
66
|
titleAlignment?: NavigationBarTitleAlignment
|
|
@@ -11,6 +11,7 @@ import type {ReactNode} from 'react'
|
|
|
11
11
|
* ceremony would buy nothing.
|
|
12
12
|
*/
|
|
13
13
|
export type PagerProps = {
|
|
14
|
+
/** The pages, one per child, in order. */
|
|
14
15
|
children?: ReactNode
|
|
15
16
|
/**
|
|
16
17
|
* Page dots. iOS draws SwiftUI's own, over the bottom edge; Compose has no built-in indicator, so
|
|
@@ -28,6 +29,7 @@ export type PagerProps = {
|
|
|
28
29
|
* content down with the swipe, so iOS always stays swipeable.
|
|
29
30
|
*/
|
|
30
31
|
scrollEnabled?: boolean
|
|
32
|
+
/** Test identifier, forwarded to the native view. */
|
|
31
33
|
testID?: string
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import type {ReactNode} from 'react'
|
|
2
2
|
|
|
3
|
+
/** One choice of a `RadioGroup`. */
|
|
3
4
|
export type RadioOption = {
|
|
5
|
+
/** The option's text. */
|
|
4
6
|
label: string
|
|
7
|
+
/** Identifies the option to `value` and `onValueChange`, and keys its row — keep it unique. */
|
|
5
8
|
value: string
|
|
6
9
|
}
|
|
7
10
|
|
|
11
|
+
/**
|
|
12
|
+
* A single choice from a list: rows with a checkmark on the selected one on iOS, Material radio buttons on Android. A
|
|
13
|
+
* native atom — it renders inside `<Screen>` or `<Island>`.
|
|
14
|
+
*/
|
|
8
15
|
export type RadioGroupProps = {
|
|
16
|
+
/** The user pressed an option; it passes that option's `value`. */
|
|
9
17
|
onValueChange?: (value: string) => void
|
|
18
|
+
/** The choices, top to bottom. */
|
|
10
19
|
options: RadioOption[]
|
|
20
|
+
/** The selected option's `value`. Update it from `onValueChange`. */
|
|
11
21
|
value: string
|
|
12
22
|
}
|
|
13
23
|
|
|
@@ -4,7 +4,7 @@ import type {ListItemProps} from '../list-item'
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* `ListItem`'s row in the React Native tier — plain views, no host. For lists long enough that a native host per row
|
|
7
|
-
* would cost too much to mount (a navigation list,
|
|
7
|
+
* would cost too much to mount (a navigation list, an `RnFlatList` of rows), with the platform's own press feedback: a
|
|
8
8
|
* ripple across the whole row on Android, a highlight on iOS. In a rounded card, give the card `overflow="hidden"`:
|
|
9
9
|
* Android draws the ripple as the row's foreground, which only a parent's clip keeps inside rounded corners.
|
|
10
10
|
*/
|