Skip to content

Commit 2ea5070

Browse files
committed
wip
1 parent 56ce335 commit 2ea5070

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

Sources/IntrospectionSelector.swift

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
@_spi(Internals)
22
public struct IntrospectionSelector<Target: PlatformEntity> {
3-
private var receiver: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
4-
private var ancestor: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
3+
private var receiverSelector: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
4+
private var ancestorSelector: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
55

66
@_spi(Internals)
77
public static var `default`: Self { .from(Target.self, selector: { $0 }) }
88

9+
@_spi(Internals)
10+
public func overrideAncestorSelector(
11+
_ selector: @escaping (PlatformViewController, IntrospectionAnchorID) -> Target?
12+
) -> Self {
13+
var copy = self
14+
copy.ancestorSelector = selector
15+
return copy
16+
}
17+
918
@_spi(Internals)
1019
public static func from<Entry: PlatformEntity>(_ entryType: Entry.Type, selector: @escaping (Entry) -> Target?) -> Self {
1120
.init { controller, scope, anchorID in
@@ -45,11 +54,9 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
4554
}
4655
}
4756

48-
init(
49-
_ selector: @escaping (IntrospectionPlatformViewController, IntrospectionScope, IntrospectionAnchorID) -> Target?
50-
) {
51-
self.receiver = { selector($0, .receiver, $1) }
52-
self.ancestor = { selector($0, .ancestor, $1) }
57+
init(_ selector: @escaping (IntrospectionPlatformViewController, IntrospectionScope, IntrospectionAnchorID) -> Target?) {
58+
self.receiverSelector = { selector($0, .receiver, $1) }
59+
self.ancestorSelector = { selector($0, .ancestor, $1) }
5360
}
5461

5562
func callAsFunction(
@@ -59,13 +66,13 @@ public struct IntrospectionSelector<Target: PlatformEntity> {
5966
) -> Target? {
6067
if
6168
scope.contains(.receiver),
62-
let target = receiver(controller, anchorID)
69+
let target = receiverSelector(controller, anchorID)
6370
{
6471
return target
6572
}
6673
if
6774
scope.contains(.ancestor),
68-
let target = ancestor(controller, anchorID)
75+
let target = ancestorSelector(controller, anchorID)
6976
{
7077
return target
7178
}

Sources/IntrospectionView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import SwiftUI
22

3-
typealias IntrospectionAnchorID = UUID
3+
@_spi(Internals)
4+
public typealias IntrospectionAnchorID = UUID
45

56
/// ⚓️
67
struct IntrospectionAnchorView: PlatformViewControllerRepresentable {

0 commit comments

Comments
 (0)