A flow view for SwiftUI
MIT License
A layout for placing views in a flow-like arrangement in SwiftUI. A Flow
organizes views sequentially, wrapping them onto new lines when the current line is filled. The alignment and spacing between views can be customized. Flow layouts are commonly used to display a set of tags.
Using Flow
is similar to using SwiftUI's VStack and HStack layouts/views.
Alignment and spacing changes can be animated and since Flow conforms to the Layout
protocol you can even animate changing to an entirely different layout type!
import Flow
struct ContentView: View {
@State var tags: [Tag]
var body: some View {
// Default .topLeading alignment and system spacing.
Flow {
ForEach(tags) { tag in
TagView(tag)
}
}
// Alignment and spacing specified.
Flow(alignment: .bottomTrailing, spacing: 10) {
ForEach(tags) { tag in
TagView(tag)
}
}
}
}
Check the documentation for more in-depth usage.
.xcproject
filePROJECT
Swift Package
+
signhttps://github.com/toastersocks/Flow
into the text field and hit 'Next'