Refactoring

This commit is contained in:
Justin Mazzocchi 2021-02-01 20:36:16 -08:00
parent 550a1acb8b
commit 339159abd1
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
3 changed files with 17 additions and 5 deletions

View file

@ -52,4 +52,18 @@ extension String {
return mutableString
}
func appendingWithSeparator(_ string: Self) -> Self {
appending(Self.separator).appending(string)
}
mutating func appendWithSeparator(_ string: Self) {
append(Self.separator.appending(string))
}
}
private extension String {
static var separator: Self {
Locale.autoupdatingCurrent.groupingSeparator ?? ","
}
}

View file

@ -83,7 +83,7 @@ private extension InstanceView {
titleLabel.text = viewModel.instance.title
uriLabel.text = viewModel.instance.uri
accessibilityLabel = viewModel.instance.title.appending("\n").appending(viewModel.instance.uri)
accessibilityLabel = viewModel.instance.title.appendingWithSeparator(viewModel.instance.uri)
}
func setupAccessibility() {

View file

@ -99,8 +99,7 @@ private extension TagView {
NSLocalizedString("tag.people-talking", comment: ""),
accounts)
accountsLabel.text = accountsText
accessibilityLabel.append("\n")
accessibilityLabel.append(accountsText)
accessibilityLabel.appendWithSeparator(accountsText)
accountsLabel.isHidden = false
} else {
accountsLabel.isHidden = true
@ -112,8 +111,7 @@ private extension TagView {
let accessibilityRecentUses = String.localizedStringWithFormat(
NSLocalizedString("tag.accessibility-recent-uses-%ld", comment: ""),
uses)
accessibilityLabel.append("\n")
accessibilityLabel.append(accessibilityRecentUses)
accessibilityLabel.appendWithSeparator(accessibilityRecentUses)
} else {
usesLabel.isHidden = true
}