HVStack
Description
HVStack is a view for SwiftUI that arranges its children in horizontal and vertical lines.
- Create tables with data from binding variables.
- Initialize with amount of stacks or minimum length of cells.
- Set either horizontal or vertical reading and scrolling.
- Set aligments, padding of table and spacings between cells.
- Get calculated length of cells to set their frame's width and height.
public struct HVStack<Data, Content>: View where Content: View
init(Binding<[Data]>, stacks: Int, content: (Data, CGFloat) -> (Content))
init(Binding<[Data]>, minLength: CGFloat, content: (Data, CGFloat) -> (Content))
Installation
You want to add pod 'HVStack', '~> 2.0' similar to the following to your Podfile:
target 'MyApp' do
pod 'HVStack', '~> 2.1'
end
Then run a pod install inside your terminal, or from CocoaPods.app.
Requirements
iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0 Swift 5.0
Visual
Usage
import HVStack
struct ContentView: View {
@State private var numbers: [Int] = Array(0...100)
internal var body: some View {
return HVStack(
self.$numbers,
stacks: 3,
cellAxes: .horizontal,
alignment: .center,
scrollAxes: .vertical,
showsIndicators: true,
horizontalAlignment: .leading,
horizontalPadding: 10,
horizontalSpacing: 10,
verticalAlignment: .top,
verticalPadding: 10,
verticalSpacing: 10
) { data, length in
Text(data.description)
.frame(width: length, height: length / 2)
// Place any modifiers here
}
}
}
Support
Please file a github issue.