Skip to content

iOS 17 / tvOS 17 / macOS 14 support #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 37 additions & 37 deletions Examples/Showcase/Showcase/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ struct ContentView: View {
.tag(4)
}
#if os(iOS) || os(tvOS)
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { tabBarController in
.introspect(.tabView, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tabBarController in
tabBarController.tabBar.layer.backgroundColor = UIColor.green.cgColor
}
#elseif os(macOS)
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13)) { splitView in
.introspect(.tabView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { splitView in
splitView.subviews.first?.layer?.backgroundColor = NSColor.green.cgColor
}
#endif
Expand Down Expand Up @@ -62,16 +62,16 @@ struct ListShowcase: View {
Text("Item 2")
}
#if os(iOS) || os(tvOS)
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16)) { tableView in
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17)) { tableView in
tableView.backgroundView = UIView()
tableView.backgroundColor = .cyan
}
.introspect(.list, on: .iOS(.v16)) { collectionView in
.introspect(.list, on: .iOS(.v16, .v17)) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
}
#elseif os(macOS)
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13)) { tableView in
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { tableView in
tableView.backgroundColor = .cyan
}
#endif
Expand All @@ -87,16 +87,16 @@ struct ListShowcase: View {
Text("Item 1")
Text("Item 2")
#if os(iOS) || os(tvOS)
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { tableView in
.introspect(.list, on: .iOS(.v13, .v14, .v15), .tvOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { tableView in
tableView.backgroundView = UIView()
tableView.backgroundColor = .cyan
}
.introspect(.list, on: .iOS(.v16), scope: .ancestor) { collectionView in
.introspect(.list, on: .iOS(.v16, .v17), scope: .ancestor) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
}
#elseif os(macOS)
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { tableView in
.introspect(.list, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), scope: .ancestor) { tableView in
tableView.backgroundColor = .cyan
}
#endif
Expand Down Expand Up @@ -127,11 +127,11 @@ struct ScrollViewShowcase: View {
.font(.system(.subheadline, design: .monospaced))
}
#if os(iOS) || os(tvOS)
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
}
#elseif os(macOS)
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13)) { scrollView in
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { scrollView in
scrollView.drawsBackground = true
scrollView.backgroundColor = .cyan
}
Expand All @@ -145,11 +145,11 @@ struct ScrollViewShowcase: View {
.padding(.horizontal, 12)
.font(.system(.subheadline, design: .monospaced))
#if os(iOS) || os(tvOS)
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16), scope: .ancestor) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { scrollView in
scrollView.layer.backgroundColor = UIColor.cyan.cgColor
}
#elseif os(macOS)
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13), scope: .ancestor) { scrollView in
.introspect(.scrollView, on: .macOS(.v10_15, .v11, .v12, .v13, .v14), scope: .ancestor) { scrollView in
scrollView.drawsBackground = true
scrollView.backgroundColor = .cyan
}
Expand Down Expand Up @@ -177,16 +177,16 @@ struct NavigationShowcase: View {
#endif
}
#if os(iOS) || os(tvOS)
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { navigationController in
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
navigationController.navigationBar.backgroundColor = .cyan
}
.introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16)) { splitViewController in
.introspect(.navigationView(style: .columns), on: .iOS(.v13, .v14, .v15, .v16, .v17)) { splitViewController in
splitViewController.preferredDisplayMode = .oneOverSecondary
}
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16)) { navigationController in
.introspect(.navigationView(style: .columns), on: .tvOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
navigationController.navigationBar.backgroundColor = .cyan
}
.introspect(.searchField, on: .iOS(.v15, .v16), .tvOS(.v15, .v16)) { searchBar in
.introspect(.searchField, on: .iOS(.v15, .v16, .v17), .tvOS(.v15, .v16, .v17)) { searchBar in
searchBar.backgroundColor = .red
#if os(iOS)
searchBar.searchTextField.backgroundColor = .purple
Expand All @@ -209,7 +209,7 @@ struct ViewControllerShowcase: View {
}
}
.navigationViewStyle(.stack)
.introspect(.view, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { viewController in
.introspect(.view, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { viewController in
viewController.children.first?.view.backgroundColor = .cyan
}
}
Expand All @@ -229,23 +229,23 @@ struct SimpleElementsShowcase: View {
HStack {
TextField("Text Field Red", text: $textFieldValue)
#if os(iOS) || os(tvOS)
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { textField in
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { textField in
textField.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13)) { textField in
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { textField in
textField.backgroundColor = .red
}
#endif

TextField("Text Field Green", text: $textFieldValue)
.cornerRadius(8)
#if os(iOS) || os(tvOS)
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { textField in
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { textField in
textField.backgroundColor = .green
}
#elseif os(macOS)
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13)) { textField in
.introspect(.textField, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { textField in
textField.backgroundColor = .green
}
#endif
Expand All @@ -254,22 +254,22 @@ struct SimpleElementsShowcase: View {
HStack {
Toggle("Toggle Red", isOn: $toggleValue)
#if os(iOS)
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16)) { toggle in
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { toggle in
toggle.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13)) { toggle in
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { toggle in
toggle.layer?.backgroundColor = NSColor.red.cgColor
}
#endif

Toggle("Toggle Green", isOn: $toggleValue)
#if os(iOS)
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16)) { toggle in
.introspect(.toggle, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { toggle in
toggle.backgroundColor = .green
}
#elseif os(macOS)
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13)) { toggle in
.introspect(.toggle, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { toggle in
toggle.layer?.backgroundColor = NSColor.green.cgColor
}
#endif
Expand All @@ -279,22 +279,22 @@ struct SimpleElementsShowcase: View {
HStack {
Slider(value: $sliderValue, in: 0...100)
#if os(iOS)
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16)) { slider in
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
slider.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13)) { slider in
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { slider in
slider.layer?.backgroundColor = NSColor.red.cgColor
}
#endif

Slider(value: $sliderValue, in: 0...100)
#if os(iOS)
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16)) { slider in
.introspect(.slider, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { slider in
slider.backgroundColor = .green
}
#elseif os(macOS)
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13)) { slider in
.introspect(.slider, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { slider in
slider.layer?.backgroundColor = NSColor.green.cgColor
}
#endif
Expand All @@ -305,11 +305,11 @@ struct SimpleElementsShowcase: View {
Text("Stepper Red")
}
#if os(iOS)
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16)) { stepper in
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
stepper.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13)) { stepper in
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { stepper in
stepper.layer?.backgroundColor = NSColor.red.cgColor
}
#endif
Expand All @@ -318,11 +318,11 @@ struct SimpleElementsShowcase: View {
Text("Stepper Green")
}
#if os(iOS)
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16)) { stepper in
.introspect(.stepper, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { stepper in
stepper.backgroundColor = .green
}
#elseif os(macOS)
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13)) { stepper in
.introspect(.stepper, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { stepper in
stepper.layer?.backgroundColor = NSColor.green.cgColor
}
#endif
Expand All @@ -333,11 +333,11 @@ struct SimpleElementsShowcase: View {
Text("DatePicker Red")
}
#if os(iOS)
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16)) { datePicker in
.introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { datePicker in
datePicker.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13)) { datePicker in
.introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { datePicker in
datePicker.layer?.backgroundColor = NSColor.red.cgColor
}
#endif
Expand All @@ -352,11 +352,11 @@ struct SimpleElementsShowcase: View {
}
.pickerStyle(SegmentedPickerStyle())
#if os(iOS) || os(tvOS)
.introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16), .tvOS(.v13, .v14, .v15, .v16)) { datePicker in
.introspect(.picker(style: .segmented), on: .iOS(.v13, .v14, .v15, .v16, .v17), .tvOS(.v13, .v14, .v15, .v16, .v17)) { datePicker in
datePicker.backgroundColor = .red
}
#elseif os(macOS)
.introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13)) { datePicker in
.introspect(.picker(style: .segmented), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) { datePicker in
datePicker.layer?.backgroundColor = NSColor.red.cgColor
}
#endif
Expand Down
30 changes: 30 additions & 0 deletions Sources/PlatformVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ extension iOSVersion {
}
return false
}

public static let v17 = iOSVersion {
if #available(iOS 18, *) {
return false
}
if #available(iOS 17, *) {
return true
}
return false
}
}

public struct tvOSVersion: PlatformVersion {
Expand Down Expand Up @@ -102,6 +112,16 @@ extension tvOSVersion {
}
return false
}

public static let v17 = tvOSVersion {
if #available(tvOS 18, *) {
return false
}
if #available(tvOS 17, *) {
return true
}
return false
}
}

public struct macOSVersion: PlatformVersion {
Expand Down Expand Up @@ -162,4 +182,14 @@ extension macOSVersion {
}
return false
}

public static let v14 = macOSVersion {
if #available(macOS 15, *) {
return false
}
if #available(macOS 14, *) {
return true
}
return false
}
}
1 change: 1 addition & 0 deletions Sources/ViewTypes/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ extension macOSViewVersion<ButtonType, NSButton> {
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
2 changes: 2 additions & 0 deletions Sources/ViewTypes/ColorPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ extension iOSViewVersion<ColorPickerType, UIColorWell> {
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
}
#elseif canImport(AppKit)
@available(macOS 11, *)
Expand All @@ -26,6 +27,7 @@ extension macOSViewVersion<ColorPickerType, NSColorWell> {
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
2 changes: 2 additions & 0 deletions Sources/ViewTypes/DatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ extension iOSViewVersion<DatePickerType, UIDatePicker> {
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
}
#elseif canImport(AppKit)
extension macOSViewVersion<DatePickerType, NSDatePicker> {
public static let v10_15 = Self(for: .v10_15)
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
2 changes: 2 additions & 0 deletions Sources/ViewTypes/DatePickerWithCompactStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ extension iOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
}
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
Expand All @@ -29,6 +30,7 @@ extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
1 change: 1 addition & 0 deletions Sources/ViewTypes/DatePickerWithFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension macOSViewVersion<DatePickerWithFieldStyleType, NSDatePicker> {
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
2 changes: 2 additions & 0 deletions Sources/ViewTypes/DatePickerWithGraphicalStyleType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ extension iOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
}
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
extension macOSViewVersion<DatePickerWithGraphicalStyleType, NSDatePicker> {
public static let v10_15 = Self(for: .v10_15)
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
1 change: 1 addition & 0 deletions Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension macOSViewVersion<DatePickerWithStepperFieldStyleType, NSDatePicker> {
public static let v11 = Self(for: .v11)
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
}
#endif
#endif
1 change: 1 addition & 0 deletions Sources/ViewTypes/DatePickerWithWheelStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ extension iOSViewVersion<DatePickerWithWheelStyleType, UIDatePicker> {
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
}
#endif
#endif
Loading