Skip to content

Commit 9041022

Browse files
committed
wip
1 parent 8136027 commit 9041022

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

Examples/Showcase/Showcase/ContentView.swift

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,20 +205,34 @@ struct PresentationShowcase: View {
205205
@State var isPopoverPresented = false
206206

207207
var body: some View {
208-
if #available(iOS 14, tvOS 14, *) {
209-
Button("Full Screen Cover", action: { isFullScreenPresented = true })
210-
.fullScreenCover(isPresented: $isFullScreenPresented) {
211-
Button("Dismiss", action: { isFullScreenPresented = false })
208+
VStack(spacing: 20) {
209+
Button("Sheet", action: { isSheetPresented = true })
210+
.sheet(isPresented: $isSheetPresented) {
211+
Button("Dismiss", action: { isSheetPresented = false })
212212
#if os(iOS) || os(tvOS)
213213
.introspect(
214-
.fullScreenCover,
215-
on: .iOS(.v14, .v15, .v16, .v17), .tvOS(.v14, .v15, .v16, .v17)
214+
.sheet,
215+
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)
216216
) { presentationController in
217217
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
218-
presentationController.presentedView?.backgroundColor = .blue
219218
}
220219
#endif
221220
}
221+
222+
if #available(iOS 14, tvOS 14, *) {
223+
Button("Full Screen Cover", action: { isFullScreenPresented = true })
224+
.fullScreenCover(isPresented: $isFullScreenPresented) {
225+
Button("Dismiss", action: { isFullScreenPresented = false })
226+
#if os(iOS) || os(tvOS)
227+
.introspect(
228+
.fullScreenCover,
229+
on: .iOS(.v14, .v15, .v16, .v17), .tvOS(.v14, .v15, .v16, .v17)
230+
) { presentationController in
231+
presentationController.containerView?.backgroundColor = .red.withAlphaComponent(0.75)
232+
}
233+
#endif
234+
}
235+
}
222236
}
223237
}
224238
}

Sources/ViewTypes/Sheet.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import SwiftUI
1212
/// Button("Present", action: { isPresented = true })
1313
/// .sheet(isPresented: $isPresented) {
1414
/// Button("Dismiss", action: { isPresented = false })
15-
/// .introspect(.sheet, on: .iOS(.v14, .v15, .v16, .v17)) {
16-
/// print(type(of: $0)) // UISheetPresentationController
15+
/// .introspect(.sheet, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
16+
/// print(type(of: $0)) // UIPresentationController
1717
/// }
1818
/// }
1919
/// }
@@ -30,8 +30,8 @@ import SwiftUI
3030
/// Button("Present", action: { isPresented = true })
3131
/// .sheet(isPresented: $isPresented) {
3232
/// Button("Dismiss", action: { isPresented = false })
33-
/// .introspect(.sheet, on: .tvOS(.v14, .v15, .v16, .v17)) {
34-
/// print(type(of: $0)) // UISheetPresentationController
33+
/// .introspect(.sheet, on: .tvOS(.v13, .v14, .v15, .v16, .v17)) {
34+
/// print(type(of: $0)) // UIPresentationController
3535
/// }
3636
/// }
3737
/// }
@@ -55,6 +55,9 @@ extension IntrospectableViewType where Self == SheetType {
5555
extension iOSViewVersion<SheetType, UIPresentationController> {
5656
public static let v13 = Self(for: .v13, selector: selector)
5757
public static let v14 = Self(for: .v14, selector: selector)
58+
public static let v15 = Self(for: .v15, selector: selector)
59+
public static let v16 = Self(for: .v16, selector: selector)
60+
public static let v17 = Self(for: .v17, selector: selector)
5861

5962
private static var selector: IntrospectionSelector<UIPresentationController> {
6063
.from(UIViewController.self, selector: \.presentationController)
@@ -64,8 +67,11 @@ extension iOSViewVersion<SheetType, UIPresentationController> {
6467
@available(iOS 15, *)
6568
@available(tvOS, unavailable)
6669
extension iOSViewVersion<SheetType, UISheetPresentationController> {
70+
@_disfavoredOverload
6771
public static let v15 = Self(for: .v15, selector: selector)
72+
@_disfavoredOverload
6873
public static let v16 = Self(for: .v16, selector: selector)
74+
@_disfavoredOverload
6975
public static let v17 = Self(for: .v17, selector: selector)
7076

7177
private static var selector: IntrospectionSelector<UISheetPresentationController> {

Tests/Tests/ViewTypes/SheetTests.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,23 @@ import XCTest
55

66
final class SheetTests: XCTestCase {
77
#if os(iOS)
8-
func testSheet_beforeiOS15() throws {
9-
guard #unavailable(iOS 15, tvOS 15) else {
10-
throw XCTSkip()
11-
}
12-
8+
func testSheet() throws {
139
XCTAssertViewIntrospection(of: UIPresentationController.self) { spies in
1410
let spy0 = spies[0]
1511

1612
Text("Root")
1713
.sheet(isPresented: .constant(true)) {
1814
Text("Sheet")
19-
#if os(iOS) || os(tvOS)
2015
.introspect(
2116
.sheet,
22-
on: .iOS(.v13, .v14), .tvOS(.v13, .v14, .v15, .v16, .v17),
17+
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17),
2318
customize: spy0
2419
)
25-
#endif
2620
}
2721
}
2822
}
2923

30-
func testSheet_iOS15AndLater() throws {
24+
func testSheetAsSheetPresentationController() throws {
3125
guard #available(iOS 15, tvOS 15, *) else {
3226
throw XCTSkip()
3327
}
@@ -38,13 +32,11 @@ final class SheetTests: XCTestCase {
3832
Text("Root")
3933
.sheet(isPresented: .constant(true)) {
4034
Text("Sheet")
41-
#if os(iOS) || os(tvOS)
4235
.introspect(
4336
.sheet,
4437
on: .iOS(.v15, .v16, .v17),
4538
customize: spy0
4639
)
47-
#endif
4840
}
4941
}
5042
}

0 commit comments

Comments
 (0)