-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
MagicVarsIconView.swift
67 lines (64 loc) · 2.2 KB
/
MagicVarsIconView.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import SwiftUI
struct MagicVarsIconView: View {
let size: CGFloat
var body: some View {
Rectangle()
.fill(
LinearGradient(
stops: [
.init(color: Color(nsColor: .systemOrange.blended(withFraction: 0.3, of: .systemOrange)!), location: 0.1),
.init(color: Color(nsColor: .systemOrange.blended(withFraction: 0.6, of: .black)!), location: 1.0)
],
startPoint: .top,
endPoint: .bottom)
)
.overlay { iconOverlay().opacity(0.25) }
.overlay { iconBorder(size) }
.overlay {
LinearGradient(stops: [
.init(color: Color(nsColor: .systemYellow.blended(withFraction: 0.5, of: .white)!), location: 0.2),
.init(color: Color(nsColor: .systemOrange.blended(withFraction: 0.1, of: .yellow)!), location: 1.0),
], startPoint: .topLeading, endPoint: .bottom)
.mask {
Image(systemName: "square.fill")
.resizable()
.frame(width: size * 0.9, height: size * 0.9)
.mask {
RoundedRectangle(cornerRadius: size * 0.15)
}
.offset(x: size * 0.01, y: size * 0.01)
}
.overlay(alignment: .center) {
Text("var")
.font(.system(size: size * 0.4, weight: .heavy, design: .monospaced))
.offset(y: -size * 0.05)
}
.overlay(alignment: .bottomTrailing) {
Image(systemName: "wand.and.stars")
.resizable()
.foregroundStyle(
Color.white,
Color(nsColor: .systemYellow.blended(withFraction: 0.5, of: .white)!))
.frame(width: size * 0.6, height: size * 0.6)
}
.shadow(color: Color(nsColor: .systemOrange.blended(withFraction: 0.5, of: .black)!), radius: 2, y: 2)
}
.frame(width: size, height: size)
.fixedSize()
.iconShape(size)
}
}
#Preview {
HStack(alignment: .top, spacing: 8) {
MagicVarsIconView(size: 192)
VStack(alignment: .leading, spacing: 8) {
MagicVarsIconView(size: 128)
HStack(alignment: .top, spacing: 8) {
MagicVarsIconView(size: 64)
MagicVarsIconView(size: 32)
MagicVarsIconView(size: 16)
}
}
}
.padding()
}