Widgets: remove Event Countdown (dots) + Tasks Done Today (KC-17)
Drop the dot-grid EventCountdownWidget and TasksCompleteWidget from the gallery: widget structs, their views, the todayTaskCompletion() helper (only consumer), and bundle registrations. Shared event plumbing (EventConfigIntent/Provider/Entry, CycleCountdownUnitIntent) stays for the surviving Event Countdown (Bars); DotGrid stays for Day Progress. Remaining widgets untouched. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -252,21 +252,6 @@ struct EventProvider: AppIntentTimelineProvider {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Widget
|
||||
|
||||
struct EventCountdownWidget: Widget {
|
||||
let kind = "KisaniEventCountdown"
|
||||
|
||||
var body: some WidgetConfiguration {
|
||||
AppIntentConfiguration(kind: kind, intent: EventConfigIntent.self, provider: EventProvider()) { entry in
|
||||
EventCountdownView(entry: entry)
|
||||
}
|
||||
.configurationDisplayName("Event Countdown")
|
||||
.description("Track the days until any upcoming event with a dot grid.")
|
||||
.supportedFamilies([.systemMedium, .systemSmall])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Event Countdown (Bars)
|
||||
|
||||
struct EventBarsWidget: Widget {
|
||||
|
||||
@@ -48,20 +48,6 @@ struct DayProgressWidget: Widget {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tasks Done Today Widget ("Tasks complete %")
|
||||
|
||||
struct TasksCompleteWidget: Widget {
|
||||
let kind = "KisaniTasksComplete"
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: KisaniProvider()) { _ in
|
||||
TasksCompleteView()
|
||||
}
|
||||
.configurationDisplayName("Tasks Done Today")
|
||||
.description("Percentage of today's tasks you've completed.")
|
||||
.supportedFamilies([.systemSmall, .systemMedium])
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Lock Screen Widgets
|
||||
|
||||
struct LockScreenWidget: Widget {
|
||||
@@ -105,11 +91,9 @@ struct LockScreenCircularWidget: Widget {
|
||||
@main
|
||||
struct KisaniWidgetBundle: WidgetBundle {
|
||||
var body: some Widget {
|
||||
EventCountdownWidget()
|
||||
EventBarsWidget()
|
||||
MyTasksWidget()
|
||||
DayProgressWidget()
|
||||
TasksCompleteWidget()
|
||||
LockScreenWidget()
|
||||
LockScreenCircularWidget()
|
||||
TaskLiveActivity()
|
||||
|
||||
@@ -138,21 +138,6 @@ private func CloudSyncManager_widgetPush(_ data: Data, _ key: String) {
|
||||
kv.synchronize()
|
||||
}
|
||||
|
||||
// Today's task completion: (done, total) for tasks due today.
|
||||
func todayTaskCompletion() -> (done: Int, total: Int) {
|
||||
let cal = Calendar.current
|
||||
let start = cal.startOfDay(for: Date())
|
||||
let end = cal.date(byAdding: .day, value: 1, to: start)!
|
||||
let tasks = loadWidgetTasks()
|
||||
func dueToday(_ t: WidgetTask) -> Bool {
|
||||
guard let due = t.dueDate else { return false }
|
||||
return due >= start && due < end
|
||||
}
|
||||
let active = tasks.filter { !$0.isComplete && dueToday($0) }
|
||||
let completed = tasks.filter { $0.isComplete && dueToday($0) }
|
||||
return (completed.count, active.count + completed.count)
|
||||
}
|
||||
|
||||
// Workout streak count
|
||||
func loadWorkoutStreak() -> Int {
|
||||
let uid = UserDefaults.kisani.string(forKey: "kisani.activeUserId") ?? "shared"
|
||||
|
||||
@@ -102,52 +102,6 @@ struct ProgressDotView: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Tasks completed today
|
||||
|
||||
struct TasksCompleteView: View {
|
||||
@Environment(\.widgetFamily) private var family
|
||||
private let teal = WidgetTheme.accent
|
||||
|
||||
private var stats: (done: Int, total: Int) { todayTaskCompletion() }
|
||||
private var percent: Int {
|
||||
let s = stats
|
||||
guard s.total > 0 else { return 0 }
|
||||
return Int((Double(s.done) / Double(s.total) * 100).rounded())
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let s = stats
|
||||
let isMedium = family == .systemMedium
|
||||
VStack(alignment: .leading, spacing: isMedium ? 10 : 6) {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text("Today's Tasks")
|
||||
.font(.system(size: isMedium ? 22 : 14, weight: .bold))
|
||||
.foregroundColor(.white)
|
||||
.lineLimit(1)
|
||||
Spacer()
|
||||
Text("\(percent)%")
|
||||
.font(.system(size: isMedium ? 22 : 13, weight: .bold))
|
||||
.foregroundColor(Color(white: 0.5))
|
||||
}
|
||||
if s.total == 0 {
|
||||
Spacer(minLength: 0)
|
||||
Text("No tasks due today")
|
||||
.font(.system(size: 12))
|
||||
.foregroundColor(Color(white: 0.5))
|
||||
Spacer(minLength: 0)
|
||||
} else {
|
||||
Text("\(s.done) of \(s.total) done")
|
||||
.font(.system(size: 12))
|
||||
.foregroundColor(teal)
|
||||
Spacer(minLength: 2)
|
||||
DotGrid(total: s.total, filled: s.done, color: teal)
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, isMedium ? 4 : 0)
|
||||
.containerBackground(WidgetTheme.background, for: .widget)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Circular dot grid (event countdown motif)
|
||||
|
||||
struct DotGrid: View {
|
||||
@@ -205,75 +159,6 @@ struct DotGrid: View {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Event Countdown Widget (small + medium)
|
||||
|
||||
struct EventCountdownView: View {
|
||||
let entry: EventEntry
|
||||
@Environment(\.widgetFamily) var family
|
||||
|
||||
private let teal = WidgetTheme.accent
|
||||
|
||||
private var percent: Int { Int((entry.progress * 100).rounded()) }
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if family == .systemSmall {
|
||||
small
|
||||
} else {
|
||||
medium
|
||||
}
|
||||
}
|
||||
.containerBackground(WidgetTheme.background, for: .widget)
|
||||
}
|
||||
|
||||
private var filled: Int { Int(entry.progress * Double(entry.totalDays)) }
|
||||
|
||||
// Wide layout: event name + days-left countdown, then the dot-grid progress.
|
||||
private var medium: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
HStack(alignment: .firstTextBaseline, spacing: 8) {
|
||||
Text(LocalizedStringKey(entry.eventName))
|
||||
.font(.system(size: 20, weight: .bold))
|
||||
.foregroundColor(teal)
|
||||
.lineLimit(1)
|
||||
Spacer(minLength: 4)
|
||||
VStack(alignment: .trailing, spacing: 1) {
|
||||
Button(intent: CycleCountdownUnitIntent()) {
|
||||
Text(entry.timeLeftLabel)
|
||||
.font(.system(size: 14, weight: .semibold))
|
||||
.foregroundColor(Color(white: 0.62))
|
||||
.lineLimit(1)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
Text("\(percent)%")
|
||||
.font(.system(size: 11, weight: .bold))
|
||||
.foregroundColor(Color(white: 0.4))
|
||||
}
|
||||
}
|
||||
DotGrid(total: entry.totalDays, filled: filled, color: teal)
|
||||
}
|
||||
.padding(.horizontal, 4)
|
||||
}
|
||||
|
||||
private var small: some View {
|
||||
VStack(alignment: .leading, spacing: 6) {
|
||||
Text(LocalizedStringKey(entry.eventName))
|
||||
.font(.system(size: 14, weight: .bold))
|
||||
.foregroundColor(teal)
|
||||
.lineLimit(2)
|
||||
Button(intent: CycleCountdownUnitIntent()) {
|
||||
Text(entry.timeLeftLabel)
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundColor(Color(white: 0.62))
|
||||
.lineLimit(1)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
Spacer(minLength: 2)
|
||||
DotGrid(total: entry.totalDays, filled: filled, color: teal)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Event Countdown — Bars style (medium)
|
||||
|
||||
struct EventBarsView: View {
|
||||
|
||||
Reference in New Issue
Block a user