From dbd65bd3442ffa14459470778b70c4604eac2c02 Mon Sep 17 00:00:00 2001 From: Daniel Kloeck Date: Sat, 26 Nov 2022 13:21:36 +0100 Subject: [PATCH] removed coordinate system transformation since it shouldn't have an influence on the height --- Sources/WrappingHStack/WrappingHStack.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/WrappingHStack/WrappingHStack.swift b/Sources/WrappingHStack/WrappingHStack.swift index 74823e7..f4f408e 100644 --- a/Sources/WrappingHStack/WrappingHStack.swift +++ b/Sources/WrappingHStack/WrappingHStack.swift @@ -10,7 +10,7 @@ import SwiftUI /// between items and from the items to the border.) and lineSpacing (which /// adds a vertical separation between lines) public struct WrappingHStack: View { - private struct CGFloatPreferenceKey: PreferenceKey { + private struct HeightPreferenceKey: PreferenceKey { static var defaultValue = CGFloat.zero static func reduce(value: inout CGFloat , nextValue: () -> CGFloat) { value = nextValue() @@ -53,14 +53,14 @@ public struct WrappingHStack: View { public var body: some View { GeometryReader { geo in InternalWrappingHStack ( - width: geo.frame(in: .global).width, + width: geo.size.width, alignment: alignment, spacing: spacing, lineSpacing: lineSpacing, content: items ) .anchorPreference( - key: CGFloatPreferenceKey.self, + key: HeightPreferenceKey.self, value: .bounds, transform: { geo[$0].size.height @@ -68,7 +68,7 @@ public struct WrappingHStack: View { ) } .frame(height: height) - .onPreferenceChange(CGFloatPreferenceKey.self, perform: { + .onPreferenceChange(HeightPreferenceKey.self, perform: { if abs(height - $0) > 1 { height = $0 }