Skip to content

Instantly share code, notes, and snippets.

@ostk0069
Created October 17, 2021 17:19
Show Gist options
  • Save ostk0069/06d060219661f1e6158b1343d8a49f0e to your computer and use it in GitHub Desktop.
Save ostk0069/06d060219661f1e6158b1343d8a49f0e to your computer and use it in GitHub Desktop.
SwiftUI Gap class inspired from Flutter Gap
import SwiftUI
public struct Gap: View {
private let spacing: CGFloat
private let axis: Axis
private let backgroundColor: Color
public init(
spacing: CGFloat,
axis: Axis = .vertical,
backgroundColor: Color = .clear
) {
self.spacing = spacing
self.axis = axis
self.backgroundColor = backgroundColor
}
public var body: some View {
Spacer()
.frame(
width: axis == .horizontal ? spacing : nil,
height: axis == .vertical ? spacing : nil
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment