mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +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 = {
|
let openWebView = {
|
||||||
if fromMenu {
|
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 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
|
let controller = standaloneWebAppController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, params: params, openUrl: { [weak self] url in
|
||||||
self?.openUrl(url, concealed: true, forceExternal: true)
|
self?.openUrl(url, concealed: true, forceExternal: true)
|
||||||
|
|||||||
@ -2565,13 +2565,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
return !value
|
return !value
|
||||||
}
|
}
|
||||||
} else if case let .webView(title, url) = presentationInterfaceState.botMenuButton {
|
} else if case let .webView(title, url) = presentationInterfaceState.botMenuButton {
|
||||||
var show = false
|
let willShow = !(self.presentationInterfaceState?.showWebView ?? false)
|
||||||
self.interfaceInteraction?.updateShowWebView { value in
|
if willShow {
|
||||||
show = !value
|
|
||||||
return show
|
|
||||||
}
|
|
||||||
if show {
|
|
||||||
self.interfaceInteraction?.openWebView(title, url, false, true)
|
self.interfaceInteraction?.openWebView(title, url, false, true)
|
||||||
|
} else {
|
||||||
|
self.interfaceInteraction?.updateShowWebView { _ in
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.interfaceInteraction?.updateShowCommands { value in
|
self.interfaceInteraction?.updateShowCommands { value in
|
||||||
|
|||||||
@ -298,21 +298,32 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
return nil
|
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!) {
|
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||||
Queue.mainQueue().after(0.6, {
|
Queue.mainQueue().after(0.6, {
|
||||||
let transition = ContainedViewLayoutTransition.animated(duration: 0.2, curve: .linear)
|
self.animateTransitionIn()
|
||||||
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)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,6 +413,8 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch eventName {
|
switch eventName {
|
||||||
|
case "web_app_ready":
|
||||||
|
self.animateTransitionIn()
|
||||||
case "web_app_data_send":
|
case "web_app_data_send":
|
||||||
if let eventData = body["eventData"] as? String {
|
if let eventData = body["eventData"] as? String {
|
||||||
self.handleSendData(data: eventData)
|
self.handleSendData(data: eventData)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user