mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 03:21:29 +00:00
Web app improvements
This commit is contained in:
parent
7f7cb498bb
commit
30d5f9ddef
@ -161,7 +161,8 @@ public class AttachmentController: ViewController {
|
|||||||
private let initialButton: AttachmentButtonType
|
private let initialButton: AttachmentButtonType
|
||||||
private let fromMenu: Bool
|
private let fromMenu: Bool
|
||||||
|
|
||||||
public var dismissed: () -> Void = {}
|
public var willDismiss: () -> Void = {}
|
||||||
|
public var didDismiss: () -> Void = {}
|
||||||
|
|
||||||
public var mediaPickerContext: AttachmentMediaPickerContext? {
|
public var mediaPickerContext: AttachmentMediaPickerContext? {
|
||||||
get {
|
get {
|
||||||
@ -843,9 +844,8 @@ public class AttachmentController: ViewController {
|
|||||||
self.displayNodeDidLoad()
|
self.displayNodeDidLoad()
|
||||||
}
|
}
|
||||||
|
|
||||||
private var didDismiss = false
|
private var dismissedFlag = false
|
||||||
public func _dismiss() {
|
public func _dismiss() {
|
||||||
self.dismissed()
|
|
||||||
super.dismiss(animated: false, completion: {})
|
super.dismiss(animated: false, completion: {})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -856,15 +856,17 @@ public class AttachmentController: ViewController {
|
|||||||
self.view.endEditing(true)
|
self.view.endEditing(true)
|
||||||
}
|
}
|
||||||
if flag {
|
if flag {
|
||||||
if !self.didDismiss {
|
if !self.dismissedFlag {
|
||||||
self.didDismiss = true
|
self.dismissedFlag = true
|
||||||
self.dismissed()
|
self.willDismiss()
|
||||||
self.node.animateOut(completion: { [weak self] in
|
self.node.animateOut(completion: { [weak self] in
|
||||||
|
self?.didDismiss()
|
||||||
self?._dismiss()
|
self?._dismiss()
|
||||||
completion?()
|
completion?()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
self.didDismiss()
|
||||||
self._dismiss()
|
self._dismiss()
|
||||||
completion?()
|
completion?()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import OverlayStatusController
|
|||||||
import AccountContext
|
import AccountContext
|
||||||
import AppBundle
|
import AppBundle
|
||||||
import ZipArchive
|
import ZipArchive
|
||||||
|
import WebKit
|
||||||
|
|
||||||
@objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate {
|
@objc private final class DebugControllerMailComposeDelegate: NSObject, MFMailComposeViewControllerDelegate {
|
||||||
public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
public func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
|
||||||
@ -74,6 +75,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
|||||||
case resetHoles(PresentationTheme)
|
case resetHoles(PresentationTheme)
|
||||||
case reindexUnread(PresentationTheme)
|
case reindexUnread(PresentationTheme)
|
||||||
case resetBiometricsData(PresentationTheme)
|
case resetBiometricsData(PresentationTheme)
|
||||||
|
case resetWebViewCache(PresentationTheme)
|
||||||
case optimizeDatabase(PresentationTheme)
|
case optimizeDatabase(PresentationTheme)
|
||||||
case photoPreview(PresentationTheme, Bool)
|
case photoPreview(PresentationTheme, Bool)
|
||||||
case knockoutWallpaper(PresentationTheme, Bool)
|
case knockoutWallpaper(PresentationTheme, Bool)
|
||||||
@ -103,7 +105,7 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
|||||||
return DebugControllerSection.logging.rawValue
|
return DebugControllerSection.logging.rawValue
|
||||||
case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries:
|
case .enableRaiseToSpeak, .keepChatNavigationStack, .skipReadHistory, .crashOnSlowQueries:
|
||||||
return DebugControllerSection.experiments.rawValue
|
return DebugControllerSection.experiments.rawValue
|
||||||
case .clearTips, .crash, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .playerEmbedding, .playlistPlayback, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .experimentalBackground, .snow:
|
case .clearTips, .crash, .resetData, .resetDatabase, .resetDatabaseAndCache, .resetHoles, .reindexUnread, .resetBiometricsData, .resetWebViewCache, .optimizeDatabase, .photoPreview, .knockoutWallpaper, .playerEmbedding, .playlistPlayback, .voiceConference, .experimentalCompatibility, .enableDebugDataDisplay, .acceleratedStickers, .experimentalBackground, .snow:
|
||||||
return DebugControllerSection.experiments.rawValue
|
return DebugControllerSection.experiments.rawValue
|
||||||
case .preferredVideoCodec:
|
case .preferredVideoCodec:
|
||||||
return DebugControllerSection.videoExperiments.rawValue
|
return DebugControllerSection.videoExperiments.rawValue
|
||||||
@ -160,30 +162,32 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
|||||||
return 20
|
return 20
|
||||||
case .resetBiometricsData:
|
case .resetBiometricsData:
|
||||||
return 21
|
return 21
|
||||||
case .optimizeDatabase:
|
case .resetWebViewCache:
|
||||||
return 22
|
return 22
|
||||||
case .photoPreview:
|
case .optimizeDatabase:
|
||||||
return 23
|
return 23
|
||||||
case .knockoutWallpaper:
|
case .photoPreview:
|
||||||
return 24
|
return 24
|
||||||
|
case .knockoutWallpaper:
|
||||||
|
return 25
|
||||||
case .experimentalCompatibility:
|
case .experimentalCompatibility:
|
||||||
return 26
|
return 26
|
||||||
case .enableDebugDataDisplay:
|
case .enableDebugDataDisplay:
|
||||||
return 27
|
return 27
|
||||||
case .acceleratedStickers:
|
case .acceleratedStickers:
|
||||||
return 29
|
return 28
|
||||||
case .experimentalBackground:
|
case .experimentalBackground:
|
||||||
return 30
|
return 29
|
||||||
case .snow:
|
case .snow:
|
||||||
return 31
|
return 30
|
||||||
case .playerEmbedding:
|
case .playerEmbedding:
|
||||||
return 32
|
return 31
|
||||||
case .playlistPlayback:
|
case .playlistPlayback:
|
||||||
return 33
|
return 32
|
||||||
case .voiceConference:
|
case .voiceConference:
|
||||||
return 34
|
return 33
|
||||||
case let .preferredVideoCodec(index, _, _, _):
|
case let .preferredVideoCodec(index, _, _, _):
|
||||||
return 35 + index
|
return 34 + index
|
||||||
case .disableVideoAspectScaling:
|
case .disableVideoAspectScaling:
|
||||||
return 100
|
return 100
|
||||||
case .enableVoipTcp:
|
case .enableVoipTcp:
|
||||||
@ -777,6 +781,10 @@ private enum DebugControllerEntry: ItemListNodeEntry {
|
|||||||
return settings.withUpdatedBiometricsDomainState(nil).withUpdatedShareBiometricsDomainState(nil)
|
return settings.withUpdatedBiometricsDomainState(nil).withUpdatedShareBiometricsDomainState(nil)
|
||||||
}).start()
|
}).start()
|
||||||
})
|
})
|
||||||
|
case .resetWebViewCache:
|
||||||
|
return ItemListActionItem(presentationData: presentationData, title: "Clear Web View Cache", kind: .destructive, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||||
|
WKWebsiteDataStore.default().removeData(ofTypes: [WKWebsiteDataTypeDiskCache, WKWebsiteDataTypeMemoryCache], modifiedSince: Date(timeIntervalSince1970: 0), completionHandler:{ })
|
||||||
|
})
|
||||||
case .optimizeDatabase:
|
case .optimizeDatabase:
|
||||||
return ItemListActionItem(presentationData: presentationData, title: "Optimize Database", kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
return ItemListActionItem(presentationData: presentationData, title: "Optimize Database", kind: .generic, alignment: .natural, sectionId: self.section, style: .blocks, action: {
|
||||||
guard let context = arguments.context else {
|
guard let context = arguments.context else {
|
||||||
@ -968,6 +976,7 @@ private func debugControllerEntries(sharedContext: SharedAccountContext, present
|
|||||||
entries.append(.resetHoles(presentationData.theme))
|
entries.append(.resetHoles(presentationData.theme))
|
||||||
if isMainApp {
|
if isMainApp {
|
||||||
entries.append(.reindexUnread(presentationData.theme))
|
entries.append(.reindexUnread(presentationData.theme))
|
||||||
|
entries.append(.resetWebViewCache(presentationData.theme))
|
||||||
}
|
}
|
||||||
entries.append(.optimizeDatabase(presentationData.theme))
|
entries.append(.optimizeDatabase(presentationData.theme))
|
||||||
if isMainApp {
|
if isMainApp {
|
||||||
|
|||||||
@ -3376,14 +3376,17 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
}, completion: { [weak self] in
|
}, completion: { [weak self] in
|
||||||
self?.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
self?.chatDisplayNode.historyNode.scrollToEndOfHistory()
|
||||||
}, dismissed: { [weak self] in
|
}, willDismiss: { [weak self] in
|
||||||
self?.interfaceInteraction?.updateShowWebView { _ in
|
self?.interfaceInteraction?.updateShowWebView { _ in
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
let isFocused = strongSelf.chatDisplayNode.textInputPanelNode?.isFocused ?? false
|
}, didDismiss: { [weak self] in
|
||||||
strongSelf.chatDisplayNode.insertSubnode(strongSelf.chatDisplayNode.inputPanelContainerNode, aboveSubnode: strongSelf.chatDisplayNode.historyNodeContainer)
|
if let strongSelf = self {
|
||||||
if isFocused {
|
let isFocused = strongSelf.chatDisplayNode.textInputPanelNode?.isFocused ?? false
|
||||||
strongSelf.chatDisplayNode.textInputPanelNode?.ensureFocused()
|
strongSelf.chatDisplayNode.insertSubnode(strongSelf.chatDisplayNode.inputPanelContainerNode, aboveSubnode: strongSelf.chatDisplayNode.historyNodeContainer)
|
||||||
|
if isFocused {
|
||||||
|
strongSelf.chatDisplayNode.textInputPanelNode?.ensureFocused()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
strongSelf.present(controller, in: .window(.root))
|
strongSelf.present(controller, in: .window(.root))
|
||||||
@ -6792,7 +6795,14 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return value
|
return value
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
if updatedInputMode == .text {
|
var dismissWebView = false
|
||||||
|
switch updatedInputMode {
|
||||||
|
case .text, .media, .inputButtons:
|
||||||
|
dismissWebView = true
|
||||||
|
default:
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if dismissWebView {
|
||||||
updated = updated.updatedShowWebView(false)
|
updated = updated.updatedShowWebView(false)
|
||||||
}
|
}
|
||||||
return updated
|
return updated
|
||||||
@ -6802,9 +6812,6 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.interfaceInteraction?.updateShowWebView { _ in
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
strongSelf.chatDisplayNode.openStickers()
|
strongSelf.chatDisplayNode.openStickers()
|
||||||
strongSelf.mediaRecordingModeTooltipController?.dismissImmediately()
|
strongSelf.mediaRecordingModeTooltipController?.dismissImmediately()
|
||||||
}, editMessage: { [weak self] in
|
}, editMessage: { [weak self] in
|
||||||
|
|||||||
@ -261,30 +261,21 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
private var loadCount = 0
|
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||||
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
|
Queue.mainQueue().after(0.65, {
|
||||||
self.loadCount += 1
|
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()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
|
if let (layout, navigationBarHeight) = self.validLayout {
|
||||||
self.loadCount -= 1
|
self.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: .immediate)
|
||||||
|
|
||||||
Queue.mainQueue().after(0.1, {
|
|
||||||
if self.loadCount == 0, let webView = self.webView {
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(iOSApplicationExtension 15.0, iOS 15.0, *)
|
@available(iOSApplicationExtension 15.0, iOS 15.0, *)
|
||||||
@ -677,7 +668,7 @@ private final class WebAppContextReferenceContentSource: ContextReferenceContent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, dismissed: @escaping () -> Void = {}) -> ViewController {
|
public func standaloneWebAppController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, params: WebAppParameters, openUrl: @escaping (String) -> Void, getInputContainerNode: @escaping () -> (CGFloat, ASDisplayNode, () -> AttachmentController.InputPanelTransition?)? = { return nil }, completion: @escaping () -> Void = {}, willDismiss: @escaping () -> Void = {}, didDismiss: @escaping () -> Void = {}) -> ViewController {
|
||||||
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu)
|
let controller = AttachmentController(context: context, updatedPresentationData: updatedPresentationData, chatLocation: .peer(id: params.peerId), buttons: [.standalone], initialButton: .standalone, fromMenu: params.fromMenu)
|
||||||
controller.getInputContainerNode = getInputContainerNode
|
controller.getInputContainerNode = getInputContainerNode
|
||||||
controller.requestController = { _, present in
|
controller.requestController = { _, present in
|
||||||
@ -686,6 +677,7 @@ public func standaloneWebAppController(context: AccountContext, updatedPresentat
|
|||||||
webAppController.completion = completion
|
webAppController.completion = completion
|
||||||
present(webAppController, webAppController.mediaPickerContext)
|
present(webAppController, webAppController.mediaPickerContext)
|
||||||
}
|
}
|
||||||
controller.dismissed = dismissed
|
controller.willDismiss = willDismiss
|
||||||
|
controller.didDismiss = didDismiss
|
||||||
return controller
|
return controller
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user