Skip to content

Commit

Permalink
Trailing alignment fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
diniska committed Jul 25, 2021
2 parents ff31300 + cd91a06 commit 530e1d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import SwiftUI

@available(iOS 14, macOS 11, *)
struct TightHeightGeometryReader<Content: View>: View {
var alignment: Alignment
@State private var height: CGFloat = 0

var content: (GeometryProxy) -> Content

init(@ViewBuilder content: @escaping (GeometryProxy) -> Content) {
init(
alignment: Alignment = .topLeading,
@ViewBuilder content: @escaping (GeometryProxy) -> Content
) {
self.alignment = alignment
self.content = content
}

Expand All @@ -20,6 +25,7 @@ struct TightHeightGeometryReader<Content: View>: View {
self.height = size.height
}
}
.frame(maxWidth: .infinity, alignment: alignment)
}
.frame(height: height)
}
Expand Down
3 changes: 2 additions & 1 deletion Sources/WrappingStack/WrappingHStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public struct WrappingHStack<Data: RandomAccessCollection, ID: Hashable, Content

public var body: some View {
if calculatesSizesKeys.isSuperset(of: idsForCalculatingSizes) {
TightHeightGeometryReader { geometry in
TightHeightGeometryReader(alignment: alignment) { geometry in
let splitted = splitIntoLines(maxWidth: geometry.size.width)

// All sizes are known
Expand Down Expand Up @@ -147,6 +147,7 @@ struct WrappingHStack_Previews: PreviewProvider {
static var previews: some View {
WrappingHStack(
id: \.self,
alignment: .trailing,
horizontalSpacing: 8,
verticalSpacing: 8
) {
Expand Down

0 comments on commit 530e1d2

Please sign in to comment.