Last active
April 21, 2022 18:12
-
-
Save arekt/f5b9fcfdcf6b0614c71581ef85cead71 to your computer and use it in GitHub Desktop.
main.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
import SwiftUI | |
import Combine | |
class AppState: ObservableObject { | |
@Published var isRescaling = false | |
@Published var scaleCurrent: CGFloat = 1.0 | |
@Published var scaleFinal: CGFloat = 1.0 | |
func rescaling(_ enabled: Bool) { | |
self.isRescaling = enabled | |
} | |
} | |
@main | |
struct MyApp: App { | |
//@NSApplicationDelegateAdaptor(AppDelegate.self) var appDelegate | |
@StateObject var appState = AppState() | |
@SceneBuilder var body: some Scene { | |
WindowGroup("Foo Bar") { | |
ContentView() | |
.environmentObject(appState) | |
.onAppear { | |
NSApp.setActivationPolicy(.regular) | |
NSApp.activate(ignoringOtherApps: true) | |
let _ = NSApplication.shared.windows.map { | |
$0.styleMask = [ .titled, .closable, .miniaturizable, .resizable, .fullSizeContentView] | |
$0.setFrameAutosaveName("Main Window") | |
$0.title = "Awesome Drawing App" | |
$0.center() | |
//$0.makeMain() | |
$0.makeKeyAndOrderFront(nil) | |
} | |
} | |
.frame(maxWidth: .infinity, maxHeight: .infinity) | |
} | |
.windowStyle(DefaultWindowStyle()) | |
.commands { | |
AppCommands() | |
} | |
#if os(macOS) | |
Settings { | |
SettingsView() | |
} | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment