Files
Reflect/Shared/AppDelegate.swift
Trey t 440b04159e Add Apple platform features and UX improvements
- Add HealthKit State of Mind sync for mood entries
- Add Live Activity with streak display and rating time window
- Add App Shortcuts/Siri integration for voice mood logging
- Add TipKit hints for feature discovery
- Add centralized MoodLogger for consistent side effects
- Add reminder time setting in Settings with time picker
- Fix duplicate notifications when changing reminder time
- Fix Live Activity streak showing 0 when not yet rated today
- Fix slow tap response in entry detail mood selection
- Update widget timeline to refresh at rating time
- Sync widgets when reminder time changes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 17:21:55 -06:00

80 lines
2.8 KiB
Swift

//
// AppDelegate.swift
// Feels (iOS)
//
// Created by Trey Tartt on 1/10/22.
//
import Foundation
import UserNotifications
import UIKit
import SwiftUI
class AppDelegate: NSObject, UIApplicationDelegate {
private let savedOnboardingData = UserDefaultsStore.getOnboarding()
@AppStorage(UserDefaultsStore.Keys.textColor.rawValue, store: GroupUserDefaults.groupDefaults) private var textColor: Color = DefaultTextColor.textColor
@MainActor
func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
DataController.shared.removeNoForDates()
DataController.shared.fillInMissingDates()
UNUserNotificationCenter.current().delegate = self
UIPageControl.appearance().currentPageIndicatorTintColor = UIColor(textColor)
UIPageControl.appearance().pageIndicatorTintColor = UIColor.systemGray
let appearance = UITabBarAppearance()
appearance.configureWithOpaqueBackground()
UITabBar.appearance().standardAppearance = appearance
UITabBar.appearance().scrollEdgeAppearance = appearance
EventLogger.log(event: "app_launced")
return true
}
@MainActor
func applicationWillEnterForeground(_ application: UIApplication) {
DataController.shared.fillInMissingDates()
// reschedule notifications so there's a new title next notification
LocalNotification.rescheduleNotifiations()
EventLogger.log(event: "app_foregorund")
}
}
extension AppDelegate: @preconcurrency UNUserNotificationCenterDelegate {
func requestAuthorization() { }
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.badge, .banner, .sound])
}
@MainActor
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
if let action = LocalNotification.ActionType(rawValue: response.actionIdentifier) {
let date = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: savedOnboardingData)
let mood: Mood
switch action {
case .horrible:
mood = .horrible
case .bad:
mood = .bad
case .average:
mood = .average
case .good:
mood = .good
case .great:
mood = .great
}
// Use centralized mood logger
MoodLogger.shared.logMood(mood, for: date, entryType: .notification)
UNUserNotificationCenter.current().setBadgeCount(0)
}
completionHandler()
}
}