summaryrefslogtreecommitdiff
path: root/Hutch/Views/Shared/StaleCacheStatusRow.swift
diff options
context:
space:
mode:
Diffstat (limited to 'Hutch/Views/Shared/StaleCacheStatusRow.swift')
-rw-r--r--Hutch/Views/Shared/StaleCacheStatusRow.swift32
1 files changed, 32 insertions, 0 deletions
diff --git a/Hutch/Views/Shared/StaleCacheStatusRow.swift b/Hutch/Views/Shared/StaleCacheStatusRow.swift
new file mode 100644
index 0000000..166fec4
--- /dev/null
+++ b/Hutch/Views/Shared/StaleCacheStatusRow.swift
@@ -0,0 +1,32 @@
+import SwiftUI
+
+struct StaleCacheStatusRow: View {
+ let metadata: CacheEntryMetadata
+ let isRefreshing: Bool
+
+ var body: some View {
+ HStack(spacing: 8) {
+ Image(systemName: metadata.isExpired() ? "clock.badge.exclamationmark" : "clock")
+ .foregroundStyle(.secondary)
+ Text(statusText)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ Spacer(minLength: 0)
+ if isRefreshing {
+ ProgressView()
+ .controlSize(.mini)
+ }
+ }
+ .themedRow()
+ }
+
+ private var statusText: String {
+ if isRefreshing {
+ return "Showing cached data. Refreshing…"
+ }
+ if metadata.isExpired() {
+ return "Showing cached data. Last updated \(metadata.fetchedAt.relativeDescription)."
+ }
+ return "Last updated \(metadata.fetchedAt.relativeDescription)"
+ }
+}