Updates PillButton appearance

This commit is contained in:
Riley Testut
2019-10-23 14:20:01 -07:00
parent 6ea8503c3d
commit 6f58cb9579
6 changed files with 6 additions and 18 deletions

View File

@@ -347,12 +347,10 @@ private extension AppViewController
if self.app.installedApp == nil if self.app.installedApp == nil
{ {
button.setTitle(NSLocalizedString("FREE", comment: ""), for: .normal) button.setTitle(NSLocalizedString("FREE", comment: ""), for: .normal)
button.isInverted = false
} }
else else
{ {
button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal) button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal)
button.isInverted = true
} }
let progress = AppManager.shared.installationProgress(for: self.app) let progress = AppManager.shared.installationProgress(for: self.app)

View File

@@ -100,7 +100,6 @@ private extension BrowseViewController
let progress = AppManager.shared.installationProgress(for: app) let progress = AppManager.shared.installationProgress(for: app)
cell.bannerView.button.progress = progress cell.bannerView.button.progress = progress
cell.bannerView.button.isInverted = false
if Date() < app.versionDate if Date() < app.versionDate
{ {
@@ -115,7 +114,6 @@ private extension BrowseViewController
{ {
cell.bannerView.button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal) cell.bannerView.button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal)
cell.bannerView.button.progress = nil cell.bannerView.button.progress = nil
cell.bannerView.button.isInverted = true
cell.bannerView.button.countdownDate = nil cell.bannerView.button.countdownDate = nil
} }
} }

View File

@@ -11,13 +11,15 @@ import UIKit
class PillButton: UIButton class PillButton: UIButton
{ {
var progress: Progress? { var progress: Progress? {
didSet { didSet {
self.progressView.progress = Float(self.progress?.fractionCompleted ?? 0) self.progressView.progress = Float(self.progress?.fractionCompleted ?? 0)
self.progressView.observedProgress = self.progress self.progressView.observedProgress = self.progress
let isUserInteractionEnabled = self.isUserInteractionEnabled let isUserInteractionEnabled = self.isUserInteractionEnabled
self.isIndicatingActivity = (self.progress != nil) self.isIndicatingActivity = (self.progress != nil)
self.isUserInteractionEnabled = isUserInteractionEnabled self.isUserInteractionEnabled = isUserInteractionEnabled
self.update()
} }
} }
@@ -30,12 +32,6 @@ class PillButton: UIButton
} }
} }
var isInverted: Bool = false {
didSet {
self.update()
}
}
var countdownDate: Date? { var countdownDate: Date? {
didSet { didSet {
self.isEnabled = (self.countdownDate == nil) self.isEnabled = (self.countdownDate == nil)
@@ -120,18 +116,18 @@ private extension PillButton
{ {
func update() func update()
{ {
if self.isInverted if self.progress == nil
{ {
self.setTitleColor(.white, for: .normal) self.setTitleColor(.white, for: .normal)
self.backgroundColor = self.tintColor self.backgroundColor = self.tintColor
self.progressView.progressTintColor = self.tintColor.withAlphaComponent(0.15)
} }
else else
{ {
self.setTitleColor(self.tintColor, for: .normal) self.setTitleColor(self.tintColor, for: .normal)
self.backgroundColor = self.tintColor.withAlphaComponent(0.15) self.backgroundColor = self.tintColor.withAlphaComponent(0.15)
self.progressView.progressTintColor = self.tintColor
} }
self.progressView.progressTintColor = self.tintColor
} }
@objc func updateCountdown() @objc func updateCountdown()

View File

@@ -268,7 +268,6 @@ private extension MyAppsViewController
cell.bannerView.iconImageView.isIndicatingActivity = true cell.bannerView.iconImageView.isIndicatingActivity = true
cell.bannerView.betaBadgeView.isHidden = !(installedApp.storeApp?.isBeta ?? false) cell.bannerView.betaBadgeView.isHidden = !(installedApp.storeApp?.isBeta ?? false)
cell.bannerView.button.isInverted = true
cell.bannerView.button.isIndicatingActivity = false cell.bannerView.button.isIndicatingActivity = false
cell.bannerView.button.addTarget(self, action: #selector(MyAppsViewController.refreshApp(_:)), for: .primaryActionTriggered) cell.bannerView.button.addTarget(self, action: #selector(MyAppsViewController.refreshApp(_:)), for: .primaryActionTriggered)

View File

@@ -94,7 +94,6 @@ private extension UpdateCollectionViewCell
self.versionDescriptionTitleLabel.textColor = self.tintColor self.versionDescriptionTitleLabel.textColor = self.tintColor
self.blurView.backgroundColor = self.tintColor self.blurView.backgroundColor = self.tintColor
self.bannerView.button.isInverted = true
self.bannerView.button.tintColor = self.tintColor self.bannerView.button.tintColor = self.tintColor
self.bannerView.button.progressTintColor = self.tintColor self.bannerView.button.progressTintColor = self.tintColor

View File

@@ -344,7 +344,6 @@ extension NewsViewController
let progress = AppManager.shared.installationProgress(for: storeApp) let progress = AppManager.shared.installationProgress(for: storeApp)
footerView.bannerView.button.progress = progress footerView.bannerView.button.progress = progress
footerView.bannerView.button.isInverted = false
if Date() < storeApp.versionDate if Date() < storeApp.versionDate
{ {
@@ -359,7 +358,6 @@ extension NewsViewController
{ {
footerView.bannerView.button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal) footerView.bannerView.button.setTitle(NSLocalizedString("OPEN", comment: ""), for: .normal)
footerView.bannerView.button.progress = nil footerView.bannerView.button.progress = nil
footerView.bannerView.button.isInverted = true
footerView.bannerView.button.countdownDate = nil footerView.bannerView.button.countdownDate = nil
} }