Skip to content

Commit 0f15f14

Browse files
committed
Update View implementation
1 parent 0eac4bc commit 0f15f14

File tree

2 files changed

+46
-11
lines changed

2 files changed

+46
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// Never+View.swift
3+
// OpenSwiftUICore
4+
//
5+
// Audited for iOS 18.0
6+
// Status: Complete
7+
8+
// MARK: - Never + View
9+
10+
#if canImport(CoreTransferable)
11+
import CoreTransferable
12+
#endif
13+
14+
extension Never: View {
15+
#if !canImport(CoreTransferable)
16+
public var body: Never { self }
17+
#endif
18+
19+
nonisolated public static func _viewListCount(inputs _: _ViewListCountInputs) -> Int? {
20+
nil
21+
}
22+
}

Sources/OpenSwiftUICore/View/View.swift

+24-11
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,6 @@ public protocol View {
8787
var body: Self.Body { get }
8888
}
8989

90-
// MARK: - Never + View
91-
92-
extension Never: View {
93-
public var body: Never { self }
94-
95-
nonisolated public static func _viewListCount(inputs _: _ViewListCountInputs) -> Int? {
96-
nil
97-
}
98-
}
99-
10090
// MARK: - PrimitiveView
10191

10292
package protocol PrimitiveView: View {}
@@ -141,7 +131,30 @@ extension MultiView {
141131
}
142132
}
143133

144-
// TODO: _UnaryViewAdaptor
134+
// MARK: - _UnaryViewAdaptor
135+
136+
/// Shim to turn a view that may implement _makeViewList() into a
137+
/// single view.
138+
@frozen
139+
public struct _UnaryViewAdaptor<Content>: View, UnaryView, PrimitiveView where Content : View {
140+
public var content: Content
141+
142+
@inlinable
143+
public init(_ content: Content) {
144+
self.content = content
145+
}
146+
147+
package init(@ViewBuilder content: () -> Content) {
148+
self.content = content()
149+
}
150+
151+
nonisolated public static func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
152+
Content.makeDebuggableView(view: view[offset: { .of(&$0.content)} ], inputs: inputs)
153+
}
154+
}
155+
156+
@available(*, unavailable)
157+
extension _UnaryViewAdaptor: Sendable {}
145158

146159
// MARK: - ViewVisitor
147160

0 commit comments

Comments
 (0)