mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Web app improvements
This commit is contained in:
parent
845cc48c61
commit
af9dcd2f19
@ -3363,6 +3363,10 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
let openWebView = {
|
||||
if fromMenu {
|
||||
strongSelf.interfaceInteraction?.updateShowWebView { _ in
|
||||
return true
|
||||
}
|
||||
|
||||
let params = WebAppParameters(peerId: peerId, botId: peerId, botName: botName, url: url, queryId: nil, payload: nil, buttonText: buttonText, keepAliveSignal: nil, fromMenu: true)
|
||||
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, openUrl: { [weak self] url in
|
||||
self?.openUrl(url, concealed: true, forceExternal: true)
|
||||
|
@ -2565,13 +2565,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
return !value
|
||||
}
|
||||
} else if case let .webView(title, url) = presentationInterfaceState.botMenuButton {
|
||||
var show = false
|
||||
self.interfaceInteraction?.updateShowWebView { value in
|
||||
show = !value
|
||||
return show
|
||||
}
|
||||
if show {
|
||||
let willShow = !(self.presentationInterfaceState?.showWebView ?? false)
|
||||
if willShow {
|
||||
self.interfaceInteraction?.openWebView(title, url, false, true)
|
||||
} else {
|
||||
self.interfaceInteraction?.updateShowWebView { _ in
|
||||
return false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.interfaceInteraction?.updateShowCommands { value in
|
||||
|
@ -298,21 +298,32 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
var didTransitionIn = false
|
||||
private func animateTransitionIn() {
|
||||
guard !self.didTransitionIn, let webView = self.webView else {
|
||||
return
|
||||
}
|
||||
self.didTransitionIn = true
|
||||
|
||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear)
|
||||
transition.updateAlpha(layer: webView.layer, alpha: 1.0)
|
||||
if let placeholderNode = self.placeholderNode {
|
||||
self.placeholderNode = nil
|
||||
transition.updateAlpha(node: placeholderNode, alpha: 0.0, completion: { [weak placeholderNode] _ in
|
||||
placeholderNode?.removeFromSupernode()
|
||||
})
|
||||
}
|
||||
|
||||
if let (layout, navigationBarHeight) = self.validLayout {
|
||||
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
}
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||
Queue.mainQueue().after(0.6, {
|
||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear)
|
||||
transition.updateAlpha(layer: webView.layer, alpha: 1.0)
|
||||
if let placeholderNode = self.placeholderNode {
|
||||
self.placeholderNode = nil
|
||||
transition.updateAlpha(node: placeholderNode, alpha: 0.0, completion: { [weak placeholderNode] _ in
|
||||
placeholderNode?.removeFromSupernode()
|
||||
})
|
||||
}
|
||||
|
||||
if let (layout, navigationBarHeight) = self.validLayout {
|
||||
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||
}
|
||||
self.animateTransitionIn()
|
||||
})
|
||||
}
|
||||
|
||||
@ -402,6 +413,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
}
|
||||
|
||||
switch eventName {
|
||||
case "web_app_ready":
|
||||
self.animateTransitionIn()
|
||||
case "web_app_data_send":
|
||||
if let eventData = body["eventData"] as? String {
|
||||
self.handleSendData(data: eventData)
|
||||
|
Loading…
x
Reference in New Issue
Block a user