Remove widget extension

Delete KisaniCalWidget target, Shared/WidgetDataStore, WidgetBridge,
App Group entitlements, and all syncWidget() calls.
This commit is contained in:
kutesir
2026-05-29 10:36:39 +03:00
parent 1d4d7f07c5
commit 28f8b4a0f1
9 changed files with 3 additions and 702 deletions

View File

@@ -76,18 +76,14 @@ struct ContentView: View {
}
.onAppear {
if !hasOnboarded { showOnboarding = true }
taskVM.syncWidget()
workoutVM.syncWidget()
NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM)
}
.onChange(of: scenePhase) { phase in
if phase == .active {
NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM)
taskVM.syncWidget()
workoutVM.syncWidget()
}
}
.onChange(of: taskVM.tasks) { _ in
taskVM.syncWidget()
NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM)
}
.onChange(of: workoutVM.doneSets) { _ in

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.kutesir.KisaniCal</string>
</array>
</dict>
</plist>

View File

@@ -1,41 +0,0 @@
import WidgetKit
// Syncs app ViewModels into App Group UserDefaults so the widget can read them,
// then asks WidgetKit to reload all timelines.
extension TaskViewModel {
func syncWidget() {
let cal = Calendar.current
let start = cal.startOfDay(for: Date())
let end = cal.date(byAdding: .day, value: 1, to: start)!
let entries = tasks
.filter { !$0.isComplete }
.prefix(10)
.map { t in
WidgetDataStore.WidgetTask(
id: t.id,
title: t.title,
dueDate: t.dueDate,
isToday: t.dueDate.map { $0 >= start && $0 < end } ?? false,
isOverdue: t.dueDate.map { $0 < start } ?? false
)
}
WidgetDataStore.saveTasks(Array(entries))
WidgetCenter.shared.reloadAllTimelines()
}
}
extension WorkoutViewModel {
func syncWidget() {
let weekday = Calendar.current.component(.weekday, from: Date())
let todayProgram = program(for: Date())
let workout = WidgetDataStore.WidgetWorkout(
name: activeProgram?.name ?? "Workout",
sectionsCount: activeProgram?.sections.count ?? 0,
hasWorkoutToday: todayProgram != nil
)
WidgetDataStore.saveWorkout(workout)
WidgetCenter.shared.reloadAllTimelines()
}
}