Displays basic toast view when syncing starts/finishes
This commit is contained in:
parent
88601fb952
commit
c3301f9384
@ -13,6 +13,7 @@ import MobileCoreServices
|
||||
import DeltaCore
|
||||
|
||||
import Roxas
|
||||
import Harmony
|
||||
|
||||
class GamesViewController: UIViewController
|
||||
{
|
||||
@ -61,6 +62,9 @@ class GamesViewController: UIViewController
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
self.fetchedResultsController.delegate = self
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(GamesViewController.syncingDidStart(_:)), name: SyncCoordinator.didStartSyncingNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(GamesViewController.syncingDidFinish(_:)), name: SyncCoordinator.didFinishSyncingNotification, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,6 +391,32 @@ private extension GamesViewController
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc func syncingDidStart(_ notification: Notification)
|
||||
{
|
||||
DispatchQueue.main.async {
|
||||
let toastView = RSTToastView(text: NSLocalizedString("Syncing...", comment: ""), detailText: nil)
|
||||
toastView.activityIndicatorView.startAnimating()
|
||||
toastView.show(in: self.view)
|
||||
}
|
||||
}
|
||||
|
||||
@objc func syncingDidFinish(_ notification: Notification)
|
||||
{
|
||||
DispatchQueue.main.async {
|
||||
guard let result = notification.userInfo?[SyncCoordinator.syncResultKey] as? Result<[Result<Void>]> else { return }
|
||||
|
||||
let toastView: RSTToastView
|
||||
|
||||
switch result
|
||||
{
|
||||
case .success: toastView = RSTToastView(text: NSLocalizedString("Sync Complete", comment: ""), detailText: nil)
|
||||
case .failure(let error): toastView = RSTToastView(error: error)
|
||||
}
|
||||
|
||||
toastView.show(in: self.view, duration: 2.0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//MARK: - UIPageViewController -
|
||||
|
||||
2
External/Harmony
vendored
2
External/Harmony
vendored
@ -1 +1 @@
|
||||
Subproject commit 2c8aed14f6287e45eb3c32017de590ec4323e64f
|
||||
Subproject commit 0b5901b1617724af4e9d16092b2a5e1b1fcd9b29
|
||||
2
External/Roxas
vendored
2
External/Roxas
vendored
@ -1 +1 @@
|
||||
Subproject commit 8b544e7328de5f8481b5571ebf8e0a5312d1b74a
|
||||
Subproject commit c1572706ff7b463ed8ae4686c7bed4bb489fcffa
|
||||
Loading…
Reference in New Issue
Block a user