File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed
Sources/SwiftCrossUI/Views Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change 1+ /// A view that arranges subviews in a flexible grid layout.
2+ public struct Grid < Content: View > : View {
3+ let alignment : Alignment
4+ let horizontalSpacing : Int ?
5+ let verticalSpacing : Int ?
6+ let content : ( ) -> Content
7+
8+ public init (
9+ alignment: Alignment = . center,
10+ horizontalSpacing: Int ? = nil ,
11+ verticalSpacing: Int ? = nil ,
12+ @ViewBuilder content: @escaping ( ) -> Content
13+ ) {
14+ self . alignment = alignment
15+ self . horizontalSpacing = horizontalSpacing
16+ self . verticalSpacing = verticalSpacing
17+ self . content = content
18+ }
19+
20+ public var body : some View {
21+ VStack ( alignment: . leading, spacing: verticalSpacing) {
22+ content ( )
23+ }
24+ }
25+ }
26+
27+ /// A single row within a Grid.
28+ public struct GridRow < Content: View > : View {
29+ let alignment : VerticalAlignment
30+ let content : ( ) -> Content
31+
32+ public init (
33+ alignment: VerticalAlignment = . center,
34+ @ViewBuilder content: @escaping ( ) -> Content
35+ ) {
36+ self . alignment = alignment
37+ self . content = content
38+ }
39+
40+ public var body : some View {
41+ HStack ( alignment: alignment) {
42+ content ( )
43+ }
44+ }
45+ }
You can’t perform that action at this time.
0 commit comments