54 lines
1.5 KiB
Swift
54 lines
1.5 KiB
Swift
//
|
|
// CardView.swift
|
|
// app
|
|
//
|
|
// Created by Sebastian Pobel on 13.01.20.
|
|
// Copyright © 2020 Marcus Handte. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct Card<Content>: View where Content: View {
|
|
@UIState var cornerRadius: CGFloat = 10
|
|
@UIState var shadow: Bool = true
|
|
@UIState var shadowRadius: CGFloat = 7
|
|
@UIState var shadowX: CGFloat = 1
|
|
@UIState var shadowY: CGFloat = 1
|
|
|
|
var content: () -> Content
|
|
|
|
var body: some View {
|
|
ZStack {
|
|
if (shadow) {
|
|
RoundedRectangle(cornerRadius: cornerRadius)
|
|
.foregroundColor(Color("mowesta-card"))
|
|
.shadow(radius: shadowRadius, x: shadowX, y: shadowY)
|
|
} else {
|
|
RoundedRectangle(cornerRadius: cornerRadius)
|
|
.foregroundColor(Color("mowesta-card"))
|
|
}
|
|
self.content()
|
|
.padding()
|
|
}
|
|
}
|
|
}
|
|
|
|
struct Card_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
Group {
|
|
Card(cornerRadius: 22, shadowRadius: 20, shadowX: 3, shadowY: 3) {
|
|
Text("Content")
|
|
.font(.title)
|
|
}
|
|
.previewLayout(.fixed(width: 200, height: 100))
|
|
|
|
Card() {
|
|
Text("Content")
|
|
.font(.title)
|
|
}
|
|
.previewLayout(.fixed(width: 200, height: 100))
|
|
.environment(\.colorScheme, .dark)
|
|
}
|
|
}
|
|
}
|