@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.
- package/CHANGELOG.md +12 -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/HostView.kt +52 -8
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +40 -12
- package/android/src/main/java/expo/modules/ui/UniversalLayout.kt +610 -0
- 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/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/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/HStack/index.d.ts +6 -0
- package/build/swift-ui/HStack/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/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/ios/GroupView.swift +3 -0
- package/ios/HStackView.swift +26 -2
- package/ios/HostView.swift +21 -12
- package/ios/Modifiers/ViewModifierRegistry.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.23/expo.modules.ui-58.0.23-sources.jar} +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23-sources.jar.sha512 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.aar.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.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.23/expo.modules.ui-58.0.23.module} +22 -22
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.module.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.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.23/expo.modules.ui-58.0.23.pom} +1 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.md5 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha1 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha256 +1 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.23/expo.modules.ui-58.0.23.pom.sha512 +1 -0
- package/package.json +1 -1
- package/src/jetpack-compose/Column/index.tsx +5 -0
- package/src/jetpack-compose/Row/index.tsx +5 -0
- package/src/recycling/useRecycledRows.tsx +3 -0
- package/src/swift-ui/HStack/index.tsx +6 -0
- package/src/swift-ui/VStack/index.tsx +6 -0
- 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/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,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
|
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.23'
|
|
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.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
|
-
|
|
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
|
|
|
@@ -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
|
-
|
|
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 =
|
|
251
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
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, _, _ ->
|