swiftuilib / wrap-stack

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

About

License:MIT License


Languages

Language:Swift 100.0%