Skip to content

Latest commit

 

History

History
49 lines (34 loc) · 1.34 KB

README.md

File metadata and controls

49 lines (34 loc) · 1.34 KB

WrapStack is a set SwiftUI views, WHStack and WVStack designed to add wrapping behavior to regular horizontal and vertical stacks.

Demo

Example

Use similarly to HStack and VStack.

Wrapping horizontal stack (WHStack)

Distribute horizontal content across multiple lines.

WVStack {
  Text("Wrapping…").fixedSize().padding()
  Color.red.frame(height: 200).overlay(Text("1"))
  Color.green.frame(height: 200).overlay(Text("2"))
  Color.blue.frame(height: 200).overlay(Text("3"))
  Color.yellow.frame(height: 200).overlay(Text("4"))
  Text("…content").fixedSize().padding()
}

Wrapping vertical stack (WVStack)

Automatically expand vertical content into multiple columns.

WHStack {
  Text("Wrapping…").fixedSize().padding()
  Color.red.frame(height: 200).overlay(Text("1"))
  Color.green.frame(height: 200).overlay(Text("2"))
  Color.blue.frame(height: 200).overlay(Text("3"))
  Color.yellow.frame(height: 200).overlay(Text("4"))
  Text("…content").fixedSize().padding()
}

More info in the docs.

Installation via SPM

In XCode add the following URL to your project's Swift Package dependencies:

https://github.com/swiftuilib/wrap-stack

Development

To modify the package contents while still being able to see SwiftUI Previews use the provided WrapStackPreview.xcodeproj.