mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-01 16:06:59 +00:00
Various improvements
This commit is contained in:
parent
31300c3c16
commit
b79105092c
@ -79,6 +79,9 @@ public final class BotCheckoutController: ViewController {
|
||||
private let invoice: TelegramMediaInvoice
|
||||
private let source: BotPaymentInvoiceSource
|
||||
private let completed: (String, EngineMessage.Id?) -> Void
|
||||
private let pending: () -> Void
|
||||
private let cancelled: () -> Void
|
||||
private let failed: () -> Void
|
||||
|
||||
private var presentationData: PresentationData
|
||||
|
||||
@ -86,12 +89,14 @@ public final class BotCheckoutController: ViewController {
|
||||
|
||||
private let inputData: Promise<BotCheckoutController.InputData?>
|
||||
|
||||
public init(context: AccountContext, invoice: TelegramMediaInvoice, source: BotPaymentInvoiceSource, inputData: Promise<BotCheckoutController.InputData?>, completed: @escaping (String, EngineMessage.Id?) -> Void) {
|
||||
public init(context: AccountContext, invoice: TelegramMediaInvoice, source: BotPaymentInvoiceSource, inputData: Promise<BotCheckoutController.InputData?>, completed: @escaping (String, EngineMessage.Id?) -> Void, pending: @escaping () -> Void = {}, cancelled: @escaping () -> Void = {}, failed: @escaping () -> Void = {}) {
|
||||
self.context = context
|
||||
self.invoice = invoice
|
||||
self.source = source
|
||||
self.inputData = inputData
|
||||
self.completed = completed
|
||||
self.cancelled = cancelled
|
||||
self.failed = failed
|
||||
|
||||
self.presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
@ -122,6 +127,12 @@ public final class BotCheckoutController: ViewController {
|
||||
displayNode.dismiss = { [weak self] in
|
||||
self?.presentingViewController?.dismiss(animated: false, completion: nil)
|
||||
}
|
||||
displayNode.pending = { [weak self] in
|
||||
self?.pending()
|
||||
}
|
||||
displayNode.failed = { [weak self] in
|
||||
self?.failed()
|
||||
}
|
||||
|
||||
self.displayNode = displayNode
|
||||
super.displayNodeDidLoad()
|
||||
@ -146,6 +157,7 @@ public final class BotCheckoutController: ViewController {
|
||||
}
|
||||
|
||||
@objc private func cancelPressed() {
|
||||
self.cancelled()
|
||||
self.dismiss()
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,10 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
private let present: (ViewController, Any?) -> Void
|
||||
private let dismissAnimated: () -> Void
|
||||
private let completed: (String, EngineMessage.Id?) -> Void
|
||||
|
||||
|
||||
var pending: () -> Void = {}
|
||||
var failed: () -> Void = {}
|
||||
|
||||
private var stateValue = BotCheckoutControllerState()
|
||||
private let state = ValuePromise(BotCheckoutControllerState(), ignoreRepeated: true)
|
||||
private var arguments: BotCheckoutControllerArguments?
|
||||
@ -1312,6 +1315,8 @@ final class BotCheckoutControllerNode: ItemListControllerNode, PKPaymentAuthoriz
|
||||
}
|
||||
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), nil)
|
||||
|
||||
strongSelf.failed()
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
@ -3504,6 +3504,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}, getNavigationController: { [weak self] in
|
||||
return self?.effectiveNavigationController
|
||||
})
|
||||
controller.navigationPresentation = .flatModal
|
||||
strongSelf.currentWebAppController = controller
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
}, error: { [weak self] error in
|
||||
@ -3529,6 +3530,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}, getNavigationController: { [weak self] in
|
||||
return self?.effectiveNavigationController
|
||||
})
|
||||
controller.navigationPresentation = .flatModal
|
||||
strongSelf.currentWebAppController = controller
|
||||
strongSelf.present(controller, in: .window(.root))
|
||||
}, error: { [weak self] error in
|
||||
@ -14758,7 +14760,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
$0.updatedBotStartPayload(startPayload.payload)
|
||||
})
|
||||
} else if let navigationController = strongSelf.effectiveNavigationController {
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId), botStart: startPayload))
|
||||
strongSelf.context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: strongSelf.context, chatLocation: .peer(id: peerId), botStart: startPayload, keepStack: .always))
|
||||
}
|
||||
case let .withAttachBot(attachBotStart):
|
||||
if let navigationController = strongSelf.effectiveNavigationController {
|
||||
|
@ -602,7 +602,11 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
})
|
||||
if let navigationController = strongSelf.controller?.getNavigationController() {
|
||||
let checkoutController = BotCheckoutController(context: strongSelf.context, invoice: invoice, source: .slug(slug), inputData: inputData, completed: { currencyValue, receiptMessageId in
|
||||
|
||||
self?.sendInvoiceClosedEvent(slug: slug, result: .paid)
|
||||
}, cancelled: { [weak self] in
|
||||
self?.sendInvoiceClosedEvent(slug: slug, result: .cancelled)
|
||||
}, failed: { [weak self] in
|
||||
self?.sendInvoiceClosedEvent(slug: slug, result: .failed)
|
||||
})
|
||||
checkoutController.navigationPresentation = .modal
|
||||
navigationController.pushViewController(checkoutController)
|
||||
|
Loading…
x
Reference in New Issue
Block a user