diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryController.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryController.swift index 3a784baaa2..3fadad96f8 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryController.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryController.swift @@ -23,6 +23,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController { var reset: (() -> Void)? var requestNextOption: (() -> Void)? + var resetEmail: (() -> Void)? var data: (String, String?, SentAuthorizationCodeType, AuthorizationCodeNextType?, Int32?)? var termsOfService: (UnauthorizedAccountTermsOfService, Bool)? @@ -109,13 +110,17 @@ public final class AuthorizationSequenceCodeEntryController: ViewController { self?.navigationItem.rightBarButtonItem?.isEnabled = value } + self.controllerNode.reset = { [weak self] in + self?.resetEmail?() + } + self.controllerNode.present = { [weak self] c, a in self?.present(c, in: .window(.root), with: a) } if let (number, email, codeType, nextType, timeout) = self.data { var appleSignInAllowed = false - if case let .email(_, _, _, appleSignInAllowedValue, _) = codeType { + if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType { appleSignInAllowed = appleSignInAllowedValue } self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed) @@ -164,7 +169,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController { self.data = (number, email, codeType, nextType, timeout) var appleSignInAllowed = false - if case let .email(_, _, _, appleSignInAllowedValue, _) = codeType { + if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType { appleSignInAllowed = appleSignInAllowedValue } @@ -204,7 +209,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController { minimalCodeLength = Int(length) case let .missedCall(_, length): minimalCodeLength = Int(length) - case let .email(_, length, _, _, _): + case let .email(_, length, _, _, _, _): minimalCodeLength = Int(length) case let .fragment(_, length): minimalCodeLength = Int(length) diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryControllerNode.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryControllerNode.swift index 3c4d45d3fb..b06c675684 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryControllerNode.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequenceCodeEntryControllerNode.swift @@ -33,6 +33,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF private let nextOptionTitleNode: ImmediateTextNode private let nextOptionButtonNode: HighlightableButtonNode + private let resetNode: HighlightableButtonNode + private let dividerNode: AuthorizationDividerNode private var signInWithAppleButton: UIControl? private let proceedNode: SolidRoundedButtonNode @@ -73,6 +75,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF var requestNextOption: (() -> Void)? var requestAnotherOption: (() -> Void)? var updateNextEnabled: ((Bool) -> Void)? + var reset: (() -> Void)? var inProgress: Bool = false { didSet { @@ -151,6 +154,11 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF self.errorTextNode.displaysAsynchronously = false self.errorTextNode.textAlignment = .center + self.resetNode = HighlightableButtonNode() + self.resetNode.displaysAsynchronously = false + self.resetNode.setAttributedTitle(NSAttributedString(string: self.strings.Login_Email_CantAccess, font: Font.regular(17.0), textColor: self.theme.list.itemAccentColor, paragraphAlignment: .center), for: []) + self.resetNode.isHidden = true + self.dividerNode = AuthorizationDividerNode(theme: self.theme, strings: self.strings) if #available(iOS 13.0, *) { @@ -181,6 +189,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF self.addSubnode(self.currentOptionInfoNode) self.addSubnode(self.nextOptionButtonNode) self.addSubnode(self.animationNode) + self.addSubnode(self.resetNode) self.addSubnode(self.dividerNode) self.addSubnode(self.errorTextNode) self.addSubnode(self.proceedNode) @@ -225,6 +234,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF self?.proceedPressed() } self.signInWithAppleButton?.addTarget(self, action: #selector(self.signInWithApplePressed), for: .touchUpInside) + self.resetNode.addTarget(self, action: #selector(self.resetPressed), forControlEvents: .touchUpInside) } deinit { @@ -408,6 +418,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF let currentOptionSize = self.currentOptionNode.updateLayout(CGSize(width: maximumWidth - 48.0, height: CGFloat.greatestFiniteMagnitude)) let currentOptionInfoSize = self.currentOptionInfoNode.measure(CGSize(width: maximumWidth - 48.0, height: CGFloat.greatestFiniteMagnitude)) let nextOptionSize = self.nextOptionTitleNode.updateLayout(CGSize(width: maximumWidth, height: CGFloat.greatestFiniteMagnitude)) + let resetSize = self.resetNode.measure(CGSize(width: maximumWidth, height: CGFloat.greatestFiniteMagnitude)) let proceedHeight = self.proceedNode.updateLayout(width: maximumWidth - inset * 2.0, transition: transition) let proceedSize = CGSize(width: maximumWidth - inset * 2.0, height: proceedHeight) @@ -430,7 +441,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF codeLength = Int(length) case let .sms(length): codeLength = Int(length) - case let .email(_, length, _, _, _): + case let .email(_, length, _, _, _, _): codeLength = Int(length) case let .fragment(_, length): codeLength = Int(length) @@ -503,7 +514,19 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF items.append(AuthorizationLayoutItem(node: self.titleNode, size: titleSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 18.0, maxValue: 18.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0))) items.append(AuthorizationLayoutItem(node: self.currentOptionNode, size: currentOptionSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 18.0, maxValue: 18.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 0.0, maxValue: 0.0))) - items.append(AuthorizationLayoutItem(node: self.codeInputView, size: codeFieldSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 30.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 104.0, maxValue: 104.0))) + var canReset = false + if case let .email(_, _, resetPeriod, _, _, setup) = codeType, !setup && resetPeriod != nil { + canReset = true + } + + items.append(AuthorizationLayoutItem(node: self.codeInputView, size: codeFieldSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 30.0, maxValue: 30.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: canReset ? 0.0 : 104.0, maxValue: canReset ? 0.0 : 104.0))) + + if canReset { + self.resetNode.isHidden = false + items.append(AuthorizationLayoutItem(node: self.resetNode, size: resetSize, spacingBefore: AuthorizationLayoutItemSpacing(weight: 36.0, maxValue: 36.0), spacingAfter: AuthorizationLayoutItemSpacing(weight: 104.0, maxValue: 104.0))) + } else { + self.resetNode.isHidden = true + } let inset: CGFloat = 24.0 if case .fragment = codeType { @@ -624,7 +647,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF codeLength = length case let .sms(length): codeLength = length - case let .email(_, length, _, _, _): + case let .email(_, length, _, _, _, _): codeLength = length case let .fragment(_, length): codeLength = length @@ -673,4 +696,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF @objc func signInWithApplePressed() { self.signInWithApple?() } + + @objc func resetPressed() { + self.reset?() + } } diff --git a/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift b/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift index c9ce3a87d3..34a84c65fa 100644 --- a/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift +++ b/submodules/AuthorizationUI/Sources/AuthorizationSequenceController.swift @@ -302,6 +302,9 @@ public final class AuthorizationSequenceController: NavigationController, MFMail let _ = TelegramEngineUnauthorized(account: strongSelf.account).auth.setState(state: UnauthorizedAccountState(isTestingEnvironment: strongSelf.account.testingEnvironment, masterDatacenterId: strongSelf.account.masterDatacenterId, contents: .phoneEntry(countryCode: countryCode, number: ""))).start() }) + controller.resetEmail = { + + } controller.loginWithCode = { [weak self, weak controller] code in if let strongSelf = self { controller?.inProgress = true @@ -314,7 +317,7 @@ public final class AuthorizationSequenceController: NavigationController, MFMail authorizationCode = .phoneCode(code) } - if case let .email(_, _, _, _, setup) = type, setup, case let .emailVerification(emailCode) = authorizationCode { + if case let .email(_, _, _, _, _, setup) = type, setup, case let .emailVerification(emailCode) = authorizationCode { strongSelf.actionDisposable.set(((verifyLoginEmailSetup(account: strongSelf.account, code: emailCode)) |> deliverOnMainQueue).start(error: { error in Queue.mainQueue().async { diff --git a/submodules/AuthorizationUtils/Sources/AuthorizationOptionText.swift b/submodules/AuthorizationUtils/Sources/AuthorizationOptionText.swift index b4b4b66532..48308e3d26 100644 --- a/submodules/AuthorizationUtils/Sources/AuthorizationOptionText.swift +++ b/submodules/AuthorizationUtils/Sources/AuthorizationOptionText.swift @@ -27,7 +27,7 @@ public func authorizationCurrentOptionText(_ type: SentAuthorizationCodeType, ph return parseMarkdownIntoAttributedString(strings.Login_CodeSentCallText(phoneNumber).string, attributes: attributes, textAlignment: .center) case .emailSetupRequired: return NSAttributedString(string: "", font: Font.regular(fontSize), textColor: primaryColor, paragraphAlignment: .center) - case let .email(emailPattern, _, _, _, _): + case let .email(emailPattern, _, _, _, _, _): let mutableString = NSAttributedString(string: strings.Login_EnterCodeEmailText(email ?? emailPattern).string, font: Font.regular(fontSize), textColor: primaryColor, paragraphAlignment: .center).mutableCopy() as! NSMutableAttributedString let string = mutableString.string diff --git a/submodules/DrawingUI/Sources/DrawingScreen.swift b/submodules/DrawingUI/Sources/DrawingScreen.swift index 995cdc3864..0a9e719b8d 100644 --- a/submodules/DrawingUI/Sources/DrawingScreen.swift +++ b/submodules/DrawingUI/Sources/DrawingScreen.swift @@ -417,7 +417,7 @@ private final class BlurredGradientComponent: Component { self.gradientMask.image = generateGradientImage( size: CGSize(width: 1.0, height: availableSize.height), colors: [UIColor(rgb: 0xffffff, alpha: 1.0), UIColor(rgb: 0xffffff, alpha: 1.0), UIColor(rgb: 0xffffff, alpha: 0.0)], - locations: component.position == .top ? [0.0, 0.5, 1.0] : [1.0, 0.5, 0.0], + locations: component.position == .top ? [0.0, 0.8, 1.0] : [1.0, 0.5, 0.0], direction: .vertical ) @@ -1063,7 +1063,7 @@ private final class DrawingScreenComponent: CombinedComponent { position: .top, tag: topGradientTag ), - availableSize: CGSize(width: context.availableSize.width, height: topInset + 10.0), + availableSize: CGSize(width: context.availableSize.width, height: topInset + 15.0), transition: .immediate ) context.add(topGradient diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift index efa3ed0b0e..baa60b8a18 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift @@ -1279,7 +1279,7 @@ public func privacyAndSecurityController( emailChangeCompletion(codeController) })) } - codeController.updateData(number: "", email: email, codeType: .email(emailPattern: "", length: data.length, nextPhoneLoginDate: nil, appleSignInAllowed: false, setup: true), nextType: nil, timeout: nil, termsOfService: 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) pushControllerImpl?(codeController, true) dismissCodeControllerImpl = { [weak codeController] in codeController?.dismiss() diff --git a/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift b/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift index fc15348b78..3a3700f15f 100644 --- a/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift +++ b/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift @@ -390,7 +390,7 @@ private final class StickerPackContainer: ASDisplayNode { } } - self.titleNode.linkHighlightColor = self.presentationData.theme.actionSheet.controlAccentColor.withAlphaComponent(0.5) + self.titleNode.linkHighlightColor = self.presentationData.theme.actionSheet.controlAccentColor.withAlphaComponent(0.2) addStickerPackImpl = { [weak self] info, items in guard let strongSelf = self else { @@ -1764,6 +1764,7 @@ private final class StickerPackScreenNode: ViewControllerTracingNode { public final class StickerPackScreenImpl: ViewController { private let context: AccountContext fileprivate var presentationData: PresentationData + private let updatedPresentationData: (initial: PresentationData, signal: Signal)? private var presentationDataDisposable: Disposable? private let stickerPacks: [StickerPackReference] @@ -1807,6 +1808,7 @@ public final class StickerPackScreenImpl: ViewController { ) { self.context = context self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } + self.updatedPresentationData = updatedPresentationData self.stickerPacks = stickerPacks self.loadedStickerPacks = loadedStickerPacks self.initialSelectedStickerPackIndex = selectedStickerPackIndex @@ -1919,9 +1921,13 @@ public final class StickerPackScreenImpl: ViewController { guard let strongSelf = self else { return } - if let peer = peer, let parentNavigationController = strongSelf.parentNavigationController { - strongSelf.dismiss() - strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: parentNavigationController, context: strongSelf.context, chatLocation: .peer(EnginePeer(peer)), animated: true)) + if let peer { + if let parentNavigationController = strongSelf.parentNavigationController { + strongSelf.dismiss() + strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: parentNavigationController, context: strongSelf.context, chatLocation: .peer(EnginePeer(peer)), animated: true)) + } + } else { + strongSelf.present(textAlertController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, title: nil, text: strongSelf.presentationData.strings.Resolve_ErrorNotFound, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root)) } })) })