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

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