Skip to content

Instantly share code, notes, and snippets.

@damodarnamala
Created April 8, 2022 12:21
Show Gist options
  • Save damodarnamala/f22b6d6972c3f8eb2dfbbd50f82f3d11 to your computer and use it in GitHub Desktop.
Save damodarnamala/f22b6d6972c3f8eb2dfbbd50f82f3d11 to your computer and use it in GitHub Desktop.
DesignSystem Example
struct ContentView: View {
var body: some View {
HStack {
Rectangle()
.frame(width: 200, height: 200, alignment: .center)
}.card()
}
}
public class DesignSystem {
public typealias CornerRadious = DesignSystem.CornerRadiousOptions
public struct CornerRadiousOptions {
static var small : CGFloat = 8
static var medium : CGFloat = 16
static var large : CGFloat = 32
}
}
struct RoundedView: ViewModifier {
func body(content: Content) -> some View {
content
.foregroundColor(.white)
.cornerRadius(DesignSystem.CornerRadious.medium)
.shadow(color: Color(.lightGray), radius: 4, x: 4, y: 4)
}
}
extension View {
func card() -> some View {
modifier(RoundedView())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment