Files
jarvis/Jarvis/Views/Shared/SourceChips.swift
Robin Kutesa 27d0e22767 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>
2026-06-18 18:04:59 +03:00

43 lines
1.2 KiB
Swift

// SourceChips.swift
// Jarvis names the first 2 sources, collapses the rest into "+N".
import SwiftUI
struct SourceChips: View {
/// Source names in display order.
let names: [String]
/// Total number of sources (may exceed `names.count`).
let total: Int
var maxNamed: Int = 2
private var named: [String] { Array(names.prefix(maxNamed)) }
private var overflow: Int { max(0, total - named.count) }
var body: some View {
HStack(spacing: 6) {
ForEach(named, id: \.self) { name in
chip(name)
}
if overflow > 0 {
chip("+\(overflow)", muted: true)
}
}
}
private func chip(_ text: String, muted: Bool = false) -> some View {
Text(text)
.font(.system(size: 12, weight: .bold))
.foregroundStyle(muted ? Color(hex: "777777") : Color(hex: "CCCCCC"))
.padding(.horizontal, 9)
.padding(.vertical, 5)
.background(Palette.surface2)
.clipShape(Capsule())
}
}
#Preview {
SourceChips(names: ["Daily Monitor", "NilePost", "The EastAfrican"], total: 7)
.padding()
.background(Color.black)
}