@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
|
@@ -1,119 +1,219 @@
|
|
|
1
|
-
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class)
|
|
1
|
+
@file:OptIn(ExperimentalMaterial3ExpressiveApi::class, ExperimentalMaterial3Api::class)
|
|
2
2
|
|
|
3
3
|
package expo.modules.ui
|
|
4
4
|
|
|
5
5
|
import android.graphics.Color
|
|
6
6
|
import androidx.compose.material3.CircularProgressIndicator
|
|
7
7
|
import androidx.compose.material3.CircularWavyProgressIndicator
|
|
8
|
+
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
8
9
|
import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
|
|
9
10
|
import androidx.compose.material3.LinearProgressIndicator
|
|
10
11
|
import androidx.compose.material3.LinearWavyProgressIndicator
|
|
11
12
|
import androidx.compose.material3.ProgressIndicatorDefaults
|
|
13
|
+
import androidx.compose.material3.WavyProgressIndicatorDefaults
|
|
12
14
|
import androidx.compose.runtime.Composable
|
|
15
|
+
import androidx.compose.ui.graphics.StrokeCap
|
|
16
|
+
import androidx.compose.ui.unit.dp
|
|
13
17
|
import expo.modules.kotlin.records.Field
|
|
14
18
|
import expo.modules.kotlin.records.Record
|
|
15
|
-
import expo.modules.kotlin.types.Enumerable
|
|
16
19
|
import expo.modules.kotlin.views.ComposeProps
|
|
17
20
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
CIRCULAR("circular"),
|
|
21
|
-
LINEAR("linear"),
|
|
22
|
-
CIRCULAR_WAVY("circularWavy"),
|
|
23
|
-
LINEAR_WAVY("linearWavy")
|
|
24
|
-
}
|
|
22
|
+
// region LinearProgressIndicator
|
|
25
23
|
|
|
26
|
-
class
|
|
27
|
-
@Field
|
|
28
|
-
val
|
|
24
|
+
class DrawStopIndicatorConfig : Record {
|
|
25
|
+
@Field val color: Color? = null
|
|
26
|
+
@Field val strokeCap: String? = null
|
|
27
|
+
@Field val stopSize: Float? = null
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
data class
|
|
32
|
-
val variant: ProgressVariant = ProgressVariant.CIRCULAR,
|
|
30
|
+
data class LinearProgressIndicatorProps(
|
|
33
31
|
val progress: Float? = null,
|
|
34
32
|
val color: Color? = null,
|
|
35
|
-
val
|
|
33
|
+
val trackColor: Color? = null,
|
|
34
|
+
val strokeCap: String? = null,
|
|
35
|
+
val gapSize: Float? = null,
|
|
36
|
+
val drawStopIndicator: DrawStopIndicatorConfig? = null,
|
|
36
37
|
val modifiers: ModifierList = emptyList()
|
|
37
38
|
) : ComposeProps
|
|
38
39
|
|
|
39
40
|
@Composable
|
|
40
|
-
fun FunctionalComposableScope.
|
|
41
|
-
val progress = props.progress
|
|
42
|
-
val color = props.color
|
|
43
|
-
val colors = props.elementColors
|
|
41
|
+
fun FunctionalComposableScope.LinearProgressIndicatorContent(props: LinearProgressIndicatorProps) {
|
|
44
42
|
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
43
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.linearColor
|
|
44
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.linearTrackColor
|
|
45
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.LinearStrokeCap
|
|
46
|
+
val gapSize = props.gapSize?.dp ?: ProgressIndicatorDefaults.LinearIndicatorTrackGapSize
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
} else {
|
|
76
|
-
CircularProgressIndicator(
|
|
77
|
-
color = composeColor,
|
|
78
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor,
|
|
79
|
-
modifier = modifier
|
|
80
|
-
)
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
ProgressVariant.LINEAR_WAVY -> {
|
|
84
|
-
val composeColor = color.composeOrNull ?: ProgressIndicatorDefaults.linearColor
|
|
85
|
-
val trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.linearTrackColor
|
|
86
|
-
if (progress != null) {
|
|
87
|
-
LinearWavyProgressIndicator(
|
|
88
|
-
progress = { progress },
|
|
89
|
-
color = composeColor,
|
|
90
|
-
trackColor = trackColor,
|
|
91
|
-
modifier = modifier
|
|
92
|
-
)
|
|
93
|
-
} else {
|
|
94
|
-
LinearWavyProgressIndicator(
|
|
95
|
-
color = composeColor,
|
|
96
|
-
trackColor = trackColor,
|
|
97
|
-
modifier = modifier
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
ProgressVariant.CIRCULAR_WAVY -> {
|
|
102
|
-
val composeColor = color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
103
|
-
if (progress != null) {
|
|
104
|
-
CircularWavyProgressIndicator(
|
|
105
|
-
progress = { progress },
|
|
106
|
-
color = composeColor,
|
|
107
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor,
|
|
108
|
-
modifier = modifier
|
|
109
|
-
)
|
|
110
|
-
} else {
|
|
111
|
-
CircularWavyProgressIndicator(
|
|
112
|
-
color = composeColor,
|
|
113
|
-
trackColor = colors.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor,
|
|
114
|
-
modifier = modifier
|
|
115
|
-
)
|
|
116
|
-
}
|
|
48
|
+
if (props.progress != null) {
|
|
49
|
+
val stopIndicatorConfig = props.drawStopIndicator
|
|
50
|
+
if (stopIndicatorConfig != null) {
|
|
51
|
+
LinearProgressIndicator(
|
|
52
|
+
progress = { props.progress },
|
|
53
|
+
color = color,
|
|
54
|
+
trackColor = trackColor,
|
|
55
|
+
strokeCap = strokeCap,
|
|
56
|
+
gapSize = gapSize,
|
|
57
|
+
drawStopIndicator = {
|
|
58
|
+
ProgressIndicatorDefaults.drawStopIndicator(
|
|
59
|
+
drawScope = this,
|
|
60
|
+
stopSize = stopIndicatorConfig.stopSize?.dp ?: ProgressIndicatorDefaults.LinearTrackStopIndicatorSize,
|
|
61
|
+
color = stopIndicatorConfig.color.composeOrNull ?: color,
|
|
62
|
+
strokeCap = stopIndicatorConfig.strokeCap.toStrokeCap() ?: strokeCap
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
modifier = modifier
|
|
66
|
+
)
|
|
67
|
+
} else {
|
|
68
|
+
LinearProgressIndicator(
|
|
69
|
+
progress = { props.progress },
|
|
70
|
+
color = color,
|
|
71
|
+
trackColor = trackColor,
|
|
72
|
+
strokeCap = strokeCap,
|
|
73
|
+
gapSize = gapSize,
|
|
74
|
+
modifier = modifier
|
|
75
|
+
)
|
|
117
76
|
}
|
|
77
|
+
} else {
|
|
78
|
+
LinearProgressIndicator(
|
|
79
|
+
color = color,
|
|
80
|
+
trackColor = trackColor,
|
|
81
|
+
strokeCap = strokeCap,
|
|
82
|
+
gapSize = gapSize,
|
|
83
|
+
modifier = modifier
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// endregion
|
|
89
|
+
|
|
90
|
+
// region CircularProgressIndicator
|
|
91
|
+
|
|
92
|
+
data class CircularProgressIndicatorProps(
|
|
93
|
+
val progress: Float? = null,
|
|
94
|
+
val color: Color? = null,
|
|
95
|
+
val trackColor: Color? = null,
|
|
96
|
+
val strokeWidth: Float? = null,
|
|
97
|
+
val strokeCap: String? = null,
|
|
98
|
+
val gapSize: Float? = null,
|
|
99
|
+
val modifiers: ModifierList = emptyList()
|
|
100
|
+
) : ComposeProps
|
|
101
|
+
|
|
102
|
+
@Composable
|
|
103
|
+
fun FunctionalComposableScope.CircularProgressIndicatorContent(props: CircularProgressIndicatorProps) {
|
|
104
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
105
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
106
|
+
val strokeWidth = props.strokeWidth?.dp ?: ProgressIndicatorDefaults.CircularStrokeWidth
|
|
107
|
+
|
|
108
|
+
if (props.progress != null) {
|
|
109
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor
|
|
110
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.CircularDeterminateStrokeCap
|
|
111
|
+
val gapSize = props.gapSize?.dp ?: ProgressIndicatorDefaults.CircularIndicatorTrackGapSize
|
|
112
|
+
|
|
113
|
+
CircularProgressIndicator(
|
|
114
|
+
progress = { props.progress },
|
|
115
|
+
color = color,
|
|
116
|
+
trackColor = trackColor,
|
|
117
|
+
strokeWidth = strokeWidth,
|
|
118
|
+
strokeCap = strokeCap,
|
|
119
|
+
gapSize = gapSize,
|
|
120
|
+
modifier = modifier
|
|
121
|
+
)
|
|
122
|
+
} else {
|
|
123
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor
|
|
124
|
+
val strokeCap = props.strokeCap.toStrokeCap() ?: ProgressIndicatorDefaults.CircularIndeterminateStrokeCap
|
|
125
|
+
|
|
126
|
+
CircularProgressIndicator(
|
|
127
|
+
color = color,
|
|
128
|
+
trackColor = trackColor,
|
|
129
|
+
strokeWidth = strokeWidth,
|
|
130
|
+
strokeCap = strokeCap,
|
|
131
|
+
modifier = modifier
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// endregion
|
|
137
|
+
|
|
138
|
+
// region LinearWavyProgressIndicator
|
|
139
|
+
|
|
140
|
+
data class LinearWavyProgressIndicatorProps(
|
|
141
|
+
val progress: Float? = null,
|
|
142
|
+
val color: Color? = null,
|
|
143
|
+
val trackColor: Color? = null,
|
|
144
|
+
val stopSize: Float? = null,
|
|
145
|
+
val modifiers: ModifierList = emptyList()
|
|
146
|
+
) : ComposeProps
|
|
147
|
+
|
|
148
|
+
@Composable
|
|
149
|
+
fun FunctionalComposableScope.LinearWavyProgressIndicatorContent(props: LinearWavyProgressIndicatorProps) {
|
|
150
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
151
|
+
val color = props.color.composeOrNull ?: WavyProgressIndicatorDefaults.indicatorColor
|
|
152
|
+
val trackColor = props.trackColor.composeOrNull ?: WavyProgressIndicatorDefaults.trackColor
|
|
153
|
+
val stopSize = props.stopSize?.dp ?: WavyProgressIndicatorDefaults.LinearTrackStopIndicatorSize
|
|
154
|
+
|
|
155
|
+
if (props.progress != null) {
|
|
156
|
+
LinearWavyProgressIndicator(
|
|
157
|
+
progress = { props.progress },
|
|
158
|
+
color = color,
|
|
159
|
+
trackColor = trackColor,
|
|
160
|
+
stopSize = stopSize,
|
|
161
|
+
modifier = modifier
|
|
162
|
+
)
|
|
163
|
+
} else {
|
|
164
|
+
LinearWavyProgressIndicator(
|
|
165
|
+
color = color,
|
|
166
|
+
trackColor = trackColor,
|
|
167
|
+
modifier = modifier
|
|
168
|
+
)
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// endregion
|
|
173
|
+
|
|
174
|
+
// region CircularWavyProgressIndicator
|
|
175
|
+
|
|
176
|
+
data class CircularWavyProgressIndicatorProps(
|
|
177
|
+
val progress: Float? = null,
|
|
178
|
+
val color: Color? = null,
|
|
179
|
+
val trackColor: Color? = null,
|
|
180
|
+
val modifiers: ModifierList = emptyList()
|
|
181
|
+
) : ComposeProps
|
|
182
|
+
|
|
183
|
+
@Composable
|
|
184
|
+
fun FunctionalComposableScope.CircularWavyProgressIndicatorContent(props: CircularWavyProgressIndicatorProps) {
|
|
185
|
+
val modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
186
|
+
val color = props.color.composeOrNull ?: ProgressIndicatorDefaults.circularColor
|
|
187
|
+
|
|
188
|
+
if (props.progress != null) {
|
|
189
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularDeterminateTrackColor
|
|
190
|
+
|
|
191
|
+
CircularWavyProgressIndicator(
|
|
192
|
+
progress = { props.progress },
|
|
193
|
+
color = color,
|
|
194
|
+
trackColor = trackColor,
|
|
195
|
+
modifier = modifier
|
|
196
|
+
)
|
|
197
|
+
} else {
|
|
198
|
+
val trackColor = props.trackColor.composeOrNull ?: ProgressIndicatorDefaults.circularIndeterminateTrackColor
|
|
199
|
+
|
|
200
|
+
CircularWavyProgressIndicator(
|
|
201
|
+
color = color,
|
|
202
|
+
trackColor = trackColor,
|
|
203
|
+
modifier = modifier
|
|
204
|
+
)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// endregion
|
|
209
|
+
|
|
210
|
+
// Utility
|
|
211
|
+
|
|
212
|
+
private fun String?.toStrokeCap(): StrokeCap? {
|
|
213
|
+
return when (this?.lowercase()) {
|
|
214
|
+
"round" -> StrokeCap.Round
|
|
215
|
+
"butt" -> StrokeCap.Butt
|
|
216
|
+
"square" -> StrokeCap.Square
|
|
217
|
+
else -> null
|
|
118
218
|
}
|
|
119
219
|
}
|
|
@@ -2,86 +2,240 @@ package expo.modules.ui
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import android.util.Log
|
|
6
|
+
import android.view.MotionEvent
|
|
5
7
|
import android.view.View
|
|
6
8
|
import android.view.ViewGroup
|
|
7
|
-
import
|
|
8
|
-
import androidx.compose.foundation.
|
|
9
|
+
import android.widget.FrameLayout
|
|
10
|
+
import androidx.compose.foundation.layout.fillMaxSize
|
|
11
|
+
import androidx.compose.foundation.layout.requiredSize
|
|
9
12
|
import androidx.compose.runtime.Composable
|
|
13
|
+
import androidx.compose.runtime.DisposableEffect
|
|
10
14
|
import androidx.compose.runtime.MutableState
|
|
11
15
|
import androidx.compose.runtime.mutableStateOf
|
|
16
|
+
import androidx.compose.runtime.remember
|
|
12
17
|
import androidx.compose.ui.Modifier
|
|
18
|
+
import androidx.compose.ui.layout.onSizeChanged
|
|
19
|
+
import androidx.compose.ui.platform.LocalDensity
|
|
20
|
+
import androidx.compose.ui.unit.IntSize
|
|
13
21
|
import androidx.compose.ui.viewinterop.AndroidView
|
|
14
|
-
import com.facebook.react.
|
|
22
|
+
import com.facebook.react.bridge.ReactContext
|
|
23
|
+
import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
24
|
+
import com.facebook.react.config.ReactFeatureFlags
|
|
25
|
+
import com.facebook.react.uimanager.JSPointerDispatcher
|
|
26
|
+
import com.facebook.react.uimanager.JSTouchDispatcher
|
|
27
|
+
import com.facebook.react.uimanager.RootView
|
|
28
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
29
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
30
|
+
import com.facebook.react.uimanager.events.EventDispatcher
|
|
15
31
|
import expo.modules.kotlin.AppContext
|
|
16
32
|
import expo.modules.kotlin.views.ComposableScope
|
|
17
33
|
import expo.modules.kotlin.views.ComposeProps
|
|
18
34
|
import expo.modules.kotlin.views.ExpoComposeView
|
|
19
35
|
import expo.modules.kotlin.views.RNHostViewInterface
|
|
20
|
-
import expo.modules.kotlin.views.ShadowNodeProxy
|
|
21
|
-
import java.lang.ref.WeakReference
|
|
22
36
|
|
|
23
|
-
internal data class
|
|
24
|
-
val matchContents: MutableState<Boolean?> = mutableStateOf(null)
|
|
25
|
-
val verticalScrollEnabled: MutableState<Boolean?> = mutableStateOf(null),
|
|
26
|
-
val modifiers: MutableState<ModifierList> = mutableStateOf(emptyList())
|
|
37
|
+
internal data class RNHostViewProps(
|
|
38
|
+
val matchContents: MutableState<Boolean?> = mutableStateOf(null)
|
|
27
39
|
) : ComposeProps
|
|
28
40
|
|
|
29
41
|
@SuppressLint("ViewConstructor")
|
|
30
42
|
internal class RNHostView(context: Context, appContext: AppContext) :
|
|
31
|
-
ExpoComposeView<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
ExpoComposeView<RNHostViewProps>(context, appContext) {
|
|
44
|
+
companion object {
|
|
45
|
+
private const val TAG = "RNHostView"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override val props = RNHostViewProps()
|
|
49
|
+
|
|
50
|
+
private val childViewState = mutableStateOf<View?>(null)
|
|
51
|
+
private val wrapperState = mutableStateOf<TouchDispatchingRootViewGroup?>(null)
|
|
52
|
+
|
|
53
|
+
override fun addView(child: View, index: Int, params: ViewGroup.LayoutParams) {
|
|
54
|
+
childViewState.value = child
|
|
55
|
+
val wrapper = TouchDispatchingRootViewGroup(child.context).apply {
|
|
56
|
+
val reactContext = child.context as? ReactContext
|
|
57
|
+
if (reactContext != null) {
|
|
58
|
+
eventDispatcher = UIManagerHelper.getEventDispatcherForReactTag(reactContext, child.id)
|
|
59
|
+
} else {
|
|
60
|
+
Log.e(TAG, "RNHostView: child context is not a ReactContext, touch events will not be dispatched to JS")
|
|
61
|
+
}
|
|
62
|
+
addView(child, FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT))
|
|
63
|
+
}
|
|
64
|
+
wrapperState.value = wrapper
|
|
65
|
+
}
|
|
35
66
|
|
|
36
|
-
|
|
67
|
+
override fun removeView(view: View) {
|
|
68
|
+
if (view == childViewState.value) {
|
|
69
|
+
wrapperState.value?.removeView(view)
|
|
70
|
+
childViewState.value = null
|
|
71
|
+
wrapperState.value = null
|
|
72
|
+
} else {
|
|
73
|
+
super.removeView(view)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
override fun removeViewAt(index: Int) {
|
|
78
|
+
childViewState.value?.let { child ->
|
|
79
|
+
wrapperState.value?.removeView(child)
|
|
80
|
+
}
|
|
81
|
+
childViewState.value = null
|
|
82
|
+
wrapperState.value = null
|
|
83
|
+
}
|
|
37
84
|
|
|
38
85
|
@Composable
|
|
39
86
|
override fun ComposableScope.Content() {
|
|
40
|
-
val
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
87
|
+
val matchContents = props.matchContents.value ?: false
|
|
88
|
+
|
|
89
|
+
wrapperState.value?.let { wrapper ->
|
|
90
|
+
val childView = childViewState.value ?: return@let
|
|
91
|
+
if (matchContents) {
|
|
92
|
+
AndroidView(
|
|
93
|
+
factory = { wrapper },
|
|
94
|
+
modifier = applySizeFromYogaNodeModifier(childView)
|
|
95
|
+
)
|
|
96
|
+
} else {
|
|
97
|
+
AndroidView(
|
|
98
|
+
factory = { wrapper },
|
|
99
|
+
modifier = Modifier
|
|
100
|
+
.fillMaxSize()
|
|
101
|
+
.then(reportSizeToYogaNodeModifier())
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
50
105
|
}
|
|
51
106
|
|
|
52
|
-
|
|
53
|
-
|
|
107
|
+
// Sets Compose view size from Yoga node size
|
|
108
|
+
// Listens yoga node size changes and updates the Compose view size
|
|
109
|
+
@Composable
|
|
110
|
+
private fun applySizeFromYogaNodeModifier(childView: View): Modifier {
|
|
111
|
+
val density = LocalDensity.current
|
|
112
|
+
|
|
113
|
+
val childSize = remember {
|
|
114
|
+
mutableStateOf(
|
|
115
|
+
if (childView.width > 0 && childView.height > 0) IntSize(childView.width, childView.height)
|
|
116
|
+
else IntSize.Zero
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
DisposableEffect(childView) {
|
|
121
|
+
val listener = View.OnLayoutChangeListener { _, l, t, r, b, _, _, _, _ ->
|
|
122
|
+
childSize.value = IntSize(r - l, b - t)
|
|
123
|
+
}
|
|
124
|
+
childView.addOnLayoutChangeListener(listener)
|
|
125
|
+
onDispose { childView.removeOnLayoutChangeListener(listener) }
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return with(density) {
|
|
129
|
+
if (childSize.value.width > 0 && childSize.value.height > 0) {
|
|
130
|
+
Modifier.requiredSize(
|
|
131
|
+
childSize.value.width.toDp(),
|
|
132
|
+
childSize.value.height.toDp()
|
|
133
|
+
)
|
|
134
|
+
} else {
|
|
135
|
+
Modifier
|
|
136
|
+
}
|
|
137
|
+
}
|
|
54
138
|
}
|
|
55
139
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
val offsetX = paddingLeft
|
|
70
|
-
val offsetY = paddingRight
|
|
71
|
-
container.layout(offsetX, offsetY, offsetX + width, offsetY + height)
|
|
140
|
+
// Sets Yoga node size from Compose view size
|
|
141
|
+
// Listens Compose view size changes and updates the Yoga node size
|
|
142
|
+
@Composable
|
|
143
|
+
private fun reportSizeToYogaNodeModifier(): Modifier {
|
|
144
|
+
val density = LocalDensity.current
|
|
145
|
+
return Modifier.onSizeChanged { size ->
|
|
146
|
+
with(density) {
|
|
147
|
+
shadowNodeProxy.setViewSize(
|
|
148
|
+
size.width.toDp().value.toDouble(),
|
|
149
|
+
size.height.toDp().value.toDouble()
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
72
153
|
}
|
|
73
154
|
}
|
|
74
155
|
|
|
75
|
-
|
|
76
|
-
|
|
156
|
+
/**
|
|
157
|
+
* A thin FrameLayout that intercepts touch events and dispatches them to JS via
|
|
158
|
+
* JSTouchDispatcher/JSPointerDispatcher, replicating the pattern from React Native's
|
|
159
|
+
* DialogRootViewGroup in ReactModalHostView.
|
|
160
|
+
*/
|
|
161
|
+
private class TouchDispatchingRootViewGroup(
|
|
162
|
+
context: Context
|
|
163
|
+
) : FrameLayout(context), RootView {
|
|
164
|
+
private val jsTouchDispatcher = JSTouchDispatcher(this)
|
|
165
|
+
private var jsPointerDispatcher: JSPointerDispatcher? = null
|
|
166
|
+
|
|
167
|
+
var eventDispatcher: EventDispatcher? = null
|
|
168
|
+
|
|
169
|
+
private val reactContext: ThemedReactContext
|
|
170
|
+
get() = context as ThemedReactContext
|
|
171
|
+
|
|
172
|
+
init {
|
|
173
|
+
if (ReactFeatureFlags.dispatchPointerEvents) {
|
|
174
|
+
jsPointerDispatcher = JSPointerDispatcher(this)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
179
|
+
// Always gets called with EXACTLY mode
|
|
180
|
+
// because parent has either fillMaxSize (matchContents = false) or requiredSize (matchContents = true) modifiers
|
|
181
|
+
setMeasuredDimension(
|
|
182
|
+
MeasureSpec.getSize(widthMeasureSpec),
|
|
183
|
+
MeasureSpec.getSize(heightMeasureSpec)
|
|
184
|
+
)
|
|
185
|
+
}
|
|
77
186
|
|
|
78
187
|
override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
188
|
+
// No-op: don't re-layout children. Yoga calls child.layout() directly
|
|
189
|
+
// and we must not override those values.
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {
|
|
193
|
+
eventDispatcher?.let { dispatcher ->
|
|
194
|
+
jsTouchDispatcher.handleTouchEvent(event, dispatcher, reactContext)
|
|
195
|
+
jsPointerDispatcher?.handleMotionEvent(event, dispatcher, true)
|
|
196
|
+
}
|
|
197
|
+
return super.onInterceptTouchEvent(event)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
@SuppressLint("ClickableViewAccessibility")
|
|
201
|
+
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
202
|
+
eventDispatcher?.let { dispatcher ->
|
|
203
|
+
jsTouchDispatcher.handleTouchEvent(event, dispatcher, reactContext)
|
|
204
|
+
jsPointerDispatcher?.handleMotionEvent(event, dispatcher, false)
|
|
85
205
|
}
|
|
206
|
+
super.onTouchEvent(event)
|
|
207
|
+
return true
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
override fun onInterceptHoverEvent(event: MotionEvent): Boolean {
|
|
211
|
+
eventDispatcher?.let { jsPointerDispatcher?.handleMotionEvent(event, it, true) }
|
|
212
|
+
return super.onInterceptHoverEvent(event)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
override fun onHoverEvent(event: MotionEvent): Boolean {
|
|
216
|
+
eventDispatcher?.let { jsPointerDispatcher?.handleMotionEvent(event, it, false) }
|
|
217
|
+
return super.onHoverEvent(event)
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@OptIn(UnstableReactNativeAPI::class)
|
|
221
|
+
override fun onChildStartedNativeGesture(childView: View?, ev: MotionEvent) {
|
|
222
|
+
eventDispatcher?.let { dispatcher ->
|
|
223
|
+
jsTouchDispatcher.onChildStartedNativeGesture(ev, dispatcher, reactContext)
|
|
224
|
+
jsPointerDispatcher?.onChildStartedNativeGesture(childView, ev, dispatcher)
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
override fun onChildEndedNativeGesture(childView: View, ev: MotionEvent) {
|
|
229
|
+
eventDispatcher?.let { jsTouchDispatcher.onChildEndedNativeGesture(ev, it) }
|
|
230
|
+
jsPointerDispatcher?.onChildEndedNativeGesture()
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
override fun requestDisallowInterceptTouchEvent(disallowIntercept: Boolean) {
|
|
234
|
+
// No-op - override to still receive events in onInterceptTouchEvent
|
|
235
|
+
// even when a child view disallows interception
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
override fun handleException(t: Throwable) {
|
|
239
|
+
reactContext.reactApplicationContext.handleException(RuntimeException(t))
|
|
86
240
|
}
|
|
87
241
|
}
|
|
@@ -7,22 +7,18 @@ import expo.modules.kotlin.views.FunctionalComposableScope
|
|
|
7
7
|
|
|
8
8
|
data class RadioButtonProps(
|
|
9
9
|
val selected: Boolean = false,
|
|
10
|
-
val
|
|
10
|
+
val clickable: Boolean = true,
|
|
11
11
|
val modifiers: ModifierList = emptyList()
|
|
12
12
|
) : ComposeProps
|
|
13
13
|
|
|
14
14
|
@Composable
|
|
15
15
|
fun FunctionalComposableScope.RadioButtonContent(
|
|
16
16
|
props: RadioButtonProps,
|
|
17
|
-
|
|
17
|
+
onClick: (() -> Unit)?
|
|
18
18
|
) {
|
|
19
19
|
RadioButton(
|
|
20
20
|
selected = props.selected,
|
|
21
|
-
onClick =
|
|
22
|
-
{ onNativeClick() }
|
|
23
|
-
} else {
|
|
24
|
-
null
|
|
25
|
-
},
|
|
21
|
+
onClick = onClick,
|
|
26
22
|
modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
27
23
|
)
|
|
28
24
|
}
|