Skip to content

Commit

Permalink
Add ViewRespondersKey (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye authored Dec 15, 2024
1 parent fb084bb commit b706905
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Data/Projection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public protocol Projection: Hashable {
func set(base: inout Base, newValue: Projected)
}

@_spi(ForSwiftUIOnly)
@_spi(ForOpenSwiftUIOnly)
extension Projection {
package func composed<Tail>(with tail: Tail) -> ComposedProjection<Self, Tail> where Tail: Projection, Projected == Tail.Base {
ComposedProjection(left: self, right: tail)
Expand Down
3 changes: 2 additions & 1 deletion Sources/OpenSwiftUICore/Extension/CGPoint+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

public import Foundation

@_spi(ForOpenSwiftUIOnly) public typealias PlatformPoint = CGPoint
@_spi(ForOpenSwiftUIOnly)
public typealias PlatformPoint = CGPoint

extension CGPoint {
@inlinable
Expand Down
8 changes: 4 additions & 4 deletions Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ package final class ViewGraph: GraphHost {
inputs.preferences.add(DisplayList.Key.self)
}
if contains(.viewResponders) {
// inputs.preferences.add(ViewRespondersKey.self)
inputs.preferences.add(ViewRespondersKey.self)
}
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ package final class ViewGraph: GraphHost {
var eventSubgraph: Subgraph?

@Attribute package var defaultLayoutComputer: LayoutComputer
// @WeakAttribute var rootResponders: [ViewResponder]?
@WeakAttribute var rootResponders: [ViewResponder]?
@WeakAttribute var rootLayoutComputer: LayoutComputer?
@WeakAttribute var rootDisplayList: (DisplayList, DisplayList.Version)?

Expand Down Expand Up @@ -250,7 +250,7 @@ package final class ViewGraph: GraphHost {
}
}
if requestedOutputs.contains(.viewResponders) {
// _rootResponders = WeakAttribute(outputs.preferences[ViewRespondersKey.self])
_rootResponders = WeakAttribute(outputs.preferences[ViewRespondersKey.self])
}
if requestedOutputs.contains(.layout) {
_rootLayoutComputer = WeakAttribute(outputs.layoutComputer)
Expand All @@ -272,7 +272,7 @@ package final class ViewGraph: GraphHost {
rootGeometry.$layoutDirection = nil
}
$rootLayoutComputer = nil
// $rootResponders = nil
$rootResponders = nil
$rootDisplayList = nil
hostPreferenceValues = WeakAttribute()
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// ContentResponder.swift
// OpenSwiftUI
//
// Audited for iOS 15.5
// Audited for iOS 18.0
// Status: WIP

package import Foundation
import OpenSwiftUI_SPI

package protocol ContentResponder {
func contains(points: [CGPoint], size: CGSize) -> BitVector64
func contains(points: [PlatformPoint], size: CGSize) -> BitVector64
func contentPath(size: CGSize) -> Path
func contentPath(size: CGSize, kind: ContentShapeKinds) -> Path
}
Expand Down
22 changes: 22 additions & 0 deletions Sources/OpenSwiftUICore/View/Responder/ViewRespondersKey.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// ViewRespondersKey.swift
// OpenSwiftUICore
//
// Audited for iOS 18.0
// Status: Empty

package struct ViewRespondersKey: PreferenceKey {
package static var defaultValue: [ViewResponder] { [] }

package static var _includesRemovedValues: Bool { true }

package static func reduce(value: inout Value, nextValue: () -> Value) {
value.append(contentsOf: nextValue())
}
}

// TODO

@_spi(ForOpenSwiftUIOnly)
open class ViewResponder/*: ResponderNode, CustomStringConvertible, CustomRecursiveStringConvertible*/ {
}

0 comments on commit b706905

Please sign in to comment.