Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Sources/OpenSwiftUICore/Data/Preference/View_Indirect.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ extension _ViewInputs {
extension _ViewOutputs {
package func setIndirectDependency(_ dependency: AnyAttribute?) {
preferences.setIndirectDependency(dependency)
if let target = layoutComputer?.identifier {
target.indirectDependency = dependency
if let layoutComputer {
layoutComputer.identifier.indirectDependency = dependency
}
}

Expand All @@ -41,12 +41,15 @@ extension _ViewOutputs {
let source = childOutputs.layoutComputer?.identifier {
target.source = source
}
if let layoutComputer, let childLayoutComputer = childOutputs.layoutComputer {
layoutComputer.identifier.source = childLayoutComputer.identifier
}
}

package func detachIndirectOutputs() {
preferences.detachIndirectOutputs()
if let target = layoutComputer?.identifier {
target.source = .nil
if let layoutComputer {
layoutComputer.identifier.source = .nil
}
}
}
53 changes: 38 additions & 15 deletions Sources/OpenSwiftUICore/Event/Gesture/Gesture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,63 +228,86 @@ extension _GestureInputs: Sendable {}
@available(*, unavailable)
extension _GestureInputs.InheritedPhase: Sendable {}

// MARK: - GestureOutputs [6.5.4] [WIP]
// MARK: - GestureOutputs [6.5.4]

/// Output (aka synthesized) attributes for gesture objects.
@available(OpenSwiftUI_v1_0, *)
public struct _GestureOutputs<Value> {
package var phase: Attribute<GesturePhase<Value>>

private var _debugData: OptionalAttribute<GestureDebug.Data>

package var preferences: PreferencesOutputs

package var debugData: Attribute<GestureDebug.Data>? {
get { preconditionFailure("TODO") }
set { preconditionFailure("TODO") }
get { _debugData.attribute }
set { _debugData.attribute = newValue }
}

package init(phase: Attribute<GesturePhase<Value>>) {
preconditionFailure("TODO")
self.phase = phase
self._debugData = .init()
self.preferences = .init()
}

package func withPhase<T>(_ phase: Attribute<GesturePhase<T>>) -> _GestureOutputs<T> {
preconditionFailure("TODO")
var outputs = _GestureOutputs<T>(phase: phase)
outputs._debugData = _debugData
outputs.preferences = preferences
return outputs
}

package func overrideDefaultValues(_ childOutputs: _GestureOutputs<Value>) {
preconditionFailure("TODO")
phase.overrideDefaultValue(childOutputs.phase, type: GesturePhase<Value>.self)
if let debugData, let childDebugData = childOutputs.debugData {
debugData.overrideDefaultValue(childDebugData, type: GestureDebug.Data.self)
}
preferences.attachIndirectOutputs(to: childOutputs.preferences)
}

package func setIndirectDependency(_ dependency: AnyAttribute?) {
preconditionFailure("TODO")
phase.identifier.indirectDependency = dependency
if let debugData {
debugData.identifier.indirectDependency = dependency
}
preferences.setIndirectDependency(dependency)
}

package func attachIndirectOutputs(_ childOutputs: _GestureOutputs<Value>) {
preconditionFailure("TODO")
phase.identifier.source = childOutputs.phase.identifier
if let debugData, let childDebugData = childOutputs.debugData {
debugData.identifier.source = childDebugData.identifier
}
preferences.attachIndirectOutputs(to: childOutputs.preferences)
}

package func detachIndirectOutputs() {
preconditionFailure("TODO")
phase.identifier.source = .nil
if let debugData {
debugData.identifier.source = .nil
}
preferences.detachIndirectOutputs()
}

package subscript(anyKey key: any PreferenceKey.Type) -> AnyAttribute? {
get { preconditionFailure("TODO") }
set { preconditionFailure("TODO") }
get { preferences[anyKey: key] }
set { preferences[anyKey: key] = newValue }
}

package subscript<K>(key: K.Type) -> Attribute<K.Value>? where K: PreferenceKey {
get { preconditionFailure("TODO") }
set { preconditionFailure("TODO") }
get { preferences[key] }
set { preferences[key] = newValue }
}

package mutating func appendPreference<K>(
key: K.Type,
value: Attribute<K.Value>
) where K: PreferenceKey {
preconditionFailure("TODO")
preferences.appendPreference(key: key, value: value)
}

package func forEachPreference(_ body: (any PreferenceKey.Type, AnyAttribute) -> Void) {
preconditionFailure("TODO")
preferences.forEachPreference(body)
}
}

Expand Down
23 changes: 13 additions & 10 deletions Sources/OpenSwiftUICore/OpenGraph/OpenGraphAdditions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,21 @@ extension AsyncAttribute {
package static var flags: Flags { [] }
}

// MARK: - DefaultRule [WIP]
// MARK: - DefaultRule [6.5.4]

package struct DefaultRule<T>: Rule, AsyncAttribute, CustomStringConvertible where T: Defaultable {
package init() {
preconditionFailure("TODO")
}
@WeakAttribute var weakValue: T.Value?

package static var initialValue: T.Value? {
get { preconditionFailure("TODO") }
}
package init() {}

package static var initialValue: T.Value? { T.defaultValue }

package var value: T.Value {
get { preconditionFailure("TODO") }
weakValue ?? T.defaultValue
}

package var description: String {
get { preconditionFailure("TODO") }
"∨ \(T.Value.self)"
}

package typealias Value = T.Value
Expand All @@ -71,7 +69,12 @@ extension Attribute {
_ value: Attribute<Value>?,
type: T.Type
) where Value == T.Value, T: Defaultable {
preconditionFailure("TODO")
mutateBody(
as: DefaultRule<T>.self,
invalidating: true
) { defaultRule in
defaultRule.$weakValue = value
}
}

package func invalidateValueIfNeeded() -> Bool {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/View/Input/ViewOutputs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public struct _ViewOutputs {
_layoutComputer.attribute
}
set {
_layoutComputer = OptionalAttribute(newValue)
_layoutComputer.attribute = newValue
preferences.debugProperties.insert(.layoutComputer)
}
}
Expand Down