Skip to content

Commit 9bedf1e

Browse files
authored
Reintroduce TabView introspection on macOS 15+ (#477)
1 parent 359c2cb commit 9bedf1e

File tree

3 files changed

+67
-4
lines changed

3 files changed

+67
-4
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 4
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
end_of_line = lf

Sources/ViewTypes/TabView.swift

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,24 @@
4949
/// }
5050
/// ```
5151
///
52+
/// ### macOS 15+ (non-root placement only)
53+
///
54+
/// ```swift
55+
/// struct ContentView: View {
56+
/// var body: some View {
57+
/// GroupBox {
58+
/// TabView {
59+
/// Text("Tab 1").tabItem { Text("Tab 1") }
60+
/// Text("Tab 2").tabItem { Text("Tab 2") }
61+
/// }
62+
/// .introspect(.tabView, on: .macOS(.v15, .v26)) {
63+
/// print(type(of: $0)) // NSTabView
64+
/// }
65+
/// }
66+
/// }
67+
/// }
68+
/// ```
69+
///
5270
/// ### visionOS
5371
///
5472
/// Not available.
@@ -100,10 +118,8 @@ extension macOSViewVersion<TabViewType, NSTabView> {
100118
public static let v12 = Self(for: .v12)
101119
public static let v13 = Self(for: .v13)
102120
public static let v14 = Self(for: .v14)
103-
@available(*, unavailable, message: "TabView is no longer backed by NSTabView starting macOS 15")
104-
public static let v15 = Self.unavailable()
105-
@available(*, unavailable, message: "TabView is no longer backed by NSTabView starting macOS 15")
106-
public static let v26 = Self.unavailable()
121+
public static let v15 = Self(for: .v15)
122+
public static let v26 = Self(for: .v26)
107123
}
108124
#endif
109125
#endif

Tests/Tests/ViewTypes/TabViewTests.swift

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,43 @@ struct TabViewTests {
4545
}
4646
}
4747
}
48+
49+
@available(tvOS, unavailable)
50+
@Test func introspectWithNonRootPlacement() async throws {
51+
try await introspection(of: PlatformTabView.self) { spy in
52+
GroupBox {
53+
TabView {
54+
ZStack {
55+
Color.red
56+
Text("Something")
57+
}
58+
}
59+
#if os(iOS) || os(tvOS)
60+
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), customize: spy)
61+
#elseif os(macOS)
62+
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), customize: spy)
63+
#endif
64+
}
65+
}
66+
}
67+
68+
@available(tvOS, unavailable)
69+
@Test func introspectWithNonRootPlacementAsAncestor() async throws {
70+
try await introspection(of: PlatformTabView.self) { spy in
71+
GroupBox {
72+
TabView {
73+
ZStack {
74+
Color.red
75+
Text("Something")
76+
#if os(iOS) || os(tvOS)
77+
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), .tvOS(.v13, .v14, .v15, .v16, .v17, .v18, .v26), scope: .ancestor, customize: spy)
78+
#elseif os(macOS)
79+
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15, .v26), scope: .ancestor, customize: spy)
80+
#endif
81+
}
82+
}
83+
}
84+
}
85+
}
4886
}
4987
#endif

0 commit comments

Comments
 (0)