Skip to content

Commit e56d550

Browse files
committed
Show a notification when the new Podfile is successfully saved.
1 parent 3f092d1 commit e56d550

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

Pods Updater/AppDelegate.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
2020

2121
}
2222

23+
// Only used by the PodfileViewController to show save success message since the PodfileViewController is dismissed
24+
// immediately and NotificationCenter needs a delegate to present a Notification when the app is in front.
25+
extension AppDelegate: NSUserNotificationCenterDelegate {
26+
func userNotificationCenter(_ center: NSUserNotificationCenter,
27+
shouldPresent notification: NSUserNotification) -> Bool {
28+
return true
29+
}
30+
}
31+

Pods Updater/UI/Podfile/PodfileViewController.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ class PodfileViewController: NSViewController {
4949
// MARK:- PodfileContract.View
5050
extension PodfileViewController: PodfileContract.View {
5151
func showPodfileSaveSuccess() {
52+
let notification = NSUserNotification()
53+
notification.title = "Success!"
54+
notification.informativeText = "Your new Podfile has been saved successfully."
55+
notification.deliveryDate = Date()
56+
57+
let center = NSUserNotificationCenter.default
58+
center.delegate = NSApplication.shared.delegate as? AppDelegate
59+
center.deliver(notification)
60+
5261
view.window?.close()
5362
}
5463

0 commit comments

Comments
 (0)