diff --git a/CHANGELOG.md b/CHANGELOG.md index 49035aa8..e945e1ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,8 @@ Changelog ## master +- Removed: `Toggle` introspection on visionOS (#373) + ## [1.0.0] - Removed: obsoleted Introspect module (#275) diff --git a/Examples/Showcase/Showcase/AppView.swift b/Examples/Showcase/Showcase/AppView.swift index f00f5a70..44083e38 100644 --- a/Examples/Showcase/Showcase/AppView.swift +++ b/Examples/Showcase/Showcase/AppView.swift @@ -401,12 +401,14 @@ struct SimpleElementsShowcase: View { #endif } + #if !os(tvOS) + #if !os(visionOS) HStack { Toggle("Toggle Red", isOn: $toggleValue) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect( .toggle, - on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1) + on: .iOS(.v13, .v14, .v15, .v16, .v17) ) { toggle in toggle.backgroundColor = .red } @@ -417,10 +419,10 @@ struct SimpleElementsShowcase: View { #endif Toggle("Toggle Green", isOn: $toggleValue) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect( .toggle, - on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1) + on: .iOS(.v13, .v14, .v15, .v16, .v17) ) { toggle in toggle.backgroundColor = .green } @@ -431,8 +433,6 @@ struct SimpleElementsShowcase: View { #endif } - #if !os(tvOS) - #if !os(visionOS) HStack { Slider(value: $sliderValue, in: 0...100) #if os(iOS) diff --git a/Sources/ViewTypes/Toggle.swift b/Sources/ViewTypes/Toggle.swift index 0bedff39..064a2582 100644 --- a/Sources/ViewTypes/Toggle.swift +++ b/Sources/ViewTypes/Toggle.swift @@ -38,21 +38,10 @@ import SwiftUI /// /// ### visionOS /// -/// ```swift -/// struct ContentView: View { -/// @State var isOn = false -/// -/// var body: some View { -/// Toggle("Toggle", isOn: $isOn) -/// .introspect(.toggle, on: .visionOS(.v1)) { -/// print(type(of: $0)) // UISwitch -/// } -/// } -/// } -/// ``` +/// Not available. public struct ToggleType: IntrospectableViewType {} -#if !os(tvOS) +#if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleType { public static var toggle: Self { .init() } } @@ -65,10 +54,6 @@ extension iOSViewVersion { public static let v16 = Self(for: .v16) public static let v17 = Self(for: .v17) } - -extension visionOSViewVersion { - public static let v1 = Self(for: .v1) -} #elseif canImport(AppKit) extension macOSViewVersion { public static let v10_15 = Self(for: .v10_15) diff --git a/Sources/ViewTypes/ToggleWithSwitchStyle.swift b/Sources/ViewTypes/ToggleWithSwitchStyle.swift index 36c0ebcd..caf2aeea 100644 --- a/Sources/ViewTypes/ToggleWithSwitchStyle.swift +++ b/Sources/ViewTypes/ToggleWithSwitchStyle.swift @@ -40,26 +40,14 @@ import SwiftUI /// /// ### visionOS /// -/// ```swift -/// struct ContentView: View { -/// @State var isOn = false -/// -/// var body: some View { -/// Toggle("Switch", isOn: $isOn) -/// .toggleStyle(.switch) -/// .introspect(.toggle(style: .switch), on: .visionOS(.v1)) { -/// print(type(of: $0)) // UISwitch -/// } -/// } -/// } -/// ``` +/// Not available. public struct ToggleWithSwitchStyleType: IntrospectableViewType { public enum Style { case `switch` } } -#if !os(tvOS) +#if !os(tvOS) && !os(visionOS) extension IntrospectableViewType where Self == ToggleWithSwitchStyleType { public static func toggle(style: Self.Style) -> Self { .init() } } @@ -72,10 +60,6 @@ extension iOSViewVersion { public static let v16 = Self(for: .v16) public static let v17 = Self(for: .v17) } - -extension visionOSViewVersion { - public static let v1 = Self(for: .v1) -} #elseif canImport(AppKit) extension macOSViewVersion { public static let v10_15 = Self(for: .v10_15) diff --git a/Tests/Tests/TestUtils.swift b/Tests/Tests/TestUtils.swift index 087247f9..716f4ef5 100644 --- a/Tests/Tests/TestUtils.swift +++ b/Tests/Tests/TestUtils.swift @@ -3,7 +3,7 @@ import XCTest #if canImport(UIKit) enum TestUtils { - #if targetEnvironment(macCatalyst) + #if targetEnvironment(macCatalyst) || os(visionOS) static let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 480, height: 300)) #else static let window = UIWindow(frame: UIScreen.main.bounds) diff --git a/Tests/Tests/ViewTypes/ToggleTests.swift b/Tests/Tests/ViewTypes/ToggleTests.swift index 544fcc52..fae82b4e 100644 --- a/Tests/Tests/ViewTypes/ToggleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleTests.swift @@ -1,4 +1,4 @@ -#if !os(tvOS) +#if !os(tvOS) && !os(visionOS) import SwiftUI import SwiftUIIntrospect import XCTest @@ -18,22 +18,22 @@ final class ToggleTests: XCTestCase { VStack { Toggle("", isOn: .constant(true)) - #if os(iOS) || os(visionOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy0) #elseif os(macOS) .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy0) #endif Toggle("", isOn: .constant(false)) - #if os(iOS) || os(visionOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy1) #elseif os(macOS) .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy1) #endif Toggle("", isOn: .constant(true)) - #if os(iOS) || os(visionOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) + #if os(iOS) + .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy2) #elseif os(macOS) .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2) #endif diff --git a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift index 8836e850..8df51c45 100644 --- a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift @@ -1,4 +1,4 @@ -#if !os(tvOS) +#if !os(tvOS) && !os(visionOS) import SwiftUI import SwiftUIIntrospect import XCTest @@ -19,24 +19,24 @@ final class ToggleWithSwitchStyleTests: XCTestCase { VStack { Toggle("", isOn: .constant(true)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy0) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy0) #endif Toggle("", isOn: .constant(false)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy1) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy1) #endif Toggle("", isOn: .constant(true)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) + #if os(iOS) + .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), customize: spy2) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2) #endif