#if os(macOS) import SwiftUI /// Sparkle owns installation and its UI; apps retain their normal quit/save handling. public struct NativeUpdateCommands: Commands { @Bindable private var updater: NativeUpdater public init(updater: NativeUpdater) { self.updater = updater } static let resources = Bundle.main.url(forResource: "RastrilloNative_RastrilloMacUpdates", withExtension: "bundle").flatMap(Bundle.init(url:)) ?? Bundle.module static var appName: String { let info = Bundle.main.localizedInfoDictionary ?? Bundle.main.infoDictionary ?? [:] return (info["CFBundleDisplayName"] as? String) ?? (info["CFBundleName"] as? String) ?? ProcessInfo.processInfo.processName } public var body: some Commands { CommandGroup(after: .appInfo) { // A quiet updater's staged update, where a person looks for it. Disabled // while busy: the restart would end whatever the app is busy with. if case .ready = updater.pendingUpdate { Button(action: updater.installPendingUpdate) { Text("Update Ready — Restart \(Self.appName)", bundle: Self.resources) } .disabled(!updater.canInstallPendingUpdate) } Button(action: updater.checkForUpdates) { Text("Check for Updates…", bundle: Self.resources) } .disabled(!updater.canCheckForUpdates) Toggle(isOn: $updater.automaticallyChecksForUpdates) { Text("Automatically Check for Updates", bundle: Self.resources) } .disabled(!updater.isConfigured) } } } #endif