Files
Amphlify/Amphlify/App/AmphlifyApp.swift
T

42 lines
1.2 KiB
Swift

import SwiftUI
@main
struct AmphlifyApp: App {
@State private var app = Composition.makeApp()
@Environment(\.scenePhase) private var scenePhase
var body: some Scene {
WindowGroup {
RootView()
.environment(app)
.environment(app.player)
.environment(app.router)
.task { await app.start() }
.task(id: scenePhase) {
guard scenePhase == .active else { return }
while !Task.isCancelled {
await app.resync()
try? await Task.sleep(for: .seconds(300))
}
}
#if DEBUG
.task(id: app.revision == 0) {
if app.revision > 0 {
await DemoScene.requested?.apply(to: app)
}
}
#endif
}
#if os(macOS)
.defaultSize(width: 1280, height: 800)
.commands { MacCommands(app: app) }
#endif
#if os(macOS)
Settings {
MacSettingsView()
.environment(app)
}
#endif
}
}