Skip to content

Commit d24f6e2

Browse files
authored
Split code samples by OS (#262)
1 parent 4302c3f commit d24f6e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+904
-130
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Changelog
66
### SwiftUIIntrospect
77

88
- Changed: disabled accessibility for introspection views (#261)
9+
- Documentation: code samples are now split by OS (#262)
910
- Infrastructure: use [`xcodes`](https://github.com/XcodesOrg/xcodes) via [`tea`](https://github.com/teaxyz/cli) on CI (#261)
1011

1112
## [0.6.2]

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ let package = Package(
66
name: "Introspect",
77
platforms: [
88
.iOS(.v13),
9-
.macOS(.v10_15),
109
.tvOS(.v13),
10+
.macOS(.v10_15),
1111
],
1212
products: [
1313
.library(name: "Introspect", targets: ["Introspect"]),

[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ let package = Package(
66
name: "swiftui-introspect",
77
platforms: [
88
.iOS(.v13),
9-
.macOS(.v10_15),
109
.tvOS(.v13),
10+
.macOS(.v10_15),
1111
],
1212
products: [
1313
// legacy library

Sources/ViewTypes/Button.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@ import SwiftUI
22

33
/// An abstract representation of the `Button` type in SwiftUI.
44
///
5+
/// ### iOS
6+
///
7+
/// Not available.
8+
///
9+
/// ### tvOS
10+
///
11+
/// Not available.
12+
///
13+
/// ### macOS
14+
///
515
/// ```swift
616
/// struct ContentView: View {
717
/// var body: some View {
818
/// Button("Action", action: {})
9-
/// #if os(macOS)
1019
/// .introspect(.button, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
1120
/// print(type(of: $0)) // NSButton
1221
/// }
13-
/// #endif
1422
/// }
1523
/// }
1624
/// ```

Sources/ViewTypes/ColorPicker.swift

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,36 @@ import SwiftUI
22

33
/// An abstract representation of the `ColorPicker` type in SwiftUI.
44
///
5+
/// ### iOS
6+
///
57
/// ```swift
68
/// struct ContentView: View {
79
/// @State var color = Color.red
810
///
911
/// var body: some View {
1012
/// ColorPicker("Pick a color", selection: $color)
11-
/// #if os(iOS)
1213
/// .introspect(.colorPicker, on: .iOS(.v14, .v15, .v16, .v17)) {
1314
/// print(type(of: $0)) // UIColorPicker
1415
/// }
15-
/// #elseif os(macOS)
16+
/// }
17+
/// }
18+
/// ```
19+
///
20+
/// ### tvOS
21+
///
22+
/// Not available.
23+
///
24+
/// ### macOS
25+
///
26+
/// ```swift
27+
/// struct ContentView: View {
28+
/// @State var color = Color.red
29+
///
30+
/// var body: some View {
31+
/// ColorPicker("Pick a color", selection: $color)
1632
/// .introspect(.colorPicker, on: .macOS(.v11, .v12, .v13, .v14)) {
1733
/// print(type(of: $0)) // NSColorPicker
1834
/// }
19-
/// #endif
2035
/// }
2136
/// }
2237
/// ```

Sources/ViewTypes/DatePicker.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,34 @@ import SwiftUI
22

33
/// An abstract representation of the `DatePicker` type in SwiftUI.
44
///
5+
/// ### iOS
6+
///
57
/// ```swift
68
/// struct ContentView: View {
79
/// @State var date = Date()
810
///
911
/// var body: some View {
1012
/// DatePicker("Pick a date", selection: $date)
11-
/// #if os(iOS)
1213
/// .introspect(.datePicker, on: .iOS(.v13, .v14, .v15, .v16, .v17)) {
1314
/// print(type(of: $0)) // UIDatePicker
1415
/// }
15-
/// #elseif os(macOS)
16+
/// }
17+
/// }
18+
/// ```
19+
///
20+
/// ### tvOS
21+
///
22+
/// Not available.
23+
///
24+
/// ```swift
25+
/// struct ContentView: View {
26+
/// @State var date = Date()
27+
///
28+
/// var body: some View {
29+
/// DatePicker("Pick a date", selection: $date)
1630
/// .introspect(.datePicker, on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
1731
/// print(type(of: $0)) // NSDatePicker
1832
/// }
19-
/// #endif
2033
/// }
2134
/// }
2235
/// ```

Sources/ViewTypes/DatePickerWithCompactStyle.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,38 @@ import SwiftUI
22

33
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.compact` style.
44
///
5+
/// ### iOS
6+
///
57
/// ```swift
68
/// struct ContentView: View {
79
/// @State var date = Date()
810
///
911
/// var body: some View {
1012
/// DatePicker("Pick a date", selection: $date)
1113
/// .datePickerStyle(.compact)
12-
/// #if os(iOS)
1314
/// .introspect(.datePicker(style: .compact), on: .iOS(.v14, .v15, .v16, .v17)) {
1415
/// print(type(of: $0)) // UIDatePicker
1516
/// }
16-
/// #elseif os(macOS)
17+
/// }
18+
/// }
19+
/// ```
20+
///
21+
/// ### tvOS
22+
///
23+
/// Not available.
24+
///
25+
/// ### macOS
26+
///
27+
/// ```swift
28+
/// struct ContentView: View {
29+
/// @State var date = Date()
30+
///
31+
/// var body: some View {
32+
/// DatePicker("Pick a date", selection: $date)
33+
/// .datePickerStyle(.compact)
1734
/// .introspect(.datePicker(style: .compact), on: .macOS(.v10_15_4, .v11, .v12, .v13, .v14)) {
1835
/// print(type(of: $0)) // NSDatePicker
1936
/// }
20-
/// #endif
2137
/// }
2238
/// }
2339
/// ```

Sources/ViewTypes/DatePickerWithFieldStyle.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ import SwiftUI
22

33
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.field` style.
44
///
5+
/// ### iOS
6+
///
7+
/// Not available.
8+
///
9+
/// ### tvOS
10+
///
11+
/// Not available.
12+
///
13+
/// ### macOS
14+
///
515
/// ```swift
616
/// struct ContentView: View {
717
/// @State var date = Date()
818
///
919
/// var body: some View {
1020
/// DatePicker("Pick a date", selection: $date)
1121
/// .datePickerStyle(.field)
12-
/// #if os(macOS)
1322
/// .introspect(.datePicker(style: .field), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
1423
/// print(type(of: $0)) // NSDatePicker
1524
/// }
16-
/// #endif
1725
/// }
1826
/// }
1927
/// ```

Sources/ViewTypes/DatePickerWithGraphicalStyleType.swift

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,38 @@ import SwiftUI
22

33
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.graphical` style.
44
///
5+
/// ### iOS
6+
///
57
/// ```swift
68
/// struct ContentView: View {
79
/// @State var date = Date()
810
///
911
/// var body: some View {
1012
/// DatePicker("Pick a date", selection: $date)
1113
/// .datePickerStyle(.graphical)
12-
/// #if os(iOS)
1314
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17)) {
1415
/// print(type(of: $0)) // UIDatePicker
1516
/// }
16-
/// #elseif os(macOS)
17+
/// }
18+
/// }
19+
/// ```
20+
///
21+
/// ### tvOS
22+
///
23+
/// Not available.
24+
///
25+
/// ### macOS
26+
///
27+
/// ```swift
28+
/// struct ContentView: View {
29+
/// @State var date = Date()
30+
///
31+
/// var body: some View {
32+
/// DatePicker("Pick a date", selection: $date)
33+
/// .datePickerStyle(.graphical)
1734
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
1835
/// print(type(of: $0)) // NSDatePicker
1936
/// }
20-
/// #endif
2137
/// }
2238
/// }
2339
/// ```

Sources/ViewTypes/DatePickerWithStepperFieldStyle.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,26 @@ import SwiftUI
22

33
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.stepperField` style.
44
///
5+
/// ### iOS
6+
///
7+
/// Not available.
8+
///
9+
/// ### tvOS
10+
///
11+
/// Not available.
12+
///
13+
/// ### macOS
14+
///
515
/// ```swift
616
/// struct ContentView: View {
717
/// @State var date = Date()
818
///
919
/// var body: some View {
1020
/// DatePicker("Pick a date", selection: $date)
1121
/// .datePickerStyle(.stepperField)
12-
/// #if os(macOS)
1322
/// .introspect(.datePicker(style: .stepperField), on: .macOS(.v10_15, .v11, .v12, .v13, .v14)) {
1423
/// print(type(of: $0)) // NSDatePicker
1524
/// }
16-
/// #endif
1725
/// }
1826
/// }
1927
/// ```

0 commit comments

Comments
 (0)