NotifierUI // Redefine how a notifier gets triggered.
- The previous approach is not compatible with Grand Central Dispatch.
This commit is contained in:
parent
03d4099894
commit
cf025b2b52
|
@ -24,6 +24,15 @@ private let kWindowWidth: CGFloat = 213.0
|
||||||
private let kWindowHeight: CGFloat = 60.0
|
private let kWindowHeight: CGFloat = 60.0
|
||||||
|
|
||||||
public class NotifierController: NSWindowController, NotifierWindowDelegate {
|
public class NotifierController: NSWindowController, NotifierWindowDelegate {
|
||||||
|
static var message: String = "" {
|
||||||
|
didSet {
|
||||||
|
if !Self.message.isEmpty {
|
||||||
|
NotifierController.initiateWithNoStay(message: message)
|
||||||
|
Self.message = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private var messageTextField: NSTextField
|
private var messageTextField: NSTextField
|
||||||
|
|
||||||
private var message: String = "" {
|
private var message: String = "" {
|
||||||
|
@ -69,7 +78,17 @@ public class NotifierController: NSWindowController, NotifierWindowDelegate {
|
||||||
private static var instanceCount = 0
|
private static var instanceCount = 0
|
||||||
private static var lastLocation = NSPoint.zero
|
private static var lastLocation = NSPoint.zero
|
||||||
|
|
||||||
public static func notify(message: String, stay: Bool = false) {
|
private static func initiateWithNoStay(message: String) {
|
||||||
|
let controller = NotifierController()
|
||||||
|
controller.message = message
|
||||||
|
controller.show()
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func notify(message: String) {
|
||||||
|
Self.message = message
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func notify(message: String, stay: Bool) {
|
||||||
let controller = NotifierController()
|
let controller = NotifierController()
|
||||||
controller.message = message
|
controller.message = message
|
||||||
controller.shouldStay = stay
|
controller.shouldStay = stay
|
||||||
|
|
Loading…
Reference in New Issue