Skip to content
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

Add new platform versions for WWDC24 #420

Merged
merged 9 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 6 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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ For instance, when introspecting a `ScrollView`...
ScrollView {
Text("Item 1")
}
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
// do something with UIScrollView
}
```
Expand All @@ -38,7 +38,7 @@ By default, the `.introspect` modifier acts directly on its _receiver_. This mea
```swift
ScrollView {
Text("Item 1")
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17), scope: .ancestor) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18), scope: .ancestor) { scrollView in
// do something with UIScrollView
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ List {
tableView.backgroundView = UIView()
tableView.backgroundColor = .cyan
}
.introspect(.list, on: .iOS(.v16, .v17)) { collectionView in
.introspect(.list, on: .iOS(.v16, .v17, .v18)) { collectionView in
collectionView.backgroundView = UIView()
collectionView.subviews.dropFirst(1).first?.backgroundColor = .cyan
}
Expand All @@ -169,7 +169,7 @@ List {
ScrollView {
Text("Item")
}
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
scrollView.backgroundColor = .red
}
```
Expand All @@ -181,7 +181,7 @@ NavigationView {
Text("Item")
}
.navigationViewStyle(.stack)
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17)) { navigationController in
.introspect(.navigationView(style: .stack), on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { navigationController in
navigationController.navigationBar.backgroundColor = .cyan
}
```
Expand All @@ -190,7 +190,7 @@ NavigationView {

```swift
TextField("Text Field", text: <#Binding<String>#>)
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { textField in
.introspect(.textField, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { textField in
textField.backgroundColor = .red
}
```
Expand Down Expand Up @@ -286,7 +286,7 @@ struct ContentView: View {
ScrollView {
// ...
}
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17)) { scrollView in
.introspect(.scrollView, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) { scrollView in
self.scrollView = scrollView
}
}
Expand Down
60 changes: 58 additions & 2 deletions Sources/PlatformVersion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,20 @@ extension iOSVersion {
return nil
#endif
}

public static let v18 = iOSVersion {
#if os(iOS)
if #available(iOS 19, *) {
return .past
}
if #available(iOS 18, *) {
return .current
}
return .future
#else
return nil
#endif
}
}

public struct tvOSVersion: PlatformVersion {
Expand Down Expand Up @@ -176,16 +190,30 @@ extension tvOSVersion {
return nil
#endif
}

public static let v17 = tvOSVersion {
#if os(tvOS)
#if os(tvOS)
if #available(tvOS 18, *) {
return .past
}
if #available(tvOS 17, *) {
return .current
}
return .future
#else
return nil
#endif
}

public static let v18 = tvOSVersion {
#if os(tvOS)
if #available(tvOS 19, *) {
return .past
}
if #available(tvOS 18, *) {
return .current
}
return .future
#else
return nil
#endif
Expand Down Expand Up @@ -286,6 +314,20 @@ extension macOSVersion {
return nil
#endif
}

public static let v15 = macOSVersion {
#if os(macOS)
if #available(macOS 16, *) {
return .past
}
if #available(macOS 15, *) {
return .current
}
return .future
#else
return nil
#endif
}
}

public struct visionOSVersion: PlatformVersion {
Expand All @@ -312,5 +354,19 @@ extension visionOSVersion {
return nil
#endif
}

public static let v2 = visionOSVersion {
#if os(visionOS)
if #available(visionOS 3, *) {
return .past
}
if #available(visionOS 2, *) {
return .current
}
return .future
#else
return nil
#endif
}
}
#endif
3 changes: 2 additions & 1 deletion Sources/ViewTypes/Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import SwiftUI
/// struct ContentView: View {
/// var body: some View {
/// Button("Action", action: {})
/// .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
/// .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSButton
/// }
/// }
Expand All @@ -41,6 +41,7 @@ extension macOSViewVersion<ButtonType, NSButton> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
6 changes: 4 additions & 2 deletions Sources/ViewTypes/ColorPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
///
/// var body: some View {
/// ColorPicker("Pick a color", selection: $color)
/// .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17)) {
/// .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UIColorPicker
/// }
/// }
Expand All @@ -30,7 +30,7 @@ import SwiftUI
///
/// var body: some View {
/// ColorPicker("Pick a color", selection: $color)
/// .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14)) {
/// .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSColorPicker
/// }
/// }
Expand Down Expand Up @@ -67,6 +67,7 @@ extension iOSViewVersion<ColorPickerType, UIColorWell> {
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
public static let v18 = Self(for: .v18)
}

@available(iOS 14, *)
Expand All @@ -82,6 +83,7 @@ extension macOSViewVersion<ColorPickerType, NSColorWell> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
9 changes: 6 additions & 3 deletions Sources/ViewTypes/DatePicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftUI
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
/// .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -28,7 +28,7 @@ import SwiftUI
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
/// .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
Expand All @@ -43,7 +43,7 @@ import SwiftUI
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .introspect(.datePicker, on: .visionOS(.v1)) {
/// .introspect(.datePicker, on: .visionOS(.v1, .v2)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -63,10 +63,12 @@ extension iOSViewVersion<DatePickerType, UIDatePicker> {
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
public static let v18 = Self(for: .v18)
}

extension visionOSViewVersion<DatePickerType, UIDatePicker> {
public static let v1 = Self(for: .v1)
public static let v2 = Self(for: .v2)
}
#elseif canImport(AppKit)
extension macOSViewVersion<DatePickerType, NSDatePicker> {
Expand All @@ -75,6 +77,7 @@ extension macOSViewVersion<DatePickerType, NSDatePicker> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
9 changes: 6 additions & 3 deletions Sources/ViewTypes/DatePickerWithCompactStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.compact)
/// .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17)) {
/// .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -32,7 +32,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.compact)
/// .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14)) {
/// .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
Expand All @@ -48,7 +48,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.compact)
/// .introspect(.datePicker(style: .compact), on: .visionOS(.v1)) {
/// .introspect(.datePicker(style: .compact), on: .visionOS(.v1, .v2)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -73,10 +73,12 @@ extension iOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
public static let v18 = Self(for: .v18)
}

extension visionOSViewVersion<DatePickerWithCompactStyleType, UIDatePicker> {
public static let v1 = Self(for: .v1)
public static let v1 = Self(for: .v2)
}
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
Expand All @@ -87,6 +89,7 @@ extension macOSViewVersion<DatePickerWithCompactStyleType, NSDatePicker> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
3 changes: 2 additions & 1 deletion Sources/ViewTypes/DatePickerWithFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.field)
/// .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
/// .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
Expand Down Expand Up @@ -48,6 +48,7 @@ extension macOSViewVersion<DatePickerWithFieldStyleType, NSDatePicker> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
9 changes: 6 additions & 3 deletions Sources/ViewTypes/DatePickerWithGraphicalStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17)) {
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -32,7 +32,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
Expand All @@ -48,7 +48,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .visionOS(.v1)) {
/// .introspect(.datePicker(style: .graphical), on: .visionOS(.v1, .v2)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
Expand All @@ -73,10 +73,12 @@ extension iOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
public static let v15 = Self(for: .v15)
public static let v16 = Self(for: .v16)
public static let v17 = Self(for: .v17)
public static let v18 = Self(for: .v18)
}

extension visionOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
public static let v1 = Self(for: .v1)
public static let v2 = Self(for: .v2)
}
#elseif canImport(AppKit) && !targetEnvironment(macCatalyst)
extension macOSViewVersion<DatePickerWithGraphicalStyleType, NSDatePicker> {
Expand All @@ -85,6 +87,7 @@ extension macOSViewVersion<DatePickerWithGraphicalStyleType, NSDatePicker> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
3 changes: 2 additions & 1 deletion Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import SwiftUI
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.stepperField)
/// .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
/// .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
Expand Down Expand Up @@ -48,6 +48,7 @@ extension macOSViewVersion<DatePickerWithStepperFieldStyleType, NSDatePicker> {
public static let v12 = Self(for: .v12)
public static let v13 = Self(for: .v13)
public static let v14 = Self(for: .v14)
public static let v15 = Self(for: .v15)
}
#endif
#endif
Expand Down
Loading