Files
Tonuino-Manager/Sources/TonuinoManager/App/TonuinoManagerApp.swift
T

40 lines
1.5 KiB
Swift

import SwiftUI
import Sparkle
import AppKit
final class AppDelegate: NSObject, NSApplicationDelegate {
static var updater: SPUStandardUpdaterController?
func applicationDidFinishLaunching(_ notification: Notification) {
guard let feed = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String,
URL(string: feed)?.scheme != nil,
let key = Bundle.main.object(forInfoDictionaryKey: "SUPublicEDKey") as? String,
!key.isEmpty else { return }
Self.updater = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
}
}
@main
struct TonuinoManagerApp: App {
@NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
@StateObject private var model = AppModel()
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(model)
.frame(minWidth: 980, minHeight: 640)
}
.commands {
CommandGroup(replacing: .newItem) { }
CommandGroup(replacing: .appSettings) {
Button("Einstellungen…") { model.section = .settings }
.keyboardShortcut(",", modifiers: .command)
}
CommandGroup(after: .appInfo) {
Button("Auf Updates prüfen…") { AppDelegate.updater?.checkForUpdates(nil) }
.disabled(AppDelegate.updater?.updater.canCheckForUpdates != true)
}
}
}
}