From 33591ecf5c576e7609e6f244a4f0f7b40f103e71 Mon Sep 17 00:00:00 2001 From: Valentin Perignon Date: Thu, 24 Oct 2024 12:35:42 +0200 Subject: [PATCH] feat: Do not compute offset for leading alignment --- Sources/InfomaniakCoreSwiftUI/Layouts/FlowLayout.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/InfomaniakCoreSwiftUI/Layouts/FlowLayout.swift b/Sources/InfomaniakCoreSwiftUI/Layouts/FlowLayout.swift index 6f66054..44c57bf 100644 --- a/Sources/InfomaniakCoreSwiftUI/Layouts/FlowLayout.swift +++ b/Sources/InfomaniakCoreSwiftUI/Layouts/FlowLayout.swift @@ -92,8 +92,11 @@ public struct FlowLayout: Layout { } private func computeAlignmentOffsets(containerWidth: CGFloat, offsets: [[CGRect]]) -> [CGFloat] { - var alignmentOffsets = [CGFloat]() + guard alignment != .leading else { + return Array(repeating: 0, count: offsets.count) + } + var alignmentOffsets = [CGFloat]() for line in offsets { guard let lineWidth = line.last?.maxX else { alignmentOffsets.append(0)