-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCardModifier.swift
38 lines (34 loc) · 1.04 KB
/
CardModifier.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//
// CardModifier.swift
// Pulse
//
// Created by Riccardo Persello on 02/04/23.
//
import Foundation
import SwiftUI
struct CardModifier: ViewModifier {
@Environment(\.colorScheme) var colorScheme
var aspectRatio: Double
var title: String
func body(content: Content) -> some View {
ZStack(alignment: .topLeading) {
Text(title)
.font(.system(size: 12, weight: .bold))
.foregroundColor(.secondary)
.textCase(.uppercase)
.padding(.leading, 16)
.padding(.top, 16)
.zIndex(100)
content
.frame(maxWidth: .infinity, maxHeight: .infinity)
.clipped()
.background(.black.opacity(0.1))
.clipShape(RoundedRectangle(cornerRadius: 16, style: .continuous))
}
}
}
extension View {
func cardStyle(aspectRatio: Double = 1, title: String = "") -> some View {
modifier(CardModifier(aspectRatio: aspectRatio, title: title))
}
}