Created
October 17, 2021 17:19
-
-
Save ostk0069/06d060219661f1e6158b1343d8a49f0e to your computer and use it in GitHub Desktop.
SwiftUI Gap class inspired from Flutter Gap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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