mirror of
https://github.com/awizemann/scarf.git
synced 2026-05-10 10:36:35 +00:00
dbaadb8037
Introduces a new Projects section that renders custom dashboards from JSON files in project directories. Supports 7 widget types (stat, progress, text, table, chart, list) with live file-watching refresh. Includes project registry, SwiftUI Charts integration, schema docs, and comprehensive README documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
33 lines
911 B
Swift
33 lines
911 B
Swift
import SwiftUI
|
|
|
|
struct ProgressWidgetView: View {
|
|
let widget: DashboardWidget
|
|
|
|
private var progressValue: Double {
|
|
switch widget.value {
|
|
case .number(let n): return n
|
|
default: return 0
|
|
}
|
|
}
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading, spacing: 8) {
|
|
Text(widget.title)
|
|
.font(.caption)
|
|
.foregroundStyle(.secondary)
|
|
ProgressView(value: progressValue) {
|
|
if let label = widget.label {
|
|
Text(label)
|
|
.font(.caption2)
|
|
.foregroundStyle(.secondary)
|
|
}
|
|
}
|
|
.tint(parseColor(widget.color))
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(12)
|
|
.background(.quaternary.opacity(0.5))
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
}
|