From 733c317daaf900d1bb513bcdc70f463ccb9180ef Mon Sep 17 00:00:00 2001 From: Laszlo Teveli Date: Mon, 8 Jul 2024 18:45:00 +0200 Subject: [PATCH] Return correct size when SwiftUI proposes nil size https://developer.apple.com/documentation/swiftui/proposedviewsize/replacingunspecifieddimensions(by:) has a default of 10 by 10 --- Sources/Flow/Internal/Layout.swift | 2 +- Sources/Flow/Internal/Size.swift | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Sources/Flow/Internal/Layout.swift b/Sources/Flow/Internal/Layout.swift index 0bfe32e4..24b7abba 100644 --- a/Sources/Flow/Internal/Layout.swift +++ b/Sources/Flow/Internal/Layout.swift @@ -136,7 +136,7 @@ struct FlowLayout { let breakpoints = lineBreaker.wrapItemsToLines( sizes: sizes.map(\.breadth), spacings: spacings, - in: proposedSize.replacingUnspecifiedDimensions().value(on: axis) + in: proposedSize.replacingUnspecifiedDimensions(by: .infinity).value(on: axis) ) var lines: Lines = [] diff --git a/Sources/Flow/Internal/Size.swift b/Sources/Flow/Internal/Size.swift index b500e2ab..08a6f8a7 100644 --- a/Sources/Flow/Internal/Size.swift +++ b/Sources/Flow/Internal/Size.swift @@ -94,6 +94,13 @@ extension CGSize: FixedOrientation2DCoordinate { case .vertical: height } } + + static var infinity: CGSize { + CGSize( + width: CGFloat.infinity, + height: CGFloat.infinity + ) + } } @available(iOS 16.0, macOS 13.0, tvOS 16.0, watchOS 9.0, *)