1
0
mirror of https://github.com/nicoverbruggen/phpmon.git synced 2025-11-09 13:10:24 +01:00

🚧 WIP: Notify the user about PHP switch completion (#15)

This commit is contained in:
2020-07-16 22:25:31 +02:00
parent 33825e7b66
commit 5d69b423c1
4 changed files with 37 additions and 1 deletions

View File

@@ -7,6 +7,7 @@
//
import Cocoa
import UserNotifications
@NSApplicationMain
class AppDelegate: NSObject, NSApplicationDelegate {
@@ -27,8 +28,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
// MARK: - Lifecycle
func applicationDidFinishLaunching(_ aNotification: Notification) {
NSUserNotificationCenter.default.delegate = self
self.menu.startup()
}
@@ -37,3 +39,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}
extension AppDelegate: NSUserNotificationCenterDelegate {
func userNotificationCenter(_ center: NSUserNotificationCenter,
shouldPresent notification: NSUserNotification) -> Bool {
return true
}
}

View File

@@ -0,0 +1,19 @@
//
// LocalNotification.swift
// PHP Monitor
//
// Created by Nico Verbruggen on 16/07/2020.
// Copyright © 2020 Nico Verbruggen. All rights reserved.
//
import Foundation
class LocalNotification {
public static func send(title: String, subtitle: String)
{
let notification = NSUserNotification()
notification.title = title
notification.subtitle = subtitle
NSUserNotificationCenter.default.deliver(notification)
}
}

View File

@@ -211,6 +211,10 @@ class MainMenu: NSObject, NSWindowDelegate {
DispatchQueue.main.async {
self.updatePhpVersionInStatusBar()
self.update()
LocalNotification.send(
title: "PHP \(version) is now active",
subtitle: "PHP Monitor has finished switching to PHP \(version)."
)
}
}
}