@expo/ui 55.0.2 → 55.0.3
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 +31 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/ui/AnimatedVisibilityView.kt +130 -0
- package/android/src/main/java/expo/modules/ui/CardView.kt +138 -34
- package/android/src/main/java/expo/modules/ui/CheckboxView.kt +98 -0
- package/android/src/main/java/expo/modules/ui/ChipView.kt +267 -142
- package/android/src/main/java/expo/modules/ui/DatePickerView.kt +258 -70
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +204 -57
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +44 -1
- package/android/src/main/java/expo/modules/ui/ProgressView.kt +189 -89
- package/android/src/main/java/expo/modules/ui/RadioButtonView.kt +3 -7
- package/android/src/main/java/expo/modules/ui/SegmentedButtonView.kt +115 -0
- package/android/src/main/java/expo/modules/ui/SegmentedControlView.kt +35 -0
- package/android/src/main/java/expo/modules/ui/SliderView.kt +70 -12
- package/android/src/main/java/expo/modules/ui/SwitchView.kt +53 -161
- package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +95 -57
- package/android/src/main/java/expo/modules/ui/button/Button.kt +117 -158
- package/android/src/main/java/expo/modules/ui/button/FloatingActionButton.kt +92 -0
- package/android/src/main/java/expo/modules/ui/button/IconButton.kt +73 -86
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenu.kt +39 -0
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuItem.kt +70 -0
- package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +18 -0
- package/build/jetpack-compose/AnimatedVisibility/index.d.ts +134 -0
- package/build/jetpack-compose/AnimatedVisibility/index.d.ts.map +1 -0
- package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts +3 -0
- package/build/jetpack-compose/AnimatedVisibility/symbols.d.ts.map +1 -0
- package/build/jetpack-compose/Button/index.d.ts +65 -51
- package/build/jetpack-compose/Button/index.d.ts.map +1 -1
- package/build/jetpack-compose/Card/index.d.ts +72 -14
- package/build/jetpack-compose/Card/index.d.ts.map +1 -1
- package/build/jetpack-compose/Checkbox/index.d.ts +73 -0
- package/build/jetpack-compose/Checkbox/index.d.ts.map +1 -0
- package/build/jetpack-compose/Chip/index.d.ts +247 -27
- package/build/jetpack-compose/Chip/index.d.ts.map +1 -1
- package/build/jetpack-compose/DatePicker/index.d.ts +38 -3
- package/build/jetpack-compose/DatePicker/index.d.ts.map +1 -1
- package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts +70 -0
- package/build/jetpack-compose/DropdownMenu/DropdownMenuItem.d.ts.map +1 -0
- package/build/jetpack-compose/DropdownMenu/index.d.ts +68 -0
- package/build/jetpack-compose/DropdownMenu/index.d.ts.map +1 -0
- package/build/jetpack-compose/FloatingActionButton/index.d.ts +150 -0
- package/build/jetpack-compose/FloatingActionButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts +2 -2
- package/build/jetpack-compose/HorizontalFloatingToolbar/index.d.ts.map +1 -1
- package/build/jetpack-compose/IconButton/index.d.ts +45 -29
- package/build/jetpack-compose/IconButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts +17 -0
- package/build/jetpack-compose/MultiChoiceSegmentedButtonRow/index.d.ts.map +1 -0
- package/build/jetpack-compose/Progress/index.d.ts +78 -35
- package/build/jetpack-compose/Progress/index.d.ts.map +1 -1
- package/build/jetpack-compose/RadioButton/index.d.ts +2 -2
- package/build/jetpack-compose/RadioButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/SegmentedButton/index.d.ts +74 -0
- package/build/jetpack-compose/SegmentedButton/index.d.ts.map +1 -0
- package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts +17 -0
- package/build/jetpack-compose/SingleChoiceSegmentedButtonRow/index.d.ts.map +1 -0
- package/build/jetpack-compose/Slider/index.d.ts +34 -10
- package/build/jetpack-compose/Slider/index.d.ts.map +1 -1
- package/build/jetpack-compose/Switch/index.d.ts +10 -50
- package/build/jetpack-compose/Switch/index.d.ts.map +1 -1
- package/build/jetpack-compose/ToggleButton/index.d.ts +60 -32
- package/build/jetpack-compose/ToggleButton/index.d.ts.map +1 -1
- package/build/jetpack-compose/index.d.ts +5 -4
- package/build/jetpack-compose/index.d.ts.map +1 -1
- package/build/jetpack-compose/modifiers/index.d.ts +18 -1
- package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
- package/build/swift-ui/ProgressView/index.d.ts +1 -5
- package/build/swift-ui/ProgressView/index.d.ts.map +1 -1
- package/build/swift-ui/Stepper/index.d.ts +3 -3
- package/build/swift-ui/Stepper/index.d.ts.map +1 -1
- package/build/swift-ui/Text/index.d.ts +33 -1
- package/build/swift-ui/Text/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +22 -1
- package/build/swift-ui/modifiers/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/shapes/index.d.ts +2 -2
- package/build/swift-ui/types.d.ts +7 -0
- package/build/swift-ui/types.d.ts.map +1 -1
- package/expo-module.config.json +1 -1
- package/ios/BottomSheetView.swift +1 -6
- package/ios/ClosedRangeDateRecord.swift +10 -0
- package/ios/ColorPickerView.swift +9 -8
- package/ios/ConfirmationDialog/ConfirmationDialog.swift +4 -6
- package/ios/DatePickerView.swift +7 -5
- package/ios/DisclosureGroupView.swift +5 -7
- package/ios/ListView.swift +6 -14
- package/ios/Modifiers/DefaultScrollAnchorForRoleModifier.swift +32 -0
- package/ios/Modifiers/DefaultScrollAnchorModifier.swift +16 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +8 -0
- package/ios/Picker/PickerView.swift +6 -10
- package/ios/Popover/PopoverView.swift +3 -5
- package/ios/ProgressView.swift +0 -5
- package/ios/SectionView.swift +3 -5
- package/ios/SliderView.swift +8 -6
- package/ios/StepperView.swift +12 -16
- package/ios/TextView.swift +37 -1
- package/ios/Toggle/ToggleView.swift +5 -7
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.module → 55.0.3/expo.modules.ui-55.0.3.module} +22 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{55.0.2/expo.modules.ui-55.0.2.pom → 55.0.3/expo.modules.ui-55.0.3.pom} +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.3/expo.modules.ui-55.0.3.pom.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml +4 -4
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.md5 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha1 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha256 +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/maven-metadata.xml.sha512 +1 -1
- package/package.json +5 -2
- package/src/jetpack-compose/AnimatedVisibility/index.tsx +206 -0
- package/src/jetpack-compose/AnimatedVisibility/symbols.ts +8 -0
- package/src/jetpack-compose/Button/index.tsx +69 -92
- package/src/jetpack-compose/Card/index.tsx +105 -29
- package/src/jetpack-compose/Checkbox/index.tsx +126 -0
- package/src/jetpack-compose/Chip/index.tsx +391 -51
- package/src/jetpack-compose/DatePicker/index.tsx +112 -7
- package/src/jetpack-compose/DropdownMenu/DropdownMenuItem.tsx +126 -0
- package/src/jetpack-compose/DropdownMenu/index.tsx +107 -0
- package/src/jetpack-compose/FloatingActionButton/index.tsx +207 -0
- package/src/jetpack-compose/HorizontalFloatingToolbar/index.tsx +4 -2
- package/src/jetpack-compose/IconButton/index.tsx +49 -56
- package/src/jetpack-compose/MultiChoiceSegmentedButtonRow/index.tsx +34 -0
- package/src/jetpack-compose/Progress/index.tsx +120 -62
- package/src/jetpack-compose/RadioButton/index.tsx +8 -9
- package/src/jetpack-compose/SegmentedButton/index.tsx +109 -0
- package/src/jetpack-compose/SingleChoiceSegmentedButtonRow/index.tsx +34 -0
- package/src/jetpack-compose/Slider/index.tsx +76 -29
- package/src/jetpack-compose/Switch/index.tsx +17 -87
- package/src/jetpack-compose/ToggleButton/index.tsx +67 -43
- package/src/jetpack-compose/index.ts +5 -4
- package/src/jetpack-compose/modifiers/index.ts +26 -2
- package/src/swift-ui/ProgressView/index.tsx +1 -3
- package/src/swift-ui/Stepper/index.tsx +7 -7
- package/src/swift-ui/Text/index.tsx +66 -2
- package/src/swift-ui/modifiers/index.ts +40 -0
- package/src/swift-ui/types.ts +5 -0
- package/android/src/main/java/expo/modules/ui/FilterChipView.kt +0 -59
- package/android/src/main/java/expo/modules/ui/PickerView.kt +0 -161
- package/android/src/main/java/expo/modules/ui/TextButtonView.kt +0 -33
- package/android/src/main/java/expo/modules/ui/menu/ContextMenu.kt +0 -183
- package/android/src/main/java/expo/modules/ui/menu/ContextMenuRecords.kt +0 -64
- package/build/jetpack-compose/Button/types.d.ts +0 -5
- package/build/jetpack-compose/Button/types.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/Submenu.d.ts +0 -17
- package/build/jetpack-compose/ContextMenu/Submenu.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/index.d.ts +0 -65
- package/build/jetpack-compose/ContextMenu/index.d.ts.map +0 -1
- package/build/jetpack-compose/ContextMenu/utils.d.ts +0 -24
- package/build/jetpack-compose/ContextMenu/utils.d.ts.map +0 -1
- package/build/jetpack-compose/FilterChip/index.d.ts +0 -49
- package/build/jetpack-compose/FilterChip/index.d.ts.map +0 -1
- package/build/jetpack-compose/Picker/index.d.ts +0 -62
- package/build/jetpack-compose/Picker/index.d.ts.map +0 -1
- package/build/jetpack-compose/TextButton/index.d.ts +0 -29
- package/build/jetpack-compose/TextButton/index.d.ts.map +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.2/expo.modules.ui-55.0.2.pom.sha512 +0 -1
- package/src/jetpack-compose/Button/types.ts +0 -57
- package/src/jetpack-compose/ContextMenu/Submenu.tsx +0 -21
- package/src/jetpack-compose/ContextMenu/index.tsx +0 -149
- package/src/jetpack-compose/ContextMenu/utils.ts +0 -144
- package/src/jetpack-compose/FilterChip/index.tsx +0 -89
- package/src/jetpack-compose/Picker/index.tsx +0 -90
- package/src/jetpack-compose/TextButton/index.tsx +0 -55
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
2
|
import { NativeSyntheticEvent, type ColorValue } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { type ModifierConfig } from '../../types';
|
|
5
5
|
import { ExpoUIModule } from '../ExpoUIModule';
|
|
6
6
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
7
7
|
|
|
8
|
-
// @docsMissing
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* Colors for switch core elements.
|
|
11
10
|
*/
|
|
12
|
-
type
|
|
11
|
+
export type SwitchColors = {
|
|
13
12
|
checkedThumbColor?: ColorValue;
|
|
14
13
|
checkedTrackColor?: ColorValue;
|
|
15
14
|
checkedBorderColor?: ColorValue;
|
|
@@ -28,89 +27,38 @@ type SwitchElementColors = {
|
|
|
28
27
|
disabledUncheckedIconColor?: ColorValue;
|
|
29
28
|
};
|
|
30
29
|
|
|
31
|
-
// @docsMissing
|
|
32
|
-
/**
|
|
33
|
-
* Only for checkbox.
|
|
34
|
-
*/
|
|
35
|
-
type CheckboxElementColors = {
|
|
36
|
-
checkedColor?: ColorValue;
|
|
37
|
-
disabledCheckedColor?: ColorValue;
|
|
38
|
-
uncheckedColor?: ColorValue;
|
|
39
|
-
disabledUncheckedColor?: ColorValue;
|
|
40
|
-
checkmarkColor?: ColorValue;
|
|
41
|
-
disabledIndeterminateColor?: ColorValue;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
30
|
export type SwitchProps = {
|
|
45
31
|
/**
|
|
46
32
|
* Indicates whether the switch is checked.
|
|
47
33
|
*/
|
|
48
34
|
value: boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Label for the switch.
|
|
51
|
-
*
|
|
52
|
-
* > On Android, the label has an effect only when the `Switch` is used inside a `ContextMenu`.
|
|
53
|
-
*/
|
|
54
|
-
label?: string;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Type of the switch component. Can be `'checkbox'`, `'switch'`, or `'button'`.
|
|
58
|
-
* @default 'switch'
|
|
59
|
-
*/
|
|
60
|
-
variant?: 'checkbox' | 'switch' | 'button';
|
|
61
35
|
/**
|
|
62
36
|
* Whether the switch is enabled.
|
|
63
37
|
* @default true
|
|
64
|
-
* @platform android
|
|
65
38
|
*/
|
|
66
39
|
enabled?: boolean;
|
|
67
40
|
/**
|
|
68
41
|
* Callback function that is called when the checked state changes.
|
|
69
42
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
43
|
+
onCheckedChange?: (value: boolean) => void;
|
|
72
44
|
/**
|
|
73
|
-
*
|
|
45
|
+
* Colors for switch core elements.
|
|
74
46
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
47
|
+
colors?: SwitchColors;
|
|
77
48
|
/**
|
|
78
49
|
* Modifiers for the component.
|
|
79
50
|
*/
|
|
80
|
-
modifiers?:
|
|
81
|
-
|
|
51
|
+
modifiers?: ModifierConfig[];
|
|
82
52
|
/**
|
|
83
53
|
* Children containing ThumbContent slot.
|
|
84
54
|
* @platform android
|
|
85
55
|
*/
|
|
86
56
|
children?: React.ReactNode;
|
|
87
|
-
} & (SwitchSwitchVariantProps | SwitchCheckboxVariantProps | SwitchButtonVariantProps);
|
|
88
|
-
|
|
89
|
-
export type SwitchSwitchVariantProps = {
|
|
90
|
-
variant?: 'switch';
|
|
91
|
-
/**
|
|
92
|
-
* Colors for switch's core elements.
|
|
93
|
-
* @platform android
|
|
94
|
-
*/
|
|
95
|
-
elementColors?: SwitchElementColors;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export type SwitchCheckboxVariantProps = {
|
|
99
|
-
variant: 'checkbox';
|
|
100
|
-
/**
|
|
101
|
-
* Colors for checkbox core elements.
|
|
102
|
-
* @platform android
|
|
103
|
-
*/
|
|
104
|
-
elementColors?: CheckboxElementColors;
|
|
105
57
|
};
|
|
106
58
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
type NativeSwitchProps = Omit<SwitchProps, 'onValueChange'> & {
|
|
113
|
-
onValueChange: (event: NativeSyntheticEvent<{ value: boolean }>) => void;
|
|
59
|
+
type NativeSwitchProps = Omit<SwitchProps, 'onCheckedChange' | 'children'> & {
|
|
60
|
+
children?: React.ReactNode;
|
|
61
|
+
onCheckedChange: (event: NativeSyntheticEvent<{ value: boolean }>) => void;
|
|
114
62
|
};
|
|
115
63
|
|
|
116
64
|
type NativeSlotViewProps = {
|
|
@@ -140,39 +88,21 @@ export function SwitchThumbContent(props: ThumbContentProps) {
|
|
|
140
88
|
return <SlotNativeView slotName="thumbContent">{props.children}</SlotNativeView>;
|
|
141
89
|
}
|
|
142
90
|
|
|
143
|
-
function getElementColors(props: SwitchProps) {
|
|
144
|
-
if (props.variant === 'button') {
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
if (!props.elementColors) {
|
|
148
|
-
if (props.variant === 'switch') {
|
|
149
|
-
return {
|
|
150
|
-
checkedTrackColor: props.color,
|
|
151
|
-
};
|
|
152
|
-
} else {
|
|
153
|
-
return {
|
|
154
|
-
checkedColor: props.color,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
return props.elementColors;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
91
|
function transformSwitchProps(props: SwitchProps): Omit<NativeSwitchProps, 'children'> {
|
|
162
|
-
const { modifiers, children, ...restProps } = props;
|
|
92
|
+
const { modifiers, children, onCheckedChange, ...restProps } = props;
|
|
163
93
|
return {
|
|
164
94
|
modifiers,
|
|
165
95
|
...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
|
|
166
96
|
...restProps,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
color: props.color,
|
|
170
|
-
onValueChange: ({ nativeEvent: { value } }) => {
|
|
171
|
-
props?.onValueChange?.(value);
|
|
97
|
+
onCheckedChange: ({ nativeEvent: { value } }) => {
|
|
98
|
+
onCheckedChange?.(value);
|
|
172
99
|
},
|
|
173
|
-
}
|
|
100
|
+
};
|
|
174
101
|
}
|
|
175
102
|
|
|
103
|
+
/**
|
|
104
|
+
* A switch component.
|
|
105
|
+
*/
|
|
176
106
|
function SwitchComponent(props: SwitchProps) {
|
|
177
107
|
return <SwitchNativeView {...transformSwitchProps(props)}>{props.children}</SwitchNativeView>;
|
|
178
108
|
}
|
|
@@ -1,83 +1,107 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
2
|
import { type ColorValue } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import type { ModifierConfig, ViewEvent } from '../../types';
|
|
5
5
|
import { ExpoUIModule } from '../ExpoUIModule';
|
|
6
6
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Colors for toggle button elements.
|
|
10
|
+
*/
|
|
11
|
+
export type ToggleButtonColors = {
|
|
12
|
+
containerColor?: ColorValue;
|
|
13
|
+
contentColor?: ColorValue;
|
|
14
|
+
checkedContainerColor?: ColorValue;
|
|
15
|
+
checkedContentColor?: ColorValue;
|
|
16
|
+
disabledContainerColor?: ColorValue;
|
|
17
|
+
disabledContentColor?: ColorValue;
|
|
18
|
+
};
|
|
19
|
+
|
|
8
20
|
export type ToggleButtonProps = {
|
|
9
21
|
/**
|
|
10
22
|
* Whether the toggle button is checked.
|
|
11
23
|
*/
|
|
12
24
|
checked: boolean;
|
|
13
25
|
/**
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
16
|
-
text?: string;
|
|
17
|
-
/**
|
|
18
|
-
* The variant of the toggle button.
|
|
19
|
-
* - `'default'` - Material 3 ToggleButton
|
|
20
|
-
* - `'icon'` - Icon toggle button
|
|
21
|
-
* - `'filledIcon'` - Filled icon toggle button
|
|
22
|
-
* - `'outlinedIcon'` - Outlined icon toggle button
|
|
23
|
-
* @default 'default'
|
|
24
|
-
*/
|
|
25
|
-
variant?: 'default' | 'icon' | 'filledIcon' | 'outlinedIcon';
|
|
26
|
-
/**
|
|
27
|
-
* The color of the toggle button when checked.
|
|
26
|
+
* Callback that is called when the checked state changes.
|
|
28
27
|
*/
|
|
29
|
-
|
|
28
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
30
29
|
/**
|
|
31
|
-
* Whether the button is
|
|
30
|
+
* Whether the button is enabled for user interaction.
|
|
31
|
+
* @default true
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
enabled?: boolean;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Colors for toggle button elements.
|
|
36
36
|
*/
|
|
37
|
-
|
|
37
|
+
colors?: ToggleButtonColors;
|
|
38
38
|
/**
|
|
39
39
|
* Modifiers for the component.
|
|
40
40
|
*/
|
|
41
|
-
modifiers?:
|
|
42
|
-
|
|
41
|
+
modifiers?: ModifierConfig[];
|
|
43
42
|
/**
|
|
44
|
-
*
|
|
43
|
+
* Content to display inside the toggle button.
|
|
45
44
|
*/
|
|
46
|
-
children
|
|
45
|
+
children: React.ReactNode;
|
|
47
46
|
};
|
|
48
47
|
|
|
49
|
-
type NativeToggleButtonProps = Omit<ToggleButtonProps, 'onCheckedChange'> &
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const ToggleButtonNativeView: React.ComponentType<NativeToggleButtonProps> = requireNativeView(
|
|
53
|
-
'ExpoUI',
|
|
54
|
-
'ToggleButtonView'
|
|
55
|
-
);
|
|
48
|
+
type NativeToggleButtonProps = Omit<ToggleButtonProps, 'onCheckedChange' | 'children'> & {
|
|
49
|
+
children?: React.ReactNode;
|
|
50
|
+
} & ViewEvent<'onCheckedChange', { checked: boolean }>;
|
|
56
51
|
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
/**
|
|
53
|
+
* @hidden
|
|
54
|
+
*/
|
|
55
|
+
export function transformToggleButtonProps(
|
|
56
|
+
props: Omit<ToggleButtonProps, 'children'>
|
|
57
|
+
): NativeToggleButtonProps {
|
|
58
|
+
const { onCheckedChange, modifiers, ...restProps } = props;
|
|
59
59
|
return {
|
|
60
60
|
modifiers,
|
|
61
61
|
...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
|
|
62
62
|
...restProps,
|
|
63
|
+
enabled: props.enabled ?? true,
|
|
63
64
|
onCheckedChange: onCheckedChange
|
|
64
65
|
? ({ nativeEvent: { checked } }) => onCheckedChange(checked)
|
|
65
66
|
: undefined,
|
|
66
67
|
};
|
|
67
68
|
}
|
|
69
|
+
|
|
70
|
+
function createToggleButtonComponent(name: string) {
|
|
71
|
+
const NativeView: React.ComponentType<NativeToggleButtonProps> = requireNativeView(
|
|
72
|
+
'ExpoUI',
|
|
73
|
+
name
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
function Component(props: ToggleButtonProps) {
|
|
77
|
+
const { children, ...restProps } = props;
|
|
78
|
+
return <NativeView {...transformToggleButtonProps(restProps)}>{children}</NativeView>;
|
|
79
|
+
}
|
|
80
|
+
Component.displayName = name;
|
|
81
|
+
return Component;
|
|
82
|
+
}
|
|
83
|
+
|
|
68
84
|
/**
|
|
69
85
|
* A toggle button component that can be toggled on and off.
|
|
70
|
-
*
|
|
71
|
-
* When `text` prop is provided, it displays the text.
|
|
72
|
-
* Otherwise, custom children can be passed to render custom content.
|
|
73
86
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
87
|
+
const ToggleButton = Object.assign(createToggleButtonComponent('ToggleButton'), {
|
|
88
|
+
DefaultIconSpacing: ExpoUIModule.ToggleButtonIconSpacing as number,
|
|
89
|
+
DefaultIconSize: ExpoUIModule.ToggleButtonIconSize as number,
|
|
90
|
+
});
|
|
76
91
|
|
|
77
|
-
|
|
78
|
-
|
|
92
|
+
/**
|
|
93
|
+
* An icon toggle button with no background.
|
|
94
|
+
*/
|
|
95
|
+
const IconToggleButton = createToggleButtonComponent('IconToggleButton');
|
|
79
96
|
|
|
80
|
-
|
|
81
|
-
|
|
97
|
+
/**
|
|
98
|
+
* A filled icon toggle button with a solid background.
|
|
99
|
+
*/
|
|
100
|
+
const FilledIconToggleButton = createToggleButtonComponent('FilledIconToggleButton');
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* An outlined icon toggle button with a border and no fill.
|
|
104
|
+
*/
|
|
105
|
+
const OutlinedIconToggleButton = createToggleButtonComponent('OutlinedIconToggleButton');
|
|
82
106
|
|
|
83
|
-
export { ToggleButton };
|
|
107
|
+
export { ToggleButton, IconToggleButton, FilledIconToggleButton, OutlinedIconToggleButton };
|
|
@@ -3,24 +3,23 @@ import './MaterialSymbolsAssetsTransformer.fx';
|
|
|
3
3
|
export * from './AlertDialog';
|
|
4
4
|
export * from './BasicAlertDialog';
|
|
5
5
|
export * from './Card';
|
|
6
|
+
export * from './Checkbox';
|
|
6
7
|
export * from './Chip';
|
|
7
|
-
export * from './FilterChip';
|
|
8
8
|
export * from './Button';
|
|
9
9
|
export * from './Icon';
|
|
10
10
|
export * from './IconButton';
|
|
11
|
-
export * from './
|
|
11
|
+
export * from './DropdownMenu';
|
|
12
12
|
export * from './Divider';
|
|
13
13
|
export * from './Host';
|
|
14
14
|
export * from './LazyColumn';
|
|
15
15
|
export * from './ListItem';
|
|
16
16
|
export * from './RNHostView';
|
|
17
17
|
export * from './DatePicker';
|
|
18
|
-
export * from './
|
|
18
|
+
export * from './SegmentedButton';
|
|
19
19
|
export * from './Progress';
|
|
20
20
|
export * from './Slider';
|
|
21
21
|
export * from './Spacer';
|
|
22
22
|
export * from './Switch';
|
|
23
|
-
export * from './TextButton';
|
|
24
23
|
export * from './TextInput';
|
|
25
24
|
export * from './ToggleButton';
|
|
26
25
|
export * from './Shape';
|
|
@@ -29,11 +28,13 @@ export * from './Carousel';
|
|
|
29
28
|
export * from './SearchBar';
|
|
30
29
|
export * from './DockedSearchBar';
|
|
31
30
|
export * from './HorizontalFloatingToolbar';
|
|
31
|
+
export * from './FloatingActionButton';
|
|
32
32
|
export * from './PullToRefreshBox';
|
|
33
33
|
export * from './RadioButton';
|
|
34
34
|
export * from './Surface';
|
|
35
35
|
export * from './Text';
|
|
36
36
|
|
|
37
|
+
export * from './AnimatedVisibility';
|
|
37
38
|
export * from './Box';
|
|
38
39
|
export * from './Row';
|
|
39
40
|
export * from './Column';
|
|
@@ -262,9 +262,33 @@ export const clickable = (handler: () => void, options?: { indication?: boolean
|
|
|
262
262
|
* Makes the view selectable, like a radio button row.
|
|
263
263
|
* @param selected - Whether the item is currently selected.
|
|
264
264
|
* @param handler - Function to call when the item is clicked.
|
|
265
|
+
* @param role - Optional semantic role for accessibility: 'radioButton', 'checkbox', 'switch', or 'tab'.
|
|
265
266
|
*/
|
|
266
|
-
export const selectable = (
|
|
267
|
-
|
|
267
|
+
export const selectable = (
|
|
268
|
+
selected: boolean,
|
|
269
|
+
handler: () => void,
|
|
270
|
+
role?: 'radioButton' | 'checkbox' | 'switch' | 'tab'
|
|
271
|
+
) => createModifierWithEventListener('selectable', handler, { selected, role });
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Marks a column/row as a selectable group for accessibility.
|
|
275
|
+
* Screen readers will treat the children as a group of selectable items.
|
|
276
|
+
*/
|
|
277
|
+
export const selectableGroup = () => createModifier('selectableGroup');
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Makes the view toggleable with accessibility semantics.
|
|
281
|
+
* Use this to make a row containing a checkbox or switch tappable as a whole.
|
|
282
|
+
* @param value - The current toggle state.
|
|
283
|
+
* @param handler - Function to call when toggled.
|
|
284
|
+
* @param options - Optional configuration.
|
|
285
|
+
* @param options.role - The semantic role for accessibility: `'checkbox'`, `'radioButton'`, `'switch'`, or `'tab'`.
|
|
286
|
+
*/
|
|
287
|
+
export const toggleable = (
|
|
288
|
+
value: boolean,
|
|
289
|
+
handler: () => void,
|
|
290
|
+
options?: { role?: 'checkbox' | 'radioButton' | 'switch' | 'tab' }
|
|
291
|
+
) => createModifierWithEventListener('toggleable', handler, { value, role: options?.role });
|
|
268
292
|
|
|
269
293
|
// =============================================================================
|
|
270
294
|
// Utility Modifiers
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { requireNativeView } from 'expo';
|
|
2
2
|
|
|
3
3
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
4
|
-
import { type CommonViewModifierProps } from '../types';
|
|
5
|
-
|
|
6
|
-
export type ClosedRangeDate = { lower: Date; upper: Date };
|
|
4
|
+
import { type ClosedRangeDate, type CommonViewModifierProps } from '../types';
|
|
7
5
|
|
|
8
6
|
export type ProgressViewProps = {
|
|
9
7
|
/**
|
|
@@ -10,9 +10,9 @@ export type StepperProps = {
|
|
|
10
10
|
*/
|
|
11
11
|
label: string;
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The current value of the stepper.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
value?: number;
|
|
16
16
|
/**
|
|
17
17
|
* The step value for increment/decrement operations.
|
|
18
18
|
*/
|
|
@@ -28,11 +28,11 @@ export type StepperProps = {
|
|
|
28
28
|
/**
|
|
29
29
|
* Called when the stepper value changes.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
onValueChange: (value: number) => void;
|
|
32
32
|
} & CommonViewModifierProps;
|
|
33
33
|
|
|
34
|
-
type NativeStepperProps = Omit<StepperProps, '
|
|
35
|
-
ViewEvent<'
|
|
34
|
+
type NativeStepperProps = Omit<StepperProps, 'onValueChange'> &
|
|
35
|
+
ViewEvent<'onValueChange', { value: number }>;
|
|
36
36
|
|
|
37
37
|
const StepperNativeView: React.ComponentType<NativeStepperProps> = requireNativeView(
|
|
38
38
|
'ExpoUI',
|
|
@@ -45,8 +45,8 @@ function transformStepperProps(props: StepperProps): NativeStepperProps {
|
|
|
45
45
|
modifiers,
|
|
46
46
|
...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
|
|
47
47
|
...restProps,
|
|
48
|
-
|
|
49
|
-
props.
|
|
48
|
+
onValueChange: ({ nativeEvent: { value } }) => {
|
|
49
|
+
props.onValueChange(value);
|
|
50
50
|
},
|
|
51
51
|
};
|
|
52
52
|
}
|
|
@@ -2,7 +2,12 @@ import { requireNativeView } from 'expo';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
5
|
-
import { type CommonViewModifierProps } from '../types';
|
|
5
|
+
import { type ClosedRangeDate, type CommonViewModifierProps } from '../types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The style used to format a date in a SwiftUI `Text` view.
|
|
9
|
+
*/
|
|
10
|
+
export type TextDateStyle = 'timer' | 'relative' | 'offset' | 'date' | 'time';
|
|
6
11
|
|
|
7
12
|
export interface TextProps extends CommonViewModifierProps {
|
|
8
13
|
/**
|
|
@@ -14,12 +19,50 @@ export interface TextProps extends CommonViewModifierProps {
|
|
|
14
19
|
* Enables Markdown formatting for the text content using SwiftUI LocalizedStringKey.
|
|
15
20
|
*/
|
|
16
21
|
markdownEnabled?: boolean;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A date to display using the specified `dateStyle`. The text auto-updates as time passes.
|
|
25
|
+
*/
|
|
26
|
+
date?: Date;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The style used to format the `date` prop.
|
|
30
|
+
* @default 'date'
|
|
31
|
+
*/
|
|
32
|
+
dateStyle?: TextDateStyle;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A time interval to display as a live-updating timer.
|
|
36
|
+
* @platform ios 16.0+
|
|
37
|
+
* @platform tvos 16.0+
|
|
38
|
+
*/
|
|
39
|
+
timerInterval?: ClosedRangeDate;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Whether the timer counts down (`true`) or up (`false`).
|
|
43
|
+
* @default true
|
|
44
|
+
* @platform ios 16.0+
|
|
45
|
+
* @platform tvos 16.0+
|
|
46
|
+
*/
|
|
47
|
+
countsDown?: boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A date at which the timer should appear paused.
|
|
51
|
+
* @platform ios 16.0+
|
|
52
|
+
* @platform tvos 16.0+
|
|
53
|
+
*/
|
|
54
|
+
pauseTime?: Date;
|
|
17
55
|
}
|
|
18
56
|
|
|
19
57
|
type NativeTextProps = CommonViewModifierProps & {
|
|
20
58
|
text?: string;
|
|
21
59
|
children?: React.ReactNode;
|
|
22
60
|
markdownEnabled?: boolean;
|
|
61
|
+
date?: number;
|
|
62
|
+
dateStyle?: TextDateStyle;
|
|
63
|
+
timerInterval?: { lower: number; upper: number };
|
|
64
|
+
countsDown?: boolean;
|
|
65
|
+
pauseTime?: number;
|
|
23
66
|
};
|
|
24
67
|
|
|
25
68
|
const TextNativeView: React.ComponentType<NativeTextProps> = requireNativeView(
|
|
@@ -28,7 +71,28 @@ const TextNativeView: React.ComponentType<NativeTextProps> = requireNativeView(
|
|
|
28
71
|
);
|
|
29
72
|
|
|
30
73
|
export function Text(props: TextProps) {
|
|
31
|
-
const { children, modifiers, ...restProps } = props;
|
|
74
|
+
const { children, modifiers, date, timerInterval, pauseTime, ...restProps } = props;
|
|
75
|
+
|
|
76
|
+
// Date/timer mode: pass converted timestamps to native, ignore children
|
|
77
|
+
if (date != null || timerInterval != null) {
|
|
78
|
+
return (
|
|
79
|
+
<TextNativeView
|
|
80
|
+
modifiers={modifiers}
|
|
81
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
82
|
+
{...restProps}
|
|
83
|
+
date={date ? date.getTime() : undefined}
|
|
84
|
+
timerInterval={
|
|
85
|
+
timerInterval
|
|
86
|
+
? {
|
|
87
|
+
lower: timerInterval.lower.getTime(),
|
|
88
|
+
upper: timerInterval.upper.getTime(),
|
|
89
|
+
}
|
|
90
|
+
: undefined
|
|
91
|
+
}
|
|
92
|
+
pauseTime={pauseTime ? pauseTime.getTime() : undefined}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
32
96
|
|
|
33
97
|
if (children === undefined || children === null) {
|
|
34
98
|
return null;
|
|
@@ -567,6 +567,44 @@ export const scrollDismissesKeyboard = (
|
|
|
567
567
|
export const scrollDisabled = (disabled: boolean = true) =>
|
|
568
568
|
createModifier('scrollDisabled', { disabled });
|
|
569
569
|
|
|
570
|
+
type UnitPointValue =
|
|
571
|
+
| 'zero'
|
|
572
|
+
| 'topLeading'
|
|
573
|
+
| 'top'
|
|
574
|
+
| 'topTrailing'
|
|
575
|
+
| 'leading'
|
|
576
|
+
| 'center'
|
|
577
|
+
| 'trailing'
|
|
578
|
+
| 'bottomLeading'
|
|
579
|
+
| 'bottom'
|
|
580
|
+
| 'bottomTrailing';
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Sets the default anchor point for a scroll view's content.
|
|
584
|
+
* @param anchor - The anchor point for initial scroll position and content size changes, or `null` to reset.
|
|
585
|
+
* @platform ios 17.0+
|
|
586
|
+
* @platform tvos 17.0+
|
|
587
|
+
* @platform macos 14.0+
|
|
588
|
+
* @see Official [SwiftUI documentation](https://developer.apple.com/documentation/swiftui/view/defaultscrollanchor(_:)).
|
|
589
|
+
*/
|
|
590
|
+
export const defaultScrollAnchor = (anchor: UnitPointValue | null) =>
|
|
591
|
+
createModifier('defaultScrollAnchor', { anchor });
|
|
592
|
+
|
|
593
|
+
/**
|
|
594
|
+
* Sets the default anchor point for a scroll view for a specific role.
|
|
595
|
+
* Pass `null` to opt out of a specific role while keeping anchors for other roles.
|
|
596
|
+
* @param anchor - The anchor point, or `null` to opt out of this role.
|
|
597
|
+
* @param role - The scroll anchor role: `'initialOffset'`, `'sizeChanges'`, or `'alignment'`.
|
|
598
|
+
* @platform ios 18.0+
|
|
599
|
+
* @platform tvos 18.0+
|
|
600
|
+
* @platform macos 15.0+
|
|
601
|
+
* @see Official [SwiftUI documentation](https://developer.apple.com/documentation/swiftui/view/defaultscrollanchor(_:for:)).
|
|
602
|
+
*/
|
|
603
|
+
export const defaultScrollAnchorForRole = (
|
|
604
|
+
anchor: UnitPointValue | null,
|
|
605
|
+
role: 'initialOffset' | 'sizeChanges' | 'alignment'
|
|
606
|
+
) => createModifier('defaultScrollAnchorForRole', { anchor, role });
|
|
607
|
+
|
|
570
608
|
/**
|
|
571
609
|
* Disables the move action for a view in a list.
|
|
572
610
|
* Apply to items within a `ForEach` to prevent them from being moved.
|
|
@@ -1097,6 +1135,8 @@ export type BuiltInModifier =
|
|
|
1097
1135
|
| ReturnType<typeof containerRelativeFrame>
|
|
1098
1136
|
| ReturnType<typeof scrollContentBackground>
|
|
1099
1137
|
| ReturnType<typeof scrollDisabled>
|
|
1138
|
+
| ReturnType<typeof defaultScrollAnchor>
|
|
1139
|
+
| ReturnType<typeof defaultScrollAnchorForRole>
|
|
1100
1140
|
| ReturnType<typeof moveDisabled>
|
|
1101
1141
|
| ReturnType<typeof deleteDisabled>
|
|
1102
1142
|
| ReturnType<typeof environment>
|
package/src/swift-ui/types.ts
CHANGED
|
@@ -73,6 +73,11 @@ export interface PaddingProps {
|
|
|
73
73
|
trailing?: number;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
/**
|
|
77
|
+
* A closed date range with lower and upper bounds.
|
|
78
|
+
*/
|
|
79
|
+
export type ClosedRangeDate = { lower: Date; upper: Date };
|
|
80
|
+
|
|
76
81
|
/**
|
|
77
82
|
* Common props that can be applied to any view.
|
|
78
83
|
*/
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
package expo.modules.ui
|
|
2
|
-
|
|
3
|
-
import androidx.compose.material3.FilterChip
|
|
4
|
-
import androidx.compose.material3.FilterChipDefaults
|
|
5
|
-
import androidx.compose.material3.Text
|
|
6
|
-
import androidx.compose.runtime.Composable
|
|
7
|
-
import expo.modules.kotlin.records.Record
|
|
8
|
-
import expo.modules.kotlin.views.ComposableScope
|
|
9
|
-
import expo.modules.kotlin.views.ComposeProps
|
|
10
|
-
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
11
|
-
import java.io.Serializable
|
|
12
|
-
|
|
13
|
-
open class FilterChipPressedEvent : Record, Serializable
|
|
14
|
-
|
|
15
|
-
data class FilterChipProps(
|
|
16
|
-
val selected: Boolean = false,
|
|
17
|
-
val label: String = "",
|
|
18
|
-
val enabled: Boolean = true,
|
|
19
|
-
val modifiers: ModifierList = emptyList()
|
|
20
|
-
) : ComposeProps
|
|
21
|
-
|
|
22
|
-
@Composable
|
|
23
|
-
fun FunctionalComposableScope.FilterChipContent(
|
|
24
|
-
props: FilterChipProps,
|
|
25
|
-
onPress: (FilterChipPressedEvent) -> Unit
|
|
26
|
-
) {
|
|
27
|
-
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
28
|
-
|
|
29
|
-
val leadingIconSlotView = findChildSlotView(view, "leadingIcon")
|
|
30
|
-
val trailingIconSlotView = findChildSlotView(view, "trailingIcon")
|
|
31
|
-
|
|
32
|
-
FilterChip(
|
|
33
|
-
selected = props.selected,
|
|
34
|
-
onClick = { onPress(FilterChipPressedEvent()) },
|
|
35
|
-
label = { Text(props.label) },
|
|
36
|
-
enabled = props.enabled,
|
|
37
|
-
leadingIcon = leadingIconSlotView?.let {
|
|
38
|
-
{
|
|
39
|
-
with(ComposableScope()) {
|
|
40
|
-
with(it) {
|
|
41
|
-
Content()
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
trailingIcon = trailingIconSlotView?.let {
|
|
47
|
-
{
|
|
48
|
-
with(ComposableScope()) {
|
|
49
|
-
with(it) {
|
|
50
|
-
Content()
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
colors = FilterChipDefaults.filterChipColors(),
|
|
56
|
-
border = FilterChipDefaults.filterChipBorder(enabled = props.enabled, selected = props.selected),
|
|
57
|
-
modifier = modifier
|
|
58
|
-
)
|
|
59
|
-
}
|