mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Authorization improvements
This commit is contained in:
parent
f4e17310ed
commit
1f8e9b568a
@ -27,7 +27,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
var resetEmail: (() -> Void)?
|
||||
var retryResetEmail: (() -> Void)?
|
||||
|
||||
var data: (String, String?, SentAuthorizationCodeType, AuthorizationCodeNextType?, Int32?, SentAuthorizationCodeType?)?
|
||||
var data: (String, String?, SentAuthorizationCodeType, AuthorizationCodeNextType?, Int32?, SentAuthorizationCodeType?, Bool)?
|
||||
var termsOfService: (UnauthorizedAccountTermsOfService, Bool)?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
@ -41,17 +41,8 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
var isWordOrPhrase: Bool {
|
||||
if let type = self.data?.2 {
|
||||
switch type {
|
||||
case .word, .phrase:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
var isPrevious: Bool {
|
||||
return self.data?.6 ?? false
|
||||
}
|
||||
|
||||
public init(presentationData: PresentationData, back: @escaping () -> Void) {
|
||||
@ -74,7 +65,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
let proceed: String
|
||||
let stop: String
|
||||
|
||||
if let (_, _, type, _, _, _) = self?.data, case .email = type {
|
||||
if let (_, _, type, _, _, _, _) = self?.data, case .email = type {
|
||||
text = presentationData.strings.Login_CancelEmailVerification
|
||||
proceed = presentationData.strings.Login_CancelEmailVerificationContinue
|
||||
stop = presentationData.strings.Login_CancelEmailVerificationStop
|
||||
@ -141,12 +132,12 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
self?.present(c, in: .window(.root), with: a)
|
||||
}
|
||||
|
||||
if let (number, email, codeType, nextType, timeout, previousCodeType) = self.data {
|
||||
if let (number, email, codeType, nextType, timeout, previousCodeType, isPrevious) = self.data {
|
||||
var appleSignInAllowed = false
|
||||
if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType {
|
||||
appleSignInAllowed = appleSignInAllowedValue
|
||||
}
|
||||
self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed, previousCodeType: previousCodeType)
|
||||
self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed, previousCodeType: previousCodeType, isPrevious: isPrevious)
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,10 +185,10 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
}
|
||||
}
|
||||
|
||||
public func updateData(number: String, email: String?, codeType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, termsOfService: (UnauthorizedAccountTermsOfService, Bool)?, previousCodeType: SentAuthorizationCodeType?) {
|
||||
public func updateData(number: String, email: String?, codeType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, termsOfService: (UnauthorizedAccountTermsOfService, Bool)?, previousCodeType: SentAuthorizationCodeType?, isPrevious: Bool) {
|
||||
self.termsOfService = termsOfService
|
||||
if self.data?.0 != number || self.data?.1 != email || self.data?.2 != codeType || self.data?.3 != nextType || self.data?.4 != timeout || self.data?.5 != previousCodeType {
|
||||
self.data = (number, email, codeType, nextType, timeout, previousCodeType)
|
||||
if self.data?.0 != number || self.data?.1 != email || self.data?.2 != codeType || self.data?.3 != nextType || self.data?.4 != timeout || self.data?.5 != previousCodeType || self.data?.6 != isPrevious {
|
||||
self.data = (number, email, codeType, nextType, timeout, previousCodeType, isPrevious)
|
||||
|
||||
var appleSignInAllowed = false
|
||||
if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType {
|
||||
@ -205,7 +196,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
}
|
||||
|
||||
if self.isNodeLoaded {
|
||||
self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed, previousCodeType: previousCodeType)
|
||||
self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed, previousCodeType: previousCodeType, isPrevious: isPrevious)
|
||||
self.requestLayout(transition: .immediate)
|
||||
}
|
||||
}
|
||||
@ -229,7 +220,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
|
||||
}
|
||||
|
||||
@objc private func nextPressed() {
|
||||
guard let (_, _, type, _, _, _) = self.data else {
|
||||
guard let (_, _, type, _, _, _, _) = self.data else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
private var appleSignInAllowed = false
|
||||
|
||||
private var previousCodeType: SentAuthorizationCodeType?
|
||||
private var isPrevious = false
|
||||
|
||||
var phoneNumber: String = "" {
|
||||
didSet {
|
||||
@ -403,11 +404,12 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
self.codeInputView.text = ""
|
||||
}
|
||||
|
||||
func updateData(number: String, email: String?, codeType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, appleSignInAllowed: Bool, previousCodeType: SentAuthorizationCodeType?) {
|
||||
func updateData(number: String, email: String?, codeType: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, appleSignInAllowed: Bool, previousCodeType: SentAuthorizationCodeType?, isPrevious: Bool) {
|
||||
self.codeType = codeType
|
||||
self.phoneNumber = number.replacingOccurrences(of: " ", with: "\u{00A0}").replacingOccurrences(of: "-", with: "\u{2011}")
|
||||
self.email = email
|
||||
self.previousCodeType = previousCodeType
|
||||
self.isPrevious = isPrevious
|
||||
|
||||
var appleSignInAllowed = appleSignInAllowed
|
||||
if #available(iOS 13.0, *) {
|
||||
@ -440,7 +442,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
if let strongSelf = self {
|
||||
if let currentTimeoutTime = strongSelf.currentTimeoutTime, currentTimeoutTime > 0 {
|
||||
strongSelf.currentTimeoutTime = currentTimeoutTime - 1
|
||||
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, previousCodeType: previousCodeType, timeout: strongSelf.currentTimeoutTime, strings: strongSelf.strings, primaryColor: strongSelf.theme.list.itemSecondaryTextColor, accentColor: strongSelf.theme.list.itemAccentColor)
|
||||
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, previousCodeType: isPrevious ? previousCodeType : nil, timeout: strongSelf.currentTimeoutTime, strings: strongSelf.strings, primaryColor: strongSelf.theme.list.itemSecondaryTextColor, accentColor: strongSelf.theme.list.itemAccentColor)
|
||||
strongSelf.nextOptionTitleNode.attributedText = nextOptionText
|
||||
strongSelf.nextOptionButtonNode.isUserInteractionEnabled = nextOptionActive
|
||||
strongSelf.nextOptionButtonNode.accessibilityLabel = nextOptionText.string
|
||||
@ -481,7 +483,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
self.countdownDisposable.set(nil)
|
||||
}
|
||||
|
||||
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, previousCodeType: previousCodeType, timeout: self.currentTimeoutTime, strings: self.strings, primaryColor: self.theme.list.itemSecondaryTextColor, accentColor: self.theme.list.itemAccentColor)
|
||||
let (nextOptionText, nextOptionActive) = authorizationNextOptionText(currentType: codeType, nextType: nextType, previousCodeType: isPrevious ? previousCodeType : nil, timeout: self.currentTimeoutTime, strings: self.strings, primaryColor: self.theme.list.itemSecondaryTextColor, accentColor: self.theme.list.itemAccentColor)
|
||||
self.nextOptionTitleNode.attributedText = nextOptionText
|
||||
self.nextOptionButtonNode.isUserInteractionEnabled = nextOptionActive
|
||||
self.nextOptionButtonNode.accessibilityLabel = nextOptionText.string
|
||||
@ -491,7 +493,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
self.nextOptionButtonNode.accessibilityTraits = [.button, .notEnabled]
|
||||
}
|
||||
|
||||
self.nextOptionArrowNode.isHidden = previousCodeType == nil
|
||||
self.nextOptionArrowNode.isHidden = previousCodeType == nil || !isPrevious
|
||||
|
||||
if let layoutArguments = self.layoutArguments {
|
||||
self.containerLayoutUpdated(layoutArguments.0, navigationBarHeight: layoutArguments.1, transition: .immediate)
|
||||
@ -801,7 +803,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
|
||||
if let codeType = self.codeType {
|
||||
let yOffset: CGFloat = layout.size.width > 320.0 ? 18.0 : 5.0
|
||||
if let previousCodeType = self.previousCodeType {
|
||||
if let previousCodeType = self.previousCodeType, !self.isPrevious {
|
||||
self.hintButtonNode.alpha = 1.0
|
||||
self.hintButtonNode.isUserInteractionEnabled = true
|
||||
|
||||
@ -817,8 +819,15 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
|
||||
|
||||
self.hintTextNode.attributedText = NSAttributedString(string: actionTitle, font: Font.regular(13.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center)
|
||||
|
||||
let originY: CGFloat
|
||||
if !self.codeInputView.isHidden {
|
||||
originY = self.codeInputView.frame.maxY + 6.0
|
||||
} else {
|
||||
originY = self.textField.frame.maxY
|
||||
}
|
||||
|
||||
let hintTextSize = self.hintTextNode.updateLayout(CGSize(width: layout.size.width - 48.0, height: .greatestFiniteMagnitude))
|
||||
transition.updateFrame(node: self.hintButtonNode, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - hintTextSize.width) / 2.0), y: self.codeInputView.frame.maxY + yOffset + 6.0), size: hintTextSize))
|
||||
transition.updateFrame(node: self.hintButtonNode, frame: CGRect(origin: CGPoint(x: floorToScreenPixels((layout.size.width - hintTextSize.width) / 2.0), y: originY + yOffset), size: hintTextSize))
|
||||
self.hintTextNode.frame = CGRect(origin: .zero, size: hintTextSize)
|
||||
|
||||
if let icon = self.hintArrowNode.image {
|
||||
|
@ -312,7 +312,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
return controller
|
||||
}
|
||||
|
||||
private func codeEntryController(number: String, phoneCodeHash: String, email: String?, type: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, previousCodeType: SentAuthorizationCodeType?, termsOfService: (UnauthorizedAccountTermsOfService, Bool)?) -> AuthorizationSequenceCodeEntryController {
|
||||
private func codeEntryController(number: String, phoneCodeHash: String, email: String?, type: SentAuthorizationCodeType, nextType: AuthorizationCodeNextType?, timeout: Int32?, previousCodeType: SentAuthorizationCodeType?, isPrevious: Bool, termsOfService: (UnauthorizedAccountTermsOfService, Bool)?) -> AuthorizationSequenceCodeEntryController {
|
||||
var currentController: AuthorizationSequenceCodeEntryController?
|
||||
for c in self.viewControllers {
|
||||
if let c = c as? AuthorizationSequenceCodeEntryController {
|
||||
@ -584,7 +584,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
}
|
||||
controller.requestNextOption = { [weak self, weak controller] in
|
||||
if let strongSelf = self {
|
||||
if previousCodeType != nil {
|
||||
if previousCodeType != nil && isPrevious {
|
||||
strongSelf.actionDisposable.set(togglePreviousCodeEntry(account: strongSelf.account).start())
|
||||
return
|
||||
}
|
||||
@ -672,7 +672,7 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
strongSelf.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
}
|
||||
controller.updateData(number: formatPhoneNumber(number), email: email, codeType: type, nextType: nextType, timeout: timeout, termsOfService: termsOfService, previousCodeType: previousCodeType)
|
||||
controller.updateData(number: formatPhoneNumber(number), email: email, codeType: type, nextType: nextType, timeout: timeout, termsOfService: termsOfService, previousCodeType: previousCodeType, isPrevious: isPrevious)
|
||||
return controller
|
||||
}
|
||||
|
||||
@ -1233,18 +1233,18 @@ public final class AuthorizationSequenceController: NavigationController, ASAuth
|
||||
}
|
||||
|
||||
if let previousCodeEntry, case let .confirmationCodeEntry(number, type, phoneCodeHash, timeout, nextType, _, _, _) = previousCodeEntry, usePrevious {
|
||||
controllers.append(self.codeEntryController(number: number, phoneCodeHash: phoneCodeHash, email: self.currentEmail, type: type, nextType: nextType, timeout: timeout, previousCodeType: type, termsOfService: nil))
|
||||
controllers.append(self.codeEntryController(number: number, phoneCodeHash: phoneCodeHash, email: self.currentEmail, type: type, nextType: nextType, timeout: timeout, previousCodeType: type, isPrevious: true, termsOfService: nil))
|
||||
isGoingBack = true
|
||||
} else {
|
||||
var previousCodeType: SentAuthorizationCodeType?
|
||||
if let previousCodeEntry, case let .confirmationCodeEntry(_, type, _, _, _, _, _, _) = previousCodeEntry {
|
||||
previousCodeType = type
|
||||
}
|
||||
controllers.append(self.codeEntryController(number: number, phoneCodeHash: phoneCodeHash, email: self.currentEmail, type: type, nextType: nextType, timeout: timeout, previousCodeType: previousCodeType, termsOfService: nil))
|
||||
controllers.append(self.codeEntryController(number: number, phoneCodeHash: phoneCodeHash, email: self.currentEmail, type: type, nextType: nextType, timeout: timeout, previousCodeType: previousCodeType, isPrevious: false, termsOfService: nil))
|
||||
}
|
||||
}
|
||||
|
||||
if isGoingBack, let currentLastController = self.viewControllers.last as? AuthorizationSequenceCodeEntryController, !currentLastController.isWordOrPhrase {
|
||||
if isGoingBack, let currentLastController = self.viewControllers.last as? AuthorizationSequenceCodeEntryController, !currentLastController.isPrevious {
|
||||
var tempControllers = controllers
|
||||
tempControllers.append(currentLastController)
|
||||
self.setViewControllers(tempControllers, animated: false)
|
||||
|
@ -3082,20 +3082,20 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
})))
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.StoryFeed_ViewAnonymously, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: self.context.isPremium ? "Chat/Context Menu/Eye" : "Chat/Context Menu/EyeLocked"), color: theme.contextMenu.primaryColor)
|
||||
}, action: { [weak self] _, a in
|
||||
a(.default)
|
||||
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
if self.context.isPremium {
|
||||
// self.sendMessageContext.requestStealthMode(view: self)
|
||||
} else {
|
||||
// self.presentStealthModeUpgradeScreen()
|
||||
}
|
||||
})))
|
||||
// items.append(.action(ContextMenuActionItem(text: presentationData.strings.StoryFeed_ViewAnonymously, icon: { theme in
|
||||
// return generateTintedImage(image: UIImage(bundleImageName: self.context.isPremium ? "Chat/Context Menu/Eye" : "Chat/Context Menu/EyeLocked"), color: theme.contextMenu.primaryColor)
|
||||
// }, action: { [weak self] _, a in
|
||||
// a(.default)
|
||||
//
|
||||
// guard let self else {
|
||||
// return
|
||||
// }
|
||||
// if self.context.isPremium {
|
||||
//// self.sendMessageContext.requestStealthMode(view: self)
|
||||
// } else {
|
||||
//// self.presentStealthModeUpgradeScreen()
|
||||
// }
|
||||
// })))
|
||||
|
||||
let hideText: String
|
||||
if self.location == .chatList(groupId: .archive) {
|
||||
|
@ -108,7 +108,7 @@ public func ChangePhoneNumberController(context: AccountContext) -> ViewControll
|
||||
codeController.openFragment = { url in
|
||||
context.sharedContext.applicationBindings.openUrl(url)
|
||||
}
|
||||
codeController.updateData(number: formatPhoneNumber(context: context, number: phoneNumber), email: nil, codeType: next.type, nextType: nil, timeout: next.timeout, termsOfService: nil, previousCodeType: nil)
|
||||
codeController.updateData(number: formatPhoneNumber(context: context, number: phoneNumber), email: nil, codeType: next.type, nextType: nil, timeout: next.timeout, termsOfService: nil, previousCodeType: nil, isPrevious: false)
|
||||
dismissImpl = { [weak codeController] in
|
||||
codeController?.dismiss()
|
||||
}
|
||||
|
@ -1446,7 +1446,7 @@ public func privacyAndSecurityController(
|
||||
emailChangeCompletion(codeController)
|
||||
}))
|
||||
}
|
||||
codeController.updateData(number: "", email: email, codeType: .email(emailPattern: "", length: data.length, resetAvailablePeriod: nil, resetPendingDate: nil, appleSignInAllowed: false, setup: true), nextType: nil, timeout: nil, termsOfService: nil, previousCodeType: nil)
|
||||
codeController.updateData(number: "", email: email, codeType: .email(emailPattern: "", length: data.length, resetAvailablePeriod: nil, resetPendingDate: nil, appleSignInAllowed: false, setup: true), nextType: nil, timeout: nil, termsOfService: nil, previousCodeType: nil, isPrevious: false)
|
||||
pushControllerImpl?(codeController, true)
|
||||
dismissCodeControllerImpl = { [weak codeController] in
|
||||
codeController?.dismiss()
|
||||
|
Loading…
x
Reference in New Issue
Block a user