Skip to content

Commit 63b1705

Browse files
committed
Add shared catalog example row and screen shim
1 parent 66cb50e commit 63b1705

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
/// Type-erased catalog screen (a small AnyView shim usable as a navigation
8+
/// destination while keeping the entry list homogeneous).
9+
struct AnyCatalogScreen: View {
10+
private let content: AnyView
11+
init<V: View>(_ view: V) { self.content = AnyView(view) }
12+
var body: some View { content }
13+
}
14+
15+
/// A titled example row shared by the playgrounds.
16+
struct Example<Content: View>: View {
17+
let title: String
18+
let content: Content
19+
init(_ title: String, @ViewBuilder content: () -> Content) {
20+
self.title = title
21+
self.content = content()
22+
}
23+
var body: some View {
24+
VStack(alignment: .leading, spacing: 8) {
25+
Text(title)
26+
content
27+
Divider()
28+
}
29+
.padding()
30+
}
31+
}

0 commit comments

Comments
 (0)