Skip to content

Commit a329d3c

Browse files
committed
wip
1 parent 72ad677 commit a329d3c

File tree

3 files changed

+78
-12
lines changed

3 files changed

+78
-12
lines changed

Sources/ViewTypes/Presentation.swift

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ import SwiftUI
4343
///
4444
/// Not available.
4545
///
46-
public struct PresentationType: IntrospectableViewType {}
46+
public struct PresentationType: IntrospectableViewType {
47+
public var scope: IntrospectionScope { .ancestor }
48+
}
4749

4850
#if os(iOS) || os(tvOS)
4951
extension IntrospectableViewType where Self == PresentationType {
@@ -59,7 +61,7 @@ extension iOSViewVersion<PresentationType, UIPresentationController> {
5961
public static let v17 = Self(for: .v17, selector: selector)
6062

6163
private static var selector: IntrospectionSelector<UIPresentationController> {
62-
.default.withAncestorSelector(\.presentationController)
64+
.from(UIViewController.self, selector: \.presentationController)
6365
}
6466
}
6567

@@ -71,25 +73,19 @@ extension tvOSViewVersion<PresentationType, UIPresentationController> {
7173
public static let v17 = Self(for: .v17, selector: selector)
7274

7375
private static var selector: IntrospectionSelector<UIPresentationController> {
74-
.default.withAncestorSelector(\.presentationController)
76+
.from(UIViewController.self, selector: \.presentationController)
7577
}
7678
}
7779

7880
extension UIPresentationController: PlatformEntity {
7981
@_spi(Internals)
80-
public var ancestor: UIPresentationController? {
81-
nil
82-
}
82+
public var ancestor: UIPresentationController? { nil }
8383

8484
@_spi(Internals)
85-
public var descendants: [UIPresentationController] {
86-
[]
87-
}
85+
public var descendants: [UIPresentationController] { [] }
8886

8987
@_spi(Internals)
90-
public func isDescendant(of other: UIPresentationController) -> Bool {
91-
false
92-
}
88+
public func isDescendant(of other: UIPresentationController) -> Bool { false }
9389
}
9490
#endif
9591
#endif

Tests/Tests.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
D58CE15629C621B30081BFB0 /* SwiftUIIntrospect in Frameworks */ = {isa = PBXBuildFile; productRef = D58CE15529C621B30081BFB0 /* SwiftUIIntrospect */; };
9797
D58CE15829C621DD0081BFB0 /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D58CE15729C621DD0081BFB0 /* TestUtils.swift */; };
9898
D5AD0D912A114B98003D8DEC /* TextFieldWithVerticalAxisTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5AD0D902A114B98003D8DEC /* TextFieldWithVerticalAxisTests.swift */; };
99+
D5ADFACC2A4A22AE009494FD /* PresentationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5ADFACB2A4A22AE009494FD /* PresentationTests.swift */; };
99100
D5B67B842A0D318F007D5D9B /* TextFieldTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5B67B832A0D318F007D5D9B /* TextFieldTests.swift */; };
100101
D5F0BE4D29C0DBE800AD95AB /* TestsHostApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F0BE4C29C0DBE800AD95AB /* TestsHostApp.swift */; };
101102
D5F0BE6A29C0DC4900AD95AB /* PlatformTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D5F0BE6729C0DC4900AD95AB /* PlatformTests.swift */; };
@@ -173,6 +174,7 @@
173174
D58547F92A1D12270068ADF4 /* NavigationSplitViewTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NavigationSplitViewTests.swift; sourceTree = "<group>"; };
174175
D58CE15729C621DD0081BFB0 /* TestUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
175176
D5AD0D902A114B98003D8DEC /* TextFieldWithVerticalAxisTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldWithVerticalAxisTests.swift; sourceTree = "<group>"; };
177+
D5ADFACB2A4A22AE009494FD /* PresentationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PresentationTests.swift; sourceTree = "<group>"; };
176178
D5B67B832A0D318F007D5D9B /* TextFieldTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextFieldTests.swift; sourceTree = "<group>"; };
177179
D5F0BE4929C0DBE800AD95AB /* TestsHostApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestsHostApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
178180
D5F0BE4C29C0DBE800AD95AB /* TestsHostApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestsHostApp.swift; sourceTree = "<group>"; };
@@ -252,6 +254,7 @@
252254
D57506792A27BF6C00A628E4 /* PickerWithMenuStyleTests.swift */,
253255
D57506772A27BBBD00A628E4 /* PickerWithSegmentedStyleTests.swift */,
254256
D58119D52A23AED70081F853 /* PickerWithWheelStyleTests.swift */,
257+
D5ADFACB2A4A22AE009494FD /* PresentationTests.swift */,
255258
D575069B2A27F68700A628E4 /* ProgressViewWithCircularStyleTests.swift */,
256259
D575069D2A27F80E00A628E4 /* ProgressViewWithLinearStyleTests.swift */,
257260
D50FFE8D2A17E2A400C32641 /* ScrollViewTests.swift */,
@@ -583,6 +586,7 @@
583586
D58CE15829C621DD0081BFB0 /* TestUtils.swift in Sources */,
584587
D57506782A27BBBD00A628E4 /* PickerWithSegmentedStyleTests.swift in Sources */,
585588
D58119CE2A23A4A70081F853 /* TabViewWithPageStyleTests.swift in Sources */,
589+
D5ADFACC2A4A22AE009494FD /* PresentationTests.swift in Sources */,
586590
D575069A2A27F48D00A628E4 /* DatePickerWithFieldStyleTests.swift in Sources */,
587591
D503B2AC2A49BFE300027F5F /* VideoPlayerTests.swift in Sources */,
588592
D57506A02A27FC0400A628E4 /* TableTests.swift in Sources */,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#if os(iOS) || os(tvOS)
2+
import SwiftUI
3+
import SwiftUIIntrospect
4+
import XCTest
5+
6+
final class PresentationTests: XCTestCase {
7+
#if canImport(UIKit)
8+
typealias PlatformPresentation = UIPresentationController
9+
#endif
10+
11+
func testPresentationAsSheet() throws {
12+
XCTAssertViewIntrospection(of: PlatformPresentation.self) { spies in
13+
let spy0 = spies[0]
14+
15+
Text("Root")
16+
.sheet(isPresented: .constant(true)) {
17+
Text("Sheet")
18+
#if os(iOS) || os(tvOS)
19+
.introspect(
20+
.presentation,
21+
on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17),
22+
customize: spy0
23+
)
24+
#endif
25+
}
26+
}
27+
}
28+
29+
// func testPresentationAsFullScreenCover() throws {
30+
// guard #available(iOS 14, tvOS 14, *) else {
31+
// throw XCTSkip()
32+
// }
33+
//
34+
// struct Something: View {
35+
// @State var isPresented = false
36+
//
37+
// let spy: (PlatformPresentation) -> Void
38+
//
39+
// var body: some View {
40+
// Text("Root")
41+
// .fullScreenCover(isPresented: $isPresented) {
42+
// Text("Full Screen Cover")
43+
// #if os(iOS) || os(tvOS)
44+
// .introspect(
45+
// .presentation,
46+
// on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17),
47+
// customize: spy
48+
// )
49+
// #endif
50+
// }
51+
// .onAppear {
52+
// DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
53+
// isPresented = true
54+
// }
55+
// }
56+
// }
57+
// }
58+
//
59+
// XCTAssertViewIntrospection(of: PlatformPresentation.self) { spies in
60+
// let spy0 = spies[0]
61+
//
62+
// Something(spy: spy0)
63+
// }
64+
// }
65+
}
66+
#endif

0 commit comments

Comments
 (0)