diff --git a/writeas/AppDelegate.swift b/writeas/AppDelegate.swift index 7410c55..8e6fc95 100644 --- a/writeas/AppDelegate.swift +++ b/writeas/AppDelegate.swift @@ -27,6 +27,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { } } + @IBAction func toggleNightMode(_ sender: NSMenuItem) { + let isOff = sender.state == NSOffState + vc?.toggle(isNight: isOff) + sender.state = isOff ? NSOnState : NSOffState + } + @IBAction func saveDocument(_ sender: AnyObject) { vc?.saveDocument() } diff --git a/writeas/Base.lproj/Main.storyboard b/writeas/Base.lproj/Main.storyboard index fa197e0..ff74376 100644 --- a/writeas/Base.lproj/Main.storyboard +++ b/writeas/Base.lproj/Main.storyboard @@ -226,6 +226,18 @@ + + + + + + + + + + + + diff --git a/writeas/ViewController.swift b/writeas/ViewController.swift index 8ce22a3..7cc9f05 100644 --- a/writeas/ViewController.swift +++ b/writeas/ViewController.swift @@ -86,5 +86,18 @@ class ViewController: NSViewController, NSTextViewDelegate { print("ERROR loading: \(err)") } } + + func toggle(isNight: Bool) { + let darkBG = NSColor(red:0.13, green:0.13, blue:0.13, alpha:1.0) + if isNight { + self.view.window!.backgroundColor = darkBG + self.writerText.backgroundColor = darkBG + self.writerText.textColor = NSColor.white + } else { + self.view.window!.backgroundColor = NSColor.white + self.writerText.backgroundColor = NSColor.white + self.writerText.textColor = NSColor.black + } + } }