| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- //
- // AppDelegate.swift
- // meetings_app
- //
- // Created by Dev Mac 1 on 06/04/2026.
- //
- import Cocoa
- @main
- class AppDelegate: NSObject, NSApplicationDelegate {
- private let darkModeDefaultsKey = "settings.darkModeEnabled"
- func applicationDidFinishLaunching(_ aNotification: Notification) {
- // Always sync to current macOS appearance on launch.
- // (User can still toggle in-app later.)
- let darkEnabled = systemPrefersDarkMode()
- UserDefaults.standard.set(darkEnabled, forKey: darkModeDefaultsKey)
- NSApp.appearance = NSAppearance(named: darkEnabled ? .darkAqua : .aqua)
- }
- func applicationWillTerminate(_ aNotification: Notification) {
- // Insert code here to tear down your application
- }
- func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
- return true
- }
- private func systemPrefersDarkMode() -> Bool {
- // Use the system-wide appearance setting (not app/window effective appearance).
- // When the key is missing, macOS is in Light mode.
- let global = UserDefaults.standard.persistentDomain(forName: UserDefaults.globalDomain)
- let style = global?["AppleInterfaceStyle"] as? String
- return style?.lowercased() == "dark"
- }
- }
|