Files
jarvis/Jarvis/Views/Shared/ConnectionBanner.swift
Robin Kutesa 595f21fb6c
Some checks failed
CI / Build · macos-14 · Debug (push) Has been cancelled
CI / Build · macos-15 · Debug (push) Has been cancelled
CI / Build · macos-14 · Release (push) Has been cancelled
CI / Build · macos-15 · Release (push) Has been cancelled
feat: East Africa + Southern Africa pills with regional sub-sections
- East Africa pill: merges Uganda + east-africa tags; Uganda pinned first via sub-sections
- Southern Africa pill: covers SA, Namibia, Botswana, Zimbabwe, Zambia, Mozambique; SA/Namibia/Botswana prioritized
- StoryStore.setPill now resets lastSyncedAt to bypass 30s rate-limit on filter switch
- sectionSupplement background fetch populates sparse regional sections in All digest
- SignalFeedView digestContent: flat hero+scroll path for pills without subSections (was showing max 5)
- Theme: removed standalone Uganda pill, wired new sub-section layouts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 02:33:33 +03:00

61 lines
1.7 KiB
Swift

// ConnectionBanner.swift
// Jarvis Live / Offline / Reconnecting indicator driven by WebSocketManager.
import SwiftUI
extension ConnectionState {
var isLive: Bool {
if case .connected = self { return true }
return false
}
var label: String {
switch self {
case .connected: return "Live"
case .connecting: return "Connecting"
case .reconnecting: return "Reconnecting"
case .disconnected: return "Offline"
}
}
var dotColor: Color {
switch self {
case .connected: return Color(hex: "33C25E")
case .connecting,
.reconnecting: return Palette.healthFailing
case .disconnected: return Palette.tertiaryText
}
}
}
/// Compact Live/Offline pill a colored dot + state label.
struct ConnectionBanner: View {
let state: ConnectionState
var body: some View {
HStack(spacing: 6) {
Circle()
.fill(state.dotColor)
.frame(width: 7, height: 7)
Text(state.label.uppercased())
.font(.system(size: 11, weight: .bold))
.kerning(0.6)
.foregroundStyle(state.isLive ? Color(hex: "33C25E") : Color(hex: "888888"))
}
.padding(.horizontal, 10)
.padding(.vertical, 5)
.background(Palette.surface)
.clipShape(Capsule())
}
}
#Preview {
VStack(spacing: 12) {
ConnectionBanner(state: .connected)
ConnectionBanner(state: .reconnecting(attempt: 2))
ConnectionBanner(state: .disconnected)
}
.padding()
.background(Palette.background)
}