krz/hutch
an ios client for sourcehut
clone: git clone https://gitbay.org/krz/hutch.git
remove-splash-highlighter: Hutch/Views/Shared/StaleCacheStatusRow.swift · raw
1import SwiftUI
2
3struct StaleCacheStatusRow: View {
4 let metadata: CacheEntryMetadata
5 let isRefreshing: Bool
6
7 var body: some View {
8 HStack(spacing: 8) {
9 Image(systemName: metadata.isExpired() ? "clock.badge.exclamationmark" : "clock")
10 .foregroundStyle(.secondary)
11 Text(statusText)
12 .font(.caption)
13 .foregroundStyle(.secondary)
14 Spacer(minLength: 0)
15 if isRefreshing {
16 ProgressView()
17 .controlSize(.mini)
18 }
19 }
20 .themedRow()
21 }
22
23 private var statusText: String {
24 if isRefreshing {
25 return "Showing cached data. Refreshing…"
26 }
27 if metadata.isExpired() {
28 return "Showing cached data. Last updated \(metadata.fetchedAt.relativeDescription)."
29 }
30 return "Last updated \(metadata.fetchedAt.relativeDescription)"
31 }
32}