|
1 | | -#if os(visionOS) || os(watchOS) |
2 | | - import SwiftUI |
3 | | - |
4 | | - @MainActor |
5 | | - struct FioriIntrospectModifier<Target>: ViewModifier { |
6 | | - let customize: (Target) -> Void |
7 | | - let scope: FioriIntrospectionScope? |
8 | | - |
9 | | - init(scope: FioriIntrospectionScope? = nil, |
10 | | - customize: @escaping (Target) -> Void) |
11 | | - { |
12 | | - self.scope = scope |
13 | | - self.customize = customize |
14 | | - } |
15 | | - |
16 | | - func body(content: Content) -> some View { |
17 | | - content |
18 | | - } |
19 | | - } |
20 | | - |
21 | | - struct FioriIntrospectionScope: OptionSet, Sendable { |
22 | | - static let receiver = Self(rawValue: 1 << 0) |
23 | | - static let ancestor = Self(rawValue: 1 << 1) |
24 | | - let rawValue: UInt |
25 | | - init(rawValue: UInt) { |
26 | | - self.rawValue = rawValue |
27 | | - } |
28 | | - } |
29 | | -#else |
| 1 | +#if canImport(SwiftUIIntrospect) && canImport(UIKit) |
30 | 2 | import SwiftUI |
31 | 3 | import UIKit |
32 | 4 | @_spi(Advanced) import SwiftUIIntrospect |
|
35 | 7 | struct FioriIntrospectModifier<Target>: ViewModifier { |
36 | 8 | let customize: (Target) -> Void |
37 | 9 | let scope: IntrospectionScope? |
38 | | - |
| 10 | + |
39 | 11 | init(scope: FioriIntrospectionScope? = nil, |
40 | 12 | customize: @escaping (Target) -> Void) |
41 | 13 | { |
42 | 14 | self.scope = scope?.toIntrospectionScope() |
43 | 15 | self.customize = customize |
44 | 16 | } |
45 | | - |
| 17 | + |
46 | 18 | func body(content: Content) -> some View { |
47 | 19 | if Target.self == UIScrollView.self { |
48 | 20 | content.introspect(.scrollView, on: .iOS(.v17...), scope: self.scope) { view in |
|
82 | 54 | init(rawValue: UInt) { |
83 | 55 | self.rawValue = rawValue |
84 | 56 | } |
85 | | - |
| 57 | + |
86 | 58 | func toIntrospectionScope() -> IntrospectionScope { |
87 | 59 | IntrospectionScope(rawValue: self.rawValue) |
88 | 60 | } |
89 | 61 | } |
| 62 | + |
| 63 | +#else |
| 64 | + import SwiftUI |
| 65 | + |
| 66 | + @MainActor |
| 67 | + struct FioriIntrospectModifier<Target>: ViewModifier { |
| 68 | + let customize: (Target) -> Void |
| 69 | + let scope: FioriIntrospectionScope? |
| 70 | + |
| 71 | + init(scope: FioriIntrospectionScope? = nil, |
| 72 | + customize: @escaping (Target) -> Void) |
| 73 | + { |
| 74 | + self.scope = scope |
| 75 | + self.customize = customize |
| 76 | + } |
| 77 | + |
| 78 | + func body(content: Content) -> some View { |
| 79 | + content |
| 80 | + } |
| 81 | + } |
| 82 | + |
| 83 | + struct FioriIntrospectionScope: OptionSet, Sendable { |
| 84 | + static let receiver = Self(rawValue: 1 << 0) |
| 85 | + static let ancestor = Self(rawValue: 1 << 1) |
| 86 | + let rawValue: UInt |
| 87 | + init(rawValue: UInt) { |
| 88 | + self.rawValue = rawValue |
| 89 | + } |
| 90 | + } |
90 | 91 | #endif |
0 commit comments