Skip to content

Commit d2fb6e5

Browse files
committed
fix tvOS (and visionOS) compilation error
1 parent 64c69a9 commit d2fb6e5

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

Examples/Sources/WindowingExample/WindowingApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ struct WindowingApp: App {
219219
}
220220
}
221221
}
222-
#if !os(iOS)
222+
#if !os(iOS) && !os(tvOS)
223223
WindowGroup("Secondary window") {
224224
#hotReloadable {
225225
Text("This a secondary window!")

Sources/SwiftCrossUI/Views/Modifiers/PresentationModifiers.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extension View {
44
/// This modifier only affects the sheet presentation itself.
55
/// It allows users to resize the sheet to different predefined heights.
66
///
7-
/// - Supported platforms: iOS 15+ (ignored on unsupported platforms)
7+
/// - Supported platforms: iOS & Mac Catalyst 15+ (ignored on unsupported platforms)
88
/// - `.fraction` and `.height` fall back to `.medium` on iOS 15 and earlier
99
///
1010
/// - Parameter detents: A set of detents that the sheet can be resized to.
@@ -18,7 +18,7 @@ extension View {
1818
/// This modifier only affects the sheet presentation itself.
1919
/// It does not affect the content's corner radius.
2020
///
21-
/// - Supported platforms: iOS 15+, Gtk4 (ignored on unsupported platforms)
21+
/// - Supported platforms: iOS & Mac Catalyst 15+, Gtk4 (ignored on unsupported platforms)
2222
///
2323
/// - Parameter radius: The corner radius in points.
2424
/// - Returns: A view with the presentationCornerRadius preference set.
@@ -30,7 +30,7 @@ extension View {
3030
///
3131
/// This modifier only affects the sheet presentation itself.
3232
///
33-
/// - Supported platforms: iOS 15+ (ignored on unsupported platforms)
33+
/// - Supported platforms: iOS & Mac Catalyst 15+ (ignored on unsupported platforms)
3434
///
3535
/// - Parameter visibility: visible or hidden
3636
/// - Returns: A view with the presentationDragIndicatorVisibility preference set.

Sources/SwiftCrossUI/Views/Modifiers/SheetModifier.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
extension View {
22
/// Presents a conditional modal overlay. `onDismiss` gets invoked when the sheet is dismissed.
3+
///
4+
/// Internal modalPresentationStyle falls back to .overFullScreen (non-opaque) on tvOS 18 and earlier.
35
public func sheet<SheetContent: View>(
46
isPresented: Binding<Bool>, onDismiss: (() -> Void)? = nil,
57
@ViewBuilder content: @escaping () -> SheetContent

Sources/UIKitBackend/UIKitBackend+Sheet.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ extension UIKitBackend {
66

77
public func createSheet(content: Widget) -> CustomSheet {
88
let sheet = CustomSheet()
9-
sheet.modalPresentationStyle = .formSheet
9+
#if !os(tvOS)
10+
sheet.modalPresentationStyle = .formSheet
11+
#else
12+
if #available(tvOS 26.0, *) {
13+
sheet.modalPresentationStyle = .formSheet
14+
} else {
15+
sheet.modalPresentationStyle = .overFullScreen
16+
}
17+
#endif
1018
sheet.view = content.view
1119
return sheet
1220
}
@@ -52,7 +60,7 @@ extension UIKitBackend {
5260

5361
public func setPresentationDetents(of sheet: CustomSheet, to detents: [PresentationDetent]) {
5462
if #available(iOS 15.0, macCatalyst 15.0, *) {
55-
#if !os(visionOS)
63+
#if !os(tvOS) && !os(visionOS)
5664
if let sheetPresentation = sheet.sheetPresentationController {
5765
sheetPresentation.detents = detents.map {
5866
switch $0 {
@@ -85,23 +93,23 @@ extension UIKitBackend {
8593
} else {
8694
#if DEBUG
8795
print(
88-
"your current OS Version doesn't support variable sheet heights. Setting presentationDetents is only available from iOS 15.0"
96+
"Your current OS Version doesn't support variable sheet heights. Setting presentationDetents is only available from iOS 15.0. tvOS and visionOS are not supported."
8997
)
9098
#endif
9199
}
92100
}
93101

94102
public func setPresentationCornerRadius(of sheet: CustomSheet, to radius: Double) {
95103
if #available(iOS 15.0, *) {
96-
#if !os(visionOS)
104+
#if !os(tvOS) && !os(visionOS)
97105
if let sheetController = sheet.sheetPresentationController {
98106
sheetController.preferredCornerRadius = radius
99107
}
100108
#endif
101109
} else {
102110
#if DEBUG
103111
print(
104-
"your current OS Version doesn't support variable sheet corner radii. Setting them is only available from iOS 15.0"
112+
"Your current OS Version doesn't support variable sheet corner radii. Setting them is only available from iOS 15.0. tvOS and visionOS are not supported."
105113
)
106114
#endif
107115
}
@@ -111,15 +119,15 @@ extension UIKitBackend {
111119
of sheet: Sheet, to visibility: Visibility
112120
) {
113121
if #available(iOS 15.0, *) {
114-
#if !os(visionOS)
122+
#if !os(tvOS) && !os(visionOS)
115123
if let sheetController = sheet.sheetPresentationController {
116124
sheetController.prefersGrabberVisible = visibility == .visible ? true : false
117125
}
118126
#endif
119127
} else {
120128
#if DEBUG
121129
print(
122-
"Your current OS Version doesn't support setting sheet drag indicator visibility. Setting this is only available from iOS 15.0"
130+
"Your current OS Version doesn't support setting sheet drag indicator visibility. Setting this is only available from iOS 15.0. tvOS and visionOS are not supported."
123131
)
124132
#endif
125133
}

0 commit comments

Comments
 (0)