mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-17 20:00:38 +00:00
ActionSheetController: added dismissed API
This commit is contained in:
parent
275fd01964
commit
e065d5af3f
@ -17,6 +17,8 @@ open class ActionSheetController: ViewController {
|
|||||||
|
|
||||||
private var isDismissed: Bool = false
|
private var isDismissed: Bool = false
|
||||||
|
|
||||||
|
public var dismissed: ((Bool) -> Void)?
|
||||||
|
|
||||||
public init(theme: ActionSheetControllerTheme) {
|
public init(theme: ActionSheetControllerTheme) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
|
|
||||||
@ -30,7 +32,7 @@ open class ActionSheetController: ViewController {
|
|||||||
public func dismissAnimated() {
|
public func dismissAnimated() {
|
||||||
if !self.isDismissed {
|
if !self.isDismissed {
|
||||||
self.isDismissed = true
|
self.isDismissed = true
|
||||||
self.actionSheetNode.animateOut()
|
self.actionSheetNode.animateOut(cancelled: false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +40,8 @@ open class ActionSheetController: ViewController {
|
|||||||
self.displayNode = ActionSheetControllerNode(theme: self.theme)
|
self.displayNode = ActionSheetControllerNode(theme: self.theme)
|
||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
|
|
||||||
self.actionSheetNode.dismiss = { [weak self] in
|
self.actionSheetNode.dismiss = { [weak self] cancelled in
|
||||||
|
self?.dismissed?(cancelled)
|
||||||
self?.presentingViewController?.dismiss(animated: false)
|
self?.presentingViewController?.dismiss(animated: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -28,7 +28,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
|
|
||||||
private let scrollView: UIScrollView
|
private let scrollView: UIScrollView
|
||||||
|
|
||||||
var dismiss: () -> Void = { }
|
var dismiss: (Bool) -> Void = { _ in }
|
||||||
|
|
||||||
private var validLayout: ContainerViewLayout?
|
private var validLayout: ContainerViewLayout?
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func animateOut() {
|
func animateOut(cancelled: Bool) {
|
||||||
let tempDimView = UIView()
|
let tempDimView = UIView()
|
||||||
tempDimView.backgroundColor = self.theme.dimColor
|
tempDimView.backgroundColor = self.theme.dimColor
|
||||||
tempDimView.frame = self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height)
|
tempDimView.frame = self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height)
|
||||||
@ -141,7 +141,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
self.layer.animateBounds(from: self.bounds, to: self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height), duration: 0.35, timingFunction: kCAMediaTimingFunctionEaseOut, removeOnCompletion: false, completion: { [weak self, weak tempDimView] _ in
|
self.layer.animateBounds(from: self.bounds, to: self.bounds.offsetBy(dx: 0.0, dy: -self.bounds.size.height), duration: 0.35, timingFunction: kCAMediaTimingFunctionEaseOut, removeOnCompletion: false, completion: { [weak self, weak tempDimView] _ in
|
||||||
tempDimView?.removeFromSuperview()
|
tempDimView?.removeFromSuperview()
|
||||||
|
|
||||||
self?.dismiss()
|
self?.dismiss(cancelled)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
|
|
||||||
@objc func dimNodeTap(_ recognizer: UITapGestureRecognizer) {
|
@objc func dimNodeTap(_ recognizer: UITapGestureRecognizer) {
|
||||||
if case .ended = recognizer.state {
|
if case .ended = recognizer.state {
|
||||||
self.animateOut()
|
self.animateOut(cancelled: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ final class ActionSheetControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
let additionalTopHeight = max(0.0, -contentOffset.y)
|
let additionalTopHeight = max(0.0, -contentOffset.y)
|
||||||
|
|
||||||
if additionalTopHeight >= 30.0 {
|
if additionalTopHeight >= 30.0 {
|
||||||
self.animateOut()
|
self.animateOut(cancelled: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user