Skip to content

Commit c6a7937

Browse files
fix missing view
1 parent 108938b commit c6a7937

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Sources/Construct/ConstructView.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ public struct ConstructView<T>: View {
2323

2424
#Preview {
2525
ConstructView(for: 42)
26+
.construct {
27+
ConstructItem.missing { missing in
28+
Text("Missing \(missing.type)")
29+
}
30+
ConstructItem(for: Int.self) { value in
31+
Text("Value \(value)")
32+
}
33+
}
2634
}
2735

2836
#Preview {

Sources/Construct/ResultBuilder/ConstructItem.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ public struct ConstructItem: ConstructContent {
1414
}
1515

1616
public extension ConstructItem {
17-
init<T>(for type: T.Type, @ViewBuilder block: @escaping (T) -> some View) {
18-
self.init(symbol: Symbol(type), block: Block(block))
17+
init<T>(for symbol: T.Type, @ViewBuilder block: @escaping (_ symbol: T) -> some View) {
18+
self.init(symbol: Symbol(symbol), block: Block(block))
1919
}
2020

21-
init(for type: (some Any).Type, @ViewBuilder block: @escaping () -> some View) {
22-
self.init(for: type) { _ in block() }
21+
init(for symbol: (some Any).Type, @ViewBuilder block: @escaping () -> some View) {
22+
self.init(for: symbol) { _ in block() }
2323
}
2424

25-
static func missing<T>(_ type: T.Type, @ViewBuilder block: @escaping (T) -> some View) -> Self {
26-
Self(for: type, block: block)
25+
static func missing(@ViewBuilder block: @escaping (_ missing: MissingSymbol) -> some View) -> Self {
26+
Self(for: MissingSymbol.self, block: block)
2727
}
2828

29-
static func missing(_ type: (some Any).Type, @ViewBuilder block: @escaping () -> some View) -> Self {
30-
.missing(type) { _ in block() }
29+
static func missing(@ViewBuilder block: @escaping () -> some View) -> Self {
30+
.missing { _ in block() }
3131
}
3232
}

0 commit comments

Comments
 (0)