37 lines
1.2 KiB
Swift
37 lines
1.2 KiB
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct PortfolioJournalApp: App {
|
|
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
|
|
@StateObject private var iapService: IAPService
|
|
@StateObject private var adMobService: AdMobService
|
|
@StateObject private var accountStore: AccountStore
|
|
@StateObject private var tabSelection = TabSelectionStore()
|
|
@Environment(\.scenePhase) private var scenePhase
|
|
|
|
let coreDataStack = CoreDataStack.shared
|
|
|
|
init() {
|
|
let iap = IAPService()
|
|
_iapService = StateObject(wrappedValue: iap)
|
|
_adMobService = StateObject(wrappedValue: AdMobService())
|
|
_accountStore = StateObject(wrappedValue: AccountStore(iapService: iap))
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
ContentView()
|
|
.environment(\.managedObjectContext, coreDataStack.viewContext)
|
|
.environmentObject(iapService)
|
|
.environmentObject(adMobService)
|
|
.environmentObject(accountStore)
|
|
.environmentObject(tabSelection)
|
|
}
|
|
.onChange(of: scenePhase) { _, newPhase in
|
|
if newPhase == .active {
|
|
coreDataStack.refreshWidgetData()
|
|
}
|
|
}
|
|
}
|
|
}
|