Initial commit: Jarvis iOS app
SwiftUI client for a self-hosted RSS news-correlation platform: signal feed, story detail, article reader, feed manager, and LAN⇄Tailscale connectivity. Project generated from project.yml via XcodeGen. Includes CI build matrix (macOS 14/15 × Debug/Release), issue templates, backlog, and API/backend handoff docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
60
Jarvis/Views/Shared/ConnectionBanner.swift
Normal file
60
Jarvis/Views/Shared/ConnectionBanner.swift
Normal file
@@ -0,0 +1,60 @@
|
||||
// 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 Color(hex: "555555")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 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(Color.black)
|
||||
}
|
||||
Reference in New Issue
Block a user