mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
import Foundation
|
|
import SwiftSignalKit
|
|
import AsyncDisplayKit
|
|
import Display
|
|
|
|
class FormController<InnerState, Node: FormControllerNode<InnerState>>: ViewController {
|
|
var controllerNode: Node {
|
|
return self.displayNode as! Node
|
|
}
|
|
|
|
private var presentationData: PresentationData
|
|
|
|
private var didPlayPresentationAnimation = false
|
|
|
|
init(presentationData: PresentationData) {
|
|
self.presentationData = presentationData
|
|
|
|
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: presentationData))
|
|
|
|
self.statusBar.statusBarStyle = self.presentationData.theme.rootController.statusBar.style.style
|
|
}
|
|
|
|
required init(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
override func viewDidAppear(_ animated: Bool) {
|
|
super.viewDidAppear(animated)
|
|
|
|
if !self.didPlayPresentationAnimation {
|
|
self.didPlayPresentationAnimation = true
|
|
self.controllerNode.animateIn()
|
|
}
|
|
}
|
|
|
|
override func dismiss(completion: (() -> Void)? = nil) {
|
|
self.controllerNode.animateOut(completion: { [weak self] in
|
|
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
|
completion?()
|
|
})
|
|
}
|
|
|
|
override func loadDisplayNode() {
|
|
self.displayNode = Node(theme: self.presentationData.theme, strings: self.presentationData.strings)
|
|
|
|
self.displayNodeDidLoad()
|
|
}
|
|
|
|
override func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
|
super.containerLayoutUpdated(layout, transition: transition)
|
|
|
|
self.controllerNode.containerLayoutUpdated(layout, navigationHeight: self.navigationHeight, transition: transition)
|
|
}
|
|
}
|