mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Various improvements
This commit is contained in:
@@ -133,16 +133,18 @@ public final class BotCheckoutController: ViewController {
|
||||
self?.present(c, in: .window(.root), with: a)
|
||||
}, dismissAnimated: { [weak self] in
|
||||
self?.dismiss()
|
||||
}, completed: self.completed)
|
||||
}, completed: { [weak self] currencyValue, receiptMessageId in
|
||||
self?.complete(currencyValue: currencyValue, receiptMessageId: receiptMessageId)
|
||||
})
|
||||
|
||||
displayNode.dismiss = { [weak self] in
|
||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
displayNode.pending = { [weak self] in
|
||||
self?.pending()
|
||||
self?.setPending()
|
||||
}
|
||||
displayNode.failed = { [weak self] in
|
||||
self?.failed()
|
||||
self?.fail()
|
||||
}
|
||||
|
||||
self.displayNode = displayNode
|
||||
@@ -150,6 +152,12 @@ public final class BotCheckoutController: ViewController {
|
||||
self._ready.set(displayNode.ready)
|
||||
}
|
||||
|
||||
override public func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
|
||||
self.cancel()
|
||||
}
|
||||
|
||||
override public func viewDidAppear(_ animated: Bool) {
|
||||
super.viewDidAppear(animated)
|
||||
|
||||
@@ -167,8 +175,40 @@ public final class BotCheckoutController: ViewController {
|
||||
self.controllerNode.containerLayoutUpdated(layout, navigationBarHeight: self.navigationLayout(layout: layout).navigationFrame.maxY, transition: transition, additionalInsets: UIEdgeInsets())
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
private var didCancel = false
|
||||
private func cancel() {
|
||||
guard !self.didCancel && !self.didFail && !self.didComplete else {
|
||||
return
|
||||
}
|
||||
self.cancelled()
|
||||
}
|
||||
|
||||
private var didFail = false
|
||||
private func fail() {
|
||||
guard !self.didCancel && !self.didFail && !self.didComplete else {
|
||||
return
|
||||
}
|
||||
self.failed()
|
||||
}
|
||||
|
||||
private var didComplete = false
|
||||
private func complete(currencyValue: String, receiptMessageId: EngineMessage.Id?) {
|
||||
guard !self.didCancel && !self.didFail && !self.didComplete else {
|
||||
return
|
||||
}
|
||||
self.completed(currencyValue, receiptMessageId)
|
||||
}
|
||||
|
||||
private var isPending = false
|
||||
private func setPending() {
|
||||
guard !self.isPending && !self.didCancel && !self.didFail && !self.didComplete else {
|
||||
return
|
||||
}
|
||||
self.pending()
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.cancel()
|
||||
self.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user