Skip to content

Commit 3423c71

Browse files
committed
Update Layout.makeLayoutView
1 parent d8ce4f4 commit 3423c71

File tree

2 files changed

+77
-7
lines changed

2 files changed

+77
-7
lines changed

Sources/OpenSwiftUICore/Layout/Layout.swift

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
#if canImport(Darwin)
1010
public import CoreGraphics
11-
#endif
11+
import Foundation
12+
#else
1213
public import Foundation
14+
#endif
1315
package import OpenGraphShims
1416
import OpenSwiftUI_SPI
1517

@@ -629,6 +631,70 @@ extension Layout {
629631
root: _GraphValue<Self>,
630632
inputs: _ViewInputs,
631633
body: (_Graph, _ViewInputs) -> _ViewListOutputs
634+
) -> _ViewOutputs {
635+
var root = root
636+
var inputs = inputs
637+
_makeAnimatable(value: &root, inputs: inputs.base)
638+
let properties: LayoutProperties
639+
if Self.self == AnyLayout.self {
640+
let anyLayoutProperties = AnyLayoutProperties(layout: root.value.unsafeCast(to: AnyLayout.self))
641+
let dynamicStackOrientation = Attribute(anyLayoutProperties)
642+
inputs.dynamicStackOrientation = OptionalAttribute(dynamicStackOrientation)
643+
properties = LayoutProperties()
644+
} else {
645+
if let orientation = layoutProperties.stackOrientation {
646+
inputs.stackOrientation = orientation
647+
} else {
648+
inputs.dynamicStackOrientation = OptionalAttribute()
649+
}
650+
properties = LayoutProperties()
651+
}
652+
inputs.stackOrientation = properties.stackOrientation
653+
if inputs.archivedView.isArchived {
654+
inputs.viewListOptions.formUnion(.needsArchivedAnimationTraits)
655+
}
656+
let outputs = body(_Graph(), inputs)
657+
switch outputs.views {
658+
case let .staticList(elements):
659+
if inputs.needsDynamicLayout {
660+
return makeDynamicView(
661+
root: root,
662+
inputs: inputs,
663+
properties: properties,
664+
list: outputs.makeAttribute(viewInputs: inputs)
665+
)
666+
} else {
667+
return makeStaticView(
668+
root: root,
669+
inputs: inputs,
670+
properties: properties,
671+
list: elements
672+
)
673+
}
674+
case let .dynamicList(viewList, modifier):
675+
return makeDynamicView(
676+
root: root,
677+
inputs: inputs,
678+
properties: properties,
679+
list: outputs.makeAttribute(viewInputs: inputs)
680+
)
681+
}
682+
}
683+
684+
static func makeDynamicView(
685+
root: _GraphValue<Self>,
686+
inputs: _ViewInputs,
687+
properties: LayoutProperties,
688+
list: Attribute<any ViewList>
689+
) -> _ViewOutputs {
690+
preconditionFailure("TODO")
691+
}
692+
693+
static func makeStaticView(
694+
root: _GraphValue<Self>,
695+
inputs: _ViewInputs,
696+
properties: LayoutProperties,
697+
list: ViewList.Elements
632698
) -> _ViewOutputs {
633699
preconditionFailure("TODO")
634700
}
@@ -639,7 +705,7 @@ extension Layout {
639705
rule: inout R,
640706
layoutContext ctx: SizeAndSpacingContext,
641707
children: LayoutProxyCollection
642-
) where R : StatefulRule, R.Value == LayoutComputer {
708+
) where R: StatefulRule, R.Value == LayoutComputer {
643709
preconditionFailure("TODO")
644710
}
645711

Sources/OpenSwiftUICore/View/Input/ViewInputs.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ public struct _ViewInputs {
125125
set {
126126
if let newValue {
127127
base.options.formUnion(.viewStackOrientationIsDefined)
128-
if newValue == .horizontal {
129-
base.options.formUnion(.viewStackOrientationIsHorizontal)
130-
} else {
131-
base.options.subtract(.viewStackOrientationIsHorizontal)
132-
}
128+
base.options.setValue(newValue == .horizontal, for: .viewStackOrientationIsHorizontal)
133129
} else {
134130
base.options.subtract([.viewStackOrientationIsDefined, .viewStackOrientationIsHorizontal])
135131
}
@@ -245,6 +241,14 @@ package struct DynamicStackOrientation: ViewInput {
245241
package static let defaultValue: OptionalAttribute<Axis?> = .init()
246242
}
247243

244+
extension _ViewInputs {
245+
@inline(__always)
246+
var dynamicStackOrientation: OptionalAttribute<Axis?> {
247+
get { self[DynamicStackOrientation.self] }
248+
set { self[DynamicStackOrientation.self] = newValue }
249+
}
250+
}
251+
248252
// MARK: - ViewInputs without Geometry Dependencies [6.4.41]
249253

250254
extension _ViewInputs {

0 commit comments

Comments
 (0)