-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♿️ Disable Dynamic Type on buttons #806
Changes from all commits
59cd9aa
68b887c
84baa40
6932aee
0700aa4
5e03373
ffd72c6
25b3237
9ba819f
1723d68
2bf9ebd
9df465d
454d3c8
137b4e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import Prelude | |
final class PledgeContinueViewController: UIViewController { | ||
// MARK: - Properties | ||
|
||
private let continueButton = MultiLineButton(type: .custom) | ||
private let continueButton = UIButton(type: .custom) | ||
private let viewModel = PledgeContinueViewModel() | ||
|
||
// MARK: - Lifecycle | ||
|
@@ -25,10 +25,7 @@ final class PledgeContinueViewController: UIViewController { | |
|> checkoutBackgroundStyle | ||
|
||
_ = self.continueButton | ||
|> greenButtonStyle | ||
|> UIButton.lens.title(for: .normal) %~ { _ in | ||
Strings.Continue() | ||
} | ||
|> continueButtonStyle | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moving to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking that we can start renaming the |
||
} | ||
|
||
// MARK: - View model | ||
|
@@ -74,3 +71,11 @@ final class PledgeContinueViewController: UIViewController { | |
self.presentViewControllerWithSheetOverlay(navigationController, offset: navigationBarHeight) | ||
} | ||
} | ||
|
||
// MARK: - Styles | ||
|
||
private let continueButtonStyle: ButtonStyle = { button in | ||
button | ||
|> greenButtonStyle | ||
|> UIButton.lens.title(for: .normal) %~ { _ in Strings.Continue() } | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,33 +85,19 @@ final class PledgeCTAContainerView: UIView { | |
|> pledgeRetryButtonStyle | ||
|
||
_ = self.titleAndSubtitleStackView | ||
|> \.axis .~ NSLayoutConstraint.Axis.vertical | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.spacing .~ Styles.gridHalf(1) | ||
|
||
_ = self.pledgeCTAButton | ||
|> pledgeCTAButtonStyle( | ||
isAccessibilityCategory, | ||
amountAndRewardTitleStackViewIsHidden: self.titleAndSubtitleStackView.isHidden | ||
) | ||
|> titleAndSubtitleStackViewStyle | ||
|
||
_ = self.rootStackView | ||
|> adaptableStackViewStyle(isAccessibilityCategory) | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.layoutMargins .~ UIEdgeInsets.init(topBottom: Styles.grid(3), leftRight: Styles.grid(3)) | ||
|> \.alignment .~ .center | ||
|
||
_ = self.titleLabel | ||
|> \.font .~ UIFont.ksr_callout().bolded | ||
|> \.numberOfLines .~ 0 | ||
|> titleLabelStyle | ||
|
||
_ = self.subtitleLabel | ||
|> \.font .~ UIFont.ksr_caption1().bolded | ||
|> \.textColor .~ UIColor.ksr_dark_grey_500 | ||
|> \.numberOfLines .~ 0 | ||
|> subtitleLabelStyle | ||
|
||
_ = self.activityIndicator | ||
|> \.color .~ UIColor.ksr_dark_grey_500 | ||
|> activityIndicatorStyle | ||
} | ||
|
||
// MARK: - View model | ||
|
@@ -122,7 +108,8 @@ final class PledgeCTAContainerView: UIView { | |
self.viewModel.outputs.buttonStyleType | ||
.observeForUI() | ||
.observeValues { [weak self] buttonStyleType in | ||
_ = self?.pledgeCTAButton ?|> buttonStyleType.style | ||
_ = self?.pledgeCTAButton | ||
?|> buttonStyleType.style | ||
} | ||
|
||
self.viewModel.outputs.pledgeCTAButtonIsHidden | ||
|
@@ -196,31 +183,43 @@ final class PledgeCTAContainerView: UIView { | |
|
||
// MARK: - Styles | ||
|
||
private let activityIndicatorStyle: ActivityIndicatorStyle = { activityIndicator in | ||
activityIndicator | ||
|> \.color .~ UIColor.ksr_dark_grey_500 | ||
|> \.hidesWhenStopped .~ true | ||
} | ||
|
||
private func adaptableStackViewStyle(_ isAccessibilityCategory: Bool) -> (StackViewStyle) { | ||
return { (stackView: UIStackView) in | ||
let axis: NSLayoutConstraint.Axis = (isAccessibilityCategory ? .vertical : .horizontal) | ||
let spacing: CGFloat = (isAccessibilityCategory ? Styles.grid(1) : 0) | ||
|
||
return stackView | ||
|> \.axis .~ axis | ||
|> \.alignment .~ .center | ||
|> \.axis .~ NSLayoutConstraint.Axis.horizontal | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was the compiler giving you trouble here? 😄 I think that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not that the compiler would give us trouble but we've been seeing a lot of warnings lately related to Xcode's type checker...therefore at some point we've decided that for styles it would make more sense to be more explicit. I'll make the styling more consistent by extracting |
||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.layoutMargins .~ UIEdgeInsets.init(topBottom: Styles.grid(3), leftRight: Styles.grid(3)) | ||
|> \.spacing .~ spacing | ||
} | ||
} | ||
|
||
private func pledgeCTAButtonStyle( | ||
_ isAccessibilityCategory: Bool, amountAndRewardTitleStackViewIsHidden: Bool | ||
) -> (ButtonStyle) { | ||
return { (button: UIButton) in | ||
let lineBreakMode: NSLineBreakMode = isAccessibilityCategory || amountAndRewardTitleStackViewIsHidden | ||
? NSLineBreakMode.byWordWrapping : NSLineBreakMode.byTruncatingTail | ||
|
||
return button | ||
|> roundedStyle(cornerRadius: 12) | ||
|> UIButton.lens.titleLabel.font .~ UIFont.ksr_headline(size: 15) | ||
|> UIButton.lens.layer.borderWidth .~ 0 | ||
|> (UIButton.lens.titleLabel .. UILabel.lens.textAlignment) .~ NSTextAlignment.center | ||
|> (UIButton.lens.titleLabel .. UILabel.lens.lineBreakMode) .~ lineBreakMode | ||
} | ||
private let subtitleLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.font .~ UIFont.ksr_caption1().bolded | ||
|> \.textColor .~ UIColor.ksr_dark_grey_500 | ||
|> \.numberOfLines .~ 0 | ||
} | ||
|
||
private let titleAndSubtitleStackViewStyle: StackViewStyle = { stackView in | ||
stackView | ||
|> \.axis .~ NSLayoutConstraint.Axis.vertical | ||
|> \.isLayoutMarginsRelativeArrangement .~ true | ||
|> \.spacing .~ Styles.gridHalf(1) | ||
} | ||
|
||
private let titleLabelStyle: LabelStyle = { label in | ||
label | ||
|> \.font .~ UIFont.ksr_callout().bolded | ||
|> \.numberOfLines .~ 0 | ||
} | ||
|
||
private let pledgeRetryButtonStyle: ButtonStyle = { button in | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,8 +20,8 @@ public final class RewardCardContainerView: UIView { | |
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
private let pledgeButton: MultiLineButton = { | ||
MultiLineButton(type: .custom) | ||
private let pledgeButton: UIButton = { | ||
UIButton(type: .custom) | ||
|> \.translatesAutoresizingMaskIntoConstraints .~ false | ||
}() | ||
|
||
|
@@ -65,9 +65,6 @@ public final class RewardCardContainerView: UIView { | |
(UIColor.white.withAlphaComponent(1.0), 1) | ||
] | ||
self.gradientView.setGradient(gradient) | ||
|
||
_ = self.pledgeButton.titleLabel | ||
?|> \.lineBreakMode .~ .byTruncatingTail | ||
} | ||
|
||
public override func bindViewModel() { | ||
|
@@ -104,8 +101,8 @@ public final class RewardCardContainerView: UIView { | |
self.viewModel.outputs.pledgeButtonStyleType | ||
.observeForUI() | ||
.observeValues { [weak self] styleType in | ||
guard let self = self else { return } | ||
_ = self.pledgeButton |> styleType.style | ||
_ = self?.pledgeButton | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using optional chaining for consistency between files |
||
?|> styleType.style | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We no longer need to use
MultiLineButton
here...in fact since we've previously added trimming we haven't been using it for a while (so this is just a cleanup).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see we're only using this in one place, not time to remove
MultiLineButton
yet?