Skip to content

Commit 530e1d2

Browse files
authored
Trailing alignment fixed
2 parents ff31300 + cd91a06 commit 530e1d2

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/WrappingStack/Helpers/TightHeightGeometryReader.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ import SwiftUI
44

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

910
var content: (GeometryProxy) -> Content
1011

11-
init(@ViewBuilder content: @escaping (GeometryProxy) -> Content) {
12+
init(
13+
alignment: Alignment = .topLeading,
14+
@ViewBuilder content: @escaping (GeometryProxy) -> Content
15+
) {
16+
self.alignment = alignment
1217
self.content = content
1318
}
1419

@@ -20,6 +25,7 @@ struct TightHeightGeometryReader<Content: View>: View {
2025
self.height = size.height
2126
}
2227
}
28+
.frame(maxWidth: .infinity, alignment: alignment)
2329
}
2430
.frame(height: height)
2531
}

Sources/WrappingStack/WrappingHStack.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public struct WrappingHStack<Data: RandomAccessCollection, ID: Hashable, Content
8787

8888
public var body: some View {
8989
if calculatesSizesKeys.isSuperset(of: idsForCalculatingSizes) {
90-
TightHeightGeometryReader { geometry in
90+
TightHeightGeometryReader(alignment: alignment) { geometry in
9191
let splitted = splitIntoLines(maxWidth: geometry.size.width)
9292

9393
// All sizes are known
@@ -147,6 +147,7 @@ struct WrappingHStack_Previews: PreviewProvider {
147147
static var previews: some View {
148148
WrappingHStack(
149149
id: \.self,
150+
alignment: .trailing,
150151
horizontalSpacing: 8,
151152
verticalSpacing: 8
152153
) {

0 commit comments

Comments
 (0)