File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments