-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
FeatureIcon.swift
59 lines (54 loc) · 1.61 KB
/
FeatureIcon.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
import SwiftUI
struct FeatureIcon<Content: View>: View {
let content: () -> Content
let color: Color
let size: CGSize
init(color: Color,
size: CGSize = .init(width: 50, height: 50),
@ViewBuilder _ content: @escaping () -> Content) {
self.color = color
self.content = content
self.size = size
}
var body: some View {
ZStack {
RoundedRectangle(cornerRadius: 4)
.fill(color)
content()
.frame(width: size.width / 1.5, height: size.height / 1.5)
}
.frame(width: size.width, height: size.width)
}
}
struct FeatureIcon_Previews: PreviewProvider {
static let previewSize: CGSize = .init(width: 36, height: 36)
static var previews: some View {
HStack {
FeatureIcon(color: .red, size: previewSize, {
AppSymbol()
})
FeatureIcon(color: .orange, size: previewSize, {
TypingSymbol(foreground: .orange)
})
FeatureIcon(color: .yellow, size: previewSize, {
ScriptSymbol(cornerRadius: 3,
foreground: .yellow,
background: .white.opacity(0.7),
borderColor: .white)
})
FeatureIcon(color: .green, size: previewSize, {
CommandSymbolIcon(background: .white.opacity(0.85), textColor: Color.green)
})
FeatureIcon(color: .blue, size: previewSize, {
FolderSymbol(cornerRadius: 0.06, textColor: .blue)
})
FeatureIcon(color: .purple, size: previewSize, {
URLSymbol()
})
FeatureIcon(color: .gray, size: previewSize, {
GroupSymbol()
})
}
.redacted(reason: .placeholder)
}
}