-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
SymbolPalette.swift
71 lines (65 loc) · 1.46 KB
/
SymbolPalette.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
67
68
69
70
71
import SwiftUI
struct SymbolPalette: View {
private let symbols: [String] = [
"autostartstop",
"app.dashed",
"applescript",
"folder",
"app.connected.to.app.below.fill",
"flowchart",
"terminal",
"laptopcomputer",
"safari",
"archivebox",
"flame",
"calendar",
"book",
"bookmark",
"link",
"pencil.tip",
"sparkles",
"cloud",
"checkmark.seal",
"music.note",
"star",
"tag",
"bolt",
"macwindow"
]
var items: [GridItem] {
Array(repeating: .init(.fixed(size)), count: 5)
}
@Binding var group: WorkflowGroup
var size: CGFloat
var body: some View {
LazyVGrid(columns: items, spacing: 10) {
ForEach(symbols, id: \.self) { symbol in
ZStack {
Circle()
.fill(Color(group.symbol == symbol ? .white : .clear))
Circle()
.fill(Color(.windowBackgroundColor))
.frame(width: size, height: size)
.overlay(
Group {
if !symbol.isEmpty {
Image(systemName: symbol)
} else {
EmptyView()
}
}
)
.onTapGesture {
group.symbol = symbol
}
.padding(2)
}
}
}
}
}
struct SymbolPalette_Previews: PreviewProvider {
static var previews: some View {
SymbolPalette(group: .constant(WorkflowGroup.designTime()), size: 32)
}
}