@expo/ui 55.0.1 → 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 +58 -0
- package/CONTRIBUTING.md +30 -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 +302 -31
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +204 -57
- package/android/src/main/java/expo/modules/ui/HorizontalFloatingToolbarView.kt +21 -8
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +149 -40
- package/android/src/main/java/expo/modules/ui/ProgressView.kt +189 -89
- package/android/src/main/java/expo/modules/ui/RNHostView.kt +204 -50
- 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 +62 -104
- 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 -80
- package/android/src/main/java/expo/modules/ui/convertibles/AnimatableFloat.kt +26 -0
- package/android/src/main/java/expo/modules/ui/convertibles/AnimationSpecParams.kt +93 -0
- package/android/src/main/java/expo/modules/ui/convertibles/GraphicsLayerParams.kt +24 -0
- 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 +137 -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/Spacer/index.d.ts +2 -2
- package/build/jetpack-compose/Switch/index.d.ts +25 -47
- 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/animation.d.ts +44 -0
- package/build/jetpack-compose/modifiers/animation.d.ts.map +1 -0
- package/build/jetpack-compose/modifiers/index.d.ts +68 -4
- package/build/jetpack-compose/modifiers/index.d.ts.map +1 -1
- package/build/swift-ui/AccessoryWidgetBackground/index.d.ts +4 -0
- package/build/swift-ui/AccessoryWidgetBackground/index.d.ts.map +1 -0
- package/build/swift-ui/ConfirmationDialog/index.d.ts.map +1 -1
- package/build/swift-ui/ContextMenu/index.d.ts.map +1 -1
- package/build/swift-ui/ControlGroup/index.d.ts +29 -0
- package/build/swift-ui/ControlGroup/index.d.ts.map +1 -0
- package/build/swift-ui/Gauge/index.d.ts.map +1 -1
- package/build/swift-ui/Image/index.d.ts +7 -1
- package/build/swift-ui/Image/index.d.ts.map +1 -1
- package/build/swift-ui/Label/index.d.ts.map +1 -1
- package/build/swift-ui/LabeledContent/index.d.ts.map +1 -1
- package/build/swift-ui/Menu/index.d.ts.map +1 -1
- package/build/swift-ui/Picker/index.d.ts.map +1 -1
- package/build/swift-ui/Popover/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/Section/index.d.ts.map +1 -1
- package/build/swift-ui/Slider/index.d.ts.map +1 -1
- package/build/swift-ui/SlotView.d.ts +5 -0
- package/build/swift-ui/SlotView.d.ts.map +1 -0
- 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/index.d.ts +2 -0
- package/build/swift-ui/index.d.ts.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +54 -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/AccessoryWidgetBackgroundView.swift +27 -0
- package/ios/BottomSheetView.swift +1 -6
- package/ios/ClosedRangeDateRecord.swift +10 -0
- package/ios/ColorPickerView.swift +9 -8
- package/ios/ConfirmationDialog/ConfirmationDialog.swift +7 -15
- package/ios/ConfirmationDialog/ConfirmationDialogProps.swift +0 -5
- package/ios/ContextMenu/ContextMenu.swift +27 -22
- package/ios/ContextMenu/ContextMenuRecords.swift +0 -6
- package/ios/ControlGroupView.swift +33 -0
- package/ios/DatePickerView.swift +7 -5
- package/ios/DisclosureGroupView.swift +5 -7
- package/ios/ExpoUIModule.swift +10 -32
- package/ios/GaugeView.swift +4 -26
- package/ios/HostView.swift +1 -2
- package/ios/ImageView.swift +22 -11
- package/ios/Label.swift +2 -17
- package/ios/LabeledContentView.swift +3 -27
- package/ios/ListView.swift +6 -14
- package/ios/Menu/MenuRecords.swift +0 -2
- package/ios/Menu/MenuView.swift +2 -5
- package/ios/Modifiers/DefaultScrollAnchorForRoleModifier.swift +32 -0
- package/ios/Modifiers/DefaultScrollAnchorModifier.swift +16 -0
- package/ios/Modifiers/ResizableModifier.swift +24 -0
- package/ios/Modifiers/Rotation3DEffectModifier.swift +20 -0
- package/ios/Modifiers/View+ModifierArray.swift +29 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +37 -3
- package/ios/Modifiers/WidgetModifiers.swift +46 -0
- package/ios/Picker/PickerView.swift +8 -16
- package/ios/Popover/PopoverProps.swift +0 -4
- package/ios/Popover/PopoverView.swift +5 -11
- package/ios/ProgressView.swift +0 -5
- package/ios/RNHostView.swift +91 -10
- package/ios/SectionView.swift +9 -17
- package/ios/SecureFieldView.swift +0 -1
- package/ios/ShareLink/ShareLinkView.swift +1 -1
- package/ios/SliderView.swift +16 -31
- package/ios/SlotView.swift +38 -0
- package/ios/StepperView.swift +12 -16
- package/ios/TextFieldView.swift +0 -1
- package/ios/TextView.swift +37 -1
- package/ios/Toggle/ToggleView.swift +5 -7
- package/ios/UIBaseView.swift +34 -3
- 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.1/expo.modules.ui-55.0.1.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.1/expo.modules.ui-55.0.1.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 +215 -6
- 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/Spacer/index.tsx +2 -2
- package/src/jetpack-compose/Switch/index.tsx +32 -84
- package/src/jetpack-compose/ToggleButton/index.tsx +67 -43
- package/src/jetpack-compose/index.ts +5 -4
- package/src/jetpack-compose/modifiers/animation.ts +37 -0
- package/src/jetpack-compose/modifiers/index.ts +86 -6
- package/src/swift-ui/AccessoryWidgetBackground/index.tsx +12 -0
- package/src/swift-ui/ConfirmationDialog/index.tsx +4 -12
- package/src/swift-ui/ContextMenu/index.tsx +6 -20
- package/src/swift-ui/ControlGroup/index.tsx +59 -0
- package/src/swift-ui/Gauge/index.tsx +5 -20
- package/src/swift-ui/Image/index.tsx +7 -1
- package/src/swift-ui/Label/index.tsx +2 -5
- package/src/swift-ui/LabeledContent/index.tsx +3 -12
- package/src/swift-ui/Menu/index.tsx +2 -6
- package/src/swift-ui/Picker/index.tsx +4 -11
- package/src/swift-ui/Popover/index.tsx +3 -12
- package/src/swift-ui/ProgressView/index.tsx +1 -3
- package/src/swift-ui/Section/index.tsx +4 -9
- package/src/swift-ui/Slider/index.tsx +4 -12
- package/src/swift-ui/SlotView.tsx +8 -0
- package/src/swift-ui/Stepper/index.tsx +7 -7
- package/src/swift-ui/Text/index.tsx +66 -2
- package/src/swift-ui/index.tsx +2 -0
- package/src/swift-ui/modifiers/index.ts +87 -1
- 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/ios/ConfirmationDialog/ConfirmationDialogComponents.swift +0 -26
- package/ios/ContextMenu/ContextMenuComponents.swift +0 -37
- package/ios/Menu/MenuComponents.swift +0 -12
- package/ios/Picker/PickerComponents.swift +0 -24
- package/ios/Popover/PopoverComponents.swift +0 -18
- package/ios/SectionComponents.swift +0 -34
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/55.0.1/expo.modules.ui-55.0.1.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
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
import { type ColorValue } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { type ModifierConfig, type ViewEvent } from '../../types';
|
|
5
|
+
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Colors for the segmented button in different states.
|
|
9
|
+
*/
|
|
10
|
+
export type SegmentedButtonColors = {
|
|
11
|
+
activeBorderColor?: ColorValue;
|
|
12
|
+
activeContentColor?: ColorValue;
|
|
13
|
+
inactiveBorderColor?: ColorValue;
|
|
14
|
+
inactiveContentColor?: ColorValue;
|
|
15
|
+
disabledActiveBorderColor?: ColorValue;
|
|
16
|
+
disabledActiveContentColor?: ColorValue;
|
|
17
|
+
disabledInactiveBorderColor?: ColorValue;
|
|
18
|
+
disabledInactiveContentColor?: ColorValue;
|
|
19
|
+
activeContainerColor?: ColorValue;
|
|
20
|
+
inactiveContainerColor?: ColorValue;
|
|
21
|
+
disabledActiveContainerColor?: ColorValue;
|
|
22
|
+
disabledInactiveContainerColor?: ColorValue;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SegmentedButtonProps = {
|
|
26
|
+
/**
|
|
27
|
+
* Whether the button is currently selected (used inside `SingleChoiceSegmentedButtonRow`).
|
|
28
|
+
*/
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Callback that is called when the button is clicked (used inside `SingleChoiceSegmentedButtonRow`).
|
|
32
|
+
*/
|
|
33
|
+
onClick?: () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the button is currently checked (used inside `MultiChoiceSegmentedButtonRow`).
|
|
36
|
+
*/
|
|
37
|
+
checked?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Callback that is called when the checked state changes (used inside `MultiChoiceSegmentedButtonRow`).
|
|
40
|
+
*/
|
|
41
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the button is enabled.
|
|
44
|
+
* @default true
|
|
45
|
+
*/
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Colors for the button in different states.
|
|
49
|
+
*/
|
|
50
|
+
colors?: SegmentedButtonColors;
|
|
51
|
+
/**
|
|
52
|
+
* Modifiers for the component.
|
|
53
|
+
*/
|
|
54
|
+
modifiers?: ModifierConfig[];
|
|
55
|
+
/**
|
|
56
|
+
* Children containing a `Label` slot.
|
|
57
|
+
*/
|
|
58
|
+
children?: React.ReactNode;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type NativeSlotViewProps = {
|
|
62
|
+
slotName: string;
|
|
63
|
+
children: React.ReactNode;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type NativeSegmentedButtonProps = Omit<SegmentedButtonProps, 'onClick' | 'onCheckedChange'> &
|
|
67
|
+
ViewEvent<'onButtonPressed', void> &
|
|
68
|
+
ViewEvent<'onCheckedChange', { value: boolean }>;
|
|
69
|
+
|
|
70
|
+
const SegmentedButtonNativeView: React.ComponentType<NativeSegmentedButtonProps> =
|
|
71
|
+
requireNativeView('ExpoUI', 'SegmentedButtonView');
|
|
72
|
+
|
|
73
|
+
const SlotNativeView: React.ComponentType<NativeSlotViewProps> = requireNativeView(
|
|
74
|
+
'ExpoUI',
|
|
75
|
+
'SlotView'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Label slot for `SegmentedButton`.
|
|
80
|
+
*/
|
|
81
|
+
function SegmentedButtonLabel(props: { children: React.ReactNode }) {
|
|
82
|
+
return <SlotNativeView slotName="label">{props.children}</SlotNativeView>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A Material 3 segmented button. Must be used inside a `SingleChoiceSegmentedButtonRow`
|
|
87
|
+
* or `MultiChoiceSegmentedButtonRow`.
|
|
88
|
+
*/
|
|
89
|
+
function SegmentedButtonComponent(props: SegmentedButtonProps) {
|
|
90
|
+
const { children, modifiers, onClick, onCheckedChange, ...restProps } = props;
|
|
91
|
+
return (
|
|
92
|
+
<SegmentedButtonNativeView
|
|
93
|
+
modifiers={modifiers}
|
|
94
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
95
|
+
{...restProps}
|
|
96
|
+
onButtonPressed={() => onClick?.()}
|
|
97
|
+
onCheckedChange={(e) => onCheckedChange?.(e.nativeEvent.value)}>
|
|
98
|
+
{children}
|
|
99
|
+
</SegmentedButtonNativeView>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
SegmentedButtonComponent.Label = SegmentedButtonLabel;
|
|
104
|
+
|
|
105
|
+
export { SegmentedButtonComponent as SegmentedButton };
|
|
106
|
+
export { SingleChoiceSegmentedButtonRow } from '../SingleChoiceSegmentedButtonRow';
|
|
107
|
+
export type { SingleChoiceSegmentedButtonRowProps } from '../SingleChoiceSegmentedButtonRow';
|
|
108
|
+
export { MultiChoiceSegmentedButtonRow } from '../MultiChoiceSegmentedButtonRow';
|
|
109
|
+
export type { MultiChoiceSegmentedButtonRowProps } from '../MultiChoiceSegmentedButtonRow';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { requireNativeView } from 'expo';
|
|
2
|
+
|
|
3
|
+
import { type ModifierConfig } from '../../types';
|
|
4
|
+
import { createViewModifierEventListener } from '../modifiers/utils';
|
|
5
|
+
|
|
6
|
+
export type SingleChoiceSegmentedButtonRowProps = {
|
|
7
|
+
/**
|
|
8
|
+
* SegmentedButton children.
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Modifiers for the component.
|
|
13
|
+
*/
|
|
14
|
+
modifiers?: ModifierConfig[];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const SingleChoiceSegmentedButtonRowNativeView: React.ComponentType<SingleChoiceSegmentedButtonRowProps> =
|
|
18
|
+
requireNativeView('ExpoUI', 'SingleChoiceSegmentedButtonRowView');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A row container for single-choice `SegmentedButton` children.
|
|
22
|
+
* Maps to Material 3 `SingleChoiceSegmentedButtonRow`.
|
|
23
|
+
*/
|
|
24
|
+
export function SingleChoiceSegmentedButtonRow(props: SingleChoiceSegmentedButtonRowProps) {
|
|
25
|
+
const { children, modifiers, ...restProps } = props;
|
|
26
|
+
return (
|
|
27
|
+
<SingleChoiceSegmentedButtonRowNativeView
|
|
28
|
+
modifiers={modifiers}
|
|
29
|
+
{...(modifiers ? createViewModifierEventListener(modifiers) : undefined)}
|
|
30
|
+
{...restProps}>
|
|
31
|
+
{children}
|
|
32
|
+
</SingleChoiceSegmentedButtonRowNativeView>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -1,14 +1,24 @@
|
|
|
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 { createViewModifierEventListener } from '../modifiers/utils';
|
|
6
6
|
|
|
7
|
+
type SlotNativeViewProps = {
|
|
8
|
+
slotName: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const SlotNativeView: React.ComponentType<SlotNativeViewProps> = requireNativeView(
|
|
13
|
+
'ExpoUI',
|
|
14
|
+
'SlotView'
|
|
15
|
+
);
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
|
-
* Colors for slider's
|
|
18
|
+
* Colors for slider elements. Maps directly to Material3's `SliderDefaults.colors()`.
|
|
9
19
|
* @platform android
|
|
10
20
|
*/
|
|
11
|
-
export type
|
|
21
|
+
export type SliderColors = {
|
|
12
22
|
thumbColor?: ColorValue;
|
|
13
23
|
activeTrackColor?: ColorValue;
|
|
14
24
|
inactiveTrackColor?: ColorValue;
|
|
@@ -38,35 +48,47 @@ export type SliderProps = {
|
|
|
38
48
|
*/
|
|
39
49
|
max?: number;
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @
|
|
51
|
+
* Whether the slider is enabled for user interaction.
|
|
52
|
+
* @default true
|
|
43
53
|
*/
|
|
44
|
-
|
|
54
|
+
enabled?: boolean;
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
56
|
+
* Colors for slider elements. Maps to Material3's `SliderDefaults.colors()`.
|
|
57
|
+
* @platform android
|
|
47
58
|
*/
|
|
48
|
-
|
|
59
|
+
colors?: SliderColors;
|
|
49
60
|
/**
|
|
50
61
|
* Callback triggered on dragging along the slider.
|
|
51
62
|
*/
|
|
52
63
|
onValueChange?: (value: number) => void;
|
|
53
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Callback triggered when the user finishes changing the value (for example, lifts a finger).
|
|
66
|
+
* Maps to Material3's `onValueChangeFinished`.
|
|
67
|
+
*/
|
|
68
|
+
onValueChangeFinished?: () => void;
|
|
54
69
|
/**
|
|
55
70
|
* Modifiers for the component.
|
|
56
71
|
*/
|
|
57
|
-
modifiers?:
|
|
72
|
+
modifiers?: ModifierConfig[];
|
|
73
|
+
/**
|
|
74
|
+
* Slot children for custom thumb and track.
|
|
75
|
+
*/
|
|
76
|
+
children?: React.ReactNode;
|
|
58
77
|
};
|
|
59
78
|
|
|
60
|
-
type NativeSliderProps = Omit<SliderProps, 'onValueChange'> &
|
|
61
|
-
ViewEvent<'
|
|
79
|
+
type NativeSliderProps = Omit<SliderProps, 'onValueChange' | 'onValueChangeFinished' | 'children'> &
|
|
80
|
+
ViewEvent<'onValueChange', { value: number }> &
|
|
81
|
+
ViewEvent<'onValueChangeFinished', void> & { children?: React.ReactNode };
|
|
62
82
|
|
|
63
83
|
const SliderNativeView: React.ComponentType<NativeSliderProps> = requireNativeView(
|
|
64
84
|
'ExpoUI',
|
|
65
85
|
'SliderView'
|
|
66
86
|
);
|
|
67
87
|
|
|
68
|
-
function transformSliderProps(
|
|
69
|
-
|
|
88
|
+
function transformSliderProps(
|
|
89
|
+
props: Omit<SliderProps, 'children'>
|
|
90
|
+
): Omit<NativeSliderProps, 'children'> {
|
|
91
|
+
const { modifiers, onValueChange, onValueChangeFinished, ...restProps } = props;
|
|
70
92
|
return {
|
|
71
93
|
modifiers,
|
|
72
94
|
...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
|
|
@@ -75,22 +97,47 @@ function transformSliderProps(props: SliderProps): NativeSliderProps {
|
|
|
75
97
|
max: props.max ?? 1,
|
|
76
98
|
steps: props.steps ?? 0,
|
|
77
99
|
value: props.value ?? 0,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
:
|
|
84
|
-
|
|
85
|
-
thumbColor: props.color,
|
|
86
|
-
activeTrackColor: props.color,
|
|
87
|
-
activeTickColor: props.color,
|
|
88
|
-
}
|
|
89
|
-
: undefined,
|
|
90
|
-
color: props.color,
|
|
100
|
+
enabled: props.enabled ?? true,
|
|
101
|
+
onValueChange: onValueChange
|
|
102
|
+
? ({ nativeEvent: { value } }) => {
|
|
103
|
+
onValueChange(value);
|
|
104
|
+
}
|
|
105
|
+
: undefined,
|
|
106
|
+
onValueChangeFinished: onValueChangeFinished ? () => onValueChangeFinished() : undefined,
|
|
91
107
|
};
|
|
92
108
|
}
|
|
93
109
|
|
|
94
|
-
|
|
95
|
-
|
|
110
|
+
/**
|
|
111
|
+
* A custom thumb slot for `Slider`.
|
|
112
|
+
* Wrap any content to use as the slider's thumb indicator.
|
|
113
|
+
*
|
|
114
|
+
* @platform android
|
|
115
|
+
*/
|
|
116
|
+
function Thumb(props: { children: React.ReactNode }) {
|
|
117
|
+
return <SlotNativeView slotName="thumb">{props.children}</SlotNativeView>;
|
|
96
118
|
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* A custom track slot for `Slider`.
|
|
122
|
+
* Wrap any content to use as the slider's track.
|
|
123
|
+
*
|
|
124
|
+
* @platform android
|
|
125
|
+
*/
|
|
126
|
+
function Track(props: { children: React.ReactNode }) {
|
|
127
|
+
return <SlotNativeView slotName="track">{props.children}</SlotNativeView>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* A slider component that wraps Material3's `Slider`.
|
|
132
|
+
*
|
|
133
|
+
* @platform android
|
|
134
|
+
*/
|
|
135
|
+
function SliderComponent(props: SliderProps) {
|
|
136
|
+
const { children, ...restProps } = props;
|
|
137
|
+
return <SliderNativeView {...transformSliderProps(restProps)}>{children}</SliderNativeView>;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
SliderComponent.Thumb = Thumb;
|
|
141
|
+
SliderComponent.Track = Track;
|
|
142
|
+
|
|
143
|
+
export { SliderComponent as Slider };
|
|
@@ -5,7 +5,7 @@ import { createViewModifierEventListener } from '../modifiers/utils';
|
|
|
5
5
|
|
|
6
6
|
export type SpacerProps = {
|
|
7
7
|
/**
|
|
8
|
-
* Modifiers for the component. Use weight() modifier to make the spacer flexible.
|
|
8
|
+
* Modifiers for the component. Use `weight()` modifier to make the spacer flexible.
|
|
9
9
|
*/
|
|
10
10
|
modifiers?: ExpoModifier[];
|
|
11
11
|
};
|
|
@@ -27,7 +27,7 @@ function transformProps(props: SpacerProps): NativeSpacerProps {
|
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A spacer component that fills available space.
|
|
30
|
-
* Use with the weight() modifier to create flexible spacing in Row or Column layouts.
|
|
30
|
+
* Use with the `weight()` modifier to create flexible spacing in `Row` or `Column` layouts.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```tsx
|
|
@@ -1,32 +1,30 @@
|
|
|
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;
|
|
14
|
+
checkedBorderColor?: ColorValue;
|
|
15
|
+
checkedIconColor?: ColorValue;
|
|
15
16
|
uncheckedThumbColor?: ColorValue;
|
|
16
17
|
uncheckedTrackColor?: ColorValue;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
disabledUncheckedColor?: ColorValue;
|
|
28
|
-
checkmarkColor?: ColorValue;
|
|
29
|
-
disabledIndeterminateColor?: ColorValue;
|
|
18
|
+
uncheckedBorderColor?: ColorValue;
|
|
19
|
+
uncheckedIconColor?: ColorValue;
|
|
20
|
+
disabledCheckedThumbColor?: ColorValue;
|
|
21
|
+
disabledCheckedTrackColor?: ColorValue;
|
|
22
|
+
disabledCheckedBorderColor?: ColorValue;
|
|
23
|
+
disabledCheckedIconColor?: ColorValue;
|
|
24
|
+
disabledUncheckedThumbColor?: ColorValue;
|
|
25
|
+
disabledUncheckedTrackColor?: ColorValue;
|
|
26
|
+
disabledUncheckedBorderColor?: ColorValue;
|
|
27
|
+
disabledUncheckedIconColor?: ColorValue;
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
export type SwitchProps = {
|
|
@@ -35,64 +33,32 @@ export type SwitchProps = {
|
|
|
35
33
|
*/
|
|
36
34
|
value: boolean;
|
|
37
35
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* > On Android, the label has an effect only when the `Switch` is used inside a `ContextMenu`.
|
|
41
|
-
*/
|
|
42
|
-
label?: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Type of the switch component. Can be `'checkbox'`, `'switch'`, or `'button'`.
|
|
46
|
-
* @default 'switch'
|
|
36
|
+
* Whether the switch is enabled.
|
|
37
|
+
* @default true
|
|
47
38
|
*/
|
|
48
|
-
|
|
39
|
+
enabled?: boolean;
|
|
49
40
|
/**
|
|
50
41
|
* Callback function that is called when the checked state changes.
|
|
51
42
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
onCheckedChange?: (value: boolean) => void;
|
|
54
44
|
/**
|
|
55
|
-
*
|
|
45
|
+
* Colors for switch core elements.
|
|
56
46
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
47
|
+
colors?: SwitchColors;
|
|
59
48
|
/**
|
|
60
49
|
* Modifiers for the component.
|
|
61
50
|
*/
|
|
62
|
-
modifiers?:
|
|
63
|
-
|
|
51
|
+
modifiers?: ModifierConfig[];
|
|
64
52
|
/**
|
|
65
53
|
* Children containing ThumbContent slot.
|
|
66
54
|
* @platform android
|
|
67
55
|
*/
|
|
68
56
|
children?: React.ReactNode;
|
|
69
|
-
} & (SwitchSwitchVariantProps | SwitchCheckboxVariantProps | SwitchButtonVariantProps);
|
|
70
|
-
|
|
71
|
-
export type SwitchSwitchVariantProps = {
|
|
72
|
-
variant?: 'switch';
|
|
73
|
-
/**
|
|
74
|
-
* Colors for switch's core elements.
|
|
75
|
-
* @platform android
|
|
76
|
-
*/
|
|
77
|
-
elementColors?: SwitchElementColors;
|
|
78
57
|
};
|
|
79
58
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
* Colors for checkbox core elements.
|
|
84
|
-
* @platform android
|
|
85
|
-
*/
|
|
86
|
-
elementColors?: CheckboxElementColors;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export type SwitchButtonVariantProps = {
|
|
90
|
-
variant: 'button';
|
|
91
|
-
elementColors?: undefined;
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
type NativeSwitchProps = Omit<SwitchProps, 'onValueChange'> & {
|
|
95
|
-
onValueChange: (event: NativeSyntheticEvent<{ value: boolean }>) => void;
|
|
59
|
+
type NativeSwitchProps = Omit<SwitchProps, 'onCheckedChange' | 'children'> & {
|
|
60
|
+
children?: React.ReactNode;
|
|
61
|
+
onCheckedChange: (event: NativeSyntheticEvent<{ value: boolean }>) => void;
|
|
96
62
|
};
|
|
97
63
|
|
|
98
64
|
type NativeSlotViewProps = {
|
|
@@ -122,39 +88,21 @@ export function SwitchThumbContent(props: ThumbContentProps) {
|
|
|
122
88
|
return <SlotNativeView slotName="thumbContent">{props.children}</SlotNativeView>;
|
|
123
89
|
}
|
|
124
90
|
|
|
125
|
-
function getElementColors(props: SwitchProps) {
|
|
126
|
-
if (props.variant === 'button') {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
if (!props.elementColors) {
|
|
130
|
-
if (props.variant === 'switch') {
|
|
131
|
-
return {
|
|
132
|
-
checkedTrackColor: props.color,
|
|
133
|
-
};
|
|
134
|
-
} else {
|
|
135
|
-
return {
|
|
136
|
-
checkedColor: props.color,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return props.elementColors;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
91
|
function transformSwitchProps(props: SwitchProps): Omit<NativeSwitchProps, 'children'> {
|
|
144
|
-
const { modifiers, children, ...restProps } = props;
|
|
92
|
+
const { modifiers, children, onCheckedChange, ...restProps } = props;
|
|
145
93
|
return {
|
|
146
94
|
modifiers,
|
|
147
95
|
...(modifiers ? createViewModifierEventListener(modifiers) : undefined),
|
|
148
96
|
...restProps,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
color: props.color,
|
|
152
|
-
onValueChange: ({ nativeEvent: { value } }) => {
|
|
153
|
-
props?.onValueChange?.(value);
|
|
97
|
+
onCheckedChange: ({ nativeEvent: { value } }) => {
|
|
98
|
+
onCheckedChange?.(value);
|
|
154
99
|
},
|
|
155
|
-
}
|
|
100
|
+
};
|
|
156
101
|
}
|
|
157
102
|
|
|
103
|
+
/**
|
|
104
|
+
* A switch component.
|
|
105
|
+
*/
|
|
158
106
|
function SwitchComponent(props: SwitchProps) {
|
|
159
107
|
return <SwitchNativeView {...transformSwitchProps(props)}>{props.children}</SwitchNativeView>;
|
|
160
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';
|