mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-26 15:31:12 +00:00
62 lines
1.9 KiB
Swift
62 lines
1.9 KiB
Swift
import Foundation
|
|
|
|
open class ActionSheetController: ViewController {
|
|
private var actionSheetNode: ActionSheetControllerNode {
|
|
return self.displayNode as! ActionSheetControllerNode
|
|
}
|
|
|
|
private let theme: ActionSheetControllerTheme
|
|
|
|
private var groups: [ActionSheetItemGroup] = []
|
|
|
|
public init(theme: ActionSheetControllerTheme) {
|
|
self.theme = theme
|
|
|
|
super.init(navigationBarPresentationData: nil)
|
|
}
|
|
|
|
required public init(coder aDecoder: NSCoder) {
|
|
fatalError("init(coder:) has not been implemented")
|
|
}
|
|
|
|
public func dismissAnimated() {
|
|
self.actionSheetNode.animateOut()
|
|
}
|
|
|
|
open override func loadDisplayNode() {
|
|
self.displayNode = ActionSheetControllerNode(theme: self.theme)
|
|
self.displayNodeDidLoad()
|
|
|
|
self.actionSheetNode.dismiss = { [weak self] in
|
|
self?.presentingViewController?.dismiss(animated: false)
|
|
}
|
|
|
|
self.actionSheetNode.setGroups(self.groups)
|
|
}
|
|
|
|
override open func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
|
|
super.containerLayoutUpdated(layout, transition: transition)
|
|
|
|
self.actionSheetNode.containerLayoutUpdated(layout, transition: transition)
|
|
}
|
|
|
|
open override func viewWillAppear(_ animated: Bool) {
|
|
super.viewWillAppear(animated)
|
|
|
|
self.actionSheetNode.animateIn()
|
|
}
|
|
|
|
public func setItemGroups(_ groups: [ActionSheetItemGroup]) {
|
|
self.groups = groups
|
|
if self.isViewLoaded {
|
|
self.actionSheetNode.setGroups(groups)
|
|
}
|
|
}
|
|
|
|
public func updateItem(groupIndex: Int, itemIndex: Int, _ f: (ActionSheetItem) -> ActionSheetItem) {
|
|
if self.isViewLoaded {
|
|
self.actionSheetNode.updateItem(groupIndex: groupIndex, itemIndex: itemIndex, f)
|
|
}
|
|
}
|
|
}
|