From b986fae61106b1c614a37934368f9dfb511d20b4 Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Tue, 4 Apr 2023 15:44:29 -0500 Subject: [PATCH] Enforces 77x31 minimum size for PillButton --- AltStore/Components/PillButton.swift | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/AltStore/Components/PillButton.swift b/AltStore/Components/PillButton.swift index 3527fe02..d56ad137 100644 --- a/AltStore/Components/PillButton.swift +++ b/AltStore/Components/PillButton.swift @@ -8,6 +8,12 @@ import UIKit +extension PillButton +{ + static let minimumSize = CGSize(width: 77, height: 31) + static let contentInsets = NSDirectionalEdgeInsets(top: 7, leading: 13, bottom: 7, trailing: 13) +} + final class PillButton: UIButton { override var accessibilityValue: String? { @@ -70,9 +76,7 @@ final class PillButton: UIButton }() override var intrinsicContentSize: CGSize { - var size = super.intrinsicContentSize - size.width += 26 - size.height += 3 + let size = self.sizeThatFits(CGSize(width: Double.infinity, height: .infinity)) return size } @@ -88,6 +92,8 @@ 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.isUserInteractionEnabled = false @@ -119,6 +125,15 @@ final class PillButton: UIButton self.update() } + + 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) + + return size + } } private extension PillButton