From 148d58997c002fb09f2637661f340f0b7c87a0fe Mon Sep 17 00:00:00 2001 From: Kizito Nwose Date: Sun, 17 Mar 2019 11:22:32 +0100 Subject: [PATCH] Show a notification when pod version search completes and the app is not in front. --- Pods Updater/AppDelegate.swift | 5 +++-- Pods Updater/UI/Home/HomeContract.swift | 1 + Pods Updater/UI/Home/HomePresenter.swift | 1 + Pods Updater/UI/Home/HomeViewController.swift | 11 +++++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Pods Updater/AppDelegate.swift b/Pods Updater/AppDelegate.swift index a27ffe9..bc1c895 100644 --- a/Pods Updater/AppDelegate.swift +++ b/Pods Updater/AppDelegate.swift @@ -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 { diff --git a/Pods Updater/UI/Home/HomeContract.swift b/Pods Updater/UI/Home/HomeContract.swift index d750e17..b13b971 100644 --- a/Pods Updater/UI/Home/HomeContract.swift +++ b/Pods Updater/UI/Home/HomeContract.swift @@ -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() diff --git a/Pods Updater/UI/Home/HomePresenter.swift b/Pods Updater/UI/Home/HomePresenter.swift index 0a9bb0b..810227f 100644 --- a/Pods Updater/UI/Home/HomePresenter.swift +++ b/Pods Updater/UI/Home/HomePresenter.swift @@ -62,6 +62,7 @@ class HomePresenter: HomeContract.Presenter { } } } + view.showPodVersionsSearchCompletion() } }, onError: { [weak self] error in self?.view?.setProgress(enabled: false) diff --git a/Pods Updater/UI/Home/HomeViewController.swift b/Pods Updater/UI/Home/HomeViewController.swift index 8692fcb..ca2b7da 100644 --- a/Pods Updater/UI/Home/HomeViewController.swift +++ b/Pods Updater/UI/Home/HomeViewController.swift @@ -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"