Refactor string generation

This commit is contained in:
Ali
2021-07-20 11:57:50 +02:00
parent bbd096d88b
commit 7bed1728bb
205 changed files with 15848 additions and 33988 deletions

View File

@@ -119,7 +119,7 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
}
let titleColor: UIColor
let completeSourceString: (String, [(Int, NSRange)])
let completeSourceString: PresentationStrings.FormattedString
switch type {
case let .bubble(incoming):
@@ -140,9 +140,9 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
let rightPart = String(customFormat[range.upperBound...])
let formattedText = leftPart + peerString + rightPart
completeSourceString = (formattedText, [(0, NSRange(location: leftPart.count, length: peerString.count))])
completeSourceString = PresentationStrings.FormattedString(string: formattedText, ranges: [PresentationStrings.FormattedString.Range(index: 0, range: NSRange(location: leftPart.count, length: peerString.count))])
} else {
completeSourceString = (customFormat, [])
completeSourceString = PresentationStrings.FormattedString(string: customFormat, ranges: [])
}
} else {
completeSourceString = strings.Message_GenericForwardedPsa(peerString)
@@ -170,9 +170,9 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
let rightPart = String(customFormat[range.upperBound...])
let formattedText = leftPart + peerString + rightPart
completeSourceString = (formattedText, [(0, NSRange(location: leftPart.count, length: peerString.count))])
completeSourceString = PresentationStrings.FormattedString(string: formattedText, ranges: [PresentationStrings.FormattedString.Range(index: 0, range: NSRange(location: leftPart.count, length: peerString.count))])
} else {
completeSourceString = (customFormat, [])
completeSourceString = PresentationStrings.FormattedString(string: customFormat, ranges: [])
}
} else {
completeSourceString = strings.Message_GenericForwardedPsa(peerString)
@@ -214,9 +214,9 @@ class ChatMessageForwardInfoNode: ASDisplayNode {
highlight = false
}
let completeString: NSString = completeSourceString.0 as NSString
let completeString: NSString = completeSourceString.string as NSString
let string = NSMutableAttributedString(string: completeString as String, attributes: [NSAttributedString.Key.foregroundColor: titleColor, NSAttributedString.Key.font: prefixFont])
if highlight, let range = completeSourceString.1.first?.1 {
if highlight, let range = completeSourceString.ranges.first?.range {
string.addAttributes([NSAttributedString.Key.font: peerFont], range: range)
}