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 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 titleLabel.text = viewModel.instance.title
uriLabel.text = viewModel.instance.uri 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() { func setupAccessibility() {

View File

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