Skip to content
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

UL&S: bug fix: make the TextLinkButtonTableViewCell button word wrap, not truncate #310

Merged
merged 3 commits into from
Jun 26, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WordPressAuthenticator.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "WordPressAuthenticator"
s.version = "1.19.0-beta.4"
s.version = "1.19.0-beta.5"
s.summary = "WordPressAuthenticator implements an easy and elegant way to authenticate your WordPress Apps."

s.description = <<-DESC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ class TextLinkButtonTableViewCell: UITableViewCell {

public var actionHandler: (() -> Void)?

override func awakeFromNib() {
super.awakeFromNib()

button.titleLabel?.font = UIFont.preferredFont(forTextStyle: .callout)
button.titleLabel?.adjustsFontForContentSizeCategory = true
button.titleLabel?.lineBreakMode = .byWordWrapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a thought here: since you're using a xib, it would be nice to set these at design time, although, for a UIButton is less obvious, since you don't have the 'adjustsFontForContentSizeCategoryreadily available. You might still set the font and line break mode in there. You could also setadjustsFontForContentSizeCategoryin there using@ibdesignable` (which I don't think is worth) or trying to set that value as a user defined runtime attribute (but it would still be a runtime calculation). Again it's just a thought, there's nothing wrong in leaving as it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okie dokie, I moved setting the font and lineBreakMode to the Interface Builder. ajustsFontForContentSizeCategory is a variable in the UIContentSizeCategoryAdjusting protocol. Protocol variables don't seem to work with @IBInspectable or @IBDesignable, so I left it as-is.

}

public func configureButton(text: String?) {
button.setTitle(text, for: .normal)

let buttonTitleColor = WordPressAuthenticator.shared.unifiedStyle?.textButtonColor ?? WordPressAuthenticator.shared.style.textButtonColor
let buttonHighlightColor = WordPressAuthenticator.shared.unifiedStyle?.textButtonHighlightColor ?? WordPressAuthenticator.shared.style.textButtonHighlightColor
button.setTitleColor(buttonTitleColor, for: .normal)
button.setTitleColor(buttonHighlightColor, for: .highlighted)

button.titleLabel?.font = UIFont.preferredFont(forTextStyle: .callout)
button.titleLabel?.adjustsFontForContentSizeCategory = true
}
}