Skip to content

Commit

Permalink
Show a descriptive alert message when no pod updates are found.
Browse files Browse the repository at this point in the history
  • Loading branch information
kizitonwose committed Feb 26, 2018
1 parent 4a40cbb commit 95ed8bc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
6 changes: 2 additions & 4 deletions Pods Updater/Source/Repository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ class Repository: DataSource {
if let name = components.second, let currentVersion = components.fourth {

// If this version info has any of the magic operators, add info message and skip this index.
if currentVersion.first!.isDigit.not() {
if currentVersion.isUnsupportedPodVersionInfo {
hasPodWithUnsupportedFormat = true
}
if currentVersion.isUnsupportedPodVersionInfo {
hasPodWithUnsupportedFormat = true
continue
}

Expand Down
2 changes: 1 addition & 1 deletion Pods Updater/UI/Home/HomeContract.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protocol _HomeView: BaseContract.View {
func showProjectName(_ name: String)
func setProgress(enabled: Bool)
func showPodWithInvalidFormatWarning()
func showLocalPodsUpdateInformation()
func showLocalPodsUpdateInformation(resultCount: Int)
func showPodCleanUpResult(_ result: PodFileCleanResult)
func showPodCleanUpError(_ reason: String?)
}
Expand Down
5 changes: 3 additions & 2 deletions Pods Updater/UI/Home/HomePresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@ class HomePresenter: HomeContract.Presenter {
.subscribeOn(ConcurrentDispatchQueueScheduler(qos: .background))
.observeOn(MainScheduler.instance)
.subscribe(onNext: { [weak self] progressResult in
self?.view?.setProgress(enabled: false)

if progressResult.result == nil {
self?.view?.showPodfileReadPercentage(progressResult.progress)
} else {
self?.view?.setProgress(enabled: false)

let result = progressResult.result!
self?.view?.showPodsInformation(with: result.pods)
if result.hasPodWithUnsupportedFormat {
self?.view?.showPodWithInvalidFormatWarning()
} else {
self?.view?.showLocalPodsUpdateInformation()
self?.view?.showLocalPodsUpdateInformation(resultCount: result.pods.count)
}
}
}, onError: { [weak self] error in
Expand Down
31 changes: 16 additions & 15 deletions Pods Updater/UI/Home/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ class HomeViewController: NSViewController {
openPanel.canCreateDirectories = false
return openPanel
}()
private let infoAlert: NSAlert = {
let alert = NSAlert()
alert.messageText = "Important"
alert.informativeText = "This app searches your local pod spec repository to get pod versions. For best results, it's important that this repo is up to date. This can be achieved by running the \"pod repo update\" command."
alert.alertStyle = .informational
alert.addButton(withTitle: "Close")
alert.addButton(withTitle: "Run update command now")
return alert
}()

override func viewDidLoad() {
super.viewDidLoad()
Expand All @@ -55,7 +46,8 @@ extension HomeViewController: HomeContract.View {
func showPodWithInvalidFormatWarning() {
let alert = NSAlert()
alert.messageText = "Important"
alert.informativeText = "One or more Pods in your Podfile is declared with a format that is not supported by this app. The app can analyze your Podfile and show which lines should be fixed."
alert.informativeText = "One or more Pods in your Podfile is declared with a format that is not supported by this app. " +
"The app can analyze your Podfile and show which lines should be fixed."
alert.alertStyle = .critical
alert.addButton(withTitle: "Analyze now")
alert.addButton(withTitle: "Close")
Expand Down Expand Up @@ -92,10 +84,19 @@ extension HomeViewController: HomeContract.View {
tableView.isEnabled = !enabled
}

func showLocalPodsUpdateInformation() {
infoAlert.beginSheetModal(for: view.window!) { [unowned self] response in
func showLocalPodsUpdateInformation(resultCount: Int) {
let alert = NSAlert()
alert.messageText = "Search completed"
let emptyResultText = "\(resultCount == 0 ? "No results found.\n\n" : "")"
alert.informativeText = "\(emptyResultText)Note: This app searches your local pod spec repository to get pod versions. " +
"For best results, it's important that this repo is up to date. This can be achieved by running the \"pod repo update\" command."
alert.alertStyle = .informational
alert.addButton(withTitle: "Close")
alert.addButton(withTitle: "Run update command now")

alert.beginSheetModal(for: view.window!) { [unowned self] response in
if response == .alertSecondButtonReturn {
self.runComman(.updateRepo)
self.runCommand(.updateRepo)
}
}
}
Expand All @@ -119,7 +120,7 @@ extension HomeViewController: HomeContract.View {
alert.beginSheetModal(for: view.window!)
}

fileprivate func runComman(_ command: Command) {
fileprivate func runCommand(_ command: Command) {
let vc = self.storyboard?.instantiateController(withIdentifier: .commandViewController)
as! CommandViewController
vc.command = command
Expand Down Expand Up @@ -158,7 +159,7 @@ extension HomeViewController {
installPodButton.title = "Install Pod(s)"
installPodButton.rx.tap.asDriver()
.drive(onNext: { [unowned self] _ in
self.runComman(.install(podFileUrl: self.openPanel.url!.deletingLastPathComponent()))
self.runCommand(.install(podFileUrl: self.openPanel.url!.deletingLastPathComponent()))
}).disposed(by: disposeBag)


Expand Down

0 comments on commit 95ed8bc

Please sign in to comment.