Skip to content

Commit 8cce09c

Browse files
xiaoyu0722dyongxu
andauthored
fix: 🐛 import introspect issue (SAP#1151)
Co-authored-by: dyongxu <61523257+dyongxu@users.noreply.github.com>
1 parent dc865e5 commit 8cce09c

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

Sources/FioriSwiftUICore/Utils/FioriIntrospect.swift

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
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)
302
import SwiftUI
313
import UIKit
324
@_spi(Advanced) import SwiftUIIntrospect
@@ -35,14 +7,14 @@
357
struct FioriIntrospectModifier<Target>: ViewModifier {
368
let customize: (Target) -> Void
379
let scope: IntrospectionScope?
38-
10+
3911
init(scope: FioriIntrospectionScope? = nil,
4012
customize: @escaping (Target) -> Void)
4113
{
4214
self.scope = scope?.toIntrospectionScope()
4315
self.customize = customize
4416
}
45-
17+
4618
func body(content: Content) -> some View {
4719
if Target.self == UIScrollView.self {
4820
content.introspect(.scrollView, on: .iOS(.v17...), scope: self.scope) { view in
@@ -82,9 +54,38 @@
8254
init(rawValue: UInt) {
8355
self.rawValue = rawValue
8456
}
85-
57+
8658
func toIntrospectionScope() -> IntrospectionScope {
8759
IntrospectionScope(rawValue: self.rawValue)
8860
}
8961
}
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+
}
9091
#endif

0 commit comments

Comments
 (0)