mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
Shows “Downloading [app]…” toast view when installing app from new source
Allows users to tap it to immediately see installation progress.
This commit is contained in:
@@ -57,6 +57,8 @@ final class SourcesViewController: UICollectionViewController
|
||||
|
||||
private lazy var dataSource = self.makeDataSource()
|
||||
|
||||
private weak var _installingApp: StoreApp?
|
||||
|
||||
private var placeholderView: RSTPlaceholderView!
|
||||
private var placeholderViewButton: UIButton!
|
||||
private var placeholderViewCenterYConstraint: NSLayoutConstraint!
|
||||
@@ -115,6 +117,8 @@ final class SourcesViewController: UICollectionViewController
|
||||
|
||||
self.navigationItem.rightBarButtonItem = self.editButtonItem
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(SourcesViewController.showInstallingAppToastView(_:)), name: AppManager.willInstallAppFromNewSourceNotification, object: nil)
|
||||
|
||||
self.update()
|
||||
}
|
||||
|
||||
@@ -512,6 +516,26 @@ private extension SourcesViewController
|
||||
self.editButtonItem.isEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
@objc func showInstallingAppToastView(_ notification: Notification)
|
||||
{
|
||||
guard let app = notification.object as? StoreApp else { return }
|
||||
self._installingApp = app
|
||||
|
||||
let text = String(format: NSLocalizedString("Downloading %@…", comment: ""), app.name)
|
||||
let toastView = ToastView(text: text, detailText: NSLocalizedString("Tap to view progress.", comment: ""))
|
||||
toastView.addTarget(self, action: #selector(SourcesViewController.showAppDetail), for: .touchUpInside)
|
||||
toastView.show(in: self)
|
||||
}
|
||||
|
||||
@objc func showAppDetail()
|
||||
{
|
||||
guard let app = self._installingApp else { return }
|
||||
self._installingApp = nil
|
||||
|
||||
let appViewController = AppViewController.makeAppViewController(app: app)
|
||||
self.navigationController?.pushViewController(appViewController, animated: true)
|
||||
}
|
||||
}
|
||||
|
||||
extension SourcesViewController
|
||||
|
||||
Reference in New Issue
Block a user