mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
no message
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import Foundation
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
|
||||
final class AuthorizationSequencePasswordEntryController: ViewController {
|
||||
private var controllerNode: AuthorizationSequencePasswordEntryControllerNode {
|
||||
return self.displayNode as! AuthorizationSequencePasswordEntryControllerNode
|
||||
}
|
||||
|
||||
var loginWithPassword: ((String) -> Void)?
|
||||
var hint: String?
|
||||
|
||||
private let hapticFeedback = HapticFeedback()
|
||||
|
||||
var inProgress: Bool = false {
|
||||
didSet {
|
||||
if self.inProgress {
|
||||
let item = UIBarButtonItem(customDisplayNode: ProgressNavigationButtonNode())
|
||||
self.navigationItem.rightBarButtonItem = item
|
||||
} else {
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Next", style: .done, target: self, action: #selector(self.nextPressed))
|
||||
}
|
||||
self.controllerNode.inProgress = self.inProgress
|
||||
}
|
||||
}
|
||||
|
||||
override init(navigationBar: NavigationBar = NavigationBar()) {
|
||||
super.init(navigationBar: navigationBar)
|
||||
|
||||
self.navigationBar.backgroundColor = nil
|
||||
self.navigationBar.isOpaque = false
|
||||
self.navigationBar.stripeColor = UIColor.clear
|
||||
|
||||
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Next", style: .done, target: self, action: #selector(self.nextPressed))
|
||||
}
|
||||
|
||||
required init(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override public func loadDisplayNode() {
|
||||
self.displayNode = AuthorizationSequencePasswordEntryControllerNode()
|
||||
self.displayNodeDidLoad()
|
||||
|
||||
if let hint = self.hint {
|
||||
self.controllerNode.updateData(hint: hint)
|
||||
}
|
||||
}
|
||||
|
||||
override func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
self.controllerNode.activateInput()
|
||||
}
|
||||
|
||||
func updateData(hint: String) {
|
||||
if self.hint != hint {
|
||||
self.hint = hint
|
||||
if self.isNodeLoaded {
|
||||
self.controllerNode.updateData(hint: hint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
||||
super.containerLayoutUpdated(layout, transition: transition)
|
||||
|
||||
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: 0.0, transition: transition)
|
||||
}
|
||||
|
||||
@objc func nextPressed() {
|
||||
if self.controllerNode.currentPassword.isEmpty {
|
||||
hapticFeedback.error()
|
||||
self.controllerNode.animateError()
|
||||
} else {
|
||||
self.loginWithPassword?(self.controllerNode.currentPassword)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user