28 lines
912 B
Swift
28 lines
912 B
Swift
|
|
import SwiftUI
|
||
|
|
import AppKit
|
||
|
|
|
||
|
|
@main
|
||
|
|
struct NetworkCityApp: App {
|
||
|
|
@NSApplicationDelegateAdaptor(AppDelegate.self) private var delegate
|
||
|
|
@StateObject private var controller = TrafficController()
|
||
|
|
|
||
|
|
var body: some Scene {
|
||
|
|
WindowGroup("NetworkCity") {
|
||
|
|
CityView(controller: controller)
|
||
|
|
.frame(minWidth: 900, minHeight: 620)
|
||
|
|
.background(.black)
|
||
|
|
}
|
||
|
|
.windowStyle(.hiddenTitleBar)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
/// Running as an SPM executable (no app bundle), so promote ourselves to a
|
||
|
|
/// regular foreground app and grab focus on launch.
|
||
|
|
final class AppDelegate: NSObject, NSApplicationDelegate {
|
||
|
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
||
|
|
NSApp.setActivationPolicy(.regular)
|
||
|
|
NSApp.activate(ignoringOtherApps: true)
|
||
|
|
}
|
||
|
|
func applicationShouldTerminateAfterLastWindowClosed(_ app: NSApplication) -> Bool { true }
|
||
|
|
}
|