wip
This commit is contained in:
parent
8254af4549
commit
5d7885b2fb
|
@ -1,38 +1,43 @@
|
|||
@_spi(Internals)
|
||||
public struct IntrospectionSelector<Target: PlatformEntity> {
|
||||
private var receiverSelector: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
|
||||
private var ancestorSelector: (IntrospectionPlatformViewController) -> Target?
|
||||
|
||||
@_spi(Internals)
|
||||
public static var `default`: Self { .from(Target.self, selector: { $0 }) }
|
||||
|
||||
@_spi(Internals)
|
||||
public func withAncestorSelector(
|
||||
_ selector: @escaping (PlatformViewController) -> Target?
|
||||
) -> Self {
|
||||
var copy = self
|
||||
copy.ancestorSelector = selector
|
||||
return copy
|
||||
}
|
||||
|
||||
@_spi(Internals)
|
||||
public static func from<Entry: PlatformEntity>(_ entryType: Entry.Type, selector: @escaping (Entry) -> Target?) -> Self {
|
||||
.init(
|
||||
receiver: { controller, anchorID in
|
||||
receiverSelector: { controller, anchorID in
|
||||
controller.as(Entry.self)?.receiver(ofType: Entry.self, anchorID: anchorID).flatMap(selector)
|
||||
},
|
||||
ancestor: { controller in
|
||||
ancestorSelector: { controller in
|
||||
controller.as(Entry.self)?.ancestor(ofType: Entry.self).flatMap(selector)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
init(
|
||||
receiver: @escaping (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?,
|
||||
ancestor: @escaping (IntrospectionPlatformViewController) -> Target?
|
||||
private var receiverSelector: (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?
|
||||
private var ancestorSelector: (IntrospectionPlatformViewController) -> Target?
|
||||
|
||||
private init(
|
||||
receiverSelector: @escaping (IntrospectionPlatformViewController, IntrospectionAnchorID) -> Target?,
|
||||
ancestorSelector: @escaping (IntrospectionPlatformViewController) -> Target?
|
||||
) {
|
||||
self.receiverSelector = receiver
|
||||
self.ancestorSelector = ancestor
|
||||
self.receiverSelector = receiverSelector
|
||||
self.ancestorSelector = ancestorSelector
|
||||
}
|
||||
|
||||
@_spi(Internals)
|
||||
public func withReceiverSelector(_ selector: @escaping (PlatformViewController, IntrospectionAnchorID) -> Target?) -> Self {
|
||||
var copy = self
|
||||
copy.receiverSelector = selector
|
||||
return copy
|
||||
}
|
||||
|
||||
@_spi(Internals)
|
||||
public func withAncestorSelector(_ selector: @escaping (PlatformViewController) -> Target?) -> Self {
|
||||
var copy = self
|
||||
copy.ancestorSelector = selector
|
||||
return copy
|
||||
}
|
||||
|
||||
func callAsFunction(
|
||||
|
|
Loading…
Reference in New Issue