@@ -41,6 +41,7 @@ public struct QGrid<Data, Content>: View
4141 private let hSpacing : CGFloat
4242 private let vPadding : CGFloat
4343 private let hPadding : CGFloat
44+ private let scrollable : Bool
4445
4546 private let data : [ Data . Element ]
4647 private let content : ( Data . Element ) -> Content
@@ -66,6 +67,7 @@ public struct QGrid<Data, Content>: View
6667 hSpacing: CGFloat = 10 ,
6768 vPadding: CGFloat = 10 ,
6869 hPadding: CGFloat = 10 ,
70+ scrollable: Bool = true ,
6971 content: @escaping ( Data . Element ) -> Content ) {
7072 self . data = data. map { $0 }
7173 self . content = content
@@ -96,7 +98,7 @@ public struct QGrid<Data, Content>: View
9698 /// Declares the content and behavior of this view.
9799 public var body : some View {
98100 GeometryReader { geometry in
99- ScrollView ( showsIndicators: false ) {
101+ ScrollView ( axes , showsIndicators: false ) {
100102 VStack ( spacing: self . vSpacing) {
101103 ForEach ( ( 0 ..< self . rows) . map { QGridIndex ( id: $0) } ) { row in
102104 self . rowAtIndex ( row. id * self . cols,
@@ -137,5 +139,9 @@ public struct QGrid<Data, Content>: View
137139 let width = geometry. size. width - hSpacings - hPadding * 2
138140 return width / CGFloat( self . cols)
139141 }
142+
143+ private var scrollAxes : Axis . Set {
144+ return shouldScroll ? . vertical : [ ]
145+ }
140146}
141147
0 commit comments