mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-20 04:03:26 +01:00
Fixes button titles flashing when scrolling into view
This commit is contained in:
@@ -566,7 +566,10 @@ extension FeaturedViewController
|
|||||||
content.imageProperties.maximumSize = CGSize(width: 26, height: 26)
|
content.imageProperties.maximumSize = CGSize(width: 26, height: 26)
|
||||||
content.imageProperties.cornerRadius = 13
|
content.imageProperties.cornerRadius = 13
|
||||||
|
|
||||||
headerView.titleButton.setTitle(content.text, for: .normal)
|
UIView.performWithoutAnimation {
|
||||||
|
headerView.titleButton.setTitle(content.text, for: .normal)
|
||||||
|
headerView.titleButton.layoutIfNeeded()
|
||||||
|
}
|
||||||
|
|
||||||
headerView.iconButton.backgroundColor = storeApp.source?.effectiveTintColor?.adjustedForDisplay
|
headerView.iconButton.backgroundColor = storeApp.source?.effectiveTintColor?.adjustedForDisplay
|
||||||
headerView.iconButton.setImage(nil, for: .normal)
|
headerView.iconButton.setImage(nil, for: .normal)
|
||||||
|
|||||||
@@ -254,83 +254,85 @@ extension AppBannerView
|
|||||||
buttonAction = .open
|
buttonAction = .open
|
||||||
}
|
}
|
||||||
|
|
||||||
switch buttonAction
|
UIView.performWithoutAnimation {
|
||||||
{
|
switch buttonAction
|
||||||
case .open:
|
|
||||||
let buttonTitle = NSLocalizedString("Open", comment: "")
|
|
||||||
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
|
||||||
self.button.accessibilityLabel = String(format: NSLocalizedString("Open %@", comment: ""), values.name)
|
|
||||||
self.button.accessibilityValue = buttonTitle
|
|
||||||
|
|
||||||
self.button.countdownDate = nil
|
|
||||||
|
|
||||||
case .update:
|
|
||||||
let buttonTitle = NSLocalizedString("Update", comment: "")
|
|
||||||
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
|
||||||
self.button.accessibilityLabel = String(format: NSLocalizedString("Update %@", comment: ""), values.name)
|
|
||||||
self.button.accessibilityValue = buttonTitle
|
|
||||||
|
|
||||||
self.button.countdownDate = nil
|
|
||||||
|
|
||||||
case .custom(let buttonTitle):
|
|
||||||
self.button.setTitle(buttonTitle, for: .normal)
|
|
||||||
self.button.accessibilityLabel = buttonTitle
|
|
||||||
self.button.accessibilityValue = buttonTitle
|
|
||||||
|
|
||||||
self.button.countdownDate = nil
|
|
||||||
|
|
||||||
case .install:
|
|
||||||
if let storeApp = app.storeApp, storeApp.isPledgeRequired
|
|
||||||
{
|
{
|
||||||
// Pledge required
|
case .open:
|
||||||
|
let buttonTitle = NSLocalizedString("Open", comment: "")
|
||||||
|
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
||||||
|
self.button.accessibilityLabel = String(format: NSLocalizedString("Open %@", comment: ""), values.name)
|
||||||
|
self.button.accessibilityValue = buttonTitle
|
||||||
|
|
||||||
if storeApp.isPledged
|
self.button.countdownDate = nil
|
||||||
|
|
||||||
|
case .update:
|
||||||
|
let buttonTitle = NSLocalizedString("Update", comment: "")
|
||||||
|
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
||||||
|
self.button.accessibilityLabel = String(format: NSLocalizedString("Update %@", comment: ""), values.name)
|
||||||
|
self.button.accessibilityValue = buttonTitle
|
||||||
|
|
||||||
|
self.button.countdownDate = nil
|
||||||
|
|
||||||
|
case .custom(let buttonTitle):
|
||||||
|
self.button.setTitle(buttonTitle, for: .normal)
|
||||||
|
self.button.accessibilityLabel = buttonTitle
|
||||||
|
self.button.accessibilityValue = buttonTitle
|
||||||
|
|
||||||
|
self.button.countdownDate = nil
|
||||||
|
|
||||||
|
case .install:
|
||||||
|
if let storeApp = app.storeApp, storeApp.isPledgeRequired
|
||||||
{
|
{
|
||||||
let buttonTitle = NSLocalizedString("Install", comment: "")
|
// Pledge required
|
||||||
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
|
||||||
self.button.accessibilityLabel = String(format: NSLocalizedString("Install %@", comment: ""), app.name)
|
|
||||||
self.button.accessibilityValue = buttonTitle
|
|
||||||
}
|
|
||||||
else if let amount = storeApp.pledgeAmount, let currencyCode = storeApp.pledgeCurrency, #available(iOS 15, *)
|
|
||||||
{
|
|
||||||
let price = amount.formatted(.currency(code: currencyCode).presentation(.narrow).precision(.fractionLength(0...2)))
|
|
||||||
|
|
||||||
let buttonTitle = String(format: NSLocalizedString("%@/mo", comment: ""), price)
|
if storeApp.isPledged
|
||||||
self.button.setTitle(buttonTitle, for: .normal)
|
{
|
||||||
self.button.accessibilityLabel = String(format: NSLocalizedString("Pledge %@ a month", comment: ""), price)
|
let buttonTitle = NSLocalizedString("Install", comment: "")
|
||||||
self.button.accessibilityValue = String(format: NSLocalizedString("%@ a month", comment: ""), price)
|
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
||||||
|
self.button.accessibilityLabel = String(format: NSLocalizedString("Install %@", comment: ""), app.name)
|
||||||
|
self.button.accessibilityValue = buttonTitle
|
||||||
|
}
|
||||||
|
else if let amount = storeApp.pledgeAmount, let currencyCode = storeApp.pledgeCurrency, #available(iOS 15, *)
|
||||||
|
{
|
||||||
|
let price = amount.formatted(.currency(code: currencyCode).presentation(.narrow).precision(.fractionLength(0...2)))
|
||||||
|
|
||||||
|
let buttonTitle = String(format: NSLocalizedString("%@/mo", comment: ""), price)
|
||||||
|
self.button.setTitle(buttonTitle, for: .normal)
|
||||||
|
self.button.accessibilityLabel = String(format: NSLocalizedString("Pledge %@ a month", comment: ""), price)
|
||||||
|
self.button.accessibilityValue = String(format: NSLocalizedString("%@ a month", comment: ""), price)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
let buttonTitle = NSLocalizedString("Pledge", comment: "")
|
||||||
|
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
||||||
|
self.button.accessibilityLabel = buttonTitle
|
||||||
|
self.button.accessibilityValue = buttonTitle
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
let buttonTitle = NSLocalizedString("Pledge", comment: "")
|
// Free app
|
||||||
|
|
||||||
|
let buttonTitle = NSLocalizedString("Free", comment: "")
|
||||||
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
||||||
self.button.accessibilityLabel = buttonTitle
|
self.button.accessibilityLabel = String(format: NSLocalizedString("Download %@", comment: ""), app.name)
|
||||||
self.button.accessibilityValue = buttonTitle
|
self.button.accessibilityValue = buttonTitle
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Free app
|
|
||||||
|
|
||||||
let buttonTitle = NSLocalizedString("Free", comment: "")
|
if let versionDate = app.storeApp?.latestSupportedVersion?.date, versionDate > Date()
|
||||||
self.button.setTitle(buttonTitle.uppercased(), for: .normal)
|
{
|
||||||
self.button.accessibilityLabel = String(format: NSLocalizedString("Download %@", comment: ""), app.name)
|
self.button.countdownDate = versionDate
|
||||||
self.button.accessibilityValue = buttonTitle
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self.button.countdownDate = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let versionDate = app.storeApp?.latestSupportedVersion?.date, versionDate > Date()
|
// Ensure PillButton is correct size before assigning progress.
|
||||||
{
|
self.layoutIfNeeded()
|
||||||
self.button.countdownDate = versionDate
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
self.button.countdownDate = nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure PillButton is correct size before assigning progress.
|
|
||||||
self.layoutIfNeeded()
|
|
||||||
|
|
||||||
if let progress = AppManager.shared.installationProgress(for: app), progress.fractionCompleted < 1.0
|
if let progress = AppManager.shared.installationProgress(for: app), progress.fractionCompleted < 1.0
|
||||||
{
|
{
|
||||||
self.button.progress = progress
|
self.button.progress = progress
|
||||||
|
|||||||
@@ -226,31 +226,33 @@ private extension SourcesViewController
|
|||||||
|
|
||||||
let numberOfApps = source.apps.filter { StoreApp.visibleAppsPredicate.evaluate(with: $0) }.count
|
let numberOfApps = source.apps.filter { StoreApp.visibleAppsPredicate.evaluate(with: $0) }.count
|
||||||
|
|
||||||
if let error = source.error
|
UIView.performWithoutAnimation {
|
||||||
{
|
if let error = source.error
|
||||||
let image = UIImage(systemName: "exclamationmark")?.withTintColor(.white, renderingMode: .alwaysOriginal)
|
{
|
||||||
|
let image = UIImage(systemName: "exclamationmark")?.withTintColor(.white, renderingMode: .alwaysOriginal)
|
||||||
cell.bannerView.button.setImage(image, for: .normal)
|
|
||||||
cell.bannerView.button.setTitle(nil, for: .normal)
|
cell.bannerView.button.setImage(image, for: .normal)
|
||||||
cell.bannerView.button.tintColor = .systemYellow.withAlphaComponent(0.75)
|
cell.bannerView.button.setTitle(nil, for: .normal)
|
||||||
|
cell.bannerView.button.tintColor = .systemYellow.withAlphaComponent(0.75)
|
||||||
let action = UIAction(identifier: .showError) { _ in
|
|
||||||
self.present(error)
|
let action = UIAction(identifier: .showError) { _ in
|
||||||
|
self.present(error)
|
||||||
|
}
|
||||||
|
cell.bannerView.button.addAction(action, for: .primaryActionTriggered)
|
||||||
|
cell.bannerView.button.removeAction(identifiedBy: .showDetails, for: .primaryActionTriggered)
|
||||||
}
|
}
|
||||||
cell.bannerView.button.addAction(action, for: .primaryActionTriggered)
|
else
|
||||||
cell.bannerView.button.removeAction(identifiedBy: .showDetails, for: .primaryActionTriggered)
|
{
|
||||||
}
|
cell.bannerView.button.setImage(nil, for: .normal)
|
||||||
else
|
cell.bannerView.button.setTitle(numberOfApps.description, for: .normal)
|
||||||
{
|
cell.bannerView.button.tintColor = .white.withAlphaComponent(0.2)
|
||||||
cell.bannerView.button.setImage(nil, for: .normal)
|
|
||||||
cell.bannerView.button.setTitle(numberOfApps.description, for: .normal)
|
let action = UIAction(identifier: .showDetails) { _ in
|
||||||
cell.bannerView.button.tintColor = .white.withAlphaComponent(0.2)
|
self.showSourceDetails(for: source)
|
||||||
|
}
|
||||||
let action = UIAction(identifier: .showDetails) { _ in
|
cell.bannerView.button.addAction(action, for: .primaryActionTriggered)
|
||||||
self.showSourceDetails(for: source)
|
cell.bannerView.button.removeAction(identifiedBy: .showError, for: .primaryActionTriggered)
|
||||||
}
|
}
|
||||||
cell.bannerView.button.addAction(action, for: .primaryActionTriggered)
|
|
||||||
cell.bannerView.button.removeAction(identifiedBy: .showError, for: .primaryActionTriggered)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let dateText: String
|
let dateText: String
|
||||||
|
|||||||
Reference in New Issue
Block a user