@expo/ui 58.0.21 → 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 +34 -0
- package/README.md +86 -2
- 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/CompositionLocalProviderView.kt +26 -0
- package/android/src/main/java/expo/modules/ui/ExpoUIModule.kt +12 -0
- package/android/src/main/java/expo/modules/ui/HostView.kt +56 -9
- package/android/src/main/java/expo/modules/ui/MaskView.kt +3 -2
- package/android/src/main/java/expo/modules/ui/ModifierRegistry.kt +43 -13
- package/android/src/main/java/expo/modules/ui/RNHostView.kt +11 -7
- package/android/src/main/java/expo/modules/ui/SwitchView.kt +6 -1
- package/android/src/main/java/expo/modules/ui/TopAppBarView.kt +62 -0
- package/android/src/main/java/expo/modules/ui/UniversalLayout.kt +610 -0
- package/android/src/main/java/expo/modules/ui/colors/MaterialColors.kt +61 -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/community/bottom-sheet/BottomSheet.ios.js +8 -3
- package/build/community/bottom-sheet/BottomSheet.ios.js.map +1 -1
- package/build/community/pager-view/PagerView.ios.js +25 -8
- package/build/community/pager-view/PagerView.ios.js.map +1 -1
- package/build/community/segmented-control/SegmentedControl.ios.js +11 -2
- package/build/community/segmented-control/SegmentedControl.ios.js.map +1 -1
- package/build/community/segmented-control/types.d.ts +5 -1
- package/build/community/segmented-control/types.js.map +1 -1
- package/build/jetpack-compose/Column/index.d.ts +5 -0
- package/build/jetpack-compose/Column/index.js.map +1 -1
- package/build/jetpack-compose/CompositionLocalProvider/index.d.ts +28 -0
- package/build/jetpack-compose/CompositionLocalProvider/index.js +15 -0
- package/build/jetpack-compose/CompositionLocalProvider/index.js.map +1 -0
- package/build/jetpack-compose/Host/index.d.ts +8 -0
- package/build/jetpack-compose/Host/index.js +38 -5
- package/build/jetpack-compose/Host/index.js.map +1 -1
- package/build/jetpack-compose/Row/index.d.ts +5 -0
- package/build/jetpack-compose/Row/index.js.map +1 -1
- package/build/jetpack-compose/Switch/index.d.ts +2 -0
- package/build/jetpack-compose/Switch/index.js +1 -0
- package/build/jetpack-compose/Switch/index.js.map +1 -1
- package/build/jetpack-compose/TopAppBar/index.d.ts +72 -0
- package/build/jetpack-compose/TopAppBar/index.js +45 -0
- package/build/jetpack-compose/TopAppBar/index.js.map +1 -0
- package/build/jetpack-compose/index.d.ts +2 -0
- package/build/jetpack-compose/index.js +2 -0
- package/build/jetpack-compose/index.js.map +1 -1
- package/build/jetpack-compose/modifiers/index.d.ts +5 -1
- package/build/jetpack-compose/modifiers/index.js +6 -2
- package/build/jetpack-compose/modifiers/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/BottomSheet/index.d.ts +6 -0
- package/build/swift-ui/BottomSheet/index.js +9 -3
- package/build/swift-ui/BottomSheet/index.js.map +1 -1
- package/build/swift-ui/HStack/index.d.ts +6 -0
- package/build/swift-ui/HStack/index.js.map +1 -1
- package/build/swift-ui/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/Checkbox/index.android.js +16 -4
- package/build/universal/Checkbox/index.android.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 +15 -7
- 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/Switch/index.android.js +17 -4
- package/build/universal/Switch/index.android.js.map +1 -1
- package/build/universal/Switch/index.js +1 -0
- package/build/universal/Switch/index.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/Text/index.js +2 -2
- package/build/universal/Text/index.js.map +1 -1
- package/build/universal/TextInput/index.android.js +22 -7
- package/build/universal/TextInput/index.android.js.map +1 -1
- package/build/universal/TextInput/index.ios.js +1 -0
- package/build/universal/TextInput/index.ios.js.map +1 -1
- package/build/universal/index.d.ts +1 -1
- package/build/universal/modifierUtils.d.ts +34 -1
- package/build/universal/modifierUtils.js +98 -2
- package/build/universal/modifierUtils.js.map +1 -1
- package/build/universal/stackAxis.d.ts +9 -0
- package/build/universal/stackAxis.js +11 -0
- package/build/universal/stackAxis.js.map +1 -0
- package/build/universal/transformStyle.android.d.ts +6 -2
- package/build/universal/transformStyle.android.js +18 -11
- package/build/universal/transformStyle.android.js.map +1 -1
- package/build/universal/transformStyle.ios.d.ts +5 -1
- package/build/universal/transformStyle.ios.js +29 -11
- package/build/universal/transformStyle.ios.js.map +1 -1
- package/build/universal/types.d.ts +26 -1
- package/build/universal/types.js.map +1 -1
- package/build/universal/webUtils.js +4 -0
- package/build/universal/webUtils.js.map +1 -1
- package/ios/BottomSheetView.swift +11 -2
- package/ios/DatePickerView.swift +134 -9
- package/ios/GroupView.swift +3 -0
- package/ios/HStackView.swift +26 -2
- package/ios/HostView.swift +21 -12
- package/ios/Modifiers/SelectedSegmentTintColorModifier.swift +86 -0
- package/ios/Modifiers/ViewModifierRegistry.swift +8 -0
- package/ios/RNHostView.swift +34 -16
- 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.21/expo.modules.ui-58.0.21-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.21/expo.modules.ui-58.0.21.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.21/expo.modules.ui-58.0.21.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 +2 -2
- package/src/community/bottom-sheet/BottomSheet.ios.tsx +7 -3
- package/src/community/pager-view/PagerView.ios.tsx +25 -8
- package/src/community/segmented-control/SegmentedControl.ios.tsx +13 -1
- package/src/community/segmented-control/types.tsx +5 -1
- package/src/jetpack-compose/Column/index.tsx +5 -0
- package/src/jetpack-compose/CompositionLocalProvider/index.tsx +43 -0
- package/src/jetpack-compose/Host/index.tsx +50 -4
- package/src/jetpack-compose/Row/index.tsx +5 -0
- package/src/jetpack-compose/Switch/index.tsx +4 -0
- package/src/jetpack-compose/TopAppBar/index.tsx +113 -0
- package/src/jetpack-compose/index.ts +2 -0
- package/src/jetpack-compose/modifiers/index.ts +11 -3
- package/src/recycling/useRecycledRows.tsx +3 -0
- package/src/swift-ui/BottomSheet/index.tsx +24 -3
- 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/Checkbox/index.android.tsx +24 -5
- 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 +16 -4
- package/src/universal/Spacer/index.android.tsx +6 -4
- package/src/universal/Spacer/index.ios.tsx +2 -1
- package/src/universal/Switch/index.android.tsx +23 -4
- package/src/universal/Switch/index.tsx +1 -0
- package/src/universal/Text/index.android.tsx +2 -1
- package/src/universal/Text/index.ios.tsx +2 -1
- package/src/universal/Text/index.tsx +2 -2
- package/src/universal/TextInput/index.android.tsx +26 -5
- package/src/universal/TextInput/index.ios.tsx +1 -1
- package/src/universal/index.ts +6 -1
- package/src/universal/modifierUtils.ts +159 -2
- package/src/universal/stackAxis.ts +17 -0
- package/src/universal/transformStyle.android.ts +30 -12
- package/src/universal/transformStyle.ios.ts +41 -13
- package/src/universal/types.ts +27 -3
- package/src/universal/webUtils.ts +4 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21-sources.jar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21-sources.jar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21-sources.jar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21-sources.jar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.aar +0 -0
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.aar.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.aar.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.aar.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.aar.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.module.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.module.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.module.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.module.sha512 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.pom.md5 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.pom.sha1 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.pom.sha256 +0 -1
- package/local-maven-repo/expo/modules/ui/expo.modules.ui/58.0.21/expo.modules.ui-58.0.21.pom.sha512 +0 -1
package/ios/DatePickerView.swift
CHANGED
|
@@ -4,12 +4,7 @@ import SwiftUI
|
|
|
4
4
|
internal struct DatePickerView: ExpoSwiftUI.View {
|
|
5
5
|
@ObservedObject var props: DatePickerProps
|
|
6
6
|
@State private var date = Date()
|
|
7
|
-
|
|
8
|
-
// It shrinks height when user taps a date.
|
|
9
|
-
// https://github.com/expo/expo/issues/47062
|
|
10
|
-
// https://stackoverflow.com/a/74763440/7070640
|
|
11
|
-
// Current fix is to add a fixed min width of 320 when `.graphical` style is used.
|
|
12
|
-
// TODO: Remove if apple fixes the bug in newer versions
|
|
7
|
+
|
|
13
8
|
private var isGraphicalStyle: Bool {
|
|
14
9
|
props.modifiers?.contains {
|
|
15
10
|
$0["$type"] as? String == "datePickerStyle" && $0["style"] as? String == "graphical"
|
|
@@ -20,8 +15,7 @@ internal struct DatePickerView: ExpoSwiftUI.View {
|
|
|
20
15
|
#if os(tvOS)
|
|
21
16
|
Text("DatePicker is not supported on tvOS")
|
|
22
17
|
#else
|
|
23
|
-
|
|
24
|
-
.frame(minWidth: isGraphicalStyle ? 320 : nil)
|
|
18
|
+
datePicker
|
|
25
19
|
.onChange(of: date) { newDate in
|
|
26
20
|
if props.selection == newDate { return }
|
|
27
21
|
props.onDateChange(["date": newDate.timeIntervalSince1970 * 1000])
|
|
@@ -32,10 +26,51 @@ internal struct DatePickerView: ExpoSwiftUI.View {
|
|
|
32
26
|
.onAppear {
|
|
33
27
|
date = props.selection ?? Date()
|
|
34
28
|
}
|
|
35
|
-
.if(props.title == nil && !hasChildren) { $0.labelsHidden() }
|
|
36
29
|
#endif
|
|
37
30
|
}
|
|
38
31
|
|
|
32
|
+
#if !os(tvOS)
|
|
33
|
+
@ViewBuilder
|
|
34
|
+
private var datePicker: some View {
|
|
35
|
+
#if os(iOS)
|
|
36
|
+
if isGraphicalStyle {
|
|
37
|
+
graphicalDatePicker
|
|
38
|
+
} else {
|
|
39
|
+
swiftUIDatePicker
|
|
40
|
+
}
|
|
41
|
+
#else
|
|
42
|
+
swiftUIDatePicker
|
|
43
|
+
#endif
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private var swiftUIDatePicker: some View {
|
|
47
|
+
createDatePicker()
|
|
48
|
+
// Graphical style on macOS: https://github.com/expo/expo/issues/47062
|
|
49
|
+
.frame(minWidth: isGraphicalStyle ? 320 : nil)
|
|
50
|
+
.if(props.title == nil && !hasChildren) { $0.labelsHidden() }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#if os(iOS)
|
|
54
|
+
// SwiftUI's graphical `DatePicker` can keep a wrong height when it appears after launch.
|
|
55
|
+
// https://github.com/expo/expo/issues/47765
|
|
56
|
+
@ViewBuilder
|
|
57
|
+
private var graphicalDatePicker: some View {
|
|
58
|
+
let picker = InlineDatePicker(
|
|
59
|
+
date: $date,
|
|
60
|
+
range: props.range,
|
|
61
|
+
components: props.displayedComponents,
|
|
62
|
+
accessibilityLabel: props.title
|
|
63
|
+
)
|
|
64
|
+
// Like SwiftUI's graphical style, the label is not drawn and is only read by VoiceOver.
|
|
65
|
+
if hasChildren, #available(iOS 18.0, *) {
|
|
66
|
+
picker.accessibilityLabel { _ in Children() }
|
|
67
|
+
} else {
|
|
68
|
+
picker
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
#endif
|
|
72
|
+
#endif
|
|
73
|
+
|
|
39
74
|
private var hasChildren: Bool {
|
|
40
75
|
props.children?.isEmpty == false
|
|
41
76
|
}
|
|
@@ -94,6 +129,96 @@ internal enum DatePickerComponent: String, Enumerable {
|
|
|
94
129
|
case hourAndMinute
|
|
95
130
|
}
|
|
96
131
|
|
|
132
|
+
#if os(iOS)
|
|
133
|
+
private struct InlineDatePicker: UIViewRepresentable {
|
|
134
|
+
@Binding var date: Date
|
|
135
|
+
let range: DateRange?
|
|
136
|
+
let components: [DatePickerComponent]
|
|
137
|
+
let accessibilityLabel: String?
|
|
138
|
+
|
|
139
|
+
func makeCoordinator() -> Coordinator {
|
|
140
|
+
Coordinator(date: $date)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
func makeUIView(context: Context) -> UIDatePicker {
|
|
144
|
+
let picker = UIDatePicker()
|
|
145
|
+
picker.preferredDatePickerStyle = .inline
|
|
146
|
+
picker.addTarget(context.coordinator, action: #selector(Coordinator.valueChanged(_:)), for: .valueChanged)
|
|
147
|
+
return picker
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
func updateUIView(_ picker: UIDatePicker, context: Context) {
|
|
151
|
+
context.coordinator.date = $date
|
|
152
|
+
let environment = context.environment
|
|
153
|
+
let mode = components.toDatePickerMode()
|
|
154
|
+
|
|
155
|
+
// These change the picker's content, so SwiftUI has to measure it again.
|
|
156
|
+
var needsMeasure = false
|
|
157
|
+
if picker.datePickerMode != mode {
|
|
158
|
+
picker.datePickerMode = mode
|
|
159
|
+
needsMeasure = true
|
|
160
|
+
}
|
|
161
|
+
if picker.locale != environment.locale {
|
|
162
|
+
picker.locale = environment.locale
|
|
163
|
+
needsMeasure = true
|
|
164
|
+
}
|
|
165
|
+
if picker.calendar != environment.calendar {
|
|
166
|
+
picker.calendar = environment.calendar
|
|
167
|
+
needsMeasure = true
|
|
168
|
+
}
|
|
169
|
+
if picker.timeZone != environment.timeZone {
|
|
170
|
+
picker.timeZone = environment.timeZone
|
|
171
|
+
}
|
|
172
|
+
picker.minimumDate = range?.start
|
|
173
|
+
picker.maximumDate = range?.end
|
|
174
|
+
if picker.date != date {
|
|
175
|
+
picker.setDate(date, animated: false)
|
|
176
|
+
}
|
|
177
|
+
picker.isEnabled = environment.isEnabled
|
|
178
|
+
picker.accessibilityLabel = accessibilityLabel
|
|
179
|
+
|
|
180
|
+
if needsMeasure {
|
|
181
|
+
picker.invalidateIntrinsicContentSize()
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
func sizeThatFits(_ proposal: ProposedViewSize, uiView: UIDatePicker, context: Context) -> CGSize? {
|
|
186
|
+
let width = proposal.width.flatMap { $0.isFinite ? $0 : nil }
|
|
187
|
+
let size = uiView.systemLayoutSizeFitting(
|
|
188
|
+
CGSize(width: width ?? 0, height: UIView.layoutFittingCompressedSize.height),
|
|
189
|
+
withHorizontalFittingPriority: width == nil ? .fittingSizeLevel : .required,
|
|
190
|
+
verticalFittingPriority: .fittingSizeLevel
|
|
191
|
+
)
|
|
192
|
+
return CGSize(width: width ?? size.width, height: size.height)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
final class Coordinator: NSObject {
|
|
196
|
+
var date: Binding<Date>
|
|
197
|
+
|
|
198
|
+
init(date: Binding<Date>) {
|
|
199
|
+
self.date = date
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@objc func valueChanged(_ picker: UIDatePicker) {
|
|
203
|
+
date.wrappedValue = picker.date
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private extension [DatePickerComponent] {
|
|
209
|
+
func toDatePickerMode() -> UIDatePicker.Mode {
|
|
210
|
+
switch (contains(.date), contains(.hourAndMinute)) {
|
|
211
|
+
case (true, true):
|
|
212
|
+
return .dateAndTime
|
|
213
|
+
case (false, true):
|
|
214
|
+
return .time
|
|
215
|
+
default:
|
|
216
|
+
return .date
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
#endif
|
|
221
|
+
|
|
97
222
|
#if !os(tvOS)
|
|
98
223
|
internal extension [DatePickerComponent] {
|
|
99
224
|
func toSwiftUIComponents() -> DatePicker.Components {
|
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
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2015-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import ExpoModulesCore
|
|
4
|
+
import SwiftUI
|
|
5
|
+
|
|
6
|
+
// SwiftUI has no API for this, so set it on the `UISegmentedControl` behind the segmented `Picker`.
|
|
7
|
+
internal struct SelectedSegmentTintColorModifier: ViewModifier, Record {
|
|
8
|
+
@Field var color: Color?
|
|
9
|
+
|
|
10
|
+
func body(content: Content) -> some View {
|
|
11
|
+
#if os(iOS)
|
|
12
|
+
content.background(SegmentedControlTintSetter(color: color.map { UIColor($0) }))
|
|
13
|
+
#else
|
|
14
|
+
content
|
|
15
|
+
#endif
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
#if os(iOS)
|
|
20
|
+
private struct SegmentedControlTintSetter: UIViewRepresentable {
|
|
21
|
+
let color: UIColor?
|
|
22
|
+
|
|
23
|
+
func makeUIView(context: Context) -> SegmentedControlTintSetterView {
|
|
24
|
+
return SegmentedControlTintSetterView()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
func updateUIView(_ view: SegmentedControlTintSetterView, context: Context) {
|
|
28
|
+
view.color = color
|
|
29
|
+
view.applyColor()
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private final class SegmentedControlTintSetterView: UIView {
|
|
34
|
+
var color: UIColor?
|
|
35
|
+
|
|
36
|
+
override init(frame: CGRect) {
|
|
37
|
+
super.init(frame: frame)
|
|
38
|
+
isUserInteractionEnabled = false
|
|
39
|
+
isAccessibilityElement = false
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
required init?(coder: NSCoder) {
|
|
43
|
+
fatalError("init(coder:) has not been implemented")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override func didMoveToWindow() {
|
|
47
|
+
super.didMoveToWindow()
|
|
48
|
+
applyColor()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
func applyColor() {
|
|
52
|
+
// The segmented control may not be in the hierarchy until the next layout pass.
|
|
53
|
+
DispatchQueue.main.async { [weak self] in
|
|
54
|
+
guard let self, let segmentedControl = self.findSegmentedControl() else {
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
if segmentedControl.selectedSegmentTintColor != self.color {
|
|
58
|
+
segmentedControl.selectedSegmentTintColor = self.color
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
private func findSegmentedControl() -> UISegmentedControl? {
|
|
64
|
+
var ancestor = superview
|
|
65
|
+
while let current = ancestor {
|
|
66
|
+
if let match = Self.firstSegmentedControl(in: current) {
|
|
67
|
+
return match
|
|
68
|
+
}
|
|
69
|
+
ancestor = current.superview
|
|
70
|
+
}
|
|
71
|
+
return nil
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private static func firstSegmentedControl(in view: UIView) -> UISegmentedControl? {
|
|
75
|
+
if let segmentedControl = view as? UISegmentedControl {
|
|
76
|
+
return segmentedControl
|
|
77
|
+
}
|
|
78
|
+
for subview in view.subviews {
|
|
79
|
+
if let match = firstSegmentedControl(in: subview) {
|
|
80
|
+
return match
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return nil
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
#endif
|
|
@@ -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
|
}
|
|
@@ -1973,6 +1977,10 @@ extension ViewModifierRegistry {
|
|
|
1973
1977
|
return try TintModifier(from: params, appContext: appContext)
|
|
1974
1978
|
}
|
|
1975
1979
|
|
|
1980
|
+
register("selectedSegmentTintColor") { params, appContext, _ in
|
|
1981
|
+
return try SelectedSegmentTintColorModifier(from: params, appContext: appContext)
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1976
1984
|
register("hidden") { params, appContext, _ in
|
|
1977
1985
|
return try HiddenModifier(from: params, appContext: appContext)
|
|
1978
1986
|
}
|
package/ios/RNHostView.swift
CHANGED
|
@@ -47,6 +47,24 @@ struct RNHostView: ExpoSwiftUI.View {
|
|
|
47
47
|
isEnabled: !props.layoutRoot
|
|
48
48
|
)
|
|
49
49
|
)
|
|
50
|
+
.onAppear {
|
|
51
|
+
updateTouchHandler()
|
|
52
|
+
}
|
|
53
|
+
.onChange(of: props.children?.first?.childIdentity) { _ in
|
|
54
|
+
updateTouchHandler()
|
|
55
|
+
}
|
|
56
|
+
.onDisappear {
|
|
57
|
+
touchHandler.detach()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Follows the current child, which Fabric can replace or remount while this view stays.
|
|
62
|
+
private func updateTouchHandler() {
|
|
63
|
+
if props.layoutRoot, let view = firstChildUIView {
|
|
64
|
+
touchHandler.attach(to: view)
|
|
65
|
+
} else {
|
|
66
|
+
touchHandler.detach()
|
|
67
|
+
}
|
|
50
68
|
}
|
|
51
69
|
|
|
52
70
|
@ViewBuilder
|
|
@@ -60,14 +78,6 @@ struct RNHostView: ExpoSwiftUI.View {
|
|
|
60
78
|
) {
|
|
61
79
|
Children()
|
|
62
80
|
}
|
|
63
|
-
.onAppear {
|
|
64
|
-
if props.layoutRoot {
|
|
65
|
-
touchHandler.attach(to: childUIView)
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
.onDisappear {
|
|
69
|
-
touchHandler.detach()
|
|
70
|
-
}
|
|
71
81
|
} else if matchesContents {
|
|
72
82
|
// No hosted UIView (a pure SwiftUI child, e.g. Text/Image). Render it at its
|
|
73
83
|
// natural size instead of falling into the fill branch below, which would
|
|
@@ -82,14 +92,6 @@ struct RNHostView: ExpoSwiftUI.View {
|
|
|
82
92
|
Children()
|
|
83
93
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
84
94
|
.modifier(ReportSizeToYogaNodeModifier(shadowNodeProxy: props.shadowNodeProxy))
|
|
85
|
-
.onAppear {
|
|
86
|
-
if props.layoutRoot, let view = firstChildUIView {
|
|
87
|
-
touchHandler.attach(to: view)
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
.onDisappear {
|
|
91
|
-
touchHandler.detach()
|
|
92
|
-
}
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
|
|
@@ -173,6 +175,7 @@ private final class RNHostTouchHandler: ObservableObject {
|
|
|
173
175
|
// An axis that is not matched fills the parent and reports its size to the Yoga node instead
|
|
174
176
|
private struct ApplySizeFromYogaNode<Content: SwiftUI.View>: SwiftUI.View {
|
|
175
177
|
@StateObject private var observer: Observer
|
|
178
|
+
let childUIView: UIView
|
|
176
179
|
let horizontal: Bool
|
|
177
180
|
let vertical: Bool
|
|
178
181
|
let shadowNodeProxy: ExpoSwiftUI.ShadowNodeProxy
|
|
@@ -186,6 +189,7 @@ private struct ApplySizeFromYogaNode<Content: SwiftUI.View>: SwiftUI.View {
|
|
|
186
189
|
@ViewBuilder content: () -> Content
|
|
187
190
|
) {
|
|
188
191
|
_observer = StateObject(wrappedValue: Observer(view: childUIView))
|
|
192
|
+
self.childUIView = childUIView
|
|
189
193
|
self.horizontal = horizontal
|
|
190
194
|
self.vertical = vertical
|
|
191
195
|
self.shadowNodeProxy = shadowNodeProxy
|
|
@@ -193,6 +197,14 @@ private struct ApplySizeFromYogaNode<Content: SwiftUI.View>: SwiftUI.View {
|
|
|
193
197
|
}
|
|
194
198
|
|
|
195
199
|
var body: some SwiftUI.View {
|
|
200
|
+
sizedContent
|
|
201
|
+
.onChange(of: childUIView) { newView in
|
|
202
|
+
observer.observe(newView)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
@ViewBuilder
|
|
207
|
+
private var sizedContent: some SwiftUI.View {
|
|
196
208
|
if horizontal && vertical {
|
|
197
209
|
content
|
|
198
210
|
.frame(width: observer.size.width, height: observer.size.height)
|
|
@@ -223,6 +235,12 @@ private struct ApplySizeFromYogaNode<Content: SwiftUI.View>: SwiftUI.View {
|
|
|
223
235
|
|
|
224
236
|
init(view: UIView) {
|
|
225
237
|
self.size = view.bounds.size
|
|
238
|
+
observe(view)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
func observe(_ view: UIView) {
|
|
242
|
+
kvoToken?.invalidate()
|
|
243
|
+
size = view.bounds.size
|
|
226
244
|
kvoToken = view.observe(\.bounds) { [weak self] view, _ in
|
|
227
245
|
MainActor.assumeIsolated {
|
|
228
246
|
self?.size = view.bounds.size
|
|
@@ -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
|
}
|