From 4ad53e116c4c0b526f265e3568c7cceec595699e Mon Sep 17 00:00:00 2001 From: Daniel Kloeck Date: Fri, 18 Feb 2022 10:19:37 +0100 Subject: [PATCH] Add comments, example update --- Sources/WrappingHStack/WrappingHStack.swift | 5 ++++- .../WrappingHStackExample/ContentView.swift | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/WrappingHStack/WrappingHStack.swift b/Sources/WrappingHStack/WrappingHStack.swift index 62f2a44..a0a08f9 100644 --- a/Sources/WrappingHStack/WrappingHStack.swift +++ b/Sources/WrappingHStack/WrappingHStack.swift @@ -7,7 +7,8 @@ import SwiftUI /// or `.dynamic` spacing), spacing (use `.constant` for fixed spacing, /// `.dynamic` to have the items fill the width of the WrappingHSTack and /// `.dynamicIncludingBorders` to fill the full width with equal spacing -/// between items and from the items to the border.) +/// 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 { static var defaultValue = CGFloat.zero @@ -94,6 +95,8 @@ public extension WrappingHStack { /// the items fill the width of the WrappingHSTack and /// `.dynamicIncludingBorders` to fill the full width with equal spacing /// between items and from the items to the border. + /// - lineSpacing: The distance in points between the bottom of one line + /// fragment and the top of the next /// - content: The content and behavior of the view. init(_ data: Data, id: KeyPath = \.self, alignment: HorizontalAlignment = .leading, spacing: Spacing = .constant(8), lineSpacing: CGFloat = 0, @ViewBuilder content: @escaping (Data.Element) -> Content) { self.spacing = spacing diff --git a/WrappingHStackExample/WrappingHStackExample/ContentView.swift b/WrappingHStackExample/WrappingHStackExample/ContentView.swift index 9a8ff59..9e39165 100644 --- a/WrappingHStackExample/WrappingHStackExample/ContentView.swift +++ b/WrappingHStackExample/WrappingHStackExample/ContentView.swift @@ -28,7 +28,7 @@ struct ExampleView: View { Text("bcdefghijklmnopqrs") .font(.title) - WrappingHStack(1...9, id:\.self, alignment: alignment, spacing: spacing, lineSpacing: 10) { + WrappingHStack(1...9, id:\.self, alignment: alignment, spacing: spacing) { Text("Item: \($0)") .padding(.all, 12) .background(RoundedRectangle(cornerRadius: 10).stroke())