mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Merge commit '0d058348b0b96a30b3bb732a040364aa6eeafa93'
This commit is contained in:
commit
18c374eb2a
@ -2311,7 +2311,13 @@ public func svgIconImageFile(account: Account, fileReference: FileMediaReference
|
||||
let imageOrientation: UIImage.Orientation = .up
|
||||
|
||||
if fullSizeComplete, let data = try? Data(contentsOf: URL(fileURLWithPath: fullSizePath)) {
|
||||
fullSizeImage = renderPreparedImage(data, CGSize.zero, .clear, UIScreenScale)
|
||||
let renderSize: CGSize
|
||||
if stickToTop {
|
||||
renderSize = .zero
|
||||
} else {
|
||||
renderSize = CGSize(width: 90.0, height: 90.0)
|
||||
}
|
||||
fullSizeImage = renderPreparedImage(data, renderSize, .clear, UIScreenScale)
|
||||
if let image = fullSizeImage {
|
||||
fittedSize = image.size.aspectFitted(arguments.boundingSize)
|
||||
}
|
||||
|
@ -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)
|
||||
@ -12275,7 +12279,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
}
|
||||
|
||||
private func sendMessages(_ messages: [EnqueueMessage], commit: Bool = false) {
|
||||
private func sendMessages(_ messages: [EnqueueMessage], media: Bool = false, commit: Bool = false) {
|
||||
guard let peerId = self.chatLocation.peerId else {
|
||||
return
|
||||
}
|
||||
@ -12299,7 +12303,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
|
||||
self.updateChatPresentationInterfaceState(interactive: true, { $0.updatedShowCommands(false) })
|
||||
} else {
|
||||
self.presentScheduleTimePicker(dismissByTapOutside: false, completion: { [weak self] time in
|
||||
self.presentScheduleTimePicker(style: media ? .media : .default, dismissByTapOutside: false, completion: { [weak self] time in
|
||||
if let strongSelf = self {
|
||||
strongSelf.sendMessages(strongSelf.transformEnqueueMessages(messages, silentPosting: false, scheduleTime: time), commit: true)
|
||||
}
|
||||
@ -12324,7 +12328,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var message = item.message
|
||||
if let uniqueId = item.uniqueId {
|
||||
let correlationId: Int64
|
||||
var addTransition = true
|
||||
var addTransition = scheduleTime == nil
|
||||
if let groupingKey = message.groupingKey {
|
||||
if let existing = groupedCorrelationIds[groupingKey] {
|
||||
correlationId = existing
|
||||
@ -12401,7 +12405,11 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
completionImpl?()
|
||||
}, usedCorrelationId)
|
||||
|
||||
strongSelf.sendMessages(messages.map { $0.withUpdatedReplyToMessageId(replyMessageId) })
|
||||
strongSelf.sendMessages(messages.map { $0.withUpdatedReplyToMessageId(replyMessageId) }, media: true)
|
||||
|
||||
if let _ = scheduleTime {
|
||||
completion()
|
||||
}
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
@ -877,6 +877,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
self.attachmentButton.accessibilityTraits = (!isSlowmodeActive || isMediaEnabled) ? [.button] : [.button, .notEnabled]
|
||||
self.attachmentButtonDisabledNode.isHidden = !isSlowmodeActive || isMediaEnabled
|
||||
|
||||
var buttonTitleUpdated = false
|
||||
var menuTextSize = self.menuButtonTextNode.frame.size
|
||||
if self.presentationInterfaceState != interfaceState {
|
||||
let previousState = self.presentationInterfaceState
|
||||
@ -914,8 +915,19 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
buttonTitle = interfaceState.strings.Conversation_InputMenu
|
||||
}
|
||||
|
||||
buttonTitleUpdated = self.menuButtonTextNode.attributedText != nil && self.menuButtonTextNode.attributedText?.string != buttonTitle
|
||||
|
||||
self.menuButtonTextNode.attributedText = NSAttributedString(string: buttonTitle, font: Font.with(size: 16.0, design: .round, weight: .medium, traits: []), textColor: interfaceState.theme.chat.inputPanel.actionControlForegroundColor)
|
||||
self.menuButton.accessibilityLabel = self.menuButtonTextNode.attributedText?.string
|
||||
|
||||
if buttonTitleUpdated, let buttonTextSnapshotView = self.menuButtonTextNode.view.snapshotView(afterScreenUpdates: false) {
|
||||
buttonTextSnapshotView.frame = self.menuButtonTextNode.view.frame
|
||||
self.menuButtonTextNode.view.superview?.addSubview(buttonTextSnapshotView)
|
||||
buttonTextSnapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak buttonTextSnapshotView] _ in
|
||||
buttonTextSnapshotView?.removeFromSuperview()
|
||||
})
|
||||
self.menuButtonTextNode.view.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.2)
|
||||
}
|
||||
menuTextSize = self.menuButtonTextNode.updateLayout(CGSize(width: width, height: 44.0))
|
||||
|
||||
var updateSendButtonIcon = false
|
||||
@ -1212,6 +1224,10 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
}
|
||||
self.leftMenuInset = leftMenuInset
|
||||
|
||||
if buttonTitleUpdated && !transition.isAnimated {
|
||||
transition = .animated(duration: 0.3, curve: .easeInOut)
|
||||
}
|
||||
|
||||
let baseWidth = width - leftInset - leftMenuInset - rightInset
|
||||
let (accessoryButtonsWidth, textFieldHeight) = self.calculateTextFieldMetrics(width: baseWidth, maxHeight: maxHeight, metrics: metrics)
|
||||
let panelHeight = self.panelHeight(textFieldHeight: textFieldHeight, metrics: metrics)
|
||||
@ -1220,7 +1236,11 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
transition.updateFrameAsPositionAndBounds(node: self.menuButton, frame: menuButtonFrame)
|
||||
transition.updateFrame(node: self.menuButtonBackgroundNode, frame: CGRect(origin: CGPoint(), size: menuButtonFrame.size))
|
||||
transition.updateFrame(node: self.menuButtonClippingNode, frame: CGRect(origin: CGPoint(x: 19.0, y: 0.0), size: CGSize(width: menuButtonWidth - 19.0, height: menuButtonFrame.height)))
|
||||
transition.updateFrame(node: self.menuButtonTextNode, frame: CGRect(origin: CGPoint(x: 16.0, y: 7.0 - UIScreenPixel), size: menuTextSize))
|
||||
var buttonTitlteTransition = transition
|
||||
if buttonTitleUpdated {
|
||||
buttonTitlteTransition = .immediate
|
||||
}
|
||||
buttonTitlteTransition.updateFrame(node: self.menuButtonTextNode, frame: CGRect(origin: CGPoint(x: 16.0, y: 7.0 - UIScreenPixel), size: menuTextSize))
|
||||
transition.updateAlpha(node: self.menuButtonTextNode, alpha: menuButtonExpanded ? 1.0 : 0.0)
|
||||
transition.updateFrame(node: self.menuButtonIconNode, frame: CGRect(x: isSendAsButton ? 1.0 + UIScreenPixel : (4.0 + UIScreenPixel), y: 1.0 + UIScreenPixel, width: 30.0, height: 30.0))
|
||||
|
||||
@ -2565,13 +2585,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
|
||||
|
@ -299,20 +299,35 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
||||
return nil
|
||||
}
|
||||
|
||||
func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!) {
|
||||
Queue.mainQueue().after(1.0, {
|
||||
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)
|
||||
}
|
||||
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()
|
||||
})
|
||||
}
|
||||
|
||||
Queue.mainQueue().after(1.0, {
|
||||
webView.handleTap()
|
||||
})
|
||||
|
||||
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, {
|
||||
self.animateTransitionIn()
|
||||
})
|
||||
}
|
||||
|
||||
@ -402,6 +417,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)
|
||||
|
@ -130,7 +130,7 @@ final class WebAppWebView: WKWebView {
|
||||
self.sendEvent(name: "viewport_changed", data: "{height:\(frame.height)}")
|
||||
}
|
||||
|
||||
private(set) var didTouchOnce = true
|
||||
private(set) var didTouchOnce = false
|
||||
@objc func handleTap() {
|
||||
self.didTouchOnce = true
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user