-
Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathDatePickerWithGraphicalStyle.swift
94 lines (90 loc) · 2.76 KB
/
DatePickerWithGraphicalStyle.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#if !os(watchOS)
import SwiftUI
/// An abstract representation of the `DatePicker` type in SwiftUI, with `.graphical` style.
///
/// ### iOS
///
/// ```swift
/// struct ContentView: View {
/// @State var date = Date()
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .iOS(.v14, .v15, .v16, .v17, .v18)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
/// }
/// ```
///
/// ### tvOS
///
/// Not available.
///
/// ### macOS
///
/// ```swift
/// struct ContentView: View {
/// @State var date = Date()
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .macOS(.v10_15, .v11, .v12, .v13, .v14, .v15)) {
/// print(type(of: $0)) // NSDatePicker
/// }
/// }
/// }
/// ```
///
/// ### visionOS
///
/// ```swift
/// struct ContentView: View {
/// @State var date = Date()
///
/// var body: some View {
/// DatePicker("Pick a date", selection: $date)
/// .datePickerStyle(.graphical)
/// .introspect(.datePicker(style: .graphical), on: .visionOS(.v1, .v2)) {
/// print(type(of: $0)) // UIDatePicker
/// }
/// }
/// }
/// ```
public struct DatePickerWithGraphicalStyleType: IntrospectableViewType {
public enum Style {
case graphical
}
}
#if !os(tvOS)
extension IntrospectableViewType where Self == DatePickerWithGraphicalStyleType {
public static func datePicker(style: Self.Style) -> Self { .init() }
}
#if canImport(UIKit)
extension iOSViewVersion<DatePickerWithGraphicalStyleType, UIDatePicker> {
@available(*, unavailable, message: ".datePickerStyle(.graphical) isn't available on iOS 13")
public static let v13 = Self(for: .v13)
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)
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> {
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)
public static let v15 = Self(for: .v15)
}
#endif
#endif
#endif