Skip to content

Commit

Permalink
Fix width when popping back from another viewcontroller
Browse files Browse the repository at this point in the history
  • Loading branch information
pietropizzi committed Feb 10, 2020
1 parent 060b61f commit 32beadd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/GridStack/GridStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public struct GridStack<Content>: View where Content: View {
public var body: some View {
GeometryReader { geometry in
InnerGrid(
width: geometry.size.width,
spacing: self.spacing,
items: self.items,
alignment: self.alignment,
Expand All @@ -54,19 +55,22 @@ public struct GridStack<Content>: View where Content: View {
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
private struct InnerGrid<Content>: View where Content: View {

private let width: CGFloat
private let spacing: CGFloat
private let rows: [[Int]]
private let alignment: HorizontalAlignment
private let content: (Int, CGFloat) -> Content
private let columnWidth: CGFloat

init(
width: CGFloat,
spacing: CGFloat,
items: [Int],
alignment: HorizontalAlignment = .leading,
@ViewBuilder content: @escaping (Int, CGFloat) -> Content,
gridDefinition: GridCalculator.GridDefinition
) {
self.width = width
self.spacing = spacing
self.alignment = alignment
self.content = content
Expand All @@ -86,7 +90,9 @@ private struct InnerGrid<Content>: View where Content: View {
}
}.padding(.horizontal, self.spacing)
}
}.padding(.top, spacing)
}
.padding(.top, spacing)
.frame(width: width)
}
}
}

0 comments on commit 32beadd

Please sign in to comment.