Add night mode option
This commit is contained in:
parent
681b0358ad
commit
f9ff961e9e
@ -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()
|
||||
}
|
||||
|
@ -226,6 +226,18 @@
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="View" id="H8h-7b-M4v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="View" id="HyV-fh-RgO">
|
||||
<items>
|
||||
<menuItem title="Night Mode" keyEquivalent="u" id="jYO-0u-qN9">
|
||||
<connections>
|
||||
<action selector="toggleNightMode:" target="Voe-Tx-rLC" id="Nmq-eG-y3w"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Window" id="aUF-d1-5bR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Window" systemMenu="window" id="Td7-aD-5lo">
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user