DiveLogApp.swift (1010B)
1 // SPDX-License-Identifier: GPL-2.0-only 2 import SwiftUI 3 4 @main 5 struct DiveLogApp: App { 6 @State private var model = AppModel() 7 @State private var cards = LaunchOptions.flag("-demoCards") ? CardStore.demo() : CardStore() 8 @Environment(\.scenePhase) private var scenePhase 9 10 var body: some Scene { 11 WindowGroup { 12 RootView() 13 .environment(model) 14 .environment(cards) 15 .task { 16 cards.sync() 17 await model.start() 18 await model.importSharedDives() 19 } 20 // Open Rémora opens "subrascasse://open-remora" after dropping a dive. 21 .onOpenURL { _ in Task { await model.importSharedDives() } } 22 .onChange(of: scenePhase) { 23 if scenePhase == .active { 24 cards.sync() 25 Task { await model.importSharedDives() } 26 } 27 } 28 } 29 } 30 }