Geen omschrijving

AppDelegate.swift 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // AppDelegate.swift
  3. // meetings_app
  4. //
  5. // Created by Dev Mac 1 on 06/04/2026.
  6. //
  7. import Cocoa
  8. @main
  9. class AppDelegate: NSObject, NSApplicationDelegate {
  10. private let darkModeDefaultsKey = "settings.darkModeEnabled"
  11. func applicationDidFinishLaunching(_ aNotification: Notification) {
  12. // Always sync to current macOS appearance on launch.
  13. // (User can still toggle in-app later.)
  14. let darkEnabled = systemPrefersDarkMode()
  15. UserDefaults.standard.set(darkEnabled, forKey: darkModeDefaultsKey)
  16. NSApp.appearance = NSAppearance(named: darkEnabled ? .darkAqua : .aqua)
  17. }
  18. func applicationWillTerminate(_ aNotification: Notification) {
  19. // Insert code here to tear down your application
  20. }
  21. func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
  22. return true
  23. }
  24. private func systemPrefersDarkMode() -> Bool {
  25. // Use the system-wide appearance setting (not app/window effective appearance).
  26. // When the key is missing, macOS is in Light mode.
  27. let global = UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain)
  28. let style = global?["AppleInterfaceStyle"] as? String
  29. return style?.lowercased() == "dark"
  30. }
  31. }