mirror of
https://github.com/dscyrescotti/Memola.git
synced 2026-04-23 17:18:42 +02:00
feat: add setting view
This commit is contained in:
@@ -54,6 +54,17 @@ extension Application: NSApplicationDelegate {
|
||||
NSWindow.allowsAutomaticWindowTabbing = false
|
||||
UserDefaults.standard.register(defaults: ["NSQuitAlwaysKeepsWindows": false])
|
||||
}
|
||||
|
||||
func openWindow(for appWindow: AppWindow) {
|
||||
let window = NSApplication.shared.windows.first { window in
|
||||
window.identifier?.rawValue.contains(appWindow.id) == true
|
||||
}
|
||||
if window == nil, let url = appWindow.url {
|
||||
NSWorkspace.shared.open(url)
|
||||
} else {
|
||||
window?.makeKeyAndOrderFront(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
extension Application: UIApplicationDelegate {
|
||||
|
||||
@@ -16,7 +16,7 @@ struct MemolaApp: App {
|
||||
#endif
|
||||
|
||||
var body: some Scene {
|
||||
WindowGroup {
|
||||
WindowGroup(id: AppWindow.dashboard.id) {
|
||||
DashboardView()
|
||||
.persistence(\.viewContext)
|
||||
.onReceive(NotificationCenter.default.publisher(for: Platform.Application.willTerminateNotification)) { _ in
|
||||
@@ -36,13 +36,38 @@ struct MemolaApp: App {
|
||||
.defaultPosition(.center)
|
||||
.windowResizability(.contentSize)
|
||||
.defaultSize(width: 1200, height: 800)
|
||||
.windowToolbarStyle(.unifiedCompact)
|
||||
.windowToolbarStyle(.unified)
|
||||
.handlesExternalEvents(matching: [AppWindow.dashboard.id])
|
||||
#endif
|
||||
.commands {
|
||||
AppCommands()
|
||||
FileCommands()
|
||||
#if os(macOS)
|
||||
AppCommands(application: application)
|
||||
#endif
|
||||
FileCommands(application: application)
|
||||
EditCommands()
|
||||
ViewCommands(application: application)
|
||||
}
|
||||
#if os(macOS)
|
||||
WindowGroup(id: AppWindow.settings.id) {
|
||||
SettingsView()
|
||||
.onReceive(NotificationCenter.default.publisher(for: Platform.Application.willTerminateNotification)) { _ in
|
||||
withPersistenceSync(\.viewContext) { context in
|
||||
try context.saveIfNeeded()
|
||||
}
|
||||
withPersistenceSync(\.backgroundContext) { context in
|
||||
try context.saveIfNeeded()
|
||||
}
|
||||
}
|
||||
#if os(macOS)
|
||||
.frame(minWidth: 700, minHeight: 500)
|
||||
#endif
|
||||
.environmentObject(application)
|
||||
}
|
||||
.defaultPosition(.center)
|
||||
.windowResizability(.contentSize)
|
||||
.defaultSize(width: 800, height: 400)
|
||||
.windowToolbarStyle(.unifiedCompact)
|
||||
.handlesExternalEvents(matching: [AppWindow.settings.id])
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user