Files
Reflect/Shared/FeelsApp.swift
Trey t 682f62fa4a separate all customize views into their own files
make corner radius a constant
create the views in the main app file and pass through so they dont get re-drawn when changing UI things
2022-04-02 10:53:04 -05:00

49 lines
1.6 KiB
Swift

//
// FeelsApp.swift
// Shared
//
// Created by Trey Tartt on 1/5/22.
//
import SwiftUI
import BackgroundTasks
import WidgetKit
@main
struct FeelsApp: App {
@Environment(\.scenePhase) private var scenePhase
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
let persistenceController = PersistenceController.shared
init() {
BGTaskScheduler.shared.cancelAllTaskRequests()
BGTaskScheduler.shared.register(forTaskWithIdentifier: BGTask.updateDBMissingID, using: nil) { (task) in
BGTask.runFillInMissingDatesTask(task: task as! BGProcessingTask)
}
UIApplication.shared.applicationIconBadgeNumber = 0
}
var body: some Scene {
WindowGroup {
// build these here so when tints and other things get updated the views / their data dont
// have to get redrawn
MainTabView(dayView: DayView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: false)),
monthView: MonthView(viewModel: DayViewViewModel(addMonthStartWeekdayPadding: true)),
yearView: YearView(viewModel: YearViewModel()),
customizeView: CustomizeView())
.environment(\.managedObjectContext, persistenceController.viewContext)
}.onChange(of: scenePhase) { phase in
if phase == .background {
//BGTask.scheduleBackgroundProcessing()
WidgetCenter.shared.reloadAllTimelines()
}
if phase == .active {
UIApplication.shared.applicationIconBadgeNumber = 0
}
}
}
}