Skip to content

Commit 6ae6714

Browse files
authored
Remove Toggle introspection on visionOS (#373)
1 parent 0f309ad commit 6ae6714

File tree

7 files changed

+27
-56
lines changed

7 files changed

+27
-56
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Changelog
33

44
## master
55

6+
- Removed: `Toggle` introspection on visionOS (#373)
7+
68
## [1.0.0]
79

810
- Removed: obsoleted Introspect module (#275)

Examples/Showcase/Showcase/AppView.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,14 @@ struct SimpleElementsShowcase: View {
401401
#endif
402402
}
403403

404+
#if !os(tvOS)
405+
#if !os(visionOS)
404406
HStack {
405407
Toggle("Toggle Red", isOn: $toggleValue)
406-
#if os(iOS) || os(visionOS)
408+
#if os(iOS)
407409
.introspect(
408410
.toggle,
409-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
411+
on: .iOS(.v13, .v14, .v15, .v16, .v17)
410412
) { toggle in
411413
toggle.backgroundColor = .red
412414
}
@@ -417,10 +419,10 @@ struct SimpleElementsShowcase: View {
417419
#endif
418420

419421
Toggle("Toggle Green", isOn: $toggleValue)
420-
#if os(iOS) || os(visionOS)
422+
#if os(iOS)
421423
.introspect(
422424
.toggle,
423-
on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1)
425+
on: .iOS(.v13, .v14, .v15, .v16, .v17)
424426
) { toggle in
425427
toggle.backgroundColor = .green
426428
}
@@ -431,8 +433,6 @@ struct SimpleElementsShowcase: View {
431433
#endif
432434
}
433435

434-
#if !os(tvOS)
435-
#if !os(visionOS)
436436
HStack {
437437
Slider(value: $sliderValue, in: 0...100)
438438
#if os(iOS)

Sources/ViewTypes/Toggle.swift

+2-17
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,10 @@ import SwiftUI
3838
///
3939
/// ### visionOS
4040
///
41-
/// ```swift
42-
/// struct ContentView: View {
43-
/// @State var isOn = false
44-
///
45-
/// var body: some View {
46-
/// Toggle("Toggle", isOn: $isOn)
47-
/// .introspect(.toggle, on: .visionOS(.v1)) {
48-
/// print(type(of: $0)) // UISwitch
49-
/// }
50-
/// }
51-
/// }
52-
/// ```
41+
/// Not available.
5342
public struct ToggleType: IntrospectableViewType {}
5443

55-
#if !os(tvOS)
44+
#if !os(tvOS) && !os(visionOS)
5645
extension IntrospectableViewType where Self == ToggleType {
5746
public static var toggle: Self { .init() }
5847
}
@@ -65,10 +54,6 @@ extension iOSViewVersion<ToggleType, UISwitch> {
6554
public static let v16 = Self(for: .v16)
6655
public static let v17 = Self(for: .v17)
6756
}
68-
69-
extension visionOSViewVersion<ToggleType, UISwitch> {
70-
public static let v1 = Self(for: .v1)
71-
}
7257
#elseif canImport(AppKit)
7358
extension macOSViewVersion<ToggleType, NSButton> {
7459
public static let v10_15 = Self(for: .v10_15)

Sources/ViewTypes/ToggleWithSwitchStyle.swift

+2-18
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,14 @@ import SwiftUI
4040
///
4141
/// ### visionOS
4242
///
43-
/// ```swift
44-
/// struct ContentView: View {
45-
/// @State var isOn = false
46-
///
47-
/// var body: some View {
48-
/// Toggle("Switch", isOn: $isOn)
49-
/// .toggleStyle(.switch)
50-
/// .introspect(.toggle(style: .switch), on: .visionOS(.v1)) {
51-
/// print(type(of: $0)) // UISwitch
52-
/// }
53-
/// }
54-
/// }
55-
/// ```
43+
/// Not available.
5644
public struct ToggleWithSwitchStyleType: IntrospectableViewType {
5745
public enum Style {
5846
case `switch`
5947
}
6048
}
6149

62-
#if !os(tvOS)
50+
#if !os(tvOS) && !os(visionOS)
6351
extension IntrospectableViewType where Self == ToggleWithSwitchStyleType {
6452
public static func toggle(style: Self.Style) -> Self { .init() }
6553
}
@@ -72,10 +60,6 @@ extension iOSViewVersion<ToggleWithSwitchStyleType, UISwitch> {
7260
public static let v16 = Self(for: .v16)
7361
public static let v17 = Self(for: .v17)
7462
}
75-
76-
extension visionOSViewVersion<ToggleWithSwitchStyleType, UISwitch> {
77-
public static let v1 = Self(for: .v1)
78-
}
7963
#elseif canImport(AppKit)
8064
extension macOSViewVersion<ToggleWithSwitchStyleType, NSSwitch> {
8165
public static let v10_15 = Self(for: .v10_15)

Tests/Tests/TestUtils.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import XCTest
33

44
#if canImport(UIKit)
55
enum TestUtils {
6-
#if targetEnvironment(macCatalyst)
6+
#if targetEnvironment(macCatalyst) || os(visionOS)
77
static let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 480, height: 300))
88
#else
99
static let window = UIWindow(frame: UIScreen.main.bounds)

Tests/Tests/ViewTypes/ToggleTests.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(tvOS)
1+
#if !os(tvOS) && !os(visionOS)
22
import SwiftUI
33
import SwiftUIIntrospect
44
import XCTest
@@ -18,22 +18,22 @@ final class ToggleTests: XCTestCase {
1818

1919
VStack {
2020
Toggle("", isOn: .constant(true))
21-
#if os(iOS) || os(visionOS)
22-
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0)
21+
#if os(iOS)
22+
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy0)
2323
#elseif os(macOS)
2424
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy0)
2525
#endif
2626

2727
Toggle("", isOn: .constant(false))
28-
#if os(iOS) || os(visionOS)
29-
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1)
28+
#if os(iOS)
29+
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy1)
3030
#elseif os(macOS)
3131
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy1)
3232
#endif
3333

3434
Toggle("", isOn: .constant(true))
35-
#if os(iOS) || os(visionOS)
36-
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2)
35+
#if os(iOS)
36+
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy2)
3737
#elseif os(macOS)
3838
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2)
3939
#endif

Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if !os(tvOS)
1+
#if !os(tvOS) && !os(visionOS)
22
import SwiftUI
33
import SwiftUIIntrospect
44
import XCTest
@@ -19,24 +19,24 @@ final class ToggleWithSwitchStyleTests: XCTestCase {
1919
VStack {
2020
Toggle("", isOn: .constant(true))
2121
.toggleStyle(.switch)
22-
#if os(iOS) || os(visionOS)
23-
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0)
22+
#if os(iOS)
23+
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy0)
2424
#elseif os(macOS)
2525
.introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy0)
2626
#endif
2727

2828
Toggle("", isOn: .constant(false))
2929
.toggleStyle(.switch)
30-
#if os(iOS) || os(visionOS)
31-
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1)
30+
#if os(iOS)
31+
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy1)
3232
#elseif os(macOS)
3333
.introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy1)
3434
#endif
3535

3636
Toggle("", isOn: .constant(true))
3737
.toggleStyle(.switch)
38-
#if os(iOS) || os(visionOS)
39-
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2)
38+
#if os(iOS)
39+
.introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy2)
4040
#elseif os(macOS)
4141
.introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2)
4242
#endif

0 commit comments

Comments
 (0)