@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
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { background, border, clipShape, contentShape, disabled as disabledMod, font, foregroundStyle, frame, hidden as hiddenMod, kerning, lineSpacing, multilineTextAlignment, onAppear, onDisappear, onTapGesture, opacity, padding, shapes } from '@expo/ui/swift-ui/modifiers';
|
|
2
|
-
import { omitUserOverridden } from './modifierUtils';
|
|
2
|
+
import { createUniversalLayoutModifier, omitUserOverridden, omitUserOverriddenDimensions, serializeUniversalDimensions } from './modifierUtils';
|
|
3
|
+
// A user frame owns only the axes it sets. Keep a derived frame that still
|
|
4
|
+
// owns the other axis, and keep the layout value the parent stack reads.
|
|
5
|
+
const preservedSizingTypes = new Set([
|
|
6
|
+
'frame',
|
|
7
|
+
'universalLayout'
|
|
8
|
+
]);
|
|
3
9
|
const FONT_WEIGHT_MAP = {
|
|
4
10
|
'100': 'ultraLight',
|
|
5
11
|
'200': 'thin',
|
|
@@ -19,13 +25,18 @@ const FONT_WEIGHT_MAP = {
|
|
|
19
25
|
*
|
|
20
26
|
* SwiftUI modifiers apply inside-out (each modifier wraps the previous).
|
|
21
27
|
* To match React Native's box model (background fills the full box):
|
|
22
|
-
* padding →
|
|
28
|
+
* padding → fixed frame → universal layout → background → border → clip → opacity
|
|
23
29
|
* → events → lifecycle → behavior → user escape-hatch
|
|
24
30
|
*
|
|
31
|
+
* Fixed sizes become a `frame`.
|
|
32
|
+
* Percentages stay on `universalLayout` so the parent stack can resolve them.
|
|
25
33
|
* Style-derived modifiers yield to user-supplied modifiers of the same
|
|
26
34
|
* `$type`, so the escape hatch can override anything derived from props.
|
|
27
35
|
*/ export function transformToModifiers(style, props, extraModifiers, options) {
|
|
28
36
|
let mods = [];
|
|
37
|
+
const dimensions = omitUserOverriddenDimensions(serializeUniversalDimensions(style, options?.componentName), extraModifiers, 'ios');
|
|
38
|
+
const fixedWidth = dimensions.widthPoints;
|
|
39
|
+
const fixedHeight = dimensions.heightPoints;
|
|
29
40
|
// Text styling (innermost — applies to text content before container modifiers)
|
|
30
41
|
const textStyle = options?.textStyle;
|
|
31
42
|
if (textStyle) {
|
|
@@ -62,14 +73,19 @@ const FONT_WEIGHT_MAP = {
|
|
|
62
73
|
trailing: style.paddingRight
|
|
63
74
|
}));
|
|
64
75
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
76
|
+
}
|
|
77
|
+
// Fixed sizing is applied directly. Percentages remain as layout values for
|
|
78
|
+
// the owning universal layout to resolve against its content box.
|
|
79
|
+
if (fixedWidth != null || fixedHeight != null) {
|
|
80
|
+
mods.push(frame({
|
|
81
|
+
width: fixedWidth,
|
|
82
|
+
height: fixedHeight,
|
|
83
|
+
alignment: options?.frameAlignment
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
const universalLayoutModifier = createUniversalLayoutModifier(dimensions);
|
|
87
|
+
if (universalLayoutModifier) mods.push(universalLayoutModifier);
|
|
88
|
+
if (style) {
|
|
73
89
|
// Background (fills the frame area including padding)
|
|
74
90
|
if (style.backgroundColor) {
|
|
75
91
|
mods.push(background(style.backgroundColor));
|
|
@@ -92,7 +108,9 @@ const FONT_WEIGHT_MAP = {
|
|
|
92
108
|
}
|
|
93
109
|
// A user-supplied modifier replaces any style-derived modifier of the same
|
|
94
110
|
// type. The event, lifecycle, and behavior modifiers below are never dropped.
|
|
95
|
-
|
|
111
|
+
// Axis-aware sizing precedence has already removed only the dimensions set
|
|
112
|
+
// by a user frame. Preserve any derived frame that still owns the other axis.
|
|
113
|
+
mods = omitUserOverridden(mods, extraModifiers, preservedSizingTypes);
|
|
96
114
|
// Events. SwiftUI only hit-tests drawn content, so the `contentShape` lets
|
|
97
115
|
// taps on empty space (for example a `Spacer` in a `Row`) reach `onPress`.
|
|
98
116
|
if (props.onPress) mods.push(contentShape(shapes.rectangle()), onTapGesture(props.onPress));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["universal/transformStyle.ios.ts"],"sourcesContent":[null],"names":["background","border","clipShape","contentShape","disabled","disabledMod","font","foregroundStyle","frame","hidden","hiddenMod","kerning","lineSpacing","multilineTextAlignment","onAppear","onDisappear","onTapGesture","opacity","padding","shapes","omitUserOverridden","FONT_WEIGHT_MAP","normal","bold","transformToModifiers","style","props","extraModifiers","options","mods","textStyle","fontFamily","fontSize","fontWeight","push","family","size","weight","undefined","color","letterSpacing","lineHeight","baseFontSize","Math","max","textAlign","hasPadding","paddingHorizontal","paddingVertical","paddingTop","paddingBottom","paddingLeft","paddingRight","all","horizontal","vertical","top","bottom","leading","trailing","width","height","alignment","frameAlignment","backgroundColor","borderWidth","borderColor","content","borderRadius","onPress","rectangle"],"mappings":"AAAA,SACEA,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,YAAYC,WAAW,EACvBC,IAAI,EACJC,eAAe,EACfC,KAAK,EACLC,UAAUC,SAAS,EACnBC,OAAO,EACPC,WAAW,EACXC,sBAAsB,EACtBC,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,OAAO,EACPC,MAAM,QAED,8BAA8B;AAGrC,
|
|
1
|
+
{"version":3,"sources":["universal/transformStyle.ios.ts"],"sourcesContent":[null],"names":["background","border","clipShape","contentShape","disabled","disabledMod","font","foregroundStyle","frame","hidden","hiddenMod","kerning","lineSpacing","multilineTextAlignment","onAppear","onDisappear","onTapGesture","opacity","padding","shapes","createUniversalLayoutModifier","omitUserOverridden","omitUserOverriddenDimensions","serializeUniversalDimensions","preservedSizingTypes","Set","FONT_WEIGHT_MAP","normal","bold","transformToModifiers","style","props","extraModifiers","options","mods","dimensions","componentName","fixedWidth","widthPoints","fixedHeight","heightPoints","textStyle","fontFamily","fontSize","fontWeight","push","family","size","weight","undefined","color","letterSpacing","lineHeight","baseFontSize","Math","max","textAlign","hasPadding","paddingHorizontal","paddingVertical","paddingTop","paddingBottom","paddingLeft","paddingRight","all","horizontal","vertical","top","bottom","leading","trailing","width","height","alignment","frameAlignment","universalLayoutModifier","backgroundColor","borderWidth","borderColor","content","borderRadius","onPress","rectangle"],"mappings":"AAAA,SACEA,UAAU,EACVC,MAAM,EACNC,SAAS,EACTC,YAAY,EACZC,YAAYC,WAAW,EACvBC,IAAI,EACJC,eAAe,EACfC,KAAK,EACLC,UAAUC,SAAS,EACnBC,OAAO,EACPC,WAAW,EACXC,sBAAsB,EACtBC,QAAQ,EACRC,WAAW,EACXC,YAAY,EACZC,OAAO,EACPC,OAAO,EACPC,MAAM,QAED,8BAA8B;AAGrC,SACEC,6BAA6B,EAC7BC,kBAAkB,EAClBC,4BAA4B,EAC5BC,4BAA4B,QACvB,kBAAkB;AAGzB,2EAA2E;AAC3E,yEAAyE;AACzE,MAAMC,uBAAuB,IAAIC,IAAI;IAAC;IAAS;CAAkB;AAEjE,MAAMC,kBAAwE;IAC5E,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACPC,QAAQ;IACRC,MAAM;AACR;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASC,qBACdC,KAAiC,EACjCC,KAGC,EACDC,cAAiC,EACjCC,OAOC;IAED,IAAIC,OAAyB,EAAE;IAC/B,MAAMC,aAAab,6BACjBC,6BAA6BO,OAAOG,SAASG,gB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mBAAmBa,MAAMF,gBAAgBR;IAEhD,2EAA2E;IAC3E,2EAA2E;IAC3E,IAAIO,MAAMkD,OAAO,EAAE/C,KAAKW,IAAI,CAAC1C,aAAagB,OAAO+D,SAAS,KAAKlE,aAAae,MAAMkD,OAAO;IAEzF,YAAY;IACZ,IAAIlD,MAAMjB,QAAQ,EAAEoB,KAAKW,IAAI,CAAC/B,SAASiB,MAAMjB,QAAQ;IACrD,IAAIiB,MAAMhB,WAAW,EAAEmB,KAAKW,IAAI,CAAC9B,YAAYgB,MAAMhB,WAAW;IAE9D,WAAW;IACX,IAAIgB,MAAM3B,QAAQ,EAAE8B,KAAKW,IAAI,CAACxC,YAAY;IAC1C,IAAI0B,MAAMtB,MAAM,EAAEyB,KAAKW,IAAI,CAACnC,UAAU;IAEtC,mDAAmD;IACnD,IAAIsB,gBAAgBE,KAAKW,IAAI,IAAIb;IAEjC,OAAOE;AACT"}
|
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
import type { ViewStyle } from 'react-native';
|
|
2
2
|
import type { ModifierConfig } from '../types';
|
|
3
|
+
import type { UniversalDimension } from './modifierUtils';
|
|
4
|
+
export type { UniversalDimension } from './modifierUtils';
|
|
3
5
|
/**
|
|
4
6
|
* Subset of React Native `ViewStyle` that maps cleanly to both SwiftUI modifiers
|
|
5
7
|
* and Jetpack Compose modifiers. On web, passes through to React Native StyleSheet.
|
|
8
|
+
*
|
|
9
|
+
* `width` and `height` also accept a percentage of the parent, such as `'50%'`.
|
|
10
|
+
* On Android and iOS, a percentage resolves when the parent is a universal `Row`, `Column`,
|
|
11
|
+
* or `Host` with a size on that axis.
|
|
12
|
+
* A universal `ScrollView` resolves the cross axis only.
|
|
13
|
+
* The scroll axis stays unbounded.
|
|
14
|
+
* On web, the value is passed through to the view style.
|
|
15
|
+
* A Jetpack Compose `Row` or `Column`, or a SwiftUI stack, does not resolve it.
|
|
6
16
|
* @docsInline
|
|
7
17
|
*/
|
|
8
|
-
export type UniversalStyle = Pick<ViewStyle, 'padding' | 'paddingHorizontal' | 'paddingVertical' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'backgroundColor' | 'borderRadius' | 'borderWidth' | 'borderColor' | 'opacity'
|
|
18
|
+
export type UniversalStyle = Pick<ViewStyle, 'padding' | 'paddingHorizontal' | 'paddingVertical' | 'paddingTop' | 'paddingBottom' | 'paddingLeft' | 'paddingRight' | 'backgroundColor' | 'borderRadius' | 'borderWidth' | 'borderColor' | 'opacity'> & {
|
|
19
|
+
/**
|
|
20
|
+
* Fixed size in density-independent pixels, or a percentage of the parent's content width.
|
|
21
|
+
* On Android and iOS, percentages resolve when the parent is a universal `Row`, `Column`,
|
|
22
|
+
* `ScrollView`, or `Host` with a defined width.
|
|
23
|
+
* A horizontal `ScrollView` leaves width unbounded.
|
|
24
|
+
*/
|
|
25
|
+
width?: UniversalDimension;
|
|
26
|
+
/**
|
|
27
|
+
* Fixed size in density-independent pixels, or a percentage of the parent's content height.
|
|
28
|
+
* On Android and iOS, percentages resolve when the parent is a universal `Row`, `Column`,
|
|
29
|
+
* `ScrollView`, or `Host` with a defined height.
|
|
30
|
+
* A vertical `ScrollView` leaves height unbounded.
|
|
31
|
+
*/
|
|
32
|
+
height?: UniversalDimension;
|
|
33
|
+
};
|
|
9
34
|
/**
|
|
10
35
|
* Base props inherited by all universal components.
|
|
11
36
|
* @docsInline
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["universal/types.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["universal/types.ts"],"sourcesContent":[null],"names":[],"mappings":"AA0IA;;;;;;;;;CASC,GACD,WAeE"}
|
package/ios/GroupView.swift
CHANGED
|
@@ -7,6 +7,7 @@ public final class GroupViewProps: UIBaseViewProps {}
|
|
|
7
7
|
|
|
8
8
|
public struct GroupView: ExpoSwiftUI.View {
|
|
9
9
|
@ObservedObject public var props: GroupViewProps
|
|
10
|
+
@Environment(\.resolvesOwnPercentage) private var resolvesOwnPercentage
|
|
10
11
|
|
|
11
12
|
public init(props: GroupViewProps) {
|
|
12
13
|
self.props = props
|
|
@@ -16,5 +17,7 @@ public struct GroupView: ExpoSwiftUI.View {
|
|
|
16
17
|
Group {
|
|
17
18
|
Children()
|
|
18
19
|
}
|
|
20
|
+
// Group does not size its children, so they keep this view's parent.
|
|
21
|
+
.environment(\.universalPercentageParent, resolvesOwnPercentage)
|
|
19
22
|
}
|
|
20
23
|
}
|
package/ios/HStackView.swift
CHANGED
|
@@ -29,20 +29,44 @@ internal enum VerticalAlignmentOptions: String, Enumerable {
|
|
|
29
29
|
public final class HStackViewProps: UIBaseViewProps {
|
|
30
30
|
@Field var spacing: Double?
|
|
31
31
|
@Field var alignment: VerticalAlignmentOptions?
|
|
32
|
+
// Universal `Row` sets this so a child percentage is a fraction of this stack.
|
|
33
|
+
// A SwiftUI `HStack` leaves it off and keeps the platform layout.
|
|
34
|
+
@Field var resolvesChildPercentages: Bool = false
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
public struct HStackView: ExpoSwiftUI.View {
|
|
35
38
|
@ObservedObject public var props: HStackViewProps
|
|
39
|
+
// A fraction on this stack is a real size only when the parent opted in.
|
|
40
|
+
@Environment(\.resolvesOwnPercentage) private var resolvesOwnPercentage
|
|
36
41
|
|
|
37
42
|
public init(props: HStackViewProps) {
|
|
38
43
|
self.props = props
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
public var body: some View {
|
|
47
|
+
if props.resolvesChildPercentages {
|
|
48
|
+
ParentAwareHStackLayout(
|
|
49
|
+
alignment: props.alignment ?? .center,
|
|
50
|
+
spacing: props.spacing.map { CGFloat($0) },
|
|
51
|
+
ownDimensions: universalLayoutDimensions(from: props.modifiers),
|
|
52
|
+
resolvesOwnPercentage: resolvesOwnPercentage
|
|
53
|
+
) {
|
|
54
|
+
Children()
|
|
55
|
+
}
|
|
56
|
+
.environment(\.universalPercentageParent, true)
|
|
57
|
+
} else {
|
|
58
|
+
platformStack
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private var platformStack: some View {
|
|
42
63
|
HStack(
|
|
43
64
|
alignment: props.alignment?.toVerticalAlignment() ?? .center,
|
|
44
|
-
spacing: props.spacing.map { CGFloat($0) }
|
|
45
|
-
|
|
65
|
+
spacing: props.spacing.map { CGFloat($0) }
|
|
66
|
+
) {
|
|
67
|
+
Children()
|
|
46
68
|
}
|
|
69
|
+
// Overrides a Host, so a percentage inside a SwiftUI stack keeps the child's own size.
|
|
70
|
+
.environment(\.universalPercentageParent, false)
|
|
47
71
|
}
|
|
48
72
|
}
|
package/ios/HostView.swift
CHANGED
|
@@ -91,6 +91,7 @@ struct HostView: ExpoSwiftUI.View, ExpoSwiftUI.WithHostingView {
|
|
|
91
91
|
Children()
|
|
92
92
|
}
|
|
93
93
|
.environment(\.expoHostingView, props.hostingViewReference)
|
|
94
|
+
.environment(\.universalPercentageParent, true)
|
|
94
95
|
.modifier(HostViewContentMarginsMitigation(layoutDirection: layoutDirection, hostingView: props.hostingView))
|
|
95
96
|
.fixedSize(horizontal: props.matchContentsHorizontal, vertical: props.matchContentsVertical)
|
|
96
97
|
.modifier(LayoutDirectionModifier(layoutDirection: layoutDirection))
|
|
@@ -115,6 +116,7 @@ struct HostView: ExpoSwiftUI.View, ExpoSwiftUI.WithHostingView {
|
|
|
115
116
|
Children()
|
|
116
117
|
}
|
|
117
118
|
.environment(\.expoHostingView, props.hostingViewReference)
|
|
119
|
+
.environment(\.universalPercentageParent, true)
|
|
118
120
|
.fixedSize(horizontal: props.matchContentsHorizontal, vertical: props.matchContentsVertical)
|
|
119
121
|
.modifier(LayoutDirectionModifier(layoutDirection: layoutDirection))
|
|
120
122
|
.modifier(ColorSchemeModifier(colorScheme: props.colorScheme?.toColorScheme()))
|
|
@@ -166,16 +168,11 @@ private struct ViewportSizeMeasurementLayout: Layout {
|
|
|
166
168
|
weak var hostingView: UIView?
|
|
167
169
|
|
|
168
170
|
func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize {
|
|
169
|
-
let
|
|
170
|
-
let proposalWidth = proposal.width ?? 0
|
|
171
|
-
let proposalHeight = proposal.height ?? 0
|
|
172
|
-
let availableWidth = proposalWidth > 0 ? proposalWidth : maxSize.width
|
|
173
|
-
let availableHeight = proposalHeight > 0 ? proposalHeight : maxSize.height
|
|
174
|
-
|
|
171
|
+
let offered = measurementProposal(for: proposal)
|
|
175
172
|
var resultWidth: CGFloat = 0
|
|
176
173
|
var resultHeight: CGFloat = 0
|
|
177
174
|
for view in subviews {
|
|
178
|
-
let size = view.dimensions(in:
|
|
175
|
+
let size = view.dimensions(in: offered)
|
|
179
176
|
resultWidth = max(resultWidth, size.width)
|
|
180
177
|
resultHeight = max(resultHeight, size.height)
|
|
181
178
|
}
|
|
@@ -183,22 +180,34 @@ private struct ViewportSizeMeasurementLayout: Layout {
|
|
|
183
180
|
}
|
|
184
181
|
|
|
185
182
|
func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) {
|
|
183
|
+
// A child percentage applies to this proposal.
|
|
184
|
+
// Offering `bounds` would use the measured result and apply the fraction again.
|
|
185
|
+
let offered = measurementProposal(for: proposal)
|
|
186
186
|
let isRTL = layoutDirection == .rightToLeft
|
|
187
187
|
for subview in subviews {
|
|
188
188
|
let origin: CGPoint
|
|
189
189
|
if isRTL {
|
|
190
|
-
let size = subview.dimensions(in:
|
|
190
|
+
let size = subview.dimensions(in: offered)
|
|
191
191
|
origin = CGPoint(x: bounds.maxX - size.width, y: bounds.minY)
|
|
192
192
|
} else {
|
|
193
193
|
origin = bounds.origin
|
|
194
194
|
}
|
|
195
|
-
subview.place(
|
|
196
|
-
at: origin,
|
|
197
|
-
proposal: ProposedViewSize(bounds.size)
|
|
198
|
-
)
|
|
195
|
+
subview.place(at: origin, proposal: offered)
|
|
199
196
|
}
|
|
200
197
|
}
|
|
201
198
|
|
|
199
|
+
/// A zero or nil axis uses the safe area.
|
|
200
|
+
/// Placement offers this same size, so a percentage is applied once.
|
|
201
|
+
private func measurementProposal(for proposal: ProposedViewSize) -> ProposedViewSize {
|
|
202
|
+
let maxSize = safeAreaSize()
|
|
203
|
+
let proposalWidth = proposal.width ?? 0
|
|
204
|
+
let proposalHeight = proposal.height ?? 0
|
|
205
|
+
return ProposedViewSize(
|
|
206
|
+
width: proposalWidth > 0 ? proposalWidth : maxSize.width,
|
|
207
|
+
height: proposalHeight > 0 ? proposalHeight : maxSize.height
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
202
211
|
private func safeAreaSize() -> CGSize {
|
|
203
212
|
#if os(macOS)
|
|
204
213
|
// `SceneGeometry` is built on `UIWindowScene`, which has no macOS counterpart. The closest
|
|
@@ -1921,6 +1921,10 @@ extension ViewModifierRegistry {
|
|
|
1921
1921
|
return try FrameModifier(from: params, appContext: appContext)
|
|
1922
1922
|
}
|
|
1923
1923
|
|
|
1924
|
+
register("universalLayout") { params, appContext, _ in
|
|
1925
|
+
return try UniversalLayoutModifier(from: params, appContext: appContext)
|
|
1926
|
+
}
|
|
1927
|
+
|
|
1924
1928
|
register("padding") { params, appContext, _ in
|
|
1925
1929
|
return try PaddingModifier(from: params, appContext: appContext)
|
|
1926
1930
|
}
|
|
@@ -10,6 +10,8 @@ public final class ScrollViewComponentProps: UIBaseViewProps {
|
|
|
10
10
|
|
|
11
11
|
public struct ScrollViewComponent: ExpoSwiftUI.View {
|
|
12
12
|
@ObservedObject public var props: ScrollViewComponentProps
|
|
13
|
+
// A fraction on this view is a real size only when the parent opted in.
|
|
14
|
+
@Environment(\.resolvesOwnPercentage) private var resolvesOwnPercentage
|
|
13
15
|
|
|
14
16
|
public init(props: ScrollViewComponentProps) {
|
|
15
17
|
self.props = props
|
|
@@ -19,5 +21,23 @@ public struct ScrollViewComponent: ExpoSwiftUI.View {
|
|
|
19
21
|
ScrollView(props.axes.toAxis(), showsIndicators: props.showsIndicators) {
|
|
20
22
|
Children()
|
|
21
23
|
}
|
|
24
|
+
// The cross axis resolves a child percentage against the viewport.
|
|
25
|
+
// The scroll axis stays unbounded, so a percentage on that axis does not.
|
|
26
|
+
.environment(\.universalPercentageParent, resolvesChildPercentages)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// A vertical scroll view fills the width it is offered.
|
|
30
|
+
/// A horizontal scroll view takes its height from its content unless a size sets it.
|
|
31
|
+
/// That content height is not a percentage base.
|
|
32
|
+
private var resolvesChildPercentages: Bool {
|
|
33
|
+
switch props.axes {
|
|
34
|
+
case .vertical:
|
|
35
|
+
return true
|
|
36
|
+
case .horizontal:
|
|
37
|
+
let dimensions = universalLayoutDimensions(from: props.modifiers)
|
|
38
|
+
return dimensions.heightPoints != nil || (dimensions.heightFraction != nil && resolvesOwnPercentage)
|
|
39
|
+
case .both:
|
|
40
|
+
return false
|
|
41
|
+
}
|
|
22
42
|
}
|
|
23
43
|
}
|
package/ios/UIBaseView.swift
CHANGED
|
@@ -16,9 +16,12 @@ public struct UIBaseView<Props: UIBaseViewProps, Content: ExpoSwiftUI.View<Props
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
public var body: some View {
|
|
19
|
-
innerView
|
|
19
|
+
UniversalPercentageParentBoundary(content: innerView)
|
|
20
20
|
.applyAccessibilityIdentifier(props.testID)
|
|
21
21
|
.applyModifiers(props.modifiers, appContext: props.appContext, globalEventDispatcher: props.globalEventDispatcher)
|
|
22
|
+
// A user modifier such as `onGeometryChange` hides the layout value a universal stack reads.
|
|
23
|
+
// Set it again outside every modifier.
|
|
24
|
+
.layoutValue(key: UniversalLayoutDimensionsKey.self, value: universalLayoutDimensions(from: props.modifiers))
|
|
22
25
|
.publishZeroContentOrigin(props.shadowNodeProxy)
|
|
23
26
|
}
|
|
24
27
|
}
|