Skip to content

Commit e2d754a

Browse files
committed
Add a lazy stack playground with ten thousand rows
1 parent 46dee7c commit e2d754a

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#if canImport(AndroidSwiftUI)
2+
import AndroidSwiftUI
3+
#else
4+
import SwiftUI
5+
#endif
6+
7+
struct LazyStackPlayground: View {
8+
var body: some View {
9+
VStack(alignment: .leading, spacing: 12) {
10+
Text("LazyHStack — 500 items")
11+
LazyHStack(spacing: 8) {
12+
ForEach(0..<500, id: \.self) { index in
13+
Text("\(index)")
14+
.foregroundColor(.white)
15+
.padding()
16+
.background(Color.blue)
17+
.cornerRadius(6)
18+
}
19+
}
20+
.frame(height: 64)
21+
22+
Text("LazyVStack — 10,000 rows")
23+
// The ScrollView hands scrolling to the lazy stack, which only
24+
// materializes the rows on screen.
25+
ScrollView {
26+
LazyVStack(alignment: .leading, spacing: 10) {
27+
ForEach(0..<10_000, id: \.self) { index in
28+
Text("Row \(index)")
29+
}
30+
}
31+
}
32+
}
33+
.padding()
34+
.navigationTitle("Lazy Stacks")
35+
}
36+
}

0 commit comments

Comments
 (0)