//
//  iKeyMonApp.swift
//  iKeyMon
//
//  Created by tracer on 30.03.25.
//

import SwiftUI
#if os(macOS)
import AppKit
#endif

@main
struct iKeyMonApp: App {
    @StateObject private var sparkleUpdater = SparkleUpdater()

    init() {
        #if os(macOS)
        if let customIcon = NSImage(named: "AppIcon") {
            NSApplication.shared.applicationIconImage = customIcon
        }
        #endif
    }

    var body: some Scene {
        WindowGroup {
            MainView()
                .environmentObject(sparkleUpdater)
                .onDisappear {
                    NSApp.terminate(nil)
                }
        }
        .windowResizability(.contentMinSize)

        Settings {
            PreferencesView()
                .padding()
                .environmentObject(sparkleUpdater)
        }
    }
}
