aboutsummaryrefslogtreecommitdiff
path: root/Hotline/macOS/Trackers/TrackerItemView.swift
diff options
context:
space:
mode:
authorDustin Mierau <dustin@mierau.me>2025-11-07 16:16:00 -0800
committerDustin Mierau <dustin@mierau.me>2025-11-07 16:16:00 -0800
commite1566598c96601ebcf3229aab22fc7a593ee1904 (patch)
tree4486a58aad0df5df17ebcca0209d48dcfa3d6a5e /Hotline/macOS/Trackers/TrackerItemView.swift
parenta55318fa8d643160900bec3e6b14e7404c63497a (diff)
Further UI tweraks. Transfers button in toolbar. Better empty states in places. Fix race condition with transactions ids (yikes)!
Diffstat (limited to 'Hotline/macOS/Trackers/TrackerItemView.swift')
-rw-r--r--Hotline/macOS/Trackers/TrackerItemView.swift73
1 files changed, 73 insertions, 0 deletions
diff --git a/Hotline/macOS/Trackers/TrackerItemView.swift b/Hotline/macOS/Trackers/TrackerItemView.swift
new file mode 100644
index 0000000..59caad5
--- /dev/null
+++ b/Hotline/macOS/Trackers/TrackerItemView.swift
@@ -0,0 +1,73 @@
+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(.small)
+ }
+ 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("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)
+ }
+} \ No newline at end of file