Skip to content

Commit 53c19f8

Browse files
Remove underline from links in the login screens
1 parent 7b9d692 commit 53c19f8

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
extension String {
2-
/// Creates an attributed string from one underlined section that's surrounded by underscores
2+
/// Creates an attributed string from one link section that's surrounded by underscores
33
///
44
/// - Parameters:
55
/// - color: foreground color to use for the string (optional)
6-
/// - underlineColor: foreground color to use for the underlined section (optional)
6+
/// - linkColor: foreground color to use for the link (optional)
77
/// - Returns: Attributed string
8-
/// - Note: "this _is_ underlined" would under the "is"
9-
func underlined(color: UIColor? = nil, underlineColor: UIColor? = nil) -> NSAttributedString {
8+
/// - Note: "this _is_ an example" would color the "is" using the linkColor
9+
func withColor(color: UIColor? = nil, linkColor: UIColor? = nil) -> NSAttributedString {
1010
let labelParts = self.components(separatedBy: "_")
1111
let firstPart = labelParts[0]
12-
let underlinePart = labelParts.indices.contains(1) ? labelParts[1] : ""
12+
let linkParts = labelParts.indices.contains(1) ? labelParts[1] : ""
1313
let lastPart = labelParts.indices.contains(2) ? labelParts[2] : ""
1414

1515
let foregroundColor = color ?? UIColor.black
16-
let underlineForegroundColor = underlineColor ?? foregroundColor
16+
let linkSectionColor = linkColor ?? foregroundColor
1717

18-
let underlinedString = NSMutableAttributedString(string: firstPart, attributes: [.foregroundColor: foregroundColor])
19-
underlinedString.append(NSAttributedString(string: underlinePart, attributes: [.underlineStyle: NSUnderlineStyle.single.rawValue, .foregroundColor: underlineForegroundColor]))
20-
underlinedString.append(NSAttributedString(string: lastPart, attributes: [.foregroundColor: foregroundColor]))
18+
let result = NSMutableAttributedString(string: firstPart, attributes: [.foregroundColor: foregroundColor])
19+
result.append(NSAttributedString(string: linkParts, attributes: [.foregroundColor: linkSectionColor]))
20+
result.append(NSAttributedString(string: lastPart, attributes: [.foregroundColor: foregroundColor]))
2121

22-
return underlinedString
22+
return result
2323
}
2424
}

WooCommerce/WordPressAuthenticator/Extensions/WPStyleGuide+Login.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ extension WPStyleGuide {
175175
if WordPressAuthenticator.shared.configuration.showLoginOptions {
176176
let baseString = NSLocalizedString("Or log in by _entering your site address_.", comment: "Label for button to log in using site address. Underscores _..._ denote underline.")
177177

178-
let attrStrNormal = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonColor)
179-
let attrStrHighlight = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonHighlightColor)
178+
let attrStrNormal = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonColor)
179+
let attrStrHighlight = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonHighlightColor)
180180
let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)
181181

182182
button = textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: alignment)
@@ -203,8 +203,8 @@ extension WPStyleGuide {
203203
class func wpcomSignupButton() -> UIButton {
204204
let style = WordPressAuthenticator.shared.style
205205
let baseString = NSLocalizedString("Don't have an account? _Sign up_", comment: "Label for button to log in using your site address. The underscores _..._ denote underline")
206-
let attrStrNormal = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonColor)
207-
let attrStrHighlight = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonHighlightColor)
206+
let attrStrNormal = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonColor)
207+
let attrStrHighlight = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonHighlightColor)
208208
let font = WPStyleGuide.mediumWeightFont(forStyle: .subheadline)
209209

210210
return textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font)
@@ -219,8 +219,8 @@ extension WPStyleGuide {
219219

220220
let baseString = NSLocalizedString("By signing up, you agree to our _Terms of Service_.", comment: "Legal disclaimer for signup buttons, the underscores _..._ denote underline")
221221

222-
let attrStrNormal = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonColor)
223-
let attrStrHighlight = baseString.underlined(color: style.subheadlineColor, underlineColor: style.textButtonHighlightColor)
222+
let attrStrNormal = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonColor)
223+
let attrStrHighlight = baseString.withColor(color: style.subheadlineColor, linkColor: style.textButtonHighlightColor)
224224
let font = WPStyleGuide.mediumWeightFont(forStyle: .footnote)
225225

226226
return textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: .center)
@@ -237,8 +237,8 @@ extension WPStyleGuide {
237237
let textColor = unifiedStyle?.textSubtleColor ?? originalStyle.subheadlineColor
238238
let linkColor = unifiedStyle?.textButtonColor ?? originalStyle.textButtonColor
239239

240-
let attrStrNormal = baseString.underlined(color: textColor, underlineColor: linkColor)
241-
let attrStrHighlight = baseString.underlined(color: textColor, underlineColor: linkColor)
240+
let attrStrNormal = baseString.withColor(color: textColor, linkColor: linkColor)
241+
let attrStrHighlight = baseString.withColor(color: textColor, linkColor: linkColor)
242242
let font = WPStyleGuide.mediumWeightFont(forStyle: .footnote)
243243

244244
let button = textButton(normal: attrStrNormal, highlighted: attrStrHighlight, font: font, alignment: .center, forUnified: true)

WooCommerce/WordPressAuthenticator/Unified Auth/View Related/Reusable Views/TextWithLinkTableViewCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class TextWithLinkTableViewCell: UITableViewCell {
3333
let linkColor = WordPressAuthenticator.shared.unifiedStyle?.textButtonColor ?? WordPressAuthenticator.shared.style.textButtonColor
3434
let linkHighlightColor = WordPressAuthenticator.shared.unifiedStyle?.textButtonHighlightColor ?? WordPressAuthenticator.shared.style.textButtonHighlightColor
3535

36-
let attributedString = text.underlined(color: textColor, underlineColor: linkColor)
37-
let highlightAttributedString = text.underlined(color: textColor, underlineColor: linkHighlightColor)
36+
let attributedString = text.withColor(color: textColor, linkColor: linkColor)
37+
let highlightAttributedString = text.withColor(color: textColor, linkColor: linkHighlightColor)
3838

3939
button.setAttributedTitle(attributedString, for: .normal)
4040
button.setAttributedTitle(highlightAttributedString, for: .highlighted)

0 commit comments

Comments
 (0)