mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
no message
This commit is contained in:
@@ -20,9 +20,9 @@ private enum UsernameSetupSection: Int32 {
|
||||
}
|
||||
|
||||
private enum UsernameSetupEntry: ItemListNodeEntry {
|
||||
case editablePublicLink(String?, String)
|
||||
case publicLinkStatus(String, AddressNameValidationStatus)
|
||||
case publicLinkInfo(String)
|
||||
case editablePublicLink(PresentationTheme, String?, String)
|
||||
case publicLinkStatus(PresentationTheme, String, AddressNameValidationStatus)
|
||||
case publicLinkInfo(PresentationTheme, String)
|
||||
|
||||
var section: ItemListSectionId {
|
||||
switch self {
|
||||
@@ -44,20 +44,20 @@ private enum UsernameSetupEntry: ItemListNodeEntry {
|
||||
|
||||
static func ==(lhs: UsernameSetupEntry, rhs: UsernameSetupEntry) -> Bool {
|
||||
switch lhs {
|
||||
case let .editablePublicLink(lhsCurrentText, lhsText):
|
||||
if case let .editablePublicLink(rhsCurrentText, rhsText) = rhs, lhsCurrentText == rhsCurrentText, lhsText == rhsText {
|
||||
case let .editablePublicLink(lhsTheme, lhsCurrentText, lhsText):
|
||||
if case let .editablePublicLink(rhsTheme, rhsCurrentText, rhsText) = rhs, lhsTheme === rhsTheme, lhsCurrentText == rhsCurrentText, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .publicLinkInfo(text):
|
||||
if case .publicLinkInfo(text) = rhs {
|
||||
case let .publicLinkInfo(lhsTheme, lhsText):
|
||||
if case let .publicLinkInfo(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .publicLinkStatus(addressName, status):
|
||||
if case .publicLinkStatus(addressName, status) = rhs {
|
||||
case let .publicLinkStatus(lhsTheme, lhsAddressName, lhsStatus):
|
||||
if case let .publicLinkStatus(rhsTheme, rhsAddressName, rhsStatus) = rhs, lhsTheme === rhsTheme, lhsAddressName == rhsAddressName, lhsStatus == rhsStatus {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -71,42 +71,42 @@ private enum UsernameSetupEntry: ItemListNodeEntry {
|
||||
|
||||
func item(_ arguments: UsernameSetupControllerArguments) -> ListViewItem {
|
||||
switch self {
|
||||
case let .editablePublicLink(currentText, text):
|
||||
return ItemListSingleLineInputItem(title: NSAttributedString(string: "t.me/", textColor: .black), text: text, placeholder: "", sectionId: self.section, textUpdated: { updatedText in
|
||||
case let .editablePublicLink(theme, currentText, text):
|
||||
return ItemListSingleLineInputItem(theme: theme, title: NSAttributedString(string: "t.me/", textColor: theme.list.itemPrimaryTextColor), text: text, placeholder: "", sectionId: self.section, textUpdated: { updatedText in
|
||||
arguments.updatePublicLinkText(currentText, updatedText)
|
||||
}, action: {
|
||||
|
||||
})
|
||||
case let .publicLinkInfo(text):
|
||||
return ItemListTextItem(text: .plain(text), sectionId: self.section)
|
||||
case let .publicLinkStatus(addressName, status):
|
||||
case let .publicLinkInfo(theme, text):
|
||||
return ItemListTextItem(theme: theme, text: .plain(text), sectionId: self.section)
|
||||
case let .publicLinkStatus(theme, addressName, status):
|
||||
var displayActivity = false
|
||||
let text: NSAttributedString
|
||||
switch status {
|
||||
case let .invalidFormat(error):
|
||||
switch error {
|
||||
case .startsWithDigit:
|
||||
text = NSAttributedString(string: "Names can't start with a digit.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Names can't start with a digit.", textColor: UIColor(rgb: 0xcf3030))
|
||||
case .startsWithUnderscore:
|
||||
text = NSAttributedString(string: "Names can't start with an underscore.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Names can't start with an underscore.", textColor: UIColor(rgb: 0xcf3030))
|
||||
case .endsWithUnderscore:
|
||||
text = NSAttributedString(string: "Names can't end with an underscore.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Names can't end with an underscore.", textColor: UIColor(rgb: 0xcf3030))
|
||||
case .tooShort:
|
||||
text = NSAttributedString(string: "Names must have at least 5 characters.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Names must have at least 5 characters.", textColor: UIColor(rgb: 0xcf3030))
|
||||
case .invalidCharacters:
|
||||
text = NSAttributedString(string: "Sorry, this name is invalid.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Sorry, this name is invalid.", textColor: UIColor(rgb: 0xcf3030))
|
||||
}
|
||||
case let .availability(availability):
|
||||
switch availability {
|
||||
case .available:
|
||||
text = NSAttributedString(string: "\(addressName) is available.", textColor: UIColor(0x26972c))
|
||||
text = NSAttributedString(string: "\(addressName) is available.", textColor: UIColor(rgb: 0x26972c))
|
||||
case .invalid:
|
||||
text = NSAttributedString(string: "Sorry, this name is invalid.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "Sorry, this name is invalid.", textColor: UIColor(rgb: 0xcf3030))
|
||||
case .taken:
|
||||
text = NSAttributedString(string: "\(addressName) is already taken.", textColor: UIColor(0xcf3030))
|
||||
text = NSAttributedString(string: "\(addressName) is already taken.", textColor: UIColor(rgb: 0xcf3030))
|
||||
}
|
||||
case .checking:
|
||||
text = NSAttributedString(string: "Checking name...", textColor: UIColor(0x6d6d72))
|
||||
text = NSAttributedString(string: "Checking name...", textColor: UIColor(rgb: 0x6d6d72))
|
||||
displayActivity = true
|
||||
}
|
||||
return ItemListActivityTextItem(displayActivity: displayActivity, text: text, sectionId: self.section)
|
||||
@@ -158,7 +158,7 @@ private struct UsernameSetupControllerState: Equatable {
|
||||
}
|
||||
}
|
||||
|
||||
private func usernameSetupControllerEntries(view: PeerView, state: UsernameSetupControllerState) -> [UsernameSetupEntry] {
|
||||
private func usernameSetupControllerEntries(presentationData: PresentationData, view: PeerView, state: UsernameSetupControllerState) -> [UsernameSetupEntry] {
|
||||
var entries: [UsernameSetupEntry] = []
|
||||
|
||||
if let peer = view.peers[view.peerId] as? TelegramUser {
|
||||
@@ -173,11 +173,11 @@ private func usernameSetupControllerEntries(view: PeerView, state: UsernameSetup
|
||||
}
|
||||
}
|
||||
|
||||
entries.append(.editablePublicLink(peer.addressName, currentAddressName))
|
||||
entries.append(.editablePublicLink(presentationData.theme, peer.addressName, currentAddressName))
|
||||
if let status = state.addressNameValidationStatus {
|
||||
entries.append(.publicLinkStatus(currentAddressName, status))
|
||||
entries.append(.publicLinkStatus(presentationData.theme, currentAddressName, status))
|
||||
}
|
||||
entries.append(.publicLinkInfo("You can shoose a username on Telegram. If you do, other people will be able to find you by this username and contact you without knowing your phone number.\n\nYou can user a-z, 0-9 and underscores. Minimum length is 5 characters."))
|
||||
entries.append(.publicLinkInfo(presentationData.theme, presentationData.strings.Username_Help))
|
||||
}
|
||||
|
||||
return entries
|
||||
@@ -228,8 +228,8 @@ public func usernameSetupController(account: Account) -> ViewController {
|
||||
let peerView = account.viewTracker.peerView(account.peerId)
|
||||
|> deliverOnMainQueue
|
||||
|
||||
let signal = combineLatest(statePromise.get() |> deliverOnMainQueue, peerView)
|
||||
|> map { state, view -> (ItemListControllerState, (ItemListNodeState<UsernameSetupEntry>, UsernameSetupEntry.ItemGenerationArguments)) in
|
||||
let signal = combineLatest((account.applicationContext as! TelegramApplicationContext).presentationData, statePromise.get() |> deliverOnMainQueue, peerView)
|
||||
|> map { presentationData, state, view -> (ItemListControllerState, (ItemListNodeState<UsernameSetupEntry>, UsernameSetupEntry.ItemGenerationArguments)) in
|
||||
let peer = peerViewMainPeer(view)
|
||||
|
||||
var rightNavigationButton: ItemListNavigationButton?
|
||||
@@ -245,7 +245,7 @@ public func usernameSetupController(account: Account) -> ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
rightNavigationButton = ItemListNavigationButton(title: "Done", style: state.updatingAddressName ? .activity : .bold, enabled: doneEnabled, action: {
|
||||
rightNavigationButton = ItemListNavigationButton(title: presentationData.strings.Common_Done, style: state.updatingAddressName ? .activity : .bold, enabled: doneEnabled, action: {
|
||||
var updatedAddressNameValue: String?
|
||||
updateState { state in
|
||||
if state.editingPublicLinkText != peer.addressName {
|
||||
@@ -278,20 +278,19 @@ public func usernameSetupController(account: Account) -> ViewController {
|
||||
})
|
||||
}
|
||||
|
||||
let leftNavigationButton = ItemListNavigationButton(title: "Cancel", style: .regular, enabled: true, action: {
|
||||
let leftNavigationButton = ItemListNavigationButton(title: presentationData.strings.Common_Cancel, style: .regular, enabled: true, action: {
|
||||
dismissImpl?()
|
||||
})
|
||||
|
||||
let controllerState = ItemListControllerState(title: .text("Username"), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, animateChanges: false)
|
||||
let listState = ItemListNodeState(entries: usernameSetupControllerEntries(view: view, state: state), style: .blocks, animateChanges: false)
|
||||
let controllerState = ItemListControllerState(theme: presentationData.theme, title: .text(presentationData.strings.Username_Title), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back), animateChanges: false)
|
||||
let listState = ItemListNodeState(entries: usernameSetupControllerEntries(presentationData: presentationData, view: view, state: state), style: .blocks, animateChanges: false)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
} |> afterDisposed {
|
||||
actionsDisposable.dispose()
|
||||
}
|
||||
|
||||
let controller = ItemListController(signal)
|
||||
controller.navigationItem.backBarButtonItem = UIBarButtonItem(title: "Back", style: .plain, target: nil, action: nil)
|
||||
let controller = ItemListController(account: account, state: signal)
|
||||
dismissImpl = { [weak controller] in
|
||||
controller?.dismiss()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user