@@ -15,6 +15,7 @@ import TelegramAnimatedStickerNode
1515import SolidRoundedButtonNode
1616import AuthorizationUtils
1717import ManagedAnimationNode
18+ import Markdown
1819
1920private final class PhoneAndCountryNode : ASDisplayNode {
2021 let strings : PresentationStrings
@@ -312,7 +313,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
312313 private let managedAnimationNode : ManagedPhoneAnimationNode
313314 private let titleNode : ASTextNode
314315 private let titleActivateAreaNode : AccessibilityAreaNode
315- private let noticeNode : ASTextNode
316+ private let noticeNode : ImmediateTextNode
316317 private let noticeActivateAreaNode : AccessibilityAreaNode
317318 private let phoneAndCountryNode : PhoneAndCountryNode
318319 private let contactSyncNode : ContactSyncNode
@@ -323,6 +324,8 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
323324 private let tokenEventsDisposable = MetaDisposable ( )
324325 var accountUpdated : ( ( UnauthorizedAccount ) -> Void ) ?
325326
327+ var retryPasskey : ( ( ) -> Void ) ?
328+
326329 private let debugAction : ( ) -> Void
327330
328331 var currentNumber : String {
@@ -405,7 +408,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
405408 self . titleActivateAreaNode = AccessibilityAreaNode ( )
406409 self . titleActivateAreaNode. accessibilityTraits = . staticText
407410
408- self . noticeNode = ASTextNode ( )
411+ self . noticeNode = ImmediateTextNode ( )
409412 self . noticeNode. maximumNumberOfLines = 0
410413 self . noticeNode. isUserInteractionEnabled = true
411414 self . noticeNode. displaysAsynchronously = false
@@ -443,6 +446,23 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
443446 self . addSubnode ( self . managedAnimationNode)
444447 self . contactSyncNode. isHidden = true
445448
449+ self . noticeNode. highlightAttributeAction = { attributes in
450+ if let _ = attributes [ NSAttributedString . Key ( rawValue: " URL " ) ] {
451+ return NSAttributedString . Key ( rawValue: " URL " )
452+ } else {
453+ return nil
454+ }
455+ }
456+ self . noticeNode. tapAttributeAction = { [ weak self] attributes, _ in
457+ guard let self else {
458+ return
459+ }
460+ if let _ = attributes [ NSAttributedString . Key ( rawValue: " URL " ) ] as? String {
461+ self . retryPasskey ? ( )
462+ }
463+ }
464+ self . noticeNode. linkHighlightColor = theme. list. itemAccentColor. withAlphaComponent ( 0.2 )
465+
446466 self . phoneAndCountryNode. selectCountryCode = { [ weak self] in
447467 self ? . selectCountryCode ? ( )
448468 }
@@ -484,7 +504,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
484504 super. didLoad ( )
485505
486506 self . titleNode. view. addGestureRecognizer ( UITapGestureRecognizer ( target: self , action: #selector( self . debugTap ( _: ) ) ) )
487- #if DEBUG
507+ #if DEBUG && false
488508 self . noticeNode. view. addGestureRecognizer ( UITapGestureRecognizer ( target: self , action: #selector( self . debugQrTap ( _: ) ) ) )
489509 #endif
490510 }
@@ -555,6 +575,28 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
555575 let _ = self . phoneAndCountryNode. processNumberChange ( number: self . phoneAndCountryNode. phoneInputNode. number)
556576 }
557577
578+ func updateDisplayPasskeyLoginOption( ) {
579+ //TODO:localize
580+ if self . account == nil {
581+ return
582+ }
583+ let attributedText = NSMutableAttributedString ( attributedString: parseMarkdownIntoAttributedString ( " Enter your phone number \n or [log in using Passkey >](passkey) " , attributes: MarkdownAttributes (
584+ body: MarkdownAttributeSet ( font: Font . regular ( 17.0 ) , textColor: self . theme. list. itemPrimaryTextColor) ,
585+ bold: MarkdownAttributeSet ( font: Font . semibold ( 17.0 ) , textColor: self . theme. list. itemPrimaryTextColor) ,
586+ link: MarkdownAttributeSet ( font: Font . regular ( 17.0 ) , textColor: self . theme. list. itemAccentColor) ,
587+ linkAttribute: { url in
588+ return ( " URL " , url)
589+ }
590+ ) ) )
591+ let chevronImage = generateTintedImage ( image: UIImage ( bundleImageName: " Item List/InlineTextRightArrow " ) , color: self . theme. list. itemAccentColor)
592+
593+ if let range = attributedText. string. range ( of: " > " ) , let chevronImage {
594+ attributedText. addAttribute ( . attachment, value: chevronImage, range: NSRange ( range, in: attributedText. string) )
595+ }
596+
597+ self . noticeNode. attributedText = attributedText
598+ }
599+
558600 func containerLayoutUpdated( _ layout: ContainerViewLayout , navigationBarHeight: CGFloat , transition: ContainedViewLayoutTransition ) {
559601 var insets = layout. insets ( options: [ ] )
560602 insets. top = layout. statusBarHeight ?? 20.0
@@ -576,7 +618,7 @@ final class AuthorizationSequencePhoneEntryControllerNode: ASDisplayNode {
576618
577619 let noticeInset : CGFloat = self . account == nil ? 32.0 : 0.0
578620
579- let noticeSize = self . noticeNode. measure ( CGSize ( width: min ( 274.0 + noticeInset, maximumWidth - 28.0 ) , height: CGFloat . greatestFiniteMagnitude) )
621+ let noticeSize = self . noticeNode. updateLayout ( CGSize ( width: min ( 274.0 + noticeInset, maximumWidth - 28.0 ) , height: CGFloat . greatestFiniteMagnitude) )
580622 let proceedHeight = self . proceedNode. updateLayout ( width: maximumWidth - inset * 2.0 , transition: transition)
581623 let proceedSize = CGSize ( width: maximumWidth - inset * 2.0 , height: proceedHeight)
582624
0 commit comments