From e41ec03e836e66712ddad46601cc92a7937a7b10 Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:21:28 +0100 Subject: [PATCH 1/4] wip --- Examples/Showcase/Showcase/AppView.swift | 8 ++++---- Sources/ViewTypes/Toggle.swift | 19 ++---------------- Sources/ViewTypes/ToggleWithSwitchStyle.swift | 20 ++----------------- Tests/Tests/TestUtils.swift | 2 +- Tests/Tests/ViewTypes/ToggleTests.swift | 8 ++++---- .../ToggleWithSwitchStyleTests.swift | 8 ++++---- 6 files changed, 17 insertions(+), 48 deletions(-) diff --git a/Examples/Showcase/Showcase/AppView.swift b/Examples/Showcase/Showcase/AppView.swift index f00f5a70..5443fe50 100644 --- a/Examples/Showcase/Showcase/AppView.swift +++ b/Examples/Showcase/Showcase/AppView.swift @@ -401,9 +401,11 @@ 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) @@ -417,7 +419,7 @@ 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) @@ -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..e31dfb00 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,21 +18,21 @@ final class ToggleTests: XCTestCase { VStack { Toggle("", isOn: .constant(true)) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), 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) + #if os(iOS) .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), 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) + #if os(iOS) .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) #elseif os(macOS) .introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2) diff --git a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift index 8836e850..8507957e 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,7 +19,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { VStack { Toggle("", isOn: .constant(true)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy0) @@ -27,7 +27,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { Toggle("", isOn: .constant(false)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy1) @@ -35,7 +35,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { Toggle("", isOn: .constant(true)) .toggleStyle(.switch) - #if os(iOS) || os(visionOS) + #if os(iOS) .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) #elseif os(macOS) .introspect(.toggle(style: .switch), on: .macOS(.v10_15, .v11, .v12, .v13, .v14), customize: spy2) From b75a2c4ccc7670b0517270cfb65d67d1a3ebbfad Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:33:11 +0100 Subject: [PATCH 2/4] wip --- Examples/Showcase/Showcase/AppView.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/Showcase/Showcase/AppView.swift b/Examples/Showcase/Showcase/AppView.swift index 5443fe50..44083e38 100644 --- a/Examples/Showcase/Showcase/AppView.swift +++ b/Examples/Showcase/Showcase/AppView.swift @@ -408,7 +408,7 @@ struct SimpleElementsShowcase: View { #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 } @@ -422,7 +422,7 @@ struct SimpleElementsShowcase: View { #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 } From abf422a3b41bfb7d586f8485206982a5fe347e28 Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 4 Oct 2023 22:33:59 +0100 Subject: [PATCH 3/4] wip --- Tests/Tests/ViewTypes/ToggleTests.swift | 6 +++--- Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Tests/Tests/ViewTypes/ToggleTests.swift b/Tests/Tests/ViewTypes/ToggleTests.swift index e31dfb00..fae82b4e 100644 --- a/Tests/Tests/ViewTypes/ToggleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleTests.swift @@ -19,21 +19,21 @@ final class ToggleTests: XCTestCase { VStack { Toggle("", isOn: .constant(true)) #if os(iOS) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0) + .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) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1) + .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) - .introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) + .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 8507957e..8df51c45 100644 --- a/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift +++ b/Tests/Tests/ViewTypes/ToggleWithSwitchStyleTests.swift @@ -20,7 +20,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { Toggle("", isOn: .constant(true)) .toggleStyle(.switch) #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy0) + .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 @@ -28,7 +28,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { Toggle("", isOn: .constant(false)) .toggleStyle(.switch) #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy1) + .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 @@ -36,7 +36,7 @@ final class ToggleWithSwitchStyleTests: XCTestCase { Toggle("", isOn: .constant(true)) .toggleStyle(.switch) #if os(iOS) - .introspect(.toggle(style: .switch), on: .iOS(.v13, .v14, .v15, .v16, .v17), .visionOS(.v1), customize: spy2) + .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 From 3ca6852d18cec2dc2ed51050aef254af07d09a9c Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:46:11 +0100 Subject: [PATCH 4/4] wip [skip ci] --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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)