diff --git a/AltStore/Components/AppBannerView.xib b/AltStore/Components/AppBannerView.xib index 95337f61..c27095f2 100644 --- a/AltStore/Components/AppBannerView.xib +++ b/AltStore/Components/AppBannerView.xib @@ -110,12 +110,12 @@ - + + - diff --git a/AltStore/Components/PillButton.swift b/AltStore/Components/PillButton.swift index f32bc1a2..0fc467df 100644 --- a/AltStore/Components/PillButton.swift +++ b/AltStore/Components/PillButton.swift @@ -14,7 +14,16 @@ extension PillButton static let contentInsets = NSDirectionalEdgeInsets(top: 7, leading: 13, bottom: 7, trailing: 13) } -final class PillButton: UIButton +extension PillButton +{ + enum Style + { + case pill + case custom + } +} + +class PillButton: UIButton { override var accessibilityValue: String? { get { @@ -55,6 +64,18 @@ final class PillButton: UIButton } } + var style: Style = .pill { + didSet { + if self.style == .custom + { + // Reset insets for custom style. + self.contentEdgeInsets = UIEdgeInsets(top: 8, left: 8, bottom: 8, right: 8) + } + + self.update() + } + } + private let progressView = UIProgressView(progressViewStyle: .default) private lazy var displayLink: CADisplayLink = { @@ -106,8 +127,6 @@ final class PillButton: UIButton self.layer.masksToBounds = true self.accessibilityTraits.formUnion([.updatesFrequently, .button]) - self.contentEdgeInsets = UIEdgeInsets(top: Self.contentInsets.top, left: Self.contentInsets.leading, bottom: Self.contentInsets.bottom, right: Self.contentInsets.trailing) - self.activityIndicatorView.style = .medium self.activityIndicatorView.color = .white self.activityIndicatorView.isUserInteractionEnabled = false @@ -144,8 +163,16 @@ final class PillButton: UIButton override func sizeThatFits(_ size: CGSize) -> CGSize { var size = super.sizeThatFits(size) - size.width = max(size.width, PillButton.minimumSize.width) - size.height = max(size.height, PillButton.minimumSize.height) + + switch self.style + { + case .pill: + // Enforce minimum size for pill style. + size.width = max(size.width, PillButton.minimumSize.width) + size.height = max(size.height, PillButton.minimumSize.height) + + case .custom: break + } return size } @@ -170,6 +197,13 @@ private extension PillButton // Update font after init because the original titleLabel is replaced. self.titleLabel?.font = UIFont.boldSystemFont(ofSize: 14) + + switch self.style + { + case .custom: break // Don't update insets in case client has updated them. + case .pill: + self.contentEdgeInsets = UIEdgeInsets(top: Self.contentInsets.top, left: Self.contentInsets.leading, bottom: Self.contentInsets.bottom, right: Self.contentInsets.trailing) + } } @objc func updateCountdown()