|
1 | 1 | import UIKit |
2 | 2 |
|
| 3 | + |
| 4 | +/// WooCommerce UIButton Style Helpers |
| 5 | +/// |
3 | 6 | extension UIButton { |
| 7 | + |
| 8 | + /// Applies the Primary Button Style: Solid BG! |
| 9 | + /// |
4 | 10 | func applyPrimaryButtonStyle() { |
5 | | - layer.borderColor = StyleManager.wooCommerceBrandColor.cgColor |
6 | 11 | backgroundColor = StyleManager.wooCommerceBrandColor |
| 12 | + contentEdgeInsets = Style.defaultEdgeInsets |
7 | 13 | tintColor = .white |
8 | | - layer.cornerRadius = 8.0 |
9 | | - contentEdgeInsets = UIEdgeInsetsMake(16.0, 16.0, 16.0, 16.0) |
| 14 | + layer.borderColor = StyleManager.wooCommerceBrandColor.cgColor |
| 15 | + layer.borderWidth = Style.defaultBorderWidth |
| 16 | + layer.cornerRadius = Style.defaultCornerRadius |
10 | 17 | titleLabel?.applyHeadlineStyle() |
11 | 18 | } |
| 19 | + |
| 20 | + /// Applies the Primary Button Style: Clear BG / Bordered Outline |
| 21 | + /// |
| 22 | + func applySecondaryButtonStyle() { |
| 23 | + backgroundColor = .clear |
| 24 | + contentEdgeInsets = Style.defaultEdgeInsets |
| 25 | + tintColor = StyleManager.wooCommerceBrandColor |
| 26 | + layer.borderColor = StyleManager.wooCommerceBrandColor.cgColor |
| 27 | + layer.borderWidth = Style.defaultBorderWidth |
| 28 | + layer.cornerRadius = Style.defaultCornerRadius |
| 29 | + titleLabel?.applyHeadlineStyle() |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | + |
| 34 | +// MARK: - Private Structures |
| 35 | +// |
| 36 | +private extension UIButton { |
| 37 | + |
| 38 | + struct Style { |
| 39 | + static let defaultCornerRadius = CGFloat(8.0) |
| 40 | + static let defaultBorderWidth = CGFloat(1.0) |
| 41 | + static let defaultEdgeInsets = UIEdgeInsets(top: 12, left: 22, bottom: 12, right: 22) |
| 42 | + } |
12 | 43 | } |
0 commit comments