@expo/ui 58.0.22 → 58.0.24
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 +28 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/ui/ComposeViews.kt +53 -29
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +6 -4
- package/android/src/main/java/expo/modules/ui/HostView.kt +85 -15
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +40 -12
- package/android/src/main/java/expo/modules/ui/RNHostView.kt +138 -2
- package/android/src/main/java/expo/modules/ui/SliderView.kt +5 -4
- package/android/src/main/java/expo/modules/ui/UniversalLayout.kt +610 -0
- package/android/src/main/java/expo/modules/ui/VerticalSliderView.kt +5 -4
- package/android/src/main/java/expo/modules/ui/state/ObservableState.kt +2 -0
- package/android/src/main/java/expo/modules/ui/state/WorkletCallback.kt +2 -0
- package/build/community/bottom-sheet/BottomSheet.android.js +2 -0
- package/build/community/bottom-sheet/BottomSheet.android.js.map +1 -1
- package/build/community/menu/MenuView.ios.js +2 -1
- package/build/community/menu/MenuView.ios.js.map +1 -1
- package/build/jetpack-compose/Column/index.d.ts +5 -0
- package/build/jetpack-compose/Column/index.js.map +1 -1
- package/build/jetpack-compose/Row/index.d.ts +5 -0
- package/build/jetpack-compose/Row/index.js.map +1 -1
- package/build/jetpack-compose/Text/index.js +5 -4
- package/build/jetpack-compose/Text/index.js.map +1 -1
- package/build/recycling/useRecycledRows.d.ts +2 -0
- package/build/recycling/useRecycledRows.js +1 -0
- package/build/recycling/useRecycledRows.js.map +1 -1
- package/build/swift-ui/ContentUnavailableView/index.d.ts +5 -0
- package/build/swift-ui/ContentUnavailableView/index.js +7 -2
- package/build/swift-ui/ContentUnavailableView/index.js.map +1 -1
- package/build/swift-ui/HStack/index.d.ts +6 -0
- package/build/swift-ui/HStack/index.js.map +1 -1
- package/build/swift-ui/RNHostView.d.ts +7 -1
- package/build/swift-ui/RNHostView.js +2 -1
- package/build/swift-ui/RNHostView.js.map +1 -1
- package/build/swift-ui/Text/index.js +2 -1
- package/build/swift-ui/Text/index.js.map +1 -1
- package/build/swift-ui/VStack/index.d.ts +6 -0
- package/build/swift-ui/VStack/index.js.map +1 -1
- package/build/swift-ui/modifiers/index.d.ts +18 -0
- package/build/swift-ui/modifiers/index.js +9 -0
- package/build/swift-ui/modifiers/index.js.map +1 -1
- package/build/universal/BottomSheet/index.android.js +5 -5
- package/build/universal/BottomSheet/index.android.js.map +1 -1
- package/build/universal/Button/index.android.js +3 -1
- package/build/universal/Button/index.android.js.map +1 -1
- package/build/universal/Button/index.ios.js +3 -1
- package/build/universal/Button/index.ios.js.map +1 -1
- package/build/universal/Collapsible/index.ios.js +1 -0
- package/build/universal/Collapsible/index.ios.js.map +1 -1
- package/build/universal/Column/index.android.js +4 -1
- package/build/universal/Column/index.android.js.map +1 -1
- package/build/universal/Column/index.ios.js +2 -0
- package/build/universal/Column/index.ios.js.map +1 -1
- package/build/universal/Column/index.js +13 -4
- package/build/universal/Column/index.js.map +1 -1
- package/build/universal/FieldGroup/FieldGroup.android.js +3 -1
- package/build/universal/FieldGroup/FieldGroup.android.js.map +1 -1
- package/build/universal/FieldGroup/FieldGroup.ios.js +3 -1
- package/build/universal/FieldGroup/FieldGroup.ios.js.map +1 -1
- package/build/universal/FieldGroup/FieldSection.android.js +13 -4
- package/build/universal/FieldGroup/FieldSection.android.js.map +1 -1
- package/build/universal/FieldGroup/FieldSection.ios.js +3 -1
- package/build/universal/FieldGroup/FieldSection.ios.js.map +1 -1
- package/build/universal/Icon/index.android.js +3 -1
- package/build/universal/Icon/index.android.js.map +1 -1
- package/build/universal/Icon/index.ios.js +3 -1
- package/build/universal/Icon/index.ios.js.map +1 -1
- package/build/universal/List/ListForEach.android.d.ts +7 -0
- package/build/universal/List/ListForEach.android.js +6 -0
- package/build/universal/List/ListForEach.android.js.map +1 -0
- package/build/universal/List/ListForEach.d.ts +5 -0
- package/build/universal/List/ListForEach.ios.d.ts +5 -0
- package/build/universal/List/ListForEach.ios.js +11 -0
- package/build/universal/List/ListForEach.ios.js.map +1 -0
- package/build/universal/List/ListForEach.js +263 -0
- package/build/universal/List/ListForEach.js.map +1 -0
- package/build/universal/List/ListScrollContext.d.ts +5 -0
- package/build/universal/List/ListScrollContext.js +6 -0
- package/build/universal/List/ListScrollContext.js.map +1 -0
- package/build/universal/List/index.android.d.ts +5 -0
- package/build/universal/List/index.android.js +3 -0
- package/build/universal/List/index.android.js.map +1 -1
- package/build/universal/List/index.d.ts +5 -0
- package/build/universal/List/index.ios.d.ts +5 -0
- package/build/universal/List/index.ios.js +3 -0
- package/build/universal/List/index.ios.js.map +1 -1
- package/build/universal/List/index.js +12 -1
- package/build/universal/List/index.js.map +1 -1
- package/build/universal/List/types.d.ts +42 -1
- package/build/universal/List/types.js +1 -3
- package/build/universal/List/types.js.map +1 -1
- package/build/universal/RNHostView/index.android.js +3 -1
- package/build/universal/RNHostView/index.android.js.map +1 -1
- package/build/universal/Row/index.android.js +4 -1
- package/build/universal/Row/index.android.js.map +1 -1
- package/build/universal/Row/index.ios.js +2 -0
- package/build/universal/Row/index.ios.js.map +1 -1
- package/build/universal/Row/index.js +13 -7
- package/build/universal/Row/index.js.map +1 -1
- package/build/universal/ScrollView/index.android.js +8 -1
- package/build/universal/ScrollView/index.android.js.map +1 -1
- package/build/universal/ScrollView/index.ios.js +3 -1
- package/build/universal/ScrollView/index.ios.js.map +1 -1
- package/build/universal/Spacer/index.android.js +3 -1
- package/build/universal/Spacer/index.android.js.map +1 -1
- package/build/universal/Spacer/index.ios.js +3 -1
- package/build/universal/Spacer/index.ios.js.map +1 -1
- package/build/universal/Text/index.android.js +3 -1
- package/build/universal/Text/index.android.js.map +1 -1
- package/build/universal/Text/index.ios.js +3 -1
- package/build/universal/Text/index.ios.js.map +1 -1
- package/build/universal/TextInput/index.android.js +22 -7
- package/build/universal/TextInput/index.android.js.map +1 -1
- package/build/universal/TextInput/index.ios.js +1 -0
- package/build/universal/TextInput/index.ios.js.map +1 -1
- package/build/universal/index.d.ts +1 -1
- package/build/universal/modifierUtils.d.ts +34 -1
- package/build/universal/modifierUtils.js +98 -2
- package/build/universal/modifierUtils.js.map +1 -1
- package/build/universal/stackAxis.d.ts +9 -0
- package/build/universal/stackAxis.js +11 -0
- package/build/universal/stackAxis.js.map +1 -0
- package/build/universal/transformStyle.android.d.ts +6 -2
- package/build/universal/transformStyle.android.js +18 -11
- package/build/universal/transformStyle.android.js.map +1 -1
- package/build/universal/transformStyle.ios.d.ts +5 -1
- package/build/universal/transformStyle.ios.js +29 -11
- package/build/universal/transformStyle.ios.js.map +1 -1
- package/build/universal/types.d.ts +26 -1
- package/build/universal/types.js.map +1 -1
- package/build/utils/flattenFragments.d.ts +7 -0
- package/build/utils/flattenFragments.js +17 -0
- package/build/utils/flattenFragments.js.map +1 -0
- package/ios/ContentUnavailableView.swift +9 -1
- package/ios/GroupView.swift +3 -0
- package/ios/HStackView.swift +26 -2
- package/ios/HostView.swift +21 -12
- package/ios/Modifiers/FontModifier.swift +27 -0
- package/ios/Modifiers/SectionIndexLabelModifier.swift +21 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +26 -0
- package/ios/RNHostView.swift +4 -0
- package/ios/ScrollViewComponent.swift +20 -0
- package/ios/UIBaseView.swift +4 -1
- package/ios/UniversalLayout.swift +691 -0
- package/ios/VStackView.swift +26 -2
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22-sources.jar → 58.0.24/expo.modules.ui-58.0.24-sources.jar} +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.aar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.module → 58.0.24/expo.modules.ui-58.0.24.module} +22 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.module.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.pom → 58.0.24/expo.modules.ui-58.0.24.pom} +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.24/expo.modules.ui-58.0.24.pom.sha512 +1 -0
- package/package.json +1 -1
- package/src/community/bottom-sheet/BottomSheet.android.tsx +2 -1
- package/src/community/menu/MenuView.ios.tsx +3 -2
- package/src/jetpack-compose/Column/index.tsx +5 -0
- package/src/jetpack-compose/Row/index.tsx +5 -0
- package/src/jetpack-compose/Text/index.tsx +5 -4
- package/src/recycling/useRecycledRows.tsx +3 -0
- package/src/swift-ui/ContentUnavailableView/index.tsx +19 -4
- package/src/swift-ui/HStack/index.tsx +6 -0
- package/src/swift-ui/RNHostView.tsx +8 -1
- package/src/swift-ui/Text/index.tsx +2 -1
- package/src/swift-ui/VStack/index.tsx +6 -0
- package/src/swift-ui/modifiers/index.ts +19 -0
- package/src/universal/BottomSheet/index.android.tsx +3 -1
- package/src/universal/Button/index.android.tsx +3 -1
- package/src/universal/Button/index.ios.tsx +2 -1
- package/src/universal/Collapsible/index.ios.tsx +4 -1
- package/src/universal/Column/index.android.tsx +3 -1
- package/src/universal/Column/index.ios.tsx +2 -1
- package/src/universal/Column/index.tsx +9 -4
- package/src/universal/FieldGroup/FieldGroup.android.tsx +8 -1
- package/src/universal/FieldGroup/FieldGroup.ios.tsx +2 -1
- package/src/universal/FieldGroup/FieldSection.android.tsx +17 -4
- package/src/universal/FieldGroup/FieldSection.ios.tsx +2 -1
- package/src/universal/Icon/index.android.tsx +2 -1
- package/src/universal/Icon/index.ios.tsx +2 -1
- package/src/universal/List/ListForEach.android.tsx +6 -0
- package/src/universal/List/ListForEach.ios.tsx +9 -0
- package/src/universal/List/ListForEach.tsx +246 -0
- package/src/universal/List/ListScrollContext.ts +6 -0
- package/src/universal/List/index.android.tsx +5 -0
- package/src/universal/List/index.ios.tsx +5 -0
- package/src/universal/List/index.tsx +11 -2
- package/src/universal/List/types.ts +45 -1
- package/src/universal/RNHostView/index.android.tsx +2 -1
- package/src/universal/Row/index.android.tsx +3 -1
- package/src/universal/Row/index.ios.tsx +2 -1
- package/src/universal/Row/index.tsx +9 -10
- package/src/universal/ScrollView/index.android.tsx +15 -3
- package/src/universal/ScrollView/index.ios.tsx +2 -1
- package/src/universal/Spacer/index.android.tsx +6 -4
- package/src/universal/Spacer/index.ios.tsx +2 -1
- package/src/universal/Text/index.android.tsx +2 -1
- package/src/universal/Text/index.ios.tsx +2 -1
- package/src/universal/TextInput/index.android.tsx +26 -5
- package/src/universal/TextInput/index.ios.tsx +1 -1
- package/src/universal/index.ts +6 -1
- package/src/universal/modifierUtils.ts +159 -2
- package/src/universal/stackAxis.ts +17 -0
- package/src/universal/transformStyle.android.ts +30 -12
- package/src/universal/transformStyle.ios.ts +41 -13
- package/src/universal/types.ts +27 -3
- package/src/utils/flattenFragments.ts +22 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha512 +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 58.0.24
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [Android] Fix a crash when dragging `Slider` or `VerticalSlider` in release builds. Their `onValueChange` and `onValueChangeFinished` events are now declared with `Event<T>()` in the view definition, as `ToggleButton` and `TextField` already do. ([#52278](https://github.com/expo/expo/pull/52278) by [@github-actions](https://github.com/apps/github-actions))
|
|
8
|
+
- [Android] Fix the Jetpack Compose `Text` dropping nested `Text` spans and strings that are inside a React fragment. Move the fragment flattening helper to a shared util used by both the SwiftUI and Jetpack Compose `Text`. ([#52227](https://github.com/expo/expo/pull/52227) by [@expo-tuft](https://github.com/apps/expo-tuft))
|
|
9
|
+
- [iOS] Add an `actions` prop to `ContentUnavailableView`, which shows controls below the description. ([#52190](https://github.com/expo/expo/pull/52190) by [@drewvolz](https://github.com/drewvolz))
|
|
10
|
+
- [iOS] Add `smallCaps` and `leading` options to the `font` modifier, which apply SwiftUI's `Font.smallCaps()` and `Font.leading(_:)`. ([#52189](https://github.com/expo/expo/pull/52189) by [@drewvolz](https://github.com/drewvolz))
|
|
11
|
+
- [Android] Fix an `@expo/ui` control inside a `Pressable` losing taps to the `Pressable`. ([#52278](https://github.com/expo/expo/pull/52278) by [@github-actions](https://github.com/apps/github-actions))
|
|
12
|
+
- [iOS] Apply the `underline` and `strikethrough` modifiers to a nested `Text`. Before, a nested `Text` dropped them, and a debug build showed a "not supported for nested Text" warning. ([#52112](https://github.com/expo/expo/pull/52112) by [@drewvolz](https://github.com/drewvolz))
|
|
13
|
+
- [iOS] Fix the SwiftUI `Text` dropping nested `Text` spans and strings that are inside a React fragment. `Text` now flattens fragment children before it concatenates them. ([#52225](https://github.com/expo/expo/pull/52225) by [@expo-bot](https://github.com/expo-bot))
|
|
14
|
+
- [iOS] Fix `MenuView` triggers that fill their parent, so text in them wraps and they resize on rotation. ([#52278](https://github.com/expo/expo/pull/52278) by [@github-actions](https://github.com/apps/github-actions))
|
|
15
|
+
- [Android] Fix a tap on plain React Native content in `RNHostView` not reaching a parent Compose `clickable`. ([#52278](https://github.com/expo/expo/pull/52278) by [@github-actions](https://github.com/apps/github-actions))
|
|
16
|
+
- [iOS] Add the `sectionIndexLabel` modifier, which sets the label a list's section index shows for a `Section` on iOS 26 and later. ([#52186](https://github.com/expo/expo/pull/52186) by [@drewvolz](https://github.com/drewvolz))
|
|
17
|
+
- [Android] Fix the universal `BottomSheet` and the community `BottomSheet` / `BottomSheetModal` not opening inside a `FlatList` (or another view with `removeClippedSubviews`). ([#52278](https://github.com/expo/expo/pull/52278) by [@github-actions](https://github.com/apps/github-actions))
|
|
18
|
+
|
|
19
|
+
## 58.0.23
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [Android] Fix "Cannot use shared object that was already released" errors when a view with a shared object prop, such as the `@expo/ui` `TextInput`, is remounted right after its first render. ([#51934](https://github.com/expo/expo/pull/51934) by [@expo-tuft](https://github.com/apps/expo-tuft))
|
|
24
|
+
- Universal `Row` and `Column` on Android resolve a child `width` or `height` percentage, such as `'50%'`, against their own size. ([#51118](https://github.com/expo/expo/pull/51118) by [@Kudo](https://github.com/Kudo))
|
|
25
|
+
- Universal `Row` and `Column` on iOS resolve a child `width` or `height` percentage, such as `'50%'`, against their own size. The default `spacing` of a universal `Row` or `Column` on iOS is now `0`, as on Android and web. ([#51119](https://github.com/expo/expo/pull/51119) by [@Kudo](https://github.com/Kudo))
|
|
26
|
+
- Add `List.ForEach` to the universal `List`. It renders rows from `data` and recycles them on Android, iOS, and web. The web `List` now fills its parent, so it scrolls. ([#52047](https://github.com/expo/expo/pull/52047) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
|
|
27
|
+
- Universal `style.width` and `style.height` accept a percentage of the parent, such as `'50%'`. ([#51117](https://github.com/expo/expo/pull/51117) by [@Kudo](https://github.com/Kudo))
|
|
28
|
+
- On web, a universal `Row` or `Column` with a size on its parent's cross axis no longer stretches, so the parent's alignment can place it. ([#51120](https://github.com/expo/expo/pull/51120) by [@Kudo](https://github.com/Kudo))
|
|
29
|
+
- [Android] Fixed `TextInput` with `secureTextEntry` showing the typed password in the keyboard's suggestion strip. A secure field now asks the keyboard for a password layout and turns off autocorrect. ([#52010](https://github.com/expo/expo/pull/52010) by [@enzomanuelmangano](https://github.com/enzomanuelmangano))
|
|
30
|
+
|
|
3
31
|
## 58.0.22
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/android/build.gradle
CHANGED
|
@@ -12,13 +12,13 @@ apply plugin: 'expo-module-gradle-plugin'
|
|
|
12
12
|
apply plugin: 'org.jetbrains.kotlin.plugin.compose'
|
|
13
13
|
|
|
14
14
|
group = 'expo.modules.ui'
|
|
15
|
-
version = '58.0.
|
|
15
|
+
version = '58.0.24'
|
|
16
16
|
|
|
17
17
|
android {
|
|
18
18
|
namespace "expo.modules.ui"
|
|
19
19
|
defaultConfig {
|
|
20
20
|
versionCode 1
|
|
21
|
-
versionName "58.0.
|
|
21
|
+
versionName "58.0.24"
|
|
22
22
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
23
23
|
}
|
|
24
24
|
buildFeatures {
|
|
@@ -50,7 +50,9 @@ data class LayoutProps(
|
|
|
50
50
|
val verticalAlignment: VerticalAlignment? = null,
|
|
51
51
|
val contentAlignment: ContentAlignment? = null,
|
|
52
52
|
val floatingToolbarExitAlwaysScrollBehavior: FloatingToolbarExitAlwaysScrollBehavior? = null,
|
|
53
|
-
val modifiers: ModifierList = emptyList()
|
|
53
|
+
val modifiers: ModifierList = emptyList(),
|
|
54
|
+
// Universal `Row` and `Column` set this. Compose `Row` and `Column` leave it false.
|
|
55
|
+
val resolvesChildPercentages: Boolean = false
|
|
54
56
|
) : ComposeProps
|
|
55
57
|
|
|
56
58
|
@Composable
|
|
@@ -60,20 +62,31 @@ internal fun FunctionalComposableScope.RowContent(props: LayoutProps) {
|
|
|
60
62
|
?.let {
|
|
61
63
|
FloatingToolbarDefaults.exitAlwaysScrollBehavior(exitDirection = it)
|
|
62
64
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
)
|
|
75
|
-
|
|
76
|
-
|
|
65
|
+
val modifier = ModifierRegistry
|
|
66
|
+
.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
67
|
+
.then(
|
|
68
|
+
if (scrollBehavior != null) {
|
|
69
|
+
Modifier.nestedScroll(scrollBehavior)
|
|
70
|
+
} else {
|
|
71
|
+
Modifier
|
|
72
|
+
}
|
|
73
|
+
)
|
|
74
|
+
if (props.resolvesChildPercentages) {
|
|
75
|
+
UniversalRow(
|
|
76
|
+
horizontalArrangement = props.horizontalArrangement?.toComposeArrangement() ?: Arrangement.Start,
|
|
77
|
+
verticalAlignment = props.verticalAlignment?.toComposeAlignment() ?: Alignment.Top,
|
|
78
|
+
modifier = modifier
|
|
79
|
+
) {
|
|
80
|
+
Children(UIComposableScope(nestedScrollConnection = scrollBehavior))
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
Row(
|
|
84
|
+
horizontalArrangement = props.horizontalArrangement?.toComposeArrangement() ?: Arrangement.Start,
|
|
85
|
+
verticalAlignment = props.verticalAlignment?.toComposeAlignment() ?: Alignment.Top,
|
|
86
|
+
modifier = modifier
|
|
87
|
+
) {
|
|
88
|
+
Children(UIComposableScope(rowScope = this@Row, nestedScrollConnection = scrollBehavior))
|
|
89
|
+
}
|
|
77
90
|
}
|
|
78
91
|
}
|
|
79
92
|
|
|
@@ -96,20 +109,31 @@ internal fun FunctionalComposableScope.ColumnContent(props: LayoutProps) {
|
|
|
96
109
|
?.let {
|
|
97
110
|
FloatingToolbarDefaults.exitAlwaysScrollBehavior(exitDirection = it)
|
|
98
111
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
val modifier = ModifierRegistry
|
|
113
|
+
.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
|
|
114
|
+
.then(
|
|
115
|
+
if (scrollBehavior != null) {
|
|
116
|
+
Modifier.nestedScroll(scrollBehavior)
|
|
117
|
+
} else {
|
|
118
|
+
Modifier
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
if (props.resolvesChildPercentages) {
|
|
122
|
+
UniversalColumn(
|
|
123
|
+
verticalArrangement = props.verticalArrangement?.toComposeArrangement() ?: Arrangement.Top,
|
|
124
|
+
horizontalAlignment = props.horizontalAlignment?.toComposeAlignment() ?: Alignment.Start,
|
|
125
|
+
modifier = modifier
|
|
126
|
+
) {
|
|
127
|
+
Children(UIComposableScope(nestedScrollConnection = scrollBehavior))
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
Column(
|
|
131
|
+
verticalArrangement = props.verticalArrangement?.toComposeArrangement() ?: Arrangement.Top,
|
|
132
|
+
horizontalAlignment = props.horizontalAlignment?.toComposeAlignment() ?: Alignment.Start,
|
|
133
|
+
modifier = modifier
|
|
134
|
+
) {
|
|
135
|
+
Children(UIComposableScope(columnScope = this@Column, nestedScrollConnection = scrollBehavior))
|
|
136
|
+
}
|
|
113
137
|
}
|
|
114
138
|
}
|
|
115
139
|
|
|
@@ -359,18 +359,20 @@ class ExpoUIModule : Module() {
|
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
ExpoUIView<SliderProps>("SliderView") {
|
|
362
|
-
|
|
362
|
+
val onValueChange by Event<SliderValueChangedEvent>()
|
|
363
|
+
val onValueChangeFinished by Event<Unit>()
|
|
363
364
|
|
|
364
365
|
Content { props ->
|
|
365
|
-
SliderContent(props)
|
|
366
|
+
SliderContent(props, { onValueChange(it) }, { onValueChangeFinished(it) })
|
|
366
367
|
}
|
|
367
368
|
}
|
|
368
369
|
|
|
369
370
|
ExpoUIView<VerticalSliderProps>("VerticalSliderView") {
|
|
370
|
-
|
|
371
|
+
val onValueChange by Event<SliderValueChangedEvent>()
|
|
372
|
+
val onValueChangeFinished by Event<Unit>()
|
|
371
373
|
|
|
372
374
|
Content { props ->
|
|
373
|
-
VerticalSliderContent(props)
|
|
375
|
+
VerticalSliderContent(props, { onValueChange(it) }, { onValueChangeFinished(it) })
|
|
374
376
|
}
|
|
375
377
|
}
|
|
376
378
|
|
|
@@ -40,6 +40,7 @@ import androidx.compose.ui.unit.Density
|
|
|
40
40
|
import androidx.compose.ui.unit.IntSize
|
|
41
41
|
import androidx.compose.ui.unit.LayoutDirection
|
|
42
42
|
import androidx.compose.ui.unit.dp
|
|
43
|
+
import com.facebook.react.uimanager.events.NativeGestureUtil
|
|
43
44
|
import expo.modules.kotlin.AppContext
|
|
44
45
|
import expo.modules.kotlin.records.Field
|
|
45
46
|
import expo.modules.kotlin.records.Record
|
|
@@ -123,6 +124,11 @@ internal class HostView(context: Context, appContext: AppContext) :
|
|
|
123
124
|
private val onLayoutContent by EventDispatcher<LayoutContentEvent>()
|
|
124
125
|
private var lastDispatchedContentSize: IntSize? = null
|
|
125
126
|
|
|
127
|
+
// The size a child fraction was resolved against, in dp.
|
|
128
|
+
// matchContents would otherwise publish the percentage result and the next pass divides it again.
|
|
129
|
+
private var percentageBaseWidthDp: Double? = null
|
|
130
|
+
private var percentageBaseHeightDp: Double? = null
|
|
131
|
+
|
|
126
132
|
/**
|
|
127
133
|
* True while this view passes down an `ACTION_CANCEL` that came from its React Native parent,
|
|
128
134
|
* not from a Compose gesture detector. React Native already owns that gesture: the usual cause is
|
|
@@ -131,16 +137,41 @@ internal class HostView(context: Context, appContext: AppContext) :
|
|
|
131
137
|
internal var isDispatchingCancelFromParent = false
|
|
132
138
|
private set
|
|
133
139
|
|
|
140
|
+
// Set by a hosted `RNHostView` under the down. That content handles its touches in JS.
|
|
141
|
+
internal var reactNativeContentHit = false
|
|
142
|
+
private var ownsNativeGesture = false
|
|
143
|
+
|
|
134
144
|
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
|
135
|
-
if (ev.actionMasked
|
|
136
|
-
|
|
145
|
+
if (ev.actionMasked == MotionEvent.ACTION_DOWN) {
|
|
146
|
+
reactNativeContentHit = false
|
|
147
|
+
ownsNativeGesture = false
|
|
137
148
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
isDispatchingCancelFromParent =
|
|
149
|
+
|
|
150
|
+
val handled = if (ev.actionMasked != MotionEvent.ACTION_CANCEL) {
|
|
151
|
+
super.dispatchTouchEvent(ev)
|
|
152
|
+
} else {
|
|
153
|
+
isDispatchingCancelFromParent = true
|
|
154
|
+
try {
|
|
155
|
+
super.dispatchTouchEvent(ev)
|
|
156
|
+
} finally {
|
|
157
|
+
isDispatchingCancelFromParent = false
|
|
158
|
+
}
|
|
143
159
|
}
|
|
160
|
+
|
|
161
|
+
when (ev.actionMasked) {
|
|
162
|
+
// Compose only handles a down that a touch handler is under, like a native view.
|
|
163
|
+
// Then cancel the JS touch, so a JS responder around this view can't take the gesture.
|
|
164
|
+
MotionEvent.ACTION_DOWN -> if (handled && !reactNativeContentHit) {
|
|
165
|
+
ownsNativeGesture = true
|
|
166
|
+
NativeGestureUtil.notifyNativeGestureStarted(this, ev)
|
|
167
|
+
}
|
|
168
|
+
// On a cancel, a native parent like a scroll view took over and ends the gesture itself.
|
|
169
|
+
MotionEvent.ACTION_UP -> if (ownsNativeGesture) {
|
|
170
|
+
ownsNativeGesture = false
|
|
171
|
+
NativeGestureUtil.notifyNativeGestureEnded(this, ev)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return handled
|
|
144
175
|
}
|
|
145
176
|
|
|
146
177
|
@Composable
|
|
@@ -240,15 +271,54 @@ internal class HostView(context: Context, appContext: AppContext) :
|
|
|
240
271
|
constraints.maxHeight
|
|
241
272
|
}
|
|
242
273
|
)
|
|
243
|
-
|
|
274
|
+
// `measure` does not read a child percentage, so apply it here when this host
|
|
275
|
+
// has a size on that axis. A child with no percentage keeps these constraints.
|
|
276
|
+
// Compose Row and Column do not read that percentage.
|
|
277
|
+
val definiteWidth = boundedConstraints.maxWidth.takeIf {
|
|
278
|
+
it != Constraints.Infinity && (boundedConstraints.minWidth == it || useViewportSizeMeasurement)
|
|
279
|
+
}
|
|
280
|
+
val definiteHeight = boundedConstraints.maxHeight.takeIf {
|
|
281
|
+
it != Constraints.Infinity && (boundedConstraints.minHeight == it || useViewportSizeMeasurement)
|
|
282
|
+
}
|
|
283
|
+
val placeables = measurables.map {
|
|
284
|
+
measureUniversalChild(it, boundedConstraints, definiteWidth, definiteHeight)
|
|
285
|
+
}
|
|
244
286
|
|
|
245
287
|
val contentWidthPx = placeables.maxOfOrNull { it.width } ?: 0
|
|
246
288
|
val contentHeightPx = placeables.maxOfOrNull { it.height } ?: 0
|
|
289
|
+
// A child percentage is a fraction of the safe area proposed above.
|
|
290
|
+
// Publishing that result as the view size makes the next pass resolve it again.
|
|
291
|
+
val widthFromPercentage = definiteWidth != null && measurables.any {
|
|
292
|
+
it.parentData.asUniversalLayoutParentData().dimensions.widthFraction != null
|
|
293
|
+
}
|
|
294
|
+
val heightFromPercentage = definiteHeight != null && measurables.any {
|
|
295
|
+
it.parentData.asUniversalLayoutParentData().dimensions.heightFraction != null
|
|
296
|
+
}
|
|
297
|
+
// setStyleSize replaces the pending setViewSize flush.
|
|
298
|
+
// Publish this base for a viewport fraction so both updates describe the same size.
|
|
299
|
+
percentageBaseWidthDp = if (useViewportSizeMeasurement && widthFromPercentage && definiteWidth != null) {
|
|
300
|
+
with(density) { definiteWidth.toDp().value.toDouble() }
|
|
301
|
+
} else {
|
|
302
|
+
null
|
|
303
|
+
}
|
|
304
|
+
percentageBaseHeightDp = if (useViewportSizeMeasurement && heightFromPercentage && definiteHeight != null) {
|
|
305
|
+
with(density) { definiteHeight.toDp().value.toDouble() }
|
|
306
|
+
} else {
|
|
307
|
+
null
|
|
308
|
+
}
|
|
247
309
|
|
|
248
310
|
if (useViewportSizeMeasurement && (constraints.maxWidth == 0 || constraints.maxHeight == 0)) {
|
|
249
311
|
with(density) {
|
|
250
|
-
val widthDp =
|
|
251
|
-
|
|
312
|
+
val widthDp = if (widthFromPercentage) {
|
|
313
|
+
safeWidthPx.toDp().value.toDouble()
|
|
314
|
+
} else {
|
|
315
|
+
contentWidthPx.toDp().value.toDouble()
|
|
316
|
+
}
|
|
317
|
+
val heightDp = if (heightFromPercentage) {
|
|
318
|
+
safeHeightPx.toDp().value.toDouble()
|
|
319
|
+
} else {
|
|
320
|
+
contentHeightPx.toDp().value.toDouble()
|
|
321
|
+
}
|
|
252
322
|
|
|
253
323
|
shadowNodeProxy.setViewSize(
|
|
254
324
|
if (constraints.maxWidth == 0) {
|
|
@@ -287,17 +357,17 @@ internal class HostView(context: Context, appContext: AppContext) :
|
|
|
287
357
|
val height = size.height.toDp().value
|
|
288
358
|
|
|
289
359
|
if (matchContentsHorizontal == true || matchContentsVertical == true) {
|
|
290
|
-
val styleWidth = if (matchContentsHorizontal == true
|
|
291
|
-
width
|
|
360
|
+
val styleWidth = if (matchContentsHorizontal == true) {
|
|
361
|
+
percentageBaseWidthDp ?: width.takeIf { it > 0 }?.toDouble()
|
|
292
362
|
} else {
|
|
293
363
|
null
|
|
294
364
|
}
|
|
295
|
-
val styleHeight = if (matchContentsVertical == true
|
|
296
|
-
height
|
|
365
|
+
val styleHeight = if (matchContentsVertical == true) {
|
|
366
|
+
percentageBaseHeightDp ?: height.takeIf { it > 0 }?.toDouble()
|
|
297
367
|
} else {
|
|
298
368
|
null
|
|
299
369
|
}
|
|
300
|
-
shadowNodeProxy.setStyleSize(styleWidth
|
|
370
|
+
shadowNodeProxy.setStyleSize(styleWidth, styleHeight)
|
|
301
371
|
}
|
|
302
372
|
|
|
303
373
|
// `onSizeChanged` runs inside the Compose measure pass. Emitting the event here reaches
|
|
@@ -506,6 +506,11 @@ object ModifierRegistry {
|
|
|
506
506
|
Modifier.height(params.height.dp)
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
+
register("universalLayout") { map, _, appContext, _ ->
|
|
510
|
+
val params = recordFromMap<UniversalLayoutParams>(map, appContext)
|
|
511
|
+
UniversalLayoutElement(params.toDimensions())
|
|
512
|
+
}
|
|
513
|
+
|
|
509
514
|
register("defaultMinSize") { map, _, appContext, _ ->
|
|
510
515
|
val params = recordFromMap<DefaultMinSizeParams>(map, appContext)
|
|
511
516
|
Modifier.defaultMinSize(
|
|
@@ -674,22 +679,45 @@ object ModifierRegistry {
|
|
|
674
679
|
// Scope-dependent modifiers
|
|
675
680
|
register("weight") { map, scope, appContext, _ ->
|
|
676
681
|
val params = recordFromMap<WeightParams>(map, appContext)
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
+
val weight = params.weight.takeIf { it.isFinite() && it > 0f }
|
|
683
|
+
// Prefer row, column, or box scope.
|
|
684
|
+
// Those parents ignore universal parent data, and Box has no weight.
|
|
685
|
+
when {
|
|
686
|
+
scope?.rowScope != null || scope?.columnScope != null ->
|
|
687
|
+
scope?.rowScope?.run {
|
|
688
|
+
weight?.let { Modifier.weight(it) }
|
|
689
|
+
} ?: scope?.columnScope?.run {
|
|
690
|
+
weight?.let { Modifier.weight(it) }
|
|
691
|
+
} ?: Modifier
|
|
692
|
+
scope?.boxScope != null -> Modifier
|
|
693
|
+
LocalUniversalStackAxis.current == UniversalStackAxis.Horizontal ||
|
|
694
|
+
LocalUniversalStackAxis.current == UniversalStackAxis.Vertical ->
|
|
695
|
+
weight?.let { UniversalWeightElement(it) } ?: Modifier
|
|
696
|
+
else -> Modifier
|
|
697
|
+
}
|
|
682
698
|
}
|
|
683
699
|
|
|
684
700
|
register("align") { map, scope, appContext, _ ->
|
|
685
701
|
val params = recordFromMap<AlignParams>(map, appContext)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
702
|
+
when {
|
|
703
|
+
scope?.boxScope != null ->
|
|
704
|
+
scope?.boxScope?.run {
|
|
705
|
+
params.alignment?.toAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
706
|
+
} ?: Modifier
|
|
707
|
+
scope?.rowScope != null ->
|
|
708
|
+
scope?.rowScope?.run {
|
|
709
|
+
params.alignment?.toVerticalAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
710
|
+
} ?: Modifier
|
|
711
|
+
scope?.columnScope != null ->
|
|
712
|
+
scope?.columnScope?.run {
|
|
713
|
+
params.alignment?.toHorizontalAlignment()?.let { alignment -> Modifier.align(alignment) }
|
|
714
|
+
} ?: Modifier
|
|
715
|
+
LocalUniversalStackAxis.current == UniversalStackAxis.Horizontal ->
|
|
716
|
+
UniversalAlignElement(vertical = params.alignment?.toVerticalAlignment())
|
|
717
|
+
LocalUniversalStackAxis.current == UniversalStackAxis.Vertical ->
|
|
718
|
+
UniversalAlignElement(horizontal = params.alignment?.toHorizontalAlignment())
|
|
719
|
+
else -> Modifier
|
|
720
|
+
}
|
|
693
721
|
}
|
|
694
722
|
|
|
695
723
|
register("matchParentSize") { _, scope, _, _ ->
|
|
@@ -2,6 +2,8 @@ package expo.modules.ui
|
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
4
|
import android.content.Context
|
|
5
|
+
import android.text.Spanned
|
|
6
|
+
import android.text.style.ClickableSpan
|
|
5
7
|
import android.util.Log
|
|
6
8
|
import android.view.MotionEvent
|
|
7
9
|
import android.view.View
|
|
@@ -24,6 +26,8 @@ import androidx.compose.runtime.key
|
|
|
24
26
|
import androidx.compose.runtime.mutableStateOf
|
|
25
27
|
import androidx.compose.ui.Alignment
|
|
26
28
|
import androidx.compose.ui.Modifier
|
|
29
|
+
import androidx.compose.ui.input.pointer.PointerEventPass
|
|
30
|
+
import androidx.compose.ui.input.pointer.pointerInput
|
|
27
31
|
import androidx.compose.ui.layout.onGloballyPositioned
|
|
28
32
|
import androidx.compose.ui.layout.onSizeChanged
|
|
29
33
|
import androidx.compose.ui.layout.positionInRoot
|
|
@@ -31,6 +35,7 @@ import androidx.compose.ui.platform.AbstractComposeView
|
|
|
31
35
|
import androidx.compose.ui.platform.LocalDensity
|
|
32
36
|
import androidx.compose.ui.unit.IntSize
|
|
33
37
|
import androidx.compose.ui.viewinterop.AndroidView
|
|
38
|
+
import androidx.core.view.NestedScrollingChild
|
|
34
39
|
import androidx.core.view.NestedScrollingChild3
|
|
35
40
|
import androidx.core.view.NestedScrollingChildHelper
|
|
36
41
|
import androidx.core.view.ViewCompat
|
|
@@ -39,10 +44,16 @@ import com.facebook.react.common.annotations.UnstableReactNativeAPI
|
|
|
39
44
|
import com.facebook.react.config.ReactFeatureFlags
|
|
40
45
|
import com.facebook.react.uimanager.JSPointerDispatcher
|
|
41
46
|
import com.facebook.react.uimanager.JSTouchDispatcher
|
|
47
|
+
import com.facebook.react.uimanager.ReactCompoundView
|
|
48
|
+
import com.facebook.react.uimanager.ReactCompoundViewGroup
|
|
42
49
|
import com.facebook.react.uimanager.RootView
|
|
43
50
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
51
|
+
import com.facebook.react.uimanager.TouchTargetHelper
|
|
44
52
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
45
53
|
import com.facebook.react.uimanager.events.EventDispatcher
|
|
54
|
+
import com.facebook.react.views.image.ReactImageView
|
|
55
|
+
import com.facebook.react.views.text.ReactTextView
|
|
56
|
+
import com.facebook.react.views.view.ReactViewGroup
|
|
46
57
|
import expo.modules.kotlin.AppContext
|
|
47
58
|
import expo.modules.kotlin.views.ComposableScope
|
|
48
59
|
import expo.modules.kotlin.views.ComposeProps
|
|
@@ -204,6 +215,7 @@ internal class RNHostView(context: Context, appContext: AppContext) :
|
|
|
204
215
|
val modifiers = ModifierRegistry.applyModifiers(props.modifiers.value, appContext, scope, globalEventDispatcher)
|
|
205
216
|
.then(sizingModifier)
|
|
206
217
|
.then(publishContentOriginModifier())
|
|
218
|
+
.then(reportComposeClaimModifier(wrapper))
|
|
207
219
|
|
|
208
220
|
// `addView` creates a new wrapper for each mounted child, and `AndroidView` only calls `factory` once.
|
|
209
221
|
key(wrapper) {
|
|
@@ -296,6 +308,23 @@ internal class RNHostView(context: Context, appContext: AppContext) :
|
|
|
296
308
|
}
|
|
297
309
|
}
|
|
298
310
|
|
|
311
|
+
// After every handler has run, a consumed change means Compose claimed the gesture.
|
|
312
|
+
private fun reportComposeClaimModifier(wrapper: TouchDispatchingRootViewGroup): Modifier =
|
|
313
|
+
Modifier.pointerInput(wrapper) {
|
|
314
|
+
awaitPointerEventScope {
|
|
315
|
+
while (true) {
|
|
316
|
+
val event = awaitPointerEvent(PointerEventPass.Final)
|
|
317
|
+
if (event.changes.any { it.isConsumed }) {
|
|
318
|
+
wrapper.onComposeClaimedGesture()
|
|
319
|
+
}
|
|
320
|
+
// Also covers gestures whose down never reached the wrapper.
|
|
321
|
+
if (event.changes.all { !it.pressed }) {
|
|
322
|
+
wrapper.clearGestureLeftToCompose()
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
299
328
|
// Sets Yoga node size from Compose view size
|
|
300
329
|
// Listens to Compose view size changes and updates the Yoga node size
|
|
301
330
|
@Composable
|
|
@@ -440,6 +469,9 @@ private class TouchDispatchingRootViewGroup(
|
|
|
440
469
|
*/
|
|
441
470
|
var dispatchesTouchesToJS: Boolean = false
|
|
442
471
|
|
|
472
|
+
// The down of a gesture this view left to Compose, until Compose claims it or the next gesture.
|
|
473
|
+
private var gestureLeftToCompose: MotionEvent? = null
|
|
474
|
+
|
|
443
475
|
private val reactContext: ThemedReactContext
|
|
444
476
|
get() = context as ThemedReactContext
|
|
445
477
|
|
|
@@ -478,7 +510,23 @@ private class TouchDispatchingRootViewGroup(
|
|
|
478
510
|
composeOwnerView?.let { keepLastForTouchTargeting(it, hostedViewsContainer) }
|
|
479
511
|
}
|
|
480
512
|
|
|
513
|
+
override fun onDetachedFromWindow() {
|
|
514
|
+
super.onDetachedFromWindow()
|
|
515
|
+
clearGestureLeftToCompose()
|
|
516
|
+
}
|
|
517
|
+
|
|
481
518
|
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
|
519
|
+
if (ev.actionMasked == MotionEvent.ACTION_DOWN) {
|
|
520
|
+
// This view handles the JS side of its gestures, so the `Host` must not cancel them.
|
|
521
|
+
findAncestorHostView()?.reactNativeContentHit = true
|
|
522
|
+
// Like a native view that doesn't handle touches, plain hosted content lets the Compose
|
|
523
|
+
// parent handle the gesture. Only a host that dispatches to JavaScript must own its gestures.
|
|
524
|
+
clearGestureLeftToCompose()
|
|
525
|
+
if (!dispatchesTouchesToJS && !hasNativeTouchTarget(ev.x, ev.y)) {
|
|
526
|
+
gestureLeftToCompose = MotionEvent.obtain(ev)
|
|
527
|
+
return false
|
|
528
|
+
}
|
|
529
|
+
}
|
|
482
530
|
if (
|
|
483
531
|
ev.actionMasked == MotionEvent.ACTION_CANCEL &&
|
|
484
532
|
!dispatchesTouchesToJS &&
|
|
@@ -544,14 +592,102 @@ private class TouchDispatchingRootViewGroup(
|
|
|
544
592
|
* reporting it as a native one would cancel the press it belongs to.
|
|
545
593
|
*/
|
|
546
594
|
private fun isCancelFromReactNative(): Boolean {
|
|
595
|
+
return findAncestorHostView()?.isDispatchingCancelFromParent ?: false
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Whether a view under the point handles touches natively, like a scroll view, a text input, a
|
|
600
|
+
* switch, or a nested `Host`. Plain views, text and images only reach JavaScript through the
|
|
601
|
+
* ancestor root, so they don't count.
|
|
602
|
+
*/
|
|
603
|
+
private fun hasNativeTouchTarget(x: Float, y: Float): Boolean {
|
|
604
|
+
// React Native's own hit test, so `hitSlop`, transforms, `zIndex`, `pointerEvents` and children
|
|
605
|
+
// drawn outside their parent pick the same target that JavaScript gets.
|
|
606
|
+
// `targetPoint` ends up relative to the deepest view under the point.
|
|
607
|
+
val targetPoint = FloatArray(2)
|
|
608
|
+
val path = TouchTargetHelper.findTargetPathAndCoordinatesForTouch(x, y, this, targetPoint)
|
|
609
|
+
val targetView = path.firstNotNullOfOrNull { it.getView() }
|
|
610
|
+
return path.any { target ->
|
|
611
|
+
val view = target.getView()
|
|
612
|
+
val localPoint = targetPoint.takeIf { view === targetView }
|
|
613
|
+
view != null && view !== this && handlesTouchesNatively(view, localPoint)
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
private fun handlesTouchesNatively(view: View, localPoint: FloatArray?): Boolean {
|
|
618
|
+
return when {
|
|
619
|
+
// React Native makes a `Pressable` clickable. `accessible` alone only makes a view focusable.
|
|
620
|
+
view is ReactViewGroup || view is ReactImageView -> view.isClickable || view.isLongClickable
|
|
621
|
+
// A `Text` with `onPress` is focusable on Android, and a nested one is a link span.
|
|
622
|
+
view is ReactTextView ->
|
|
623
|
+
view.isClickable ||
|
|
624
|
+
view.isLongClickable ||
|
|
625
|
+
view.isFocusable ||
|
|
626
|
+
hasLinkSpanAt(view, localPoint)
|
|
627
|
+
// `PreparedLayoutTextView` is internal, so it's matched as React Native's other text view type.
|
|
628
|
+
view is ReactCompoundView && view !is ReactCompoundViewGroup ->
|
|
629
|
+
view.isClickable || view.isLongClickable || view.isFocusable
|
|
630
|
+
// A nested `Host` can hold Compose controls.
|
|
631
|
+
view is ExpoComposeView<*> -> true
|
|
632
|
+
// Other native views: controls, text inputs and scroll views handle touches. Views that only
|
|
633
|
+
// draw, like an image or a gradient, don't.
|
|
634
|
+
else ->
|
|
635
|
+
view.isClickable ||
|
|
636
|
+
view.isLongClickable ||
|
|
637
|
+
view.isFocusable ||
|
|
638
|
+
view.isScrollContainer ||
|
|
639
|
+
view is NestedScrollingChild ||
|
|
640
|
+
view.canScrollVertically(1) || view.canScrollVertically(-1) ||
|
|
641
|
+
view.canScrollHorizontally(1) || view.canScrollHorizontally(-1)
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// Only a link under the point counts, so the rest of the text still lets the parent handle it.
|
|
646
|
+
private fun hasLinkSpanAt(view: ReactTextView, localPoint: FloatArray?): Boolean {
|
|
647
|
+
if (localPoint == null) {
|
|
648
|
+
return false
|
|
649
|
+
}
|
|
650
|
+
val text = view.text as? Spanned ?: return false
|
|
651
|
+
val layout = view.layout ?: return false
|
|
652
|
+
val lineX = localPoint[0] - view.totalPaddingLeft + view.scrollX
|
|
653
|
+
val lineY = (localPoint[1] - view.totalPaddingTop + view.scrollY).toInt()
|
|
654
|
+
if (lineY < 0 || lineY > layout.height) {
|
|
655
|
+
return false
|
|
656
|
+
}
|
|
657
|
+
val line = layout.getLineForVertical(lineY)
|
|
658
|
+
if (lineX < layout.getLineLeft(line) || lineX > layout.getLineRight(line)) {
|
|
659
|
+
return false
|
|
660
|
+
}
|
|
661
|
+
val offset = layout.getOffsetForHorizontal(line, lineX)
|
|
662
|
+
return text.getSpans(offset, offset, ClickableSpan::class.java).isNotEmpty()
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* A gesture this view left to Compose reaches JavaScript through the ancestor root. When Compose
|
|
667
|
+
* takes it, for example a `clickable` press or a `LazyColumn` scroll, tell the root, so JavaScript
|
|
668
|
+
* cancels its touch the same way it does for a native child that claims a gesture.
|
|
669
|
+
*/
|
|
670
|
+
fun onComposeClaimedGesture() {
|
|
671
|
+
val down = gestureLeftToCompose ?: return
|
|
672
|
+
gestureLeftToCompose = null
|
|
673
|
+
notifyAncestorRootViews { it.onChildStartedNativeGesture(null, down) }
|
|
674
|
+
down.recycle()
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
fun clearGestureLeftToCompose() {
|
|
678
|
+
gestureLeftToCompose?.recycle()
|
|
679
|
+
gestureLeftToCompose = null
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
private fun findAncestorHostView(): HostView? {
|
|
547
683
|
var current: ViewParent? = parent
|
|
548
684
|
while (current != null) {
|
|
549
685
|
if (current is HostView) {
|
|
550
|
-
return current
|
|
686
|
+
return current
|
|
551
687
|
}
|
|
552
688
|
current = current.parent
|
|
553
689
|
}
|
|
554
|
-
return
|
|
690
|
+
return null
|
|
555
691
|
}
|
|
556
692
|
|
|
557
693
|
private inline fun notifyAncestorRootViews(block: (RootView) -> Unit) {
|
|
@@ -14,7 +14,6 @@ import androidx.compose.runtime.remember
|
|
|
14
14
|
import androidx.compose.runtime.setValue
|
|
15
15
|
import expo.modules.kotlin.records.Field
|
|
16
16
|
import expo.modules.kotlin.records.Record
|
|
17
|
-
import expo.modules.kotlin.viewevent.getValue
|
|
18
17
|
import expo.modules.kotlin.views.ComposeProps
|
|
19
18
|
import expo.modules.kotlin.views.FunctionalComposableScope
|
|
20
19
|
import expo.modules.kotlin.types.OptimizedRecord
|
|
@@ -58,9 +57,11 @@ data class SliderValueChangedEvent(
|
|
|
58
57
|
|
|
59
58
|
@OptIn(ExperimentalMaterial3Api::class)
|
|
60
59
|
@Composable
|
|
61
|
-
fun FunctionalComposableScope.SliderContent(
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
fun FunctionalComposableScope.SliderContent(
|
|
61
|
+
props: SliderProps,
|
|
62
|
+
onValueChange: (SliderValueChangedEvent) -> Unit,
|
|
63
|
+
onValueChangeFinished: (Unit) -> Unit
|
|
64
|
+
) {
|
|
64
65
|
val interactionSource = remember { MutableInteractionSource() }
|
|
65
66
|
|
|
66
67
|
val effectiveLower = maxOf(props.min, props.lowerLimit ?: Float.NEGATIVE_INFINITY)
|