Skip to content

Commit

Permalink
Add comments, example update
Browse files Browse the repository at this point in the history
  • Loading branch information
dkk committed Feb 18, 2022
1 parent 25de523 commit 4ad53e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Sources/WrappingHStack/WrappingHStack.swift
Expand Up @@ -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
Expand Down Expand Up @@ -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: RandomAccessCollection, Content: View>(_ data: Data, id: KeyPath<Data.Element, Data.Element> = \.self, alignment: HorizontalAlignment = .leading, spacing: Spacing = .constant(8), lineSpacing: CGFloat = 0, @ViewBuilder content: @escaping (Data.Element) -> Content) {
self.spacing = spacing
Expand Down
Expand Up @@ -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())
Expand Down

0 comments on commit 4ad53e1

Please sign in to comment.