@@ -23,30 +23,29 @@ public enum CollectionViewLayouts {
2323 }
2424 }
2525 }
26-
26+
2727 public struct PlatformListVanilla : CollectionViewLayoutType {
28-
28+
2929 public init ( ) {
3030 }
31-
31+
3232 public func body( content: Content ) -> some View {
3333 SwiftUI . List {
3434 content
3535 . listSectionSeparator ( . hidden)
3636 . listRowSeparator ( . hidden)
3737 . listRowInsets ( . init( top: 0 , leading: 0 , bottom: 0 , trailing: 0 ) )
38- }
38+ }
3939 . listStyle ( . plain)
4040 }
4141 }
4242
4343 public struct List < Separator: View > : CollectionViewLayoutType {
44-
4544
4645 public let direction : CollectionViewListDirection
47-
46+
4847 public var showsIndicators : Bool = false
49-
48+
5049 public var contentPadding : EdgeInsets
5150
5251 private let separator : Separator
@@ -79,21 +78,21 @@ public enum CollectionViewLayouts {
7978 separator: separator
8079 )
8180 }
82-
81+
8382 public consuming func contentPadding( _ contentPadding: EdgeInsets ) -> Self {
84-
83+
8584 self . contentPadding = contentPadding
86-
85+
8786 return self
8887 }
89-
88+
9089 public consuming func showsIndicators( _ showsIndicators: Bool ) -> Self {
91-
90+
9291 self . showsIndicators = showsIndicators
93-
92+
9493 return self
9594 }
96-
95+
9796 public func body( content: Content ) -> some View {
9897 switch direction {
9998 case . vertical:
@@ -157,8 +156,34 @@ public enum CollectionViewLayouts {
157156
158157 public struct Grid : CollectionViewLayoutType {
159158
159+ public let columns : [ GridItem ]
160+ public let spacing : CGFloat ?
161+ public var contentPadding : EdgeInsets
162+
163+ public init (
164+ columns: [ GridItem ] ,
165+ spacing: CGFloat ? = nil ,
166+ contentPadding: EdgeInsets = . init( )
167+ ) {
168+ self . columns = columns
169+ self . spacing = spacing
170+ self . contentPadding = contentPadding
171+ }
172+
160173 public func body( content: Content ) -> some View {
161- // FIXME:
174+ ScrollView {
175+ LazyVGrid ( columns: columns, spacing: spacing) {
176+ content
177+ }
178+ . padding ( contentPadding)
179+ }
180+ }
181+
182+ public consuming func contentPadding( _ contentPadding: EdgeInsets ) -> Self {
183+
184+ self . contentPadding = contentPadding
185+
186+ return self
162187 }
163188 }
164189
@@ -176,8 +201,11 @@ extension CollectionViewLayoutType where Self == CollectionViewLayouts.List<Empt
176201
177202extension CollectionViewLayoutType where Self == CollectionViewLayouts . Grid {
178203
179- public static var grid : Self {
180- CollectionViewLayouts . Grid ( )
204+ public static func grid(
205+ columns: [ GridItem ] ,
206+ spacing: CGFloat ? = nil
207+ ) -> Self {
208+ CollectionViewLayouts . Grid ( columns: columns, spacing: spacing)
181209 }
182210
183211}
0 commit comments