31 lines
691 B
Swift
31 lines
691 B
Swift
//
|
|
// Cardify.swift
|
|
// Memorize
|
|
//
|
|
// Created by ching on 2023/2/15.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct Cardify: ViewModifier {
|
|
var isFaceUp: Bool
|
|
func body(content: Content) -> some View {
|
|
ZStack {
|
|
let shape = RoundedRectangle(cornerRadius: const.DrawingConstants.cornerRadius)
|
|
if isFaceUp {
|
|
shape.fill().foregroundColor(.white)
|
|
shape.strokeBorder(lineWidth: const.DrawingConstants.lineWidth)
|
|
content
|
|
} else {
|
|
shape.fill()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension View {
|
|
func cadify(isFaceUp: Bool) -> some View {
|
|
self.modifier(Cardify(isFaceUp: isFaceUp))
|
|
}
|
|
}
|