Skip to content

Commit efeabbc

Browse files
committed
Add ViewGraphFeature and update ViewGraphDelegate
1 parent 70064af commit efeabbc

File tree

4 files changed

+55
-26
lines changed

4 files changed

+55
-26
lines changed

Sources/OpenSwiftUICore/View/ViewGraph.swift renamed to Sources/OpenSwiftUICore/View/Graph/ViewGraph.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ package final class ViewGraph: GraphHost {
144144
sizeThatFitsObserver?.callback(oldCachedSizeThatFits, self.cachedSizeThatFits)
145145
}
146146
if !requestedOutputs.isEmpty {
147-
delegate?.outputsDidChange(outputs: updatedOutputs)
147+
// delegate?.outputsDidChange(outputs: updatedOutputs)
148148
}
149149
if needsFocusUpdate {
150150
needsFocusUpdate = false
151-
delegate?.focusDidChange()
151+
// delegate?.focusDidChange()
152152
}
153153
} else {
154154
fatalError("TODO")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// ViewGraphDelegate.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for RELEASE_2024
6+
// Status: Complete
7+
8+
package protocol ViewGraphDelegate: GraphDelegate {
9+
func `as`<T>(_ type: T.Type) -> T?
10+
func modifyViewInputs(_ inputs: inout _ViewInputs)
11+
func updateViewGraph<T>(body: (ViewGraph) -> T) -> T
12+
func rootTransform() -> ViewTransform
13+
}
14+
15+
@_spi(ForOpenSwiftUIOnly)
16+
extension ViewGraphDelegate {
17+
package func `as`<T>(_ type: T.Type) -> T? { nil }
18+
package func modifyViewInputs(_ inputs: inout _ViewInputs) {}
19+
20+
public func updateGraph<T>(body: (GraphHost) -> T) -> T {
21+
updateViewGraph { body($0) }
22+
}
23+
24+
package func rootTransform() -> ViewTransform {
25+
ViewTransform()
26+
}
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//
2+
// ViewGraphFeature.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for RELEASE_2024
6+
// Status: Complete
7+
8+
package protocol ViewGraphFeature {
9+
mutating func modifyViewInputs(inputs: inout _ViewInputs, graph: ViewGraph)
10+
mutating func modifyViewOutputs(outputs: inout _ViewOutputs, inputs: _ViewInputs, graph: ViewGraph)
11+
mutating func uninstantiate(graph: ViewGraph)
12+
mutating func isHiddenForReuseDidChange(graph: ViewGraph)
13+
mutating func allowsAsyncUpdate(graph: ViewGraph) -> Bool?
14+
mutating func needsUpdate(graph: ViewGraph) -> Bool
15+
mutating func update(graph: ViewGraph)
16+
}
17+
18+
extension ViewGraphFeature {
19+
package mutating func modifyViewInputs(inputs: inout _ViewInputs, graph: ViewGraph) {}
20+
package mutating func modifyViewOutputs(outputs: inout _ViewOutputs, inputs: _ViewInputs, graph: ViewGraph) {}
21+
package mutating func uninstantiate(graph: ViewGraph) {}
22+
package mutating func isHiddenForReuseDidChange(graph: ViewGraph) {}
23+
package mutating func allowsAsyncUpdate(graph: ViewGraph) -> Bool? { true }
24+
package mutating func needsUpdate(graph: ViewGraph) -> Bool { false }
25+
package mutating func update(graph: ViewGraph) {}
26+
}

Sources/OpenSwiftUICore/View/ViewGraphDelegate.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)