Skip to content

Commit

Permalink
Show a notification when pod version search completes and the app is …
Browse files Browse the repository at this point in the history
…not in front.
  • Loading branch information
kizitonwose committed Mar 17, 2019
1 parent bbc5a63 commit 148d589
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Pods Updater/AppDelegate.swift
Expand Up @@ -23,8 +23,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

// Only used by the PodfileFixViewController to show save success message since the PodfileFixViewController is dismissed
// immediately and NotificationCenter needs a delegate to present a Notification when the app is in front.
// Only used by the PodfileFixViewController to show save success message since
// the PodfileFixViewController is dismissed immediately and NotificationCenter needs
// a delegate to present a Notification when the app is in front.
extension AppDelegate: NSUserNotificationCenterDelegate {
func userNotificationCenter(_ center: NSUserNotificationCenter,
shouldPresent notification: NSUserNotification) -> Bool {
Expand Down
1 change: 1 addition & 0 deletions Pods Updater/UI/Home/HomeContract.swift
Expand Up @@ -19,6 +19,7 @@ protocol _HomeView: BaseContract.View {
func showPodfileReadPercentage(_ progress: Double)
func showProjectName(_ name: String)
func setProgress(enabled: Bool)
func showPodVersionsSearchCompletion()
func showPodWithInvalidFormatWarning()
func showLocalPodsUpdateInformation(resultCount: Int)
func showNoUpdatesMessage()
Expand Down
1 change: 1 addition & 0 deletions Pods Updater/UI/Home/HomePresenter.swift
Expand Up @@ -62,6 +62,7 @@ class HomePresenter: HomeContract.Presenter {
}
}
}
view.showPodVersionsSearchCompletion()
}
}, onError: { [weak self] error in
self?.view?.setProgress(enabled: false)
Expand Down
11 changes: 11 additions & 0 deletions Pods Updater/UI/Home/HomeViewController.swift
Expand Up @@ -44,6 +44,17 @@ class HomeViewController: NSViewController {

// MARK:- HomeContract.View
extension HomeViewController: HomeContract.View {
func showPodVersionsSearchCompletion() {
let notification = NSUserNotification()
notification.title = "Search completed"
notification.informativeText = projectNameTextField.stringValue
notification.deliveryDate = Date()

// Note: Notification is not delivered when the app
// is in front. This is the intended behaviour.
NSUserNotificationCenter.default.deliver(notification)
}

func showPodWithInvalidFormatWarning() {
let alert = NSAlert()
alert.messageText = "Important"
Expand Down

0 comments on commit 148d589

Please sign in to comment.