Widget Features: - Add inline voting to timeline widget when no entry exists for today - Show random prompt from notification strings in voting mode - Update vote widget to use simple icon style for selection - Make stats bar full width in voted state view - Add Localizable.strings to widget extension target Bug Fixes: - Fix inverted date calculation in InsightsViewModel streak logic - Replace force unwraps with safe optional handling in widgets - Replace fatalError calls with graceful error handling - Fix CSV import safety in SettingsView Warning Fixes: - Add @retroactive to Color and Date extension conformances - Update deprecated onChange(of:perform:) to new syntax - Replace deprecated applicationIconBadgeNumber with setBadgeCount - Replace deprecated UIApplication.shared.windows API - Add @preconcurrency for Swift 6 protocol conformances - Add missing widget family cases to switch statement - Remove unused variables and #warning directives 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
66 lines
2.3 KiB
Swift
66 lines
2.3 KiB
Swift
//
|
|
// FeelsApp.swift
|
|
// Shared
|
|
//
|
|
// Created by Trey Tartt on 1/5/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
import SwiftData
|
|
import BackgroundTasks
|
|
import WidgetKit
|
|
|
|
@main
|
|
struct FeelsApp: App {
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
|
|
let dataController = DataController.shared
|
|
@StateObject var iapManager = IAPManager()
|
|
@AppStorage(UserDefaultsStore.Keys.firstLaunchDate.rawValue, store: GroupUserDefaults.groupDefaults) private var firstLaunchDate = Date()
|
|
@State private var showSubscriptionFromWidget = false
|
|
|
|
init() {
|
|
BGTaskScheduler.shared.cancelAllTaskRequests()
|
|
BGTaskScheduler.shared.register(forTaskWithIdentifier: BGTask.updateDBMissingID, using: nil) { (task) in
|
|
BGTask.runFillInMissingDatesTask(task: task as! BGProcessingTask)
|
|
}
|
|
UNUserNotificationCenter.current().setBadgeCount(0)
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
MainTabView(dayView: DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)),
|
|
monthView: MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true)),
|
|
yearView: YearView(viewModel: YearViewModel()),
|
|
insightsView: InsightsView(),
|
|
customizeView: CustomizeView())
|
|
.modelContainer(dataController.container)
|
|
.environmentObject(iapManager)
|
|
.sheet(isPresented: $showSubscriptionFromWidget) {
|
|
FeelsSubscriptionStoreView()
|
|
.environmentObject(iapManager)
|
|
}
|
|
.onOpenURL { url in
|
|
if url.scheme == "feels" && url.host == "subscribe" {
|
|
showSubscriptionFromWidget = true
|
|
}
|
|
}
|
|
}.onChange(of: scenePhase) { _, newPhase in
|
|
if newPhase == .background {
|
|
//BGTask.scheduleBackgroundProcessing()
|
|
WidgetCenter.shared.reloadAllTimelines()
|
|
}
|
|
|
|
if newPhase == .active {
|
|
UNUserNotificationCenter.current().setBadgeCount(0)
|
|
// Check subscription status on each app launch
|
|
Task {
|
|
await iapManager.checkSubscriptionStatus()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|