11import SwiftUI
22
3- public struct PlatformViewVersions < SwiftUIViewType: IntrospectableViewType , PlatformView > {
3+ public struct PlatformViewVersions < SwiftUIViewType: IntrospectableViewType , PlatformSpecificEntity : PlatformEntity > {
44 let isCurrent : Bool
5+ let selector : IntrospectionSelector < PlatformSpecificEntity > ?
56
6- public static func iOS( _ versions: ( iOSViewVersion < SwiftUIViewType , PlatformView > ) ... ) -> Self {
7- Self ( isCurrent: versions. contains ( where: \. isCurrent) )
7+ private init < Version: PlatformVersion > (
8+ _ versions: [ PlatformViewVersion < Version , SwiftUIViewType , PlatformSpecificEntity > ]
9+ ) {
10+ if let currentVersion = versions. first ( where: \. isCurrent) {
11+ self . isCurrent = true
12+ self . selector = currentVersion. selector
13+ } else {
14+ self . isCurrent = false
15+ self . selector = nil
16+ }
817 }
918
10- public static func tvOS ( _ versions: ( tvOSViewVersion < SwiftUIViewType , PlatformView > ) ... ) -> Self {
11- Self ( isCurrent : versions. contains ( where : \ . isCurrent ) )
19+ public static func iOS ( _ versions: ( iOSViewVersion < SwiftUIViewType , PlatformSpecificEntity > ) ... ) -> Self {
20+ Self ( versions)
1221 }
1322
14- public static func macOS( _ versions: ( macOSViewVersion < SwiftUIViewType , PlatformView > ) ... ) -> Self {
15- Self ( isCurrent: versions. contains ( where: \. isCurrent) )
23+ public static func tvOS( _ versions: ( tvOSViewVersion < SwiftUIViewType , PlatformSpecificEntity > ) ... ) -> Self {
24+ Self ( versions)
25+ }
26+
27+ public static func macOS( _ versions: ( macOSViewVersion < SwiftUIViewType , PlatformSpecificEntity > ) ... ) -> Self {
28+ Self ( versions)
1629 }
1730}
1831
19- public typealias iOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformView> = PlatformViewVersion < iOSVersion , SwiftUIViewType , PlatformView >
20- public typealias tvOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformView> = PlatformViewVersion < tvOSVersion , SwiftUIViewType , PlatformView >
21- public typealias macOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformView> = PlatformViewVersion < macOSVersion , SwiftUIViewType , PlatformView >
32+ public typealias iOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformSpecificEntity: PlatformEntity > =
33+ PlatformViewVersion < iOSVersion , SwiftUIViewType , PlatformSpecificEntity >
34+ public typealias tvOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformSpecificEntity: PlatformEntity > =
35+ PlatformViewVersion < tvOSVersion , SwiftUIViewType , PlatformSpecificEntity >
36+ public typealias macOSViewVersion < SwiftUIViewType: IntrospectableViewType , PlatformSpecificEntity: PlatformEntity > =
37+ PlatformViewVersion < macOSVersion , SwiftUIViewType , PlatformSpecificEntity >
2238
23- public struct PlatformViewVersion < Version: PlatformVersion , SwiftUIViewType: IntrospectableViewType , PlatformView > {
39+ public struct PlatformViewVersion < Version: PlatformVersion , SwiftUIViewType: IntrospectableViewType , PlatformSpecificEntity : PlatformEntity > {
2440 let isCurrent : Bool
41+ let selector : IntrospectionSelector < PlatformSpecificEntity > ?
2542}
2643
2744extension PlatformViewVersion {
28- @_spi ( Internals) public init ( for version: Version ) {
29- self . init ( isCurrent: version. isCurrent)
45+ @_spi ( Internals) public init ( for version: Version , selector : IntrospectionSelector < PlatformSpecificEntity > ? = nil ) {
46+ self . init ( isCurrent: version. isCurrent, selector : selector )
3047 }
3148
3249 @_spi ( Internals) public static func unavailable( file: StaticString = #file, line: UInt = #line) -> Self {
@@ -43,6 +60,6 @@ extension PlatformViewVersion {
4360 https://github.com/siteline/swiftui-introspect/issues/new?title=` \( fileName) : \( line) `+should+be+marked+unavailable
4461 """
4562 )
46- return Self ( isCurrent: false )
63+ return Self ( isCurrent: false , selector : nil )
4764 }
4865}
0 commit comments