From 9e01a7e7b525c7c47b489c99b0c225458d0bb132 Mon Sep 17 00:00:00 2001 From: kutesir Date: Wed, 17 Jun 2026 00:10:47 +0300 Subject: [PATCH] Settings: add "Time Milestones" toggle for period notifications (KC-31 #2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds a Customize → "Time Milestones" toggle bound to the App-Group kisani.periodMilestones flag (so NotificationManager reads the same value). Flipping it reschedules immediately — off clears the day/week/month/year notifications, on re-schedules them. Defaults on. Closes the pending #2 from the KC-31 audit; #6 (configurable thresholds/snooze) remains pending. Co-Authored-By: Claude Opus 4.8 --- KisaniCal/Views/SettingsView.swift | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/KisaniCal/Views/SettingsView.swift b/KisaniCal/Views/SettingsView.swift index 06531db..738b16d 100644 --- a/KisaniCal/Views/SettingsView.swift +++ b/KisaniCal/Views/SettingsView.swift @@ -22,6 +22,8 @@ struct SettingsView: View { @AppStorage("googleCalSync") private var googleCalSync = false @AppStorage("iCloudCalSync") private var iCloudCalSync = true @AppStorage("streakGoal") private var streakGoal = 5 + // App-Group store so NotificationManager (which reads UserDefaults.kisani) sees it. + @AppStorage("kisani.periodMilestones", store: UserDefaults.kisani) private var periodMilestones = true // Sheet presentation @State private var showProfile = false @@ -102,6 +104,11 @@ struct SettingsView: View { SttNavRow(icon: "menucard", bg: AppColors.accentSoft, fg: AppColors.accent, label: "Tab Bar", value: "\(showMatrixTab && showWorkoutTab ? "5" : showMatrixTab || showWorkoutTab ? "4" : "3") tabs") { showTabBar = true } SttNavRow(icon: "paintpalette", bg: AppColors.blueSoft, fg: AppColors.blue, label: "Appearance", value: appearanceLabel) { showAppearance = true } SttToggleRow(icon: "bell", bg: AppColors.accentSoft, fg: AppColors.accent, label: "Sounds & Notifications", isOn: $soundsOn) + SttToggleRow(icon: "calendar.badge.clock", bg: AppColors.blueSoft, fg: AppColors.blue, label: "Time Milestones", + isOn: Binding( + get: { periodMilestones }, + set: { periodMilestones = $0 + NotificationManager.shared.reschedule(workoutVM: workoutVM, taskVM: taskVM) })) SttNavRow(icon: "clock", bg: AppColors.greenSoft, fg: AppColors.green, label: "Date & Time", value: dateLabel) { showDateTime = true } SttNavRow(icon: "puzzlepiece", bg: AppColors.yellowSoft, fg: AppColors.yellow, label: "Widgets") { showWidgets = true } SttNavRow(icon: "gearshape", bg: AppColors.surface3(cs), label: "General", isLast: true) { showGeneral = true }