Skip to content

Commit

Permalink
[Link] UI Polish - Part 3 (#883)
Browse files Browse the repository at this point in the history
* Add `titleAttributes` to `Button`

* Remove redundant icon view

Prevent extra leading and trailing padding from being added to the
button.

* Update snapshots

* Hide image view if needed

* Reduce the number of constraints

* Simplify layout logic

* Update plain button insets

* Adjust insets

* Invalidate intrinsic content size when needed

* Prevent unnecessary constraint updates
  • Loading branch information
ramont-stripe authored Mar 23, 2022
1 parent e978335 commit b8e9955
Show file tree
Hide file tree
Showing 30 changed files with 162 additions and 110 deletions.
1 change: 1 addition & 0 deletions Stripe/Button+Link.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extension Button.Configuration {
configuration.disabledForegroundColor = nil
configuration.colorTransforms.highlightedForeground = .setAlpha(amount: 0.4)
configuration.colorTransforms.disabledForeground = .setAlpha(amount: 0.3)
configuration.titleAttributes = [.underlineStyle: NSUnderlineStyle.single.rawValue]
return configuration
}

Expand Down
15 changes: 3 additions & 12 deletions Stripe/Link2FAView-LogoutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,10 @@ extension Link2FAView {
return label
}()

private(set) lazy var button: UIButton = {
private(set) lazy var button: Button = {
// TODO(ramont): Localize.
let title = NSAttributedString(string: "Change email", attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue
])

// TODO(ramont): Replace with `Button(configuration: .linkPlain())` and remove
// manual underline.
let button = UIButton(type: .system)
button.titleLabel?.font = font
button.titleLabel?.adjustsFontForContentSizeCategory = true
button.setAttributedTitle(title, for: .normal)
button.tintColor = CompatibleColor.secondaryLabel
let button = Button(configuration: .linkPlain(), title: "Change email")
button.configuration.font = font
return button
}()

Expand Down
13 changes: 3 additions & 10 deletions Stripe/LinkWalletFooterView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,11 @@ final class LinkWalletFooterView: UIView {
return label
}()

private lazy var logoutButton: UIButton = {
private lazy var logoutButton: Button = {
// TODO(ramont): Localize.
let title = NSMutableAttributedString(string: "Log out", attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue
])

let button = UIButton(type: .system)
button.titleLabel?.font = font
button.titleLabel?.adjustsFontForContentSizeCategory = true
button.setAttributedTitle(title, for: .normal)
let button = Button(configuration: .linkPlain(), title: "Log out")
button.addTarget(self, action: #selector(logoutTapped(_:)), for: .touchUpInside)
button.tintColor = CompatibleColor.secondaryLabel
button.configuration.font = font
return button
}()

Expand Down
16 changes: 2 additions & 14 deletions Stripe/PayWithLinkViewController-WalletViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,9 @@ extension PayWithLinkViewController {
? .linkPlain()
: .linkSecondary()

let button = Button(configuration: buttonConfiguration)
button.addTarget(self, action: #selector(cancelButtonTapped(_:)), for: .touchUpInside)

// TODO(ramont): Localize
let buttonTitle = "Pay another way"

if shouldShowApplePayButton {
// TODO(ramont): Add `UIConfigurationTextAttributesTransformer` equivalent API to Button.
button.attributedTitle = NSAttributedString(string: buttonTitle, attributes: [
.underlineStyle: NSUnderlineStyle.single.rawValue
])
} else {
button.title = buttonTitle
}

let button = Button(configuration: buttonConfiguration, title: "Pay another way")
button.addTarget(self, action: #selector(cancelButtonTapped(_:)), for: .touchUpInside)
return button
}()

Expand Down
Loading

0 comments on commit b8e9955

Please sign in to comment.