Skip to content

Update VariadicView #212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 11, 2025
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
4 changes: 4 additions & 0 deletions Sources/OpenSwiftUI/CoreGlue/OpenSwiftUIGlue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public func OpenSwiftUIGlueClass() -> CoreGlue.Type {
}

final class OpenSwiftUIGlue: CoreGlue {
override var defaultImplicitRootType: DefaultImplicitRootTypeResult {
DefaultImplicitRootTypeResult(_VStackLayout.self)
}

override func makeDefaultLayoutComputer() -> MakeDefaultLayoutComputerResult {
MakeDefaultLayoutComputerResult(value: ViewGraph.current.$defaultLayoutComputer)
}
Expand Down
14 changes: 13 additions & 1 deletion Sources/OpenSwiftUICore/CoreGlue/CoreGlue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,26 @@ import OpenSwiftUI_SPI
@objc(OpenSwiftUICoreGlue)
open class CoreGlue: NSObject {
package static var shared: CoreGlue = _initializeCoreGlue() as! CoreGlue


open var defaultImplicitRootType: DefaultImplicitRootTypeResult {
preconditionFailure("")
}

open func makeDefaultLayoutComputer() -> MakeDefaultLayoutComputerResult {
preconditionFailure("")
}
}

@_spi(ForOpenSwiftUIOnly)
extension CoreGlue {
public struct DefaultImplicitRootTypeResult {
package var value: any _VariadicView.AnyImplicitRoot.Type

package init(_ value: any _VariadicView.AnyImplicitRoot.Type) {
self.value = value
}
}

public struct MakeDefaultLayoutComputerResult {
package var value: Attribute<LayoutComputer>

Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/Modifier/CustomViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ extension ViewModifierContentProvider {
return makeViewBody(_Graph(), inputs)
case let .list(makeViewListBody):
return .multiView(inputs: inputs) {
makeViewListBody($0, .init($1.base, options: graphInputs[ViewListOptionsInput.self]))
makeViewListBody($0, .init($1.base, options: graphInputs.viewListOptions))
}
}
}
Expand Down
13 changes: 3 additions & 10 deletions Sources/OpenSwiftUICore/View/CustomView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// CustomView.swift
// OpenSwiftUICore
//
// Audited for iOS 15.5
// Status: WIP
// Audited for iOS 18.0
// Status: Complete
// ID: 9F92ACD17B554E8AB7D29ABB1E796415 (SwiftUI)
// ID: CE1D93D8ECBBEB5FE2E32E69A123E7CB (SwiftUICore)

Expand All @@ -26,17 +26,10 @@ extension View {
let fields = DynamicPropertyCache.fields(of: Self.self)
var inputs = inputs
let (body, buffer) = makeBody(view: view, inputs: &inputs.base, fields: fields)
// FIXME
let outputs = _ViewDebug.makeView(
view: body,
inputs: inputs
) { view, inputs in
Body._makeView(view: body, inputs: inputs)
}
if let buffer {
buffer.traceMountedProperties(to: body, fields: fields)
}
return outputs
return Body.makeDebuggableView(view: body, inputs: inputs)
}

nonisolated package static func makeViewList(view: _GraphValue<Self>, inputs: _ViewListInputs) -> _ViewListOutputs {
Expand Down
2 changes: 1 addition & 1 deletion Sources/OpenSwiftUICore/View/DynamicViewContent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ package struct DynamicViewContentOffsetTraitKey: _ViewTraitKey {
package struct DynamicContentOffsetVisitor: ViewListVisitor {
package var offset: Int?

package mutating func visit(view: _ViewList_View, traits: ViewTraitCollection) -> Bool {
package mutating func visit(view: ViewList.View, traits: ViewTraitCollection) -> Bool {
offset = traits.value(for: DynamicViewContentOffsetTraitKey.self)
return false
}
Expand Down
11 changes: 5 additions & 6 deletions Sources/OpenSwiftUICore/View/IDView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,15 @@ extension View {
extension IDView {
@usableFromInline
package static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
// Disable SemanticFeature_v2 temporary as makeImplicitRoot has not been implemented yet
// if _SemanticFeature_v2.isEnabled {
// return makeImplicitRoot(view: view, inputs: inputs)
// } else {
let id = view.value[offset:{ .of(&$0.id) }]
if _SemanticFeature_v2.isEnabled {
return makeImplicitRoot(view: view, inputs: inputs)
} else {
let id = view.value[offset: { .of(&$0.id) }]
let phase = IDPhase(id: id, phase: inputs.viewPhase, lastID: nil, delta: 0)
var inputs = inputs
inputs.viewPhase = Attribute(phase)
return Content.makeDebuggableView(view: view[offset: { .of(&$0.content)}], inputs: inputs)
// }
}
}
}

Expand Down
21 changes: 2 additions & 19 deletions Sources/OpenSwiftUICore/View/Input/ViewList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package import OpenGraphShims
/// Input values to `View._makeViewList()`.
public struct _ViewListInputs {
package var base: _GraphInputs

package var implicitID: Int

package struct Options: OptionSet {
Expand Down Expand Up @@ -746,7 +747,7 @@ extension ViewList.Elements {
}
}

// MARK: - View.List.ID
// MARK: - ViewList.ID

@_spi(ForOpenSwiftUIOnly)
public struct _ViewList_ID: Hashable {
Expand Down Expand Up @@ -1950,21 +1951,3 @@ final package class _ViewList_ReleaseElements: Equatable {
return lhsBase == rhsBase
}
}

// FIXME: VariadicView Part

// MARK: - _ViewList_View

package struct _ViewList_View {
var elements: any ViewList.Elements
var id: _ViewList_ID
var index: Int
var count: Int
var contentSubgraph: Subgraph
}

// MARK: - ViewListVisitor

protocol ViewListVisitor {
mutating func visit(view: _ViewList_View, traits: ViewTraitCollection) -> Bool
}
49 changes: 0 additions & 49 deletions Sources/OpenSwiftUICore/View/Variadic/VariadicView.swift

This file was deleted.

69 changes: 0 additions & 69 deletions Sources/OpenSwiftUICore/View/Variadic/VariadicView_Children.swift

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions Sources/OpenSwiftUICore/View/Variadic/VariadicView_Root.swift

This file was deleted.

Loading
Loading