@expo/ui 58.0.15 → 58.0.17

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/android/build.gradle +6 -6
  3. package/android/src/main/java/expo/modules/ui/CarouselView.kt +2 -1
  4. package/android/src/main/java/expo/modules/ui/DatePickerView.kt +15 -5
  5. package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +3 -0
  6. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +2 -2
  7. package/android/src/main/java/expo/modules/ui/RNHostView.kt +95 -0
  8. package/android/src/main/java/expo/modules/ui/SliderView.kt +21 -9
  9. package/android/src/main/java/expo/modules/ui/ToggleButtonView.kt +1 -1
  10. package/android/src/main/java/expo/modules/ui/VerticalSliderView.kt +23 -14
  11. package/android/src/main/java/expo/modules/ui/menu/DropdownMenu.kt +8 -1
  12. package/android/src/main/java/expo/modules/ui/menu/DropdownMenuRecords.kt +13 -1
  13. package/android/src/main/java/expo/modules/ui/menu/ExposedDropdownMenuView.kt +1 -0
  14. package/build/NativeTreeContext.d.ts +10 -0
  15. package/build/NativeTreeContext.js +25 -0
  16. package/build/NativeTreeContext.js.map +1 -0
  17. package/build/community/bottom-sheet/BottomSheet.ios.js +11 -4
  18. package/build/community/bottom-sheet/BottomSheet.ios.js.map +1 -1
  19. package/build/community/menu/MenuView.android.js +6 -0
  20. package/build/community/menu/MenuView.android.js.map +1 -1
  21. package/build/jetpack-compose/Carousel/index.d.ts +7 -2
  22. package/build/jetpack-compose/Carousel/index.js.map +1 -1
  23. package/build/jetpack-compose/DatePicker/index.d.ts +20 -0
  24. package/build/jetpack-compose/DatePicker/index.js.map +1 -1
  25. package/build/jetpack-compose/DropdownMenu/index.d.ts +8 -1
  26. package/build/jetpack-compose/DropdownMenu/index.js.map +1 -1
  27. package/build/jetpack-compose/Host/index.js +8 -2
  28. package/build/jetpack-compose/Host/index.js.map +1 -1
  29. package/build/jetpack-compose/RNHostView/index.js +5 -1
  30. package/build/jetpack-compose/RNHostView/index.js.map +1 -1
  31. package/build/swift-ui/Chart/index.d.ts +10 -0
  32. package/build/swift-ui/Chart/index.js.map +1 -1
  33. package/build/swift-ui/Host/index.js +8 -2
  34. package/build/swift-ui/Host/index.js.map +1 -1
  35. package/build/swift-ui/RNHostView.js +5 -1
  36. package/build/swift-ui/RNHostView.js.map +1 -1
  37. package/build/swift-ui/modifiers/presentationModifiers.d.ts +17 -1
  38. package/build/swift-ui/modifiers/presentationModifiers.js +4 -2
  39. package/build/swift-ui/modifiers/presentationModifiers.js.map +1 -1
  40. package/build/types.d.ts +27 -0
  41. package/build/types.js +1 -1
  42. package/build/types.js.map +1 -1
  43. package/build/universal/BottomSheet/index.android.js +26 -18
  44. package/build/universal/BottomSheet/index.android.js.map +1 -1
  45. package/build/universal/BottomSheet/index.ios.js +20 -12
  46. package/build/universal/BottomSheet/index.ios.js.map +1 -1
  47. package/build/universal/ListItem/ListItem.android.js +5 -2
  48. package/build/universal/ListItem/ListItem.android.js.map +1 -1
  49. package/ios/ChartView.swift +7 -4
  50. package/ios/DataListForEachView.swift +1 -0
  51. package/ios/GridView.swift +1 -0
  52. package/ios/HostView.swift +27 -4
  53. package/ios/Modifiers/PresentationModifiers.swift +20 -4
  54. package/ios/NamespaceView.swift +1 -0
  55. package/ios/RNHostView.swift +19 -4
  56. package/ios/SlotView.swift +1 -0
  57. package/ios/TabView/TabView.swift +2 -0
  58. package/ios/ToolbarView.swift +2 -1
  59. package/ios/UIBaseView.swift +13 -0
  60. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.15/expo.modules.ui-58.0.15-sources.jar → 58.0.17/expo.modules.ui-58.0.17-sources.jar} +0 -0
  61. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17-sources.jar.md5 +1 -0
  62. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17-sources.jar.sha1 +1 -0
  63. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17-sources.jar.sha256 +1 -0
  64. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17-sources.jar.sha512 +1 -0
  65. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.aar +0 -0
  66. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.aar.md5 +1 -0
  67. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.aar.sha1 +1 -0
  68. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.aar.sha256 +1 -0
  69. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.aar.sha512 +1 -0
  70. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.15/expo.modules.ui-58.0.15.module → 58.0.17/expo.modules.ui-58.0.17.module} +26 -26
  71. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.module.md5 +1 -0
  72. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.module.sha1 +1 -0
  73. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.module.sha256 +1 -0
  74. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.module.sha512 +1 -0
  75. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.15/expo.modules.ui-58.0.15.pom → 58.0.17/expo.modules.ui-58.0.17.pom} +5 -5
  76. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.pom.md5 +1 -0
  77. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.pom.sha1 +1 -0
  78. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.pom.sha256 +1 -0
  79. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.17/expo.modules.ui-58.0.17.pom.sha512 +1 -0
  80. package/package.json +2 -2
  81. package/prebuilds/output/debug/xcframeworks/ExpoUI.tar.gz +0 -0
  82. package/prebuilds/output/release/xcframeworks/ExpoUI.tar.gz +0 -0
  83. package/src/NativeTreeContext.tsx +31 -0
  84. package/src/community/bottom-sheet/BottomSheet.ios.tsx +7 -6
  85. package/src/community/menu/MenuView.android.tsx +12 -2
  86. package/src/jetpack-compose/Carousel/index.tsx +7 -2
  87. package/src/jetpack-compose/DatePicker/index.tsx +20 -0
  88. package/src/jetpack-compose/DropdownMenu/index.tsx +12 -1
  89. package/src/jetpack-compose/Host/index.tsx +6 -2
  90. package/src/jetpack-compose/RNHostView/index.tsx +3 -1
  91. package/src/swift-ui/Chart/index.tsx +10 -0
  92. package/src/swift-ui/Host/index.tsx +6 -2
  93. package/src/swift-ui/RNHostView.tsx +3 -1
  94. package/src/swift-ui/modifiers/presentationModifiers.ts +18 -2
  95. package/src/types.ts +28 -0
  96. package/src/universal/BottomSheet/index.android.tsx +23 -12
  97. package/src/universal/BottomSheet/index.ios.tsx +20 -9
  98. package/src/universal/ListItem/ListItem.android.tsx +7 -2
  99. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15-sources.jar.md5 +0 -1
  100. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15-sources.jar.sha1 +0 -1
  101. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15-sources.jar.sha256 +0 -1
  102. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15-sources.jar.sha512 +0 -1
  103. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.aar +0 -0
  104. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.aar.md5 +0 -1
  105. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.aar.sha1 +0 -1
  106. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.aar.sha256 +0 -1
  107. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.aar.sha512 +0 -1
  108. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.module.md5 +0 -1
  109. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.module.sha1 +0 -1
  110. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.module.sha256 +0 -1
  111. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.module.sha512 +0 -1
  112. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.pom.md5 +0 -1
  113. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.pom.sha1 +0 -1
  114. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.pom.sha256 +0 -1
  115. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.15/expo.modules.ui-58.0.15.pom.sha512 +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.17
4
+
5
+ ### Patch Changes
6
+
7
+ - [Android] Fix the universal `ListItem` ignoring `testID`. The prop was never passed to Compose, so end-to-end tools such as Maestro could not find list rows on Android. It is now applied as the `testID` modifier, like the universal `Button` and `Checkbox` do. ([#51480](https://github.com/expo/expo/pull/51480) by [@devonik](https://github.com/devonik))
8
+ - [Android] Bump Jetpack Compose UI and Foundation to 1.12.1 and Material3 to 1.5.0-beta01. Add `preferredItemWidth` to `HorizontalCenteredHeroCarousel` and deprecate `maxItemWidth`, matching the Material3 rename. Add `TimePickerElementColors` props without the `Unselected` infix (for example `clockDialContentColor`) and deprecate the old names. ([#51426](https://github.com/expo/expo/pull/51426) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
9
+
10
+ ## 58.0.16
11
+
12
+ ### Patch Changes
13
+
14
+ - [Internal] Bump precompiled artifacts due to ABI breakage in expo-modules-jsi, which makes `JavaScriptValue` a non-copyable struct. ([#51368](https://github.com/expo/expo/pull/51368) by [@tsapeta](https://github.com/tsapeta))
15
+ - [iOS] Fix the community `BottomSheet` clipping its content when the sheet is narrower than the window, as on iPhone Duo. When the sheet sized itself to its content, the content was pinned to the window width and centered in the sheet, so its leading edge was cut off. The content now takes its width from the sheet and its height from the content. `presentationSizing` takes a `fitted` option (`{ horizontal, vertical }`) to fit a sheet to its content on one axis only. ([#51319](https://github.com/expo/expo/pull/51319) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
16
+ - [Android] Fix an `RNHostView` that ignores touches when a Compose button with a ripple in the same `Host` was pressed earlier. The ripple container that Compose adds was found first during React Native's touch-target search, so the touch went to the `Host` instead of the hosted view. ([#51237](https://github.com/expo/expo/pull/51237) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
17
+ - Fixed `measure()` of views hosted in `RNHostView` inside SwiftUI and Jetpack Compose containers. ([#50715](https://github.com/expo/expo/pull/50715) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
18
+ - Added a development warning when a `Host` renders directly inside another `Host` without an `RNHostView`. The universal `BottomSheet` no longer adds its own `Host` when it renders inside one. ([#50715](https://github.com/expo/expo/pull/50715) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
19
+ - [iOS] Fixed `measure()` of views hosted in `RNHostView` when SwiftUI insets the `Host`'s content, for example by the safe area. ([#50727](https://github.com/expo/expo/pull/50727) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
20
+ - [Android] Fix the community `MenuView` opening detached above its anchor near the bottom of the screen, and add a `properties` prop to the Jetpack Compose `DropdownMenu`. ([#51412](https://github.com/expo/expo/pull/51412) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
21
+ - [Android] Fix a numeric `width()` modifier crashing the app on launch with `FieldCastException: Cannot cast value for field 'width'` since the `IntrinsicSize` support added in 57.0.22 / 58.0.9. JS numbers reach the modifier record as `Double`, which matched neither branch of `Either<Int, IntrinsicSizeType>`; the field is now `Either<Double, IntrinsicSizeType>`, so numeric widths convert again and `width(IntrinsicSize.Min|Max)` keeps working. ([#51322](https://github.com/expo/expo/pull/51322) by [@expo-bot](https://github.com/expo-bot))
22
+ - [iOS] Add `cornerRadius` and `opacity` to `Chart`'s `pieStyle`. Pie slices could not have rounded corners, and their opacity was fixed at 0.8, so a chart drawn in solid colors always looked washed out. Both default to the previous behavior. Rounded corners let a single-slice donut work as a progress ring with rounded ends. ([#51351](https://github.com/expo/expo/pull/51351) by [@jsg2021](https://github.com/jsg2021))
23
+
3
24
  ## 58.0.15
4
25
 
5
26
  ### Patch Changes
@@ -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'
15
+ version = '58.0.17'
16
16
 
17
17
  android {
18
18
  namespace "expo.modules.ui"
19
19
  defaultConfig {
20
20
  versionCode 1
21
- versionName "58.0.15"
21
+ versionName "58.0.17"
22
22
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
23
23
  }
24
24
  buildFeatures {
@@ -38,10 +38,10 @@ android {
38
38
  dependencies {
39
39
  implementation 'com.facebook.react:react-android'
40
40
 
41
- implementation 'androidx.compose.foundation:foundation-android:1.10.6'
42
- implementation 'androidx.compose.ui:ui-android:1.10.6'
43
- implementation "androidx.compose.material3:material3:1.5.0-alpha17"
44
- implementation 'androidx.compose.material3:material3-android:1.5.0-alpha17'
41
+ implementation 'androidx.compose.foundation:foundation-android:1.12.1'
42
+ implementation 'androidx.compose.ui:ui-android:1.12.1'
43
+ implementation "androidx.compose.material3:material3:1.5.0-beta01"
44
+ implementation 'androidx.compose.material3:material3-android:1.5.0-beta01'
45
45
  implementation 'androidx.lifecycle:lifecycle-runtime:2.10.0'
46
46
  implementation 'androidx.fragment:fragment-ktx:1.8.9'
47
47
  implementation "androidx.graphics:graphics-shapes:1.1.0"
@@ -24,6 +24,7 @@ enum class FlingBehaviorType(val value: String) : Enumerable {
24
24
 
25
25
  @OptimizedComposeProps
26
26
  data class HorizontalCenteredHeroCarouselProps(
27
+ val preferredItemWidth: Float? = null,
27
28
  val maxItemWidth: Float? = null,
28
29
  val itemSpacing: Float? = null,
29
30
  val contentPadding: Either<Float, PaddingValuesRecord>? = null,
@@ -50,7 +51,7 @@ fun FunctionalComposableScope.HorizontalCenteredHeroCarouselContent(props: Horiz
50
51
  HorizontalCenteredHeroCarousel(
51
52
  state = carouselState,
52
53
  modifier = ModifierRegistry.applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher),
53
- maxItemWidth = props.maxItemWidth?.dp ?: Dp.Unspecified,
54
+ preferredItemWidth = (props.preferredItemWidth ?: props.maxItemWidth)?.dp ?: Dp.Unspecified,
54
55
  itemSpacing = (props.itemSpacing ?: 0f).dp,
55
56
  flingBehavior = flingBehavior,
56
57
  userScrollEnabled = props.userScrollEnabled ?: true,
@@ -123,6 +123,8 @@ class DateTimePickerColorOverrides : Record {
123
123
 
124
124
  @Field val clockDialSelectedContentColor: AndroidColor? = null
125
125
 
126
+ @Field val clockDialContentColor: AndroidColor? = null
127
+
126
128
  @Field val clockDialUnselectedContentColor: AndroidColor? = null
127
129
 
128
130
  @Field val selectorColor: AndroidColor? = null
@@ -131,18 +133,26 @@ class DateTimePickerColorOverrides : Record {
131
133
 
132
134
  @Field val periodSelectorSelectedContainerColor: AndroidColor? = null
133
135
 
136
+ @Field val periodSelectorContainerColor: AndroidColor? = null
137
+
134
138
  @Field val periodSelectorUnselectedContainerColor: AndroidColor? = null
135
139
 
136
140
  @Field val periodSelectorSelectedContentColor: AndroidColor? = null
137
141
 
142
+ @Field val periodSelectorContentColor: AndroidColor? = null
143
+
138
144
  @Field val periodSelectorUnselectedContentColor: AndroidColor? = null
139
145
 
140
146
  @Field val timeSelectorSelectedContainerColor: AndroidColor? = null
141
147
 
148
+ @Field val timeSelectorContainerColor: AndroidColor? = null
149
+
142
150
  @Field val timeSelectorUnselectedContainerColor: AndroidColor? = null
143
151
 
144
152
  @Field val timeSelectorSelectedContentColor: AndroidColor? = null
145
153
 
154
+ @Field val timeSelectorContentColor: AndroidColor? = null
155
+
146
156
  @Field val timeSelectorUnselectedContentColor: AndroidColor? = null
147
157
  }
148
158
 
@@ -323,17 +333,17 @@ fun buildTimePickerColors(
323
333
  containerColor = elementColors.containerColor.composeOrNull ?: defaults.containerColor,
324
334
  clockDialColor = elementColors.clockDialColor.composeOrNull ?: colorProp?.copy(alpha = 0.3f) ?: defaults.clockDialColor,
325
335
  clockDialSelectedContentColor = elementColors.clockDialSelectedContentColor.composeOrNull ?: defaults.clockDialSelectedContentColor,
326
- clockDialUnselectedContentColor = elementColors.clockDialUnselectedContentColor.composeOrNull ?: defaults.clockDialUnselectedContentColor,
336
+ clockDialContentColor = (elementColors.clockDialContentColor ?: elementColors.clockDialUnselectedContentColor).composeOrNull ?: defaults.clockDialContentColor,
327
337
  selectorColor = elementColors.selectorColor.composeOrNull ?: colorProp ?: defaults.selectorColor,
328
338
  periodSelectorBorderColor = elementColors.periodSelectorBorderColor.composeOrNull ?: defaults.periodSelectorBorderColor,
329
339
  periodSelectorSelectedContainerColor = elementColors.periodSelectorSelectedContainerColor.composeOrNull ?: defaults.periodSelectorSelectedContainerColor,
330
- periodSelectorUnselectedContainerColor = elementColors.periodSelectorUnselectedContainerColor.composeOrNull ?: defaults.periodSelectorUnselectedContainerColor,
340
+ periodSelectorContainerColor = (elementColors.periodSelectorContainerColor ?: elementColors.periodSelectorUnselectedContainerColor).composeOrNull ?: defaults.periodSelectorContainerColor,
331
341
  periodSelectorSelectedContentColor = elementColors.periodSelectorSelectedContentColor.composeOrNull ?: defaults.periodSelectorSelectedContentColor,
332
- periodSelectorUnselectedContentColor = elementColors.periodSelectorUnselectedContentColor.composeOrNull ?: defaults.periodSelectorUnselectedContentColor,
342
+ periodSelectorContentColor = (elementColors.periodSelectorContentColor ?: elementColors.periodSelectorUnselectedContentColor).composeOrNull ?: defaults.periodSelectorContentColor,
333
343
  timeSelectorSelectedContainerColor = elementColors.timeSelectorSelectedContainerColor.composeOrNull ?: colorProp ?: defaults.timeSelectorSelectedContainerColor,
334
- timeSelectorUnselectedContainerColor = elementColors.timeSelectorUnselectedContainerColor.composeOrNull ?: defaults.timeSelectorUnselectedContainerColor,
344
+ timeSelectorContainerColor = (elementColors.timeSelectorContainerColor ?: elementColors.timeSelectorUnselectedContainerColor).composeOrNull ?: defaults.timeSelectorContainerColor,
335
345
  timeSelectorSelectedContentColor = elementColors.timeSelectorSelectedContentColor.composeOrNull ?: defaults.timeSelectorSelectedContentColor,
336
- timeSelectorUnselectedContentColor = elementColors.timeSelectorUnselectedContentColor.composeOrNull ?: defaults.timeSelectorUnselectedContentColor
346
+ timeSelectorContentColor = (elementColors.timeSelectorContentColor ?: elementColors.timeSelectorUnselectedContentColor).composeOrNull ?: defaults.timeSelectorContentColor
337
347
  )
338
348
  }
339
349
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  package expo.modules.ui
4
4
 
5
+ import android.os.Handler
5
6
  import android.os.Looper
6
7
  import androidx.compose.material3.ExperimentalMaterial3ExpressiveApi
7
8
  import androidx.compose.material3.SwitchDefaults
@@ -77,6 +78,8 @@ class ExpoUIModule : Module() {
77
78
  // Tags restart in the next app context, so an entry whose view was never torn down would be
78
79
  // read by an unrelated view after a reload.
79
80
  NativeStatePropsGetter().clearAllContentOrigins()
81
+ // React Native destroys modules on a background thread, but `ZeroContentOrigins` is UI-thread only.
82
+ Handler(Looper.getMainLooper()).post { ZeroContentOrigins.clear() }
80
83
 
81
84
  imageLoader?.close()
82
85
  imageLoader = null
@@ -147,7 +147,7 @@ internal enum class IntrinsicSizeType(val value: String) : Enumerable {
147
147
 
148
148
  @OptimizedRecord
149
149
  internal data class ComposeWidthParams(
150
- @Field val width: Either<Int, IntrinsicSizeType>? = null
150
+ @Field val width: Either<Double, IntrinsicSizeType>? = null
151
151
  ) : Record
152
152
 
153
153
  @OptimizedRecord
@@ -496,7 +496,7 @@ object ModifierRegistry {
496
496
  if (width?.`is`(IntrinsicSizeType::class) == true) {
497
497
  Modifier.width(width.second().toComposeIntrinsicSize())
498
498
  } else {
499
- Modifier.width((width?.first() ?: 0).dp)
499
+ Modifier.width((width?.first() ?: 0.0).dp)
500
500
  }
501
501
  }
502
502
 
@@ -8,6 +8,7 @@ import android.view.View
8
8
  import android.view.ViewGroup
9
9
  import android.view.ViewParent
10
10
  import android.widget.FrameLayout
11
+ import androidx.annotation.UiThread
11
12
  import androidx.compose.foundation.layout.fillMaxHeight
12
13
  import androidx.compose.foundation.layout.fillMaxSize
13
14
  import androidx.compose.foundation.layout.fillMaxWidth
@@ -25,6 +26,7 @@ import androidx.compose.ui.Modifier
25
26
  import androidx.compose.ui.layout.onGloballyPositioned
26
27
  import androidx.compose.ui.layout.onSizeChanged
27
28
  import androidx.compose.ui.layout.positionInRoot
29
+ import androidx.compose.ui.platform.AbstractComposeView
28
30
  import androidx.compose.ui.platform.LocalDensity
29
31
  import androidx.compose.ui.unit.IntSize
30
32
  import androidx.compose.ui.viewinterop.AndroidView
@@ -45,6 +47,7 @@ import expo.modules.kotlin.views.ComposableScope
45
47
  import expo.modules.kotlin.views.ComposeProps
46
48
  import expo.modules.kotlin.views.ExpoComposeView
47
49
  import expo.modules.kotlin.views.OptimizedComposeProps
50
+ import java.util.WeakHashMap
48
51
 
49
52
  @OptimizedComposeProps
50
53
  internal data class RNHostViewProps(
@@ -151,6 +154,25 @@ internal class RNHostView(context: Context, appContext: AppContext) :
151
154
  shadowNodeProxy.clearContentOrigin()
152
155
  }
153
156
 
157
+ // Compose places the views between this view and its `Host`, so `measure()` must skip their Yoga
158
+ // origins. A zero content origin on each one does that while this view is attached.
159
+ private var composeAncestors: List<ExpoComposeView<*>> = emptyList()
160
+
161
+ override fun onAttachedToWindow() {
162
+ super.onAttachedToWindow()
163
+ composeAncestors = generateSequence(parent) { it.parent }
164
+ .takeWhile { it is ExpoComposeView<*> && !it.shouldUseAndroidLayout }
165
+ .filterIsInstance<ExpoComposeView<*>>()
166
+ .toList()
167
+ composeAncestors.forEach(ZeroContentOrigins::acquire)
168
+ }
169
+
170
+ override fun onDetachedFromWindow() {
171
+ super.onDetachedFromWindow()
172
+ composeAncestors.forEach(ZeroContentOrigins::release)
173
+ composeAncestors = emptyList()
174
+ }
175
+
154
176
  @Composable
155
177
  override fun ComposableScope.Content() {
156
178
  val matchContentsHorizontal = props.matchContentsHorizontal.value ?: false
@@ -294,6 +316,44 @@ internal class RNHostView(context: Context, appContext: AppContext) :
294
316
  }
295
317
  }
296
318
 
319
+ /**
320
+ * Counts, for each Compose ancestor, the attached `RNHostView`s below it. Several can share an
321
+ * ancestor, so the ancestor's zero content origin is set when its count becomes 1 and cleared when
322
+ * it returns to 0.
323
+ */
324
+ internal object ZeroContentOrigins {
325
+ private val counts = WeakHashMap<ExpoComposeView<*>, Int>()
326
+
327
+ @UiThread
328
+ fun acquire(view: ExpoComposeView<*>) {
329
+ val count = counts[view] ?: 0
330
+ if (count == 0) {
331
+ view.shadowNodeProxy.setContentOrigin(0.0, 0.0)
332
+ }
333
+ counts[view] = count + 1
334
+ }
335
+
336
+ @UiThread
337
+ fun release(view: ExpoComposeView<*>) {
338
+ val count = counts[view] ?: return
339
+ if (count > 1) {
340
+ counts[view] = count - 1
341
+ return
342
+ }
343
+ counts.remove(view)
344
+ view.shadowNodeProxy.clearContentOrigin()
345
+ }
346
+
347
+ /**
348
+ * Called on reload, after the content origins themselves are cleared. A late `release` from the
349
+ * old app context then finds no count and can't clear an entry for a reused tag.
350
+ */
351
+ @UiThread
352
+ fun clear() {
353
+ counts.clear()
354
+ }
355
+ }
356
+
297
357
  /**
298
358
  * Removes [wrapper] from the view that currently contains it, and clears its bounds.
299
359
  *
@@ -309,6 +369,28 @@ internal fun detachForReuse(wrapper: View) {
309
369
  wrapper.layout(0, 0, 0, 0)
310
370
  }
311
371
 
372
+ /**
373
+ * React Native looks for touch targets from the last child to the first, and Compose appends helper
374
+ * views such as ripple containers to its owner view after the hosted views. Those helpers have no
375
+ * React tag, so a touch on them goes to the `Host` instead of the hosted view.
376
+ * This is a workaround: React Native has no way to let the `Host` choose the touch target.
377
+ * This causes https://github.com/expo/expo/issues/51159
378
+ */
379
+ internal fun keepLastForTouchTargeting(composeOwnerView: ViewGroup, hostedViewsContainer: View) {
380
+ if (composeOwnerView.indexOfChild(hostedViewsContainer) != composeOwnerView.childCount - 1) {
381
+ composeOwnerView.bringChildToFront(hostedViewsContainer)
382
+ }
383
+ composeOwnerView.setOnHierarchyChangeListener(object : ViewGroup.OnHierarchyChangeListener {
384
+ override fun onChildViewAdded(parent: View, child: View) {
385
+ if (child !== hostedViewsContainer) {
386
+ composeOwnerView.bringChildToFront(hostedViewsContainer)
387
+ }
388
+ }
389
+
390
+ override fun onChildViewRemoved(parent: View, child: View) = Unit
391
+ })
392
+ }
393
+
312
394
  /**
313
395
  * A thin FrameLayout that intercepts touch events and dispatches them to JS via
314
396
  * JSTouchDispatcher/JSPointerDispatcher, replicating the pattern from React Native's
@@ -379,6 +461,19 @@ private class TouchDispatchingRootViewGroup(
379
461
  // and we must not override those values.
380
462
  }
381
463
 
464
+ override fun onAttachedToWindow() {
465
+ super.onAttachedToWindow()
466
+ // Walk up until the parent is the ComposeView. That ancestor is the Compose owner view, and the
467
+ // child we came from is the container that Compose keeps all hosted views in.
468
+ var hostedViewsContainer: View = this
469
+ var composeOwnerView = parent as? ViewGroup
470
+ while (composeOwnerView != null && composeOwnerView.parent !is AbstractComposeView) {
471
+ hostedViewsContainer = composeOwnerView
472
+ composeOwnerView = composeOwnerView.parent as? ViewGroup
473
+ }
474
+ composeOwnerView?.let { keepLastForTouchTargeting(it, hostedViewsContainer) }
475
+ }
476
+
382
477
  override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
383
478
  if (
384
479
  ev.actionMasked == MotionEvent.ACTION_CANCEL &&
@@ -5,10 +5,11 @@ import androidx.compose.foundation.interaction.MutableInteractionSource
5
5
  import androidx.compose.material3.ExperimentalMaterial3Api
6
6
  import androidx.compose.material3.Slider
7
7
  import androidx.compose.material3.SliderDefaults
8
+ import androidx.compose.material3.SliderState
8
9
  import androidx.compose.runtime.Composable
10
+ import androidx.compose.runtime.SideEffect
9
11
  import androidx.compose.runtime.getValue
10
12
  import androidx.compose.runtime.mutableFloatStateOf
11
- import androidx.compose.runtime.mutableStateOf
12
13
  import androidx.compose.runtime.remember
13
14
  import androidx.compose.runtime.setValue
14
15
  import expo.modules.kotlin.records.Field
@@ -66,13 +67,20 @@ fun FunctionalComposableScope.SliderContent(props: SliderProps) {
66
67
  val effectiveUpper = minOf(props.max, props.upperLimit ?: Float.POSITIVE_INFINITY)
67
68
 
68
69
  var localValue by remember { mutableFloatStateOf(props.value.coerceIn(effectiveLower, effectiveUpper)) }
69
- var isDragging by remember { mutableStateOf(false) }
70
70
  val clampedPropsValue = props.value.coerceIn(effectiveLower, effectiveUpper)
71
71
  var prevPropsValue by remember { mutableFloatStateOf(clampedPropsValue) }
72
72
 
73
+ val sliderState = remember(props.min, props.max, props.steps) {
74
+ SliderState(
75
+ value = localValue.coerceIn(effectiveLower, effectiveUpper),
76
+ steps = props.steps,
77
+ trackRange = props.min..props.max
78
+ )
79
+ }
80
+
73
81
  if (clampedPropsValue != prevPropsValue) {
74
82
  prevPropsValue = clampedPropsValue
75
- if (!isDragging) {
83
+ if (!sliderState.isDragging) {
76
84
  localValue = clampedPropsValue
77
85
  }
78
86
  }
@@ -88,24 +96,28 @@ fun FunctionalComposableScope.SliderContent(props: SliderProps) {
88
96
  inactiveTickColor = props.colors.inactiveTickColor.compose
89
97
  )
90
98
 
99
+ SideEffect {
100
+ val target = localValue.coerceIn(effectiveLower, effectiveUpper)
101
+ if (sliderState.value != target) {
102
+ sliderState.value = target
103
+ }
104
+ }
105
+
91
106
  Slider(
92
- value = localValue,
93
- valueRange = props.min..props.max,
94
- steps = props.steps,
107
+ state = sliderState,
95
108
  enabled = props.enabled,
96
109
  interactionSource = interactionSource,
97
110
  onValueChange = {
98
111
  val clamped = it.coerceIn(effectiveLower, effectiveUpper)
99
- isDragging = true
100
112
  localValue = clamped
113
+ sliderState.value = clamped
101
114
  onValueChange(SliderValueChangedEvent(clamped))
102
115
  },
103
116
  onValueChangeFinished = {
104
- isDragging = false
105
117
  onValueChangeFinished(Unit)
106
118
  },
107
119
  colors = sliderColors,
108
- thumb = { sliderState ->
120
+ thumb = {
109
121
  if (thumbSlotView != null) {
110
122
  with(UIComposableScope()) { with(thumbSlotView) { Content() } }
111
123
  } else {
@@ -52,7 +52,7 @@ fun FunctionalComposableScope.ToggleButtonContent(
52
52
  onCheckedChange = { onCheckedChange(ToggleButtonValueChangeEvent(it)) },
53
53
  enabled = props.enabled,
54
54
  modifier = modifier,
55
- colors = ToggleButtonDefaults.toggleButtonColors(
55
+ colors = ToggleButtonDefaults.colors(
56
56
  checkedContainerColor = props.colors.checkedContainerColor.compose,
57
57
  checkedContentColor = props.colors.checkedContentColor.compose,
58
58
  containerColor = props.colors.containerColor.compose,
@@ -49,7 +49,7 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
49
49
  SliderState(
50
50
  value = localValue.coerceIn(effectiveLower, effectiveUpper),
51
51
  steps = props.steps,
52
- valueRange = props.min..props.max
52
+ trackRange = props.min..props.max
53
53
  )
54
54
  }
55
55
 
@@ -77,16 +77,17 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
77
77
  globalEventDispatcher
78
78
  )
79
79
 
80
+ val handleValueChange: (Float) -> Unit = {
81
+ val clamped = it.coerceIn(effectiveLower, effectiveUpper)
82
+ localValue = clamped
83
+ sliderState.value = clamped
84
+ onValueChange(SliderValueChangedEvent(clamped))
85
+ }
86
+ val handleValueChangeFinished: () -> Unit = {
87
+ onValueChangeFinished(Unit)
88
+ }
89
+
80
90
  SideEffect {
81
- sliderState.onValueChange = {
82
- val clamped = it.coerceIn(effectiveLower, effectiveUpper)
83
- localValue = clamped
84
- sliderState.value = clamped
85
- onValueChange(SliderValueChangedEvent(clamped))
86
- }
87
- sliderState.onValueChangeFinished = {
88
- onValueChangeFinished(Unit)
89
- }
90
91
  val target = localValue.coerceIn(effectiveLower, effectiveUpper)
91
92
  if (sliderState.value != target) {
92
93
  sliderState.value = target
@@ -97,7 +98,9 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
97
98
  thumbSlotView != null && trackSlotView != null -> VerticalSlider(
98
99
  state = sliderState,
99
100
  enabled = props.enabled,
100
- reverseDirection = props.reverseDirection,
101
+ onValueChange = handleValueChange,
102
+ onValueChangeFinished = handleValueChangeFinished,
103
+ topToBottom = !props.reverseDirection,
101
104
  colors = sliderColors,
102
105
  interactionSource = interactionSource,
103
106
  thumb = {
@@ -112,7 +115,9 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
112
115
  thumbSlotView != null -> VerticalSlider(
113
116
  state = sliderState,
114
117
  enabled = props.enabled,
115
- reverseDirection = props.reverseDirection,
118
+ onValueChange = handleValueChange,
119
+ onValueChangeFinished = handleValueChangeFinished,
120
+ topToBottom = !props.reverseDirection,
116
121
  colors = sliderColors,
117
122
  interactionSource = interactionSource,
118
123
  thumb = {
@@ -124,7 +129,9 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
124
129
  trackSlotView != null -> VerticalSlider(
125
130
  state = sliderState,
126
131
  enabled = props.enabled,
127
- reverseDirection = props.reverseDirection,
132
+ onValueChange = handleValueChange,
133
+ onValueChangeFinished = handleValueChangeFinished,
134
+ topToBottom = !props.reverseDirection,
128
135
  colors = sliderColors,
129
136
  interactionSource = interactionSource,
130
137
  track = {
@@ -136,7 +143,9 @@ fun FunctionalComposableScope.VerticalSliderContent(props: VerticalSliderProps)
136
143
  else -> VerticalSlider(
137
144
  state = sliderState,
138
145
  enabled = props.enabled,
139
- reverseDirection = props.reverseDirection,
146
+ onValueChange = handleValueChange,
147
+ onValueChangeFinished = handleValueChangeFinished,
148
+ topToBottom = !props.reverseDirection,
140
149
  colors = sliderColors,
141
150
  interactionSource = interactionSource,
142
151
  modifier = modifier
@@ -6,6 +6,7 @@ import androidx.compose.material3.DropdownMenu
6
6
  import androidx.compose.material3.MenuDefaults
7
7
  import androidx.compose.runtime.Composable
8
8
  import androidx.compose.ui.unit.dp
9
+ import androidx.compose.ui.window.PopupProperties
9
10
  import expo.modules.kotlin.views.FunctionalComposableScope
10
11
  import expo.modules.ui.UIComposableScope
11
12
  import expo.modules.ui.ModifierRegistry
@@ -29,7 +30,13 @@ fun FunctionalComposableScope.DropdownMenuContent(
29
30
  shape = props.cornerRadius?.let { RoundedCornerShape(it.dp) } ?: MenuDefaults.shape,
30
31
  shadowElevation = props.shadowElevation?.dp ?: MenuDefaults.ShadowElevation,
31
32
  expanded = props.expanded,
32
- onDismissRequest = onDismissRequest
33
+ onDismissRequest = onDismissRequest,
34
+ properties = PopupProperties(
35
+ focusable = props.properties.focusable,
36
+ dismissOnBackPress = props.properties.dismissOnBackPress,
37
+ dismissOnClickOutside = props.properties.dismissOnClickOutside,
38
+ clippingEnabled = props.properties.clippingEnabled
39
+ )
33
40
  ) {
34
41
  itemsSlotView?.let {
35
42
  with(UIComposableScope()) {
@@ -1,7 +1,10 @@
1
1
  package expo.modules.ui.menu
2
2
 
3
3
  import android.graphics.Color
4
+ import expo.modules.kotlin.records.Field
5
+ import expo.modules.kotlin.records.Record
4
6
  import expo.modules.kotlin.types.Enumerable
7
+ import expo.modules.kotlin.types.OptimizedRecord
5
8
  import expo.modules.kotlin.views.ComposeProps
6
9
  import expo.modules.ui.ModifierList
7
10
  import expo.modules.kotlin.views.OptimizedComposeProps
@@ -11,6 +14,14 @@ enum class ActivationMethod(val value: String) : Enumerable {
11
14
  LONG_PRESS("longPress")
12
15
  }
13
16
 
17
+ @OptimizedRecord
18
+ data class ExpoPopupProperties(
19
+ @Field val focusable: Boolean = true,
20
+ @Field val dismissOnBackPress: Boolean = true,
21
+ @Field val dismissOnClickOutside: Boolean = true,
22
+ @Field val clippingEnabled: Boolean = true
23
+ ) : Record
24
+
14
25
  @OptimizedComposeProps
15
26
  data class DropdownMenuProps(
16
27
  val activationMethod: ActivationMethod = ActivationMethod.SINGLE_PRESS,
@@ -18,5 +29,6 @@ data class DropdownMenuProps(
18
29
  val color: Color? = null,
19
30
  val cornerRadius: Float? = null,
20
31
  val modifiers: ModifierList = emptyList(),
21
- val shadowElevation: Float? = null
32
+ val shadowElevation: Float? = null,
33
+ val properties: ExpoPopupProperties = ExpoPopupProperties()
22
34
  ) : ComposeProps
@@ -2,6 +2,7 @@ package expo.modules.ui.menu
2
2
 
3
3
  import android.graphics.Color
4
4
  import androidx.compose.material3.ExperimentalMaterial3Api
5
+ import androidx.compose.material3.ExposedDropdownMenu
5
6
  import androidx.compose.material3.MenuDefaults
6
7
  import androidx.compose.runtime.Composable
7
8
  import expo.modules.kotlin.views.ComposeProps
@@ -0,0 +1,10 @@
1
+ /**
2
+ * `true` inside a `Host`, where SwiftUI or Jetpack Compose renders the content. `RNHostView` sets it
3
+ * back to `false`, because its children are React Native views again.
4
+ */
5
+ export declare const NativeTreeContext: import("react").Context<boolean>;
6
+ export declare function useIsInsideNativeTree(): boolean;
7
+ /**
8
+ * Warns once in development when a `Host` renders directly inside another `Host`'s native content.
9
+ */
10
+ export declare function useWarnIfNestedHost(layoutSystem: 'SwiftUI' | 'Jetpack Compose'): void;
@@ -0,0 +1,25 @@
1
+ import { createContext, useContext, useEffect } from 'react';
2
+ /**
3
+ * `true` inside a `Host`, where SwiftUI or Jetpack Compose renders the content. `RNHostView` sets it
4
+ * back to `false`, because its children are React Native views again.
5
+ */ export const NativeTreeContext = /*#__PURE__*/ createContext(false);
6
+ export function useIsInsideNativeTree() {
7
+ return useContext(NativeTreeContext);
8
+ }
9
+ let warned = false;
10
+ /**
11
+ * Warns once in development when a `Host` renders directly inside another `Host`'s native content.
12
+ */ export function useWarnIfNestedHost(layoutSystem) {
13
+ const isNested = useIsInsideNativeTree();
14
+ useEffect(()=>{
15
+ if (__DEV__ && isNested && !warned) {
16
+ warned = true;
17
+ console.warn(`[@expo/ui] A \`Host\` is rendered directly inside another \`Host\`'s ${layoutSystem} content. ` + `${layoutSystem} places it, but React Native can't see where, so its layout and \`measure()\` ` + `can be wrong, and a \`Pressable\` inside it can cancel its press. Wrap the nested \`Host\` in ` + `\`RNHostView\`, or render its ${layoutSystem} components directly in the outer \`Host\`.`);
18
+ }
19
+ }, [
20
+ isNested,
21
+ layoutSystem
22
+ ]);
23
+ }
24
+
25
+ //# sourceMappingURL=NativeTreeContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["NativeTreeContext.tsx"],"sourcesContent":[null],"names":["createContext","useContext","useEffect","NativeTreeContext","useIsInsideNativeTree","warned","useWarnIfNestedHost","layoutSystem","isNested","__DEV__","console","warn"],"mappings":"AAAA,SAASA,aAAa,EAAEC,UAAU,EAAEC,SAAS,QAAQ,QAAQ;AAE7D;;;CAGC,GACD,OAAO,MAAMC,kCAAoBH,cAAc,OAAO;AAEtD,OAAO,SAASI;IACd,OAAOH,WAAWE;AACpB;AAEA,IAAIE,SAAS;AAEb;;CAEC,GACD,OAAO,SAASC,oBAAoBC,YAA2C;IAC7E,MAAMC,WAAWJ;IACjBF,UAAU;QACR,IAAIO,WAAWD,YAAY,CAACH,QAAQ;YAClCA,SAAS;YACTK,QAAQC,IAAI,CACV,CAAC,qEAAqE,EAAEJ,aAAa,UAAU,CAAC,GAC9F,GAAGA,aAAa,8EAA8E,CAAC,GAC/F,CAAC,8FAA8F,CAAC,GAChG,CAAC,8BAA8B,EAAEA,aAAa,2CAA2C,CAAC;QAEhG;IACF,GAAG;QAACC;QAAUD;KAAa;AAC7B"}
@@ -177,8 +177,14 @@ function findNearestDetentIndex(detents, position) {
177
177
  const modifiers = useMemo(()=>{
178
178
  const bg = extractBackgroundColor(backgroundStyle);
179
179
  return [
180
- ...fitToContents ? [
181
- presentationSizing('fitted')
180
+ ...fitToContents ? // the system choose the width.
181
+ [
182
+ presentationSizing('automatic', {
183
+ fitted: {
184
+ horizontal: false,
185
+ vertical: true
186
+ }
187
+ })
182
188
  ] : [
183
189
  presentationDetents(detents, {
184
190
  selection: selectedDetent,
@@ -218,10 +224,11 @@ function findNearestDetentIndex(detents, position) {
218
224
  children: /*#__PURE__*/ _jsx(Group, {
219
225
  modifiers: modifiers,
220
226
  children: /*#__PURE__*/ _jsx(RNHostView, {
221
- matchContents: fitToContents,
227
+ matchContents: fitToContents ? {
228
+ vertical: true
229
+ } : false,
222
230
  children: /*#__PURE__*/ _jsx(View, {
223
231
  style: fitToContents ? {
224
- width,
225
232
  paddingTop: handleComponent !== null ? 16 : 0
226
233
  } : {
227
234
  flexGrow: 1,