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

@@ -71,14 +71,14 @@ private enum ResetPasswordEntry: ItemListNodeEntry, Equatable {
func item(presentationData: ItemListPresentationData, arguments: Any) -> ListViewItem {
let arguments = arguments as! ResetPasswordControllerArguments
switch self {
case let .code(theme, strings, text, value):
case let .code(theme, _, text, value):
return ItemListSingleLineInputItem(presentationData: presentationData, title: NSAttributedString(string: text, textColor: theme.list.itemPrimaryTextColor), text: value, placeholder: "", type: .number, spacing: 10.0, tag: ResetPasswordEntryTag.code, sectionId: self.section, textUpdated: { updatedText in
arguments.updateCodeText(updatedText)
}, action: {
})
case let .codeInfo(theme, text):
case let .codeInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .plain(text), sectionId: self.section)
case let .helpInfo(theme, text):
case let .helpInfo(_, text):
return ItemListTextItem(presentationData: presentationData, text: .markdown(text), sectionId: self.section, linkAction: { action in
if case .tap = action {
arguments.openHelp()
@@ -100,10 +100,10 @@ private func resetPasswordControllerEntries(presentationData: PresentationData,
entries.append(.codeInfo(presentationData.theme, presentationData.strings.TwoStepAuth_RecoveryCodeHelp))
let stringData = presentationData.strings.TwoStepAuth_RecoveryEmailUnavailable(pattern)
var string = stringData.0
if let (_, range) = stringData.1.first {
string.insert(contentsOf: "]()", at: string.index(string.startIndex, offsetBy: range.upperBound))
string.insert(contentsOf: "[", at: string.index(string.startIndex, offsetBy: range.lowerBound))
var string = stringData.string
if let range = stringData.ranges.first {
string.insert(contentsOf: "]()", at: string.index(string.startIndex, offsetBy: range.range.upperBound))
string.insert(contentsOf: "[", at: string.index(string.startIndex, offsetBy: range.range.lowerBound))
}
entries.append(.helpInfo(presentationData.theme, string))