Skip to content

Commit

Permalink
fix: further improvements to 10.14 dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
acheronfail committed Jun 6, 2018
1 parent 7c41b97 commit 9af7f76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Apptivator/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ let ICON_OFF = setupMenuBarIcon(NSImage(named: NSImage.Name(stringLiteral: "icon
enable(APState.shared.isEnabled)
popoverViewController.reloadView()

#if !DEBUG
// Check for accessibility permissions.
if !UIElement.isProcessTrusted(withPrompt: true) {
Log.info?.message("Application does not have Accessibility Permissions, requesting...")
Expand All @@ -65,6 +66,7 @@ let ICON_OFF = setupMenuBarIcon(NSImage(named: NSImage.Name(stringLiteral: "icon
alert.alertStyle = .warning
alert.runModal()
}
#endif

Log.info?.message("Sucessfully launched.")
}
Expand Down
15 changes: 14 additions & 1 deletion Apptivator/UI/APPopoverViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,19 @@ class APPopoverViewController: NSViewController {
showSequenceEditor(for: APState.shared.getEntry(at: index))
}
}

override func viewDidLoad() {
super.viewDidLoad()

// Default to Aqua appearance (Apptivator in Aqua looks better than Vibrant Light).
if !mojaveDarkModeSupported() {
self.view.appearance = NSAppearance(named: .aqua)
view.appearance = NSAppearance(named: .aqua)
} else {
// Otherwise, disable the button in macOS 10.14 and above.
enableDarkMode.state = .off
enableDarkMode.isEnabled = false
enableDarkMode.alphaValue = 0
boxWrapper.fillColor = NSColor.windowBackgroundColor
}

bannerImage.image?.isTemplate = true
Expand Down Expand Up @@ -111,6 +114,16 @@ class APPopoverViewController: NSViewController {
}
}

override func viewWillAppear() {
if #available(OSX 10.14, *) {
if let value = UserDefaults.standard.string(forKey: APPLE_INTERFACE_STYLE), value.lowercased() == "dark" {
view.appearance = NSAppearance(named: .darkAqua)
} else {
view.appearance = NSAppearance(named: .aqua)
}
}
}

override func viewWillDisappear() {
sequenceEditor?.slideOutAndRemove()
APState.shared.saveToDisk()
Expand Down

0 comments on commit 9af7f76

Please sign in to comment.