Fix build

This commit is contained in:
Ilya Laktyushin 2023-03-08 13:57:22 +04:00
parent 4c5f4c9590
commit 685b0a765c
7 changed files with 56 additions and 15 deletions

View File

@ -23,6 +23,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
var reset: (() -> Void)? var reset: (() -> Void)?
var requestNextOption: (() -> Void)? var requestNextOption: (() -> Void)?
var resetEmail: (() -> Void)?
var data: (String, String?, SentAuthorizationCodeType, AuthorizationCodeNextType?, Int32?)? var data: (String, String?, SentAuthorizationCodeType, AuthorizationCodeNextType?, Int32?)?
var termsOfService: (UnauthorizedAccountTermsOfService, Bool)? var termsOfService: (UnauthorizedAccountTermsOfService, Bool)?
@ -109,13 +110,17 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
self?.navigationItem.rightBarButtonItem?.isEnabled = value self?.navigationItem.rightBarButtonItem?.isEnabled = value
} }
self.controllerNode.reset = { [weak self] in
self?.resetEmail?()
}
self.controllerNode.present = { [weak self] c, a in self.controllerNode.present = { [weak self] c, a in
self?.present(c, in: .window(.root), with: a) self?.present(c, in: .window(.root), with: a)
} }
if let (number, email, codeType, nextType, timeout) = self.data { if let (number, email, codeType, nextType, timeout) = self.data {
var appleSignInAllowed = false var appleSignInAllowed = false
if case let .email(_, _, _, appleSignInAllowedValue, _) = codeType { if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType {
appleSignInAllowed = appleSignInAllowedValue appleSignInAllowed = appleSignInAllowedValue
} }
self.controllerNode.updateData(number: number, email: email, codeType: codeType, nextType: nextType, timeout: timeout, appleSignInAllowed: appleSignInAllowed) 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) self.data = (number, email, codeType, nextType, timeout)
var appleSignInAllowed = false var appleSignInAllowed = false
if case let .email(_, _, _, appleSignInAllowedValue, _) = codeType { if case let .email(_, _, _, _, appleSignInAllowedValue, _) = codeType {
appleSignInAllowed = appleSignInAllowedValue appleSignInAllowed = appleSignInAllowedValue
} }
@ -204,7 +209,7 @@ public final class AuthorizationSequenceCodeEntryController: ViewController {
minimalCodeLength = Int(length) minimalCodeLength = Int(length)
case let .missedCall(_, length): case let .missedCall(_, length):
minimalCodeLength = Int(length) minimalCodeLength = Int(length)
case let .email(_, length, _, _, _): case let .email(_, length, _, _, _, _):
minimalCodeLength = Int(length) minimalCodeLength = Int(length)
case let .fragment(_, length): case let .fragment(_, length):
minimalCodeLength = Int(length) minimalCodeLength = Int(length)

View File

@ -33,6 +33,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
private let nextOptionTitleNode: ImmediateTextNode private let nextOptionTitleNode: ImmediateTextNode
private let nextOptionButtonNode: HighlightableButtonNode private let nextOptionButtonNode: HighlightableButtonNode
private let resetNode: HighlightableButtonNode
private let dividerNode: AuthorizationDividerNode private let dividerNode: AuthorizationDividerNode
private var signInWithAppleButton: UIControl? private var signInWithAppleButton: UIControl?
private let proceedNode: SolidRoundedButtonNode private let proceedNode: SolidRoundedButtonNode
@ -73,6 +75,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
var requestNextOption: (() -> Void)? var requestNextOption: (() -> Void)?
var requestAnotherOption: (() -> Void)? var requestAnotherOption: (() -> Void)?
var updateNextEnabled: ((Bool) -> Void)? var updateNextEnabled: ((Bool) -> Void)?
var reset: (() -> Void)?
var inProgress: Bool = false { var inProgress: Bool = false {
didSet { didSet {
@ -151,6 +154,11 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.errorTextNode.displaysAsynchronously = false self.errorTextNode.displaysAsynchronously = false
self.errorTextNode.textAlignment = .center 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) self.dividerNode = AuthorizationDividerNode(theme: self.theme, strings: self.strings)
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
@ -181,6 +189,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self.addSubnode(self.currentOptionInfoNode) self.addSubnode(self.currentOptionInfoNode)
self.addSubnode(self.nextOptionButtonNode) self.addSubnode(self.nextOptionButtonNode)
self.addSubnode(self.animationNode) self.addSubnode(self.animationNode)
self.addSubnode(self.resetNode)
self.addSubnode(self.dividerNode) self.addSubnode(self.dividerNode)
self.addSubnode(self.errorTextNode) self.addSubnode(self.errorTextNode)
self.addSubnode(self.proceedNode) self.addSubnode(self.proceedNode)
@ -225,6 +234,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
self?.proceedPressed() self?.proceedPressed()
} }
self.signInWithAppleButton?.addTarget(self, action: #selector(self.signInWithApplePressed), for: .touchUpInside) self.signInWithAppleButton?.addTarget(self, action: #selector(self.signInWithApplePressed), for: .touchUpInside)
self.resetNode.addTarget(self, action: #selector(self.resetPressed), forControlEvents: .touchUpInside)
} }
deinit { deinit {
@ -408,6 +418,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
let currentOptionSize = self.currentOptionNode.updateLayout(CGSize(width: maximumWidth - 48.0, height: CGFloat.greatestFiniteMagnitude)) 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 currentOptionInfoSize = self.currentOptionInfoNode.measure(CGSize(width: maximumWidth - 48.0, height: CGFloat.greatestFiniteMagnitude))
let nextOptionSize = self.nextOptionTitleNode.updateLayout(CGSize(width: maximumWidth, 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 proceedHeight = self.proceedNode.updateLayout(width: maximumWidth - inset * 2.0, transition: transition)
let proceedSize = CGSize(width: maximumWidth - inset * 2.0, height: proceedHeight) let proceedSize = CGSize(width: maximumWidth - inset * 2.0, height: proceedHeight)
@ -430,7 +441,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
codeLength = Int(length) codeLength = Int(length)
case let .sms(length): case let .sms(length):
codeLength = Int(length) codeLength = Int(length)
case let .email(_, length, _, _, _): case let .email(_, length, _, _, _, _):
codeLength = Int(length) codeLength = Int(length)
case let .fragment(_, length): case let .fragment(_, length):
codeLength = Int(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.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.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 let inset: CGFloat = 24.0
if case .fragment = codeType { if case .fragment = codeType {
@ -624,7 +647,7 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
codeLength = length codeLength = length
case let .sms(length): case let .sms(length):
codeLength = length codeLength = length
case let .email(_, length, _, _, _): case let .email(_, length, _, _, _, _):
codeLength = length codeLength = length
case let .fragment(_, length): case let .fragment(_, length):
codeLength = length codeLength = length
@ -673,4 +696,8 @@ final class AuthorizationSequenceCodeEntryControllerNode: ASDisplayNode, UITextF
@objc func signInWithApplePressed() { @objc func signInWithApplePressed() {
self.signInWithApple?() self.signInWithApple?()
} }
@objc func resetPressed() {
self.reset?()
}
} }

View File

@ -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() 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 controller.loginWithCode = { [weak self, weak controller] code in
if let strongSelf = self { if let strongSelf = self {
controller?.inProgress = true controller?.inProgress = true
@ -314,7 +317,7 @@ public final class AuthorizationSequenceController: NavigationController, MFMail
authorizationCode = .phoneCode(code) 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)) strongSelf.actionDisposable.set(((verifyLoginEmailSetup(account: strongSelf.account, code: emailCode))
|> deliverOnMainQueue).start(error: { error in |> deliverOnMainQueue).start(error: { error in
Queue.mainQueue().async { Queue.mainQueue().async {

View File

@ -27,7 +27,7 @@ public func authorizationCurrentOptionText(_ type: SentAuthorizationCodeType, ph
return parseMarkdownIntoAttributedString(strings.Login_CodeSentCallText(phoneNumber).string, attributes: attributes, textAlignment: .center) return parseMarkdownIntoAttributedString(strings.Login_CodeSentCallText(phoneNumber).string, attributes: attributes, textAlignment: .center)
case .emailSetupRequired: case .emailSetupRequired:
return NSAttributedString(string: "", font: Font.regular(fontSize), textColor: primaryColor, paragraphAlignment: .center) 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 mutableString = NSAttributedString(string: strings.Login_EnterCodeEmailText(email ?? emailPattern).string, font: Font.regular(fontSize), textColor: primaryColor, paragraphAlignment: .center).mutableCopy() as! NSMutableAttributedString
let string = mutableString.string let string = mutableString.string

View File

@ -417,7 +417,7 @@ private final class BlurredGradientComponent: Component {
self.gradientMask.image = generateGradientImage( self.gradientMask.image = generateGradientImage(
size: CGSize(width: 1.0, height: availableSize.height), 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)], 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 direction: .vertical
) )
@ -1063,7 +1063,7 @@ private final class DrawingScreenComponent: CombinedComponent {
position: .top, position: .top,
tag: topGradientTag tag: topGradientTag
), ),
availableSize: CGSize(width: context.availableSize.width, height: topInset + 10.0), availableSize: CGSize(width: context.availableSize.width, height: topInset + 15.0),
transition: .immediate transition: .immediate
) )
context.add(topGradient context.add(topGradient

View File

@ -1279,7 +1279,7 @@ public func privacyAndSecurityController(
emailChangeCompletion(codeController) 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) pushControllerImpl?(codeController, true)
dismissCodeControllerImpl = { [weak codeController] in dismissCodeControllerImpl = { [weak codeController] in
codeController?.dismiss() codeController?.dismiss()

View File

@ -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 addStickerPackImpl = { [weak self] info, items in
guard let strongSelf = self else { guard let strongSelf = self else {
@ -1764,6 +1764,7 @@ private final class StickerPackScreenNode: ViewControllerTracingNode {
public final class StickerPackScreenImpl: ViewController { public final class StickerPackScreenImpl: ViewController {
private let context: AccountContext private let context: AccountContext
fileprivate var presentationData: PresentationData fileprivate var presentationData: PresentationData
private let updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)?
private var presentationDataDisposable: Disposable? private var presentationDataDisposable: Disposable?
private let stickerPacks: [StickerPackReference] private let stickerPacks: [StickerPackReference]
@ -1807,6 +1808,7 @@ public final class StickerPackScreenImpl: ViewController {
) { ) {
self.context = context self.context = context
self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 } self.presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
self.updatedPresentationData = updatedPresentationData
self.stickerPacks = stickerPacks self.stickerPacks = stickerPacks
self.loadedStickerPacks = loadedStickerPacks self.loadedStickerPacks = loadedStickerPacks
self.initialSelectedStickerPackIndex = selectedStickerPackIndex self.initialSelectedStickerPackIndex = selectedStickerPackIndex
@ -1919,9 +1921,13 @@ public final class StickerPackScreenImpl: ViewController {
guard let strongSelf = self else { guard let strongSelf = self else {
return return
} }
if let peer = peer, let parentNavigationController = strongSelf.parentNavigationController { if let peer {
strongSelf.dismiss() if let parentNavigationController = strongSelf.parentNavigationController {
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: parentNavigationController, context: strongSelf.context, chatLocation: .peer(EnginePeer(peer)), animated: true)) 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))
} }
})) }))
}) })