@expo/ui 58.0.22 → 58.0.23

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 (195) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/android/build.gradle +2 -2
  3. package/android/src/main/java/expo/modules/ui/ComposeViews.kt +53 -29
  4. package/android/src/main/java/expo/modules/ui/HostView.kt +52 -8
  5. package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +40 -12
  6. package/android/src/main/java/expo/modules/ui/UniversalLayout.kt +610 -0
  7. package/android/src/main/java/expo/modules/ui/state/ObservableState.kt +2 -0
  8. package/android/src/main/java/expo/modules/ui/state/WorkletCallback.kt +2 -0
  9. package/build/jetpack-compose/Column/index.d.ts +5 -0
  10. package/build/jetpack-compose/Column/index.js.map +1 -1
  11. package/build/jetpack-compose/Row/index.d.ts +5 -0
  12. package/build/jetpack-compose/Row/index.js.map +1 -1
  13. package/build/recycling/useRecycledRows.d.ts +2 -0
  14. package/build/recycling/useRecycledRows.js +1 -0
  15. package/build/recycling/useRecycledRows.js.map +1 -1
  16. package/build/swift-ui/HStack/index.d.ts +6 -0
  17. package/build/swift-ui/HStack/index.js.map +1 -1
  18. package/build/swift-ui/VStack/index.d.ts +6 -0
  19. package/build/swift-ui/VStack/index.js.map +1 -1
  20. package/build/universal/Button/index.android.js +3 -1
  21. package/build/universal/Button/index.android.js.map +1 -1
  22. package/build/universal/Button/index.ios.js +3 -1
  23. package/build/universal/Button/index.ios.js.map +1 -1
  24. package/build/universal/Collapsible/index.ios.js +1 -0
  25. package/build/universal/Collapsible/index.ios.js.map +1 -1
  26. package/build/universal/Column/index.android.js +4 -1
  27. package/build/universal/Column/index.android.js.map +1 -1
  28. package/build/universal/Column/index.ios.js +2 -0
  29. package/build/universal/Column/index.ios.js.map +1 -1
  30. package/build/universal/Column/index.js +13 -4
  31. package/build/universal/Column/index.js.map +1 -1
  32. package/build/universal/FieldGroup/FieldGroup.android.js +3 -1
  33. package/build/universal/FieldGroup/FieldGroup.android.js.map +1 -1
  34. package/build/universal/FieldGroup/FieldGroup.ios.js +3 -1
  35. package/build/universal/FieldGroup/FieldGroup.ios.js.map +1 -1
  36. package/build/universal/FieldGroup/FieldSection.android.js +13 -4
  37. package/build/universal/FieldGroup/FieldSection.android.js.map +1 -1
  38. package/build/universal/FieldGroup/FieldSection.ios.js +3 -1
  39. package/build/universal/FieldGroup/FieldSection.ios.js.map +1 -1
  40. package/build/universal/Icon/index.android.js +3 -1
  41. package/build/universal/Icon/index.android.js.map +1 -1
  42. package/build/universal/Icon/index.ios.js +3 -1
  43. package/build/universal/Icon/index.ios.js.map +1 -1
  44. package/build/universal/List/ListForEach.android.d.ts +7 -0
  45. package/build/universal/List/ListForEach.android.js +6 -0
  46. package/build/universal/List/ListForEach.android.js.map +1 -0
  47. package/build/universal/List/ListForEach.d.ts +5 -0
  48. package/build/universal/List/ListForEach.ios.d.ts +5 -0
  49. package/build/universal/List/ListForEach.ios.js +11 -0
  50. package/build/universal/List/ListForEach.ios.js.map +1 -0
  51. package/build/universal/List/ListForEach.js +263 -0
  52. package/build/universal/List/ListForEach.js.map +1 -0
  53. package/build/universal/List/ListScrollContext.d.ts +5 -0
  54. package/build/universal/List/ListScrollContext.js +6 -0
  55. package/build/universal/List/ListScrollContext.js.map +1 -0
  56. package/build/universal/List/index.android.d.ts +5 -0
  57. package/build/universal/List/index.android.js +3 -0
  58. package/build/universal/List/index.android.js.map +1 -1
  59. package/build/universal/List/index.d.ts +5 -0
  60. package/build/universal/List/index.ios.d.ts +5 -0
  61. package/build/universal/List/index.ios.js +3 -0
  62. package/build/universal/List/index.ios.js.map +1 -1
  63. package/build/universal/List/index.js +12 -1
  64. package/build/universal/List/index.js.map +1 -1
  65. package/build/universal/List/types.d.ts +42 -1
  66. package/build/universal/List/types.js +1 -3
  67. package/build/universal/List/types.js.map +1 -1
  68. package/build/universal/RNHostView/index.android.js +3 -1
  69. package/build/universal/RNHostView/index.android.js.map +1 -1
  70. package/build/universal/Row/index.android.js +4 -1
  71. package/build/universal/Row/index.android.js.map +1 -1
  72. package/build/universal/Row/index.ios.js +2 -0
  73. package/build/universal/Row/index.ios.js.map +1 -1
  74. package/build/universal/Row/index.js +13 -7
  75. package/build/universal/Row/index.js.map +1 -1
  76. package/build/universal/ScrollView/index.android.js +8 -1
  77. package/build/universal/ScrollView/index.android.js.map +1 -1
  78. package/build/universal/ScrollView/index.ios.js +3 -1
  79. package/build/universal/ScrollView/index.ios.js.map +1 -1
  80. package/build/universal/Spacer/index.android.js +3 -1
  81. package/build/universal/Spacer/index.android.js.map +1 -1
  82. package/build/universal/Spacer/index.ios.js +3 -1
  83. package/build/universal/Spacer/index.ios.js.map +1 -1
  84. package/build/universal/Text/index.android.js +3 -1
  85. package/build/universal/Text/index.android.js.map +1 -1
  86. package/build/universal/Text/index.ios.js +3 -1
  87. package/build/universal/Text/index.ios.js.map +1 -1
  88. package/build/universal/TextInput/index.android.js +22 -7
  89. package/build/universal/TextInput/index.android.js.map +1 -1
  90. package/build/universal/TextInput/index.ios.js +1 -0
  91. package/build/universal/TextInput/index.ios.js.map +1 -1
  92. package/build/universal/index.d.ts +1 -1
  93. package/build/universal/modifierUtils.d.ts +34 -1
  94. package/build/universal/modifierUtils.js +98 -2
  95. package/build/universal/modifierUtils.js.map +1 -1
  96. package/build/universal/stackAxis.d.ts +9 -0
  97. package/build/universal/stackAxis.js +11 -0
  98. package/build/universal/stackAxis.js.map +1 -0
  99. package/build/universal/transformStyle.android.d.ts +6 -2
  100. package/build/universal/transformStyle.android.js +18 -11
  101. package/build/universal/transformStyle.android.js.map +1 -1
  102. package/build/universal/transformStyle.ios.d.ts +5 -1
  103. package/build/universal/transformStyle.ios.js +29 -11
  104. package/build/universal/transformStyle.ios.js.map +1 -1
  105. package/build/universal/types.d.ts +26 -1
  106. package/build/universal/types.js.map +1 -1
  107. package/ios/GroupView.swift +3 -0
  108. package/ios/HStackView.swift +26 -2
  109. package/ios/HostView.swift +21 -12
  110. package/ios/Modifiers/ViewModifierRegistry.swift +4 -0
  111. package/ios/ScrollViewComponent.swift +20 -0
  112. package/ios/UIBaseView.swift +4 -1
  113. package/ios/UniversalLayout.swift +691 -0
  114. package/ios/VStackView.swift +26 -2
  115. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22-sources.jar → 58.0.23/expo.modules.ui-58.0.23-sources.jar} +0 -0
  116. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.md5 +1 -0
  117. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha1 +1 -0
  118. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha256 +1 -0
  119. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha512 +1 -0
  120. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar +0 -0
  121. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.md5 +1 -0
  122. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.sha1 +1 -0
  123. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.sha256 +1 -0
  124. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.sha512 +1 -0
  125. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.module → 58.0.23/expo.modules.ui-58.0.23.module} +22 -22
  126. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.md5 +1 -0
  127. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.sha1 +1 -0
  128. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.sha256 +1 -0
  129. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.sha512 +1 -0
  130. package/local-maven-repo/expo/modules/ui/expo.modules.ui/{58.0.22/expo.modules.ui-58.0.22.pom → 58.0.23/expo.modules.ui-58.0.23.pom} +1 -1
  131. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.md5 +1 -0
  132. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha1 +1 -0
  133. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha256 +1 -0
  134. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha512 +1 -0
  135. package/package.json +1 -1
  136. package/src/jetpack-compose/Column/index.tsx +5 -0
  137. package/src/jetpack-compose/Row/index.tsx +5 -0
  138. package/src/recycling/useRecycledRows.tsx +3 -0
  139. package/src/swift-ui/HStack/index.tsx +6 -0
  140. package/src/swift-ui/VStack/index.tsx +6 -0
  141. package/src/universal/Button/index.android.tsx +3 -1
  142. package/src/universal/Button/index.ios.tsx +2 -1
  143. package/src/universal/Collapsible/index.ios.tsx +4 -1
  144. package/src/universal/Column/index.android.tsx +3 -1
  145. package/src/universal/Column/index.ios.tsx +2 -1
  146. package/src/universal/Column/index.tsx +9 -4
  147. package/src/universal/FieldGroup/FieldGroup.android.tsx +8 -1
  148. package/src/universal/FieldGroup/FieldGroup.ios.tsx +2 -1
  149. package/src/universal/FieldGroup/FieldSection.android.tsx +17 -4
  150. package/src/universal/FieldGroup/FieldSection.ios.tsx +2 -1
  151. package/src/universal/Icon/index.android.tsx +2 -1
  152. package/src/universal/Icon/index.ios.tsx +2 -1
  153. package/src/universal/List/ListForEach.android.tsx +6 -0
  154. package/src/universal/List/ListForEach.ios.tsx +9 -0
  155. package/src/universal/List/ListForEach.tsx +246 -0
  156. package/src/universal/List/ListScrollContext.ts +6 -0
  157. package/src/universal/List/index.android.tsx +5 -0
  158. package/src/universal/List/index.ios.tsx +5 -0
  159. package/src/universal/List/index.tsx +11 -2
  160. package/src/universal/List/types.ts +45 -1
  161. package/src/universal/RNHostView/index.android.tsx +2 -1
  162. package/src/universal/Row/index.android.tsx +3 -1
  163. package/src/universal/Row/index.ios.tsx +2 -1
  164. package/src/universal/Row/index.tsx +9 -10
  165. package/src/universal/ScrollView/index.android.tsx +15 -3
  166. package/src/universal/ScrollView/index.ios.tsx +2 -1
  167. package/src/universal/Spacer/index.android.tsx +6 -4
  168. package/src/universal/Spacer/index.ios.tsx +2 -1
  169. package/src/universal/Text/index.android.tsx +2 -1
  170. package/src/universal/Text/index.ios.tsx +2 -1
  171. package/src/universal/TextInput/index.android.tsx +26 -5
  172. package/src/universal/TextInput/index.ios.tsx +1 -1
  173. package/src/universal/index.ts +6 -1
  174. package/src/universal/modifierUtils.ts +159 -2
  175. package/src/universal/stackAxis.ts +17 -0
  176. package/src/universal/transformStyle.android.ts +30 -12
  177. package/src/universal/transformStyle.ios.ts +41 -13
  178. package/src/universal/types.ts +27 -3
  179. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.md5 +0 -1
  180. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha1 +0 -1
  181. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha256 +0 -1
  182. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22-sources.jar.sha512 +0 -1
  183. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar +0 -0
  184. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.md5 +0 -1
  185. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha1 +0 -1
  186. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha256 +0 -1
  187. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.aar.sha512 +0 -1
  188. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.md5 +0 -1
  189. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha1 +0 -1
  190. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha256 +0 -1
  191. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.module.sha512 +0 -1
  192. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.md5 +0 -1
  193. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha1 +0 -1
  194. package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.22/expo.modules.ui-58.0.22.pom.sha256 +0 -1
  195. 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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 58.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - [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))
8
+ - 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))
9
+ - 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))
10
+ - 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))
11
+ - 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))
12
+ - 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))
13
+ - [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))
14
+
3
15
  ## 58.0.22
4
16
 
5
17
  ### 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.22'
15
+ version = '58.0.23'
16
16
 
17
17
  android {
18
18
  namespace "expo.modules.ui"
19
19
  defaultConfig {
20
20
  versionCode 1
21
- versionName "58.0.22"
21
+ versionName "58.0.23"
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
- Row(
64
- horizontalArrangement = props.horizontalArrangement?.toComposeArrangement() ?: Arrangement.Start,
65
- verticalAlignment = props.verticalAlignment?.toComposeAlignment() ?: Alignment.Top,
66
- modifier = ModifierRegistry
67
- .applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
68
- .then(
69
- if (scrollBehavior != null) {
70
- Modifier.nestedScroll(scrollBehavior)
71
- } else {
72
- Modifier
73
- }
74
- )
75
- ) {
76
- Children(UIComposableScope(rowScope = this@Row, nestedScrollConnection = scrollBehavior))
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
- Column(
100
- verticalArrangement = props.verticalArrangement?.toComposeArrangement() ?: Arrangement.Top,
101
- horizontalAlignment = props.horizontalAlignment?.toComposeAlignment() ?: Alignment.Start,
102
- modifier = ModifierRegistry
103
- .applyModifiers(props.modifiers, appContext, composableScope, globalEventDispatcher)
104
- .then(
105
- if (scrollBehavior != null) {
106
- Modifier.nestedScroll(scrollBehavior)
107
- } else {
108
- Modifier
109
- }
110
- )
111
- ) {
112
- Children(UIComposableScope(columnScope = this@Column, nestedScrollConnection = scrollBehavior))
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
 
@@ -123,6 +123,11 @@ internal class HostView(context: Context, appContext: AppContext) :
123
123
  private val onLayoutContent by EventDispatcher<LayoutContentEvent>()
124
124
  private var lastDispatchedContentSize: IntSize? = null
125
125
 
126
+ // The size a child fraction was resolved against, in dp.
127
+ // matchContents would otherwise publish the percentage result and the next pass divides it again.
128
+ private var percentageBaseWidthDp: Double? = null
129
+ private var percentageBaseHeightDp: Double? = null
130
+
126
131
  /**
127
132
  * True while this view passes down an `ACTION_CANCEL` that came from its React Native parent,
128
133
  * not from a Compose gesture detector. React Native already owns that gesture: the usual cause is
@@ -240,15 +245,54 @@ internal class HostView(context: Context, appContext: AppContext) :
240
245
  constraints.maxHeight
241
246
  }
242
247
  )
243
- val placeables = measurables.map { it.measure(boundedConstraints) }
248
+ // `measure` does not read a child percentage, so apply it here when this host
249
+ // has a size on that axis. A child with no percentage keeps these constraints.
250
+ // Compose Row and Column do not read that percentage.
251
+ val definiteWidth = boundedConstraints.maxWidth.takeIf {
252
+ it != Constraints.Infinity && (boundedConstraints.minWidth == it || useViewportSizeMeasurement)
253
+ }
254
+ val definiteHeight = boundedConstraints.maxHeight.takeIf {
255
+ it != Constraints.Infinity && (boundedConstraints.minHeight == it || useViewportSizeMeasurement)
256
+ }
257
+ val placeables = measurables.map {
258
+ measureUniversalChild(it, boundedConstraints, definiteWidth, definiteHeight)
259
+ }
244
260
 
245
261
  val contentWidthPx = placeables.maxOfOrNull { it.width } ?: 0
246
262
  val contentHeightPx = placeables.maxOfOrNull { it.height } ?: 0
263
+ // A child percentage is a fraction of the safe area proposed above.
264
+ // Publishing that result as the view size makes the next pass resolve it again.
265
+ val widthFromPercentage = definiteWidth != null && measurables.any {
266
+ it.parentData.asUniversalLayoutParentData().dimensions.widthFraction != null
267
+ }
268
+ val heightFromPercentage = definiteHeight != null && measurables.any {
269
+ it.parentData.asUniversalLayoutParentData().dimensions.heightFraction != null
270
+ }
271
+ // setStyleSize replaces the pending setViewSize flush.
272
+ // Publish this base for a viewport fraction so both updates describe the same size.
273
+ percentageBaseWidthDp = if (useViewportSizeMeasurement && widthFromPercentage && definiteWidth != null) {
274
+ with(density) { definiteWidth.toDp().value.toDouble() }
275
+ } else {
276
+ null
277
+ }
278
+ percentageBaseHeightDp = if (useViewportSizeMeasurement && heightFromPercentage && definiteHeight != null) {
279
+ with(density) { definiteHeight.toDp().value.toDouble() }
280
+ } else {
281
+ null
282
+ }
247
283
 
248
284
  if (useViewportSizeMeasurement && (constraints.maxWidth == 0 || constraints.maxHeight == 0)) {
249
285
  with(density) {
250
- val widthDp = contentWidthPx.toDp().value.toDouble()
251
- val heightDp = contentHeightPx.toDp().value.toDouble()
286
+ val widthDp = if (widthFromPercentage) {
287
+ safeWidthPx.toDp().value.toDouble()
288
+ } else {
289
+ contentWidthPx.toDp().value.toDouble()
290
+ }
291
+ val heightDp = if (heightFromPercentage) {
292
+ safeHeightPx.toDp().value.toDouble()
293
+ } else {
294
+ contentHeightPx.toDp().value.toDouble()
295
+ }
252
296
 
253
297
  shadowNodeProxy.setViewSize(
254
298
  if (constraints.maxWidth == 0) {
@@ -287,17 +331,17 @@ internal class HostView(context: Context, appContext: AppContext) :
287
331
  val height = size.height.toDp().value
288
332
 
289
333
  if (matchContentsHorizontal == true || matchContentsVertical == true) {
290
- val styleWidth = if (matchContentsHorizontal == true && width > 0) {
291
- width
334
+ val styleWidth = if (matchContentsHorizontal == true) {
335
+ percentageBaseWidthDp ?: width.takeIf { it > 0 }?.toDouble()
292
336
  } else {
293
337
  null
294
338
  }
295
- val styleHeight = if (matchContentsVertical == true && height > 0) {
296
- height
339
+ val styleHeight = if (matchContentsVertical == true) {
340
+ percentageBaseHeightDp ?: height.takeIf { it > 0 }?.toDouble()
297
341
  } else {
298
342
  null
299
343
  }
300
- shadowNodeProxy.setStyleSize(styleWidth?.toDouble(), styleHeight?.toDouble())
344
+ shadowNodeProxy.setStyleSize(styleWidth, styleHeight)
301
345
  }
302
346
 
303
347
  // `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
- scope?.rowScope?.run {
678
- Modifier.weight(params.weight)
679
- } ?: scope?.columnScope?.run {
680
- Modifier.weight(params.weight)
681
- } ?: Modifier
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
- scope?.boxScope?.run {
687
- params.alignment?.toAlignment()?.let { alignment -> Modifier.align(alignment) }
688
- } ?: scope?.rowScope?.run {
689
- params.alignment?.toVerticalAlignment()?.let { alignment -> Modifier.align(alignment) }
690
- } ?: scope?.columnScope?.run {
691
- params.alignment?.toHorizontalAlignment()?.let { alignment -> Modifier.align(alignment) }
692
- } ?: Modifier
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, _, _ ->