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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
import SwiftUI
struct TrackerItemView: View {
let bookmark: Bookmark
let isExpanded: Bool
let isLoading: Bool
let count: Int
let onToggleExpanded: () -> Void
@Environment(\.appearsActive) private var appearsActive
var body: some View {
HStack(alignment: .center, spacing: 6) {
if bookmark.type == .tracker {
Button {
self.onToggleExpanded()
} label: {
Text(Image(systemName: self.isExpanded ? "chevron.down" : "chevron.right"))
.bold()
.font(.system(size: 10))
.opacity(0.5)
.frame(alignment: .center)
}
.buttonStyle(.plain)
.frame(width: 10)
.padding(.leading, 4)
.padding(.trailing, 2)
}
switch bookmark.type {
case .tracker:
Image("Tracker")
.resizable()
.scaledToFit()
.frame(width: 16, height: 16, alignment: .center)
Text(bookmark.name).bold().lineLimit(1).truncationMode(.tail)
if isLoading {
ProgressView()
.padding([.leading, .trailing], 2)
.controlSize(.mini)
}
Spacer(minLength: 0)
if isExpanded && count > 0 {
HStack(spacing: 4) {
Text(String(count))
SpinningGlobeView()
.fontWeight(.semibold)
.frame(width: 12, height: 12)
}
.padding(.horizontal, 6)
.padding(.vertical, 2)
.foregroundStyle(.secondary)
// .background(.quinary)
.clipShape(.capsule)
}
case .server:
Image(systemName: "bookmark.fill")
.resizable()
.scaledToFit()
.foregroundStyle(Color.secondary)
.frame(width: 11, height: 11, alignment: .center)
.opacity(0.75)
.padding(.leading, 3)
.padding(.trailing, 2)
Image(systemName: "bolt.fill")
.resizable()
.renderingMode(.template)
.aspectRatio(contentMode: .fit)
.frame(width: 13, height: 13, alignment: .center)
.opacity(0.5)
.padding(.leading, 3)
.padding(.trailing, 2)
.foregroundStyle(bookmark.autoconnect ? Color.accentColor : Color.gray)
.onTapGesture {
bookmark.autoconnect.toggle()
try? bookmark.modelContext?.save()
}
Image("Server")
.resizable()
.scaledToFit()
.frame(width: 16, height: 16, alignment: .center)
Text(bookmark.name).lineLimit(1).truncationMode(.tail)
Spacer(minLength: 0)
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
|