WidgetTheme now uses the true brand colors — accent RGB(232,98,42) on the logo's dark RGB(26,29,34) — replacing a near-miss orange on slate. Bars countdown, My Tasks, and Day Progress inherit it; Task Live Activity drops its hardcoded accent/black tint for the theme; lock screen rings tint brand orange. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
75 lines
3.2 KiB
Swift
75 lines
3.2 KiB
Swift
import ActivityKit
|
|
import WidgetKit
|
|
import SwiftUI
|
|
|
|
@available(iOS 16.1, *)
|
|
struct TaskLiveActivity: Widget {
|
|
private let accent = WidgetTheme.accent // brand orange
|
|
|
|
var body: some WidgetConfiguration {
|
|
ActivityConfiguration(for: TaskActivityAttributes.self) { context in
|
|
// ── Lock screen / banner ──
|
|
HStack(spacing: 12) {
|
|
Image(systemName: context.state.isComplete ? "checkmark.circle.fill" : "circle")
|
|
.font(.system(size: 22))
|
|
.foregroundColor(context.state.isComplete ? .green : accent)
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Text(context.attributes.title)
|
|
.font(.system(size: 15, weight: .semibold))
|
|
.foregroundColor(.white)
|
|
.lineLimit(1)
|
|
.strikethrough(context.state.isComplete)
|
|
if let due = context.state.dueDate {
|
|
Text(due, style: context.state.isComplete ? .date : .relative)
|
|
.font(.system(size: 12, design: .monospaced))
|
|
.foregroundColor(.white.opacity(0.6))
|
|
}
|
|
}
|
|
Spacer()
|
|
if let due = context.state.dueDate, !context.state.isComplete {
|
|
Text(due, style: .timer)
|
|
.font(.system(size: 16, weight: .bold, design: .monospaced))
|
|
.foregroundColor(accent)
|
|
.frame(maxWidth: 70)
|
|
}
|
|
}
|
|
.padding(.horizontal, 16)
|
|
.padding(.vertical, 12)
|
|
.activityBackgroundTint(WidgetTheme.background.opacity(0.9))
|
|
.activitySystemActionForegroundColor(.white)
|
|
|
|
} dynamicIsland: { context in
|
|
DynamicIsland {
|
|
DynamicIslandExpandedRegion(.leading) {
|
|
Image(systemName: "checklist")
|
|
.foregroundColor(accent)
|
|
}
|
|
DynamicIslandExpandedRegion(.trailing) {
|
|
if let due = context.state.dueDate, !context.state.isComplete {
|
|
Text(due, style: .timer)
|
|
.font(.system(.body, design: .monospaced))
|
|
.foregroundColor(accent)
|
|
.frame(maxWidth: 64)
|
|
}
|
|
}
|
|
DynamicIslandExpandedRegion(.center) {
|
|
Text(context.attributes.title)
|
|
.font(.system(size: 14, weight: .semibold))
|
|
.lineLimit(1)
|
|
}
|
|
} compactLeading: {
|
|
Image(systemName: "checklist").foregroundColor(accent)
|
|
} compactTrailing: {
|
|
if let due = context.state.dueDate, !context.state.isComplete {
|
|
Text(due, style: .timer)
|
|
.font(.system(.caption2, design: .monospaced))
|
|
.foregroundColor(accent)
|
|
.frame(maxWidth: 44)
|
|
}
|
|
} minimal: {
|
|
Image(systemName: "checklist").foregroundColor(accent)
|
|
}
|
|
}
|
|
}
|
|
}
|