Supports updating apps from (almost) all AppBannerViews

Previously, you could only update apps from MyAppsViewController and AppViewController.
This commit is contained in:
Riley Testut
2023-11-30 18:50:54 -06:00
committed by Magesh K
parent 850b6890e2
commit 5da80863b9
9 changed files with 240 additions and 194 deletions

View File

@@ -87,8 +87,6 @@ final class AppViewController: UIViewController
self.bannerView.iconImageView.tintColor = self.app.tintColor
self.bannerView.button.tintColor = self.app.tintColor
self.bannerView.tintColor = self.app.tintColor
self.bannerView.configure(for: self.app)
self.bannerView.accessibilityTraits.remove(.button)
self.bannerView.button.addTarget(self, action: #selector(AppViewController.performAppAction(_:)), for: .primaryActionTriggered)
@@ -352,37 +350,14 @@ private extension AppViewController
{
button.tintColor = self.app.tintColor
button.isIndicatingActivity = false
if let installedApp = self.app.installedApp
{
if let latestVersion = self.app.latestSupportedVersion, !installedApp.matches(latestVersion)
{
button.setTitle(NSLocalizedString("UPDATE", comment: ""), for: .normal)
}
else
{
button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal)
}
}
else
{
button.setTitle(NSLocalizedString("FREE", comment: ""), for: .normal)
}
let progress = AppManager.shared.installationProgress(for: self.app)
button.progress = progress
}
if let versionDate = self.app.latestSupportedVersion?.date, versionDate > Date()
{
self.bannerView.button.countdownDate = versionDate
self.navigationBarDownloadButton.countdownDate = versionDate
}
else
{
self.bannerView.button.countdownDate = nil
self.navigationBarDownloadButton.countdownDate = nil
}
self.bannerView.configure(for: self.app)
let title = self.bannerView.button.title(for: .normal)
self.navigationBarDownloadButton.setTitle(title, for: .normal)
self.navigationBarDownloadButton.progress = self.bannerView.button.progress
self.navigationBarDownloadButton.countdownDate = self.bannerView.button.countdownDate
let barButtonItem = self.navigationItem.rightBarButtonItem
self.navigationItem.rightBarButtonItem = nil