mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various fixes
This commit is contained in:
parent
c0377584ae
commit
fd88343573
@ -169,7 +169,6 @@ public class AttachmentController: ViewController {
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.panel.updateLoadingProgress(progress)
|
strongSelf.panel.updateLoadingProgress(progress)
|
||||||
if let layout = strongSelf.validLayout {
|
if let layout = strongSelf.validLayout {
|
||||||
print(progress ?? 0)
|
|
||||||
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
strongSelf.containerLayoutUpdated(layout, transition: .immediate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1046,7 +1046,7 @@ final class InstantPageControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
}
|
}
|
||||||
})]
|
})]
|
||||||
|
|
||||||
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages)
|
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: true, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||||
if canTranslate {
|
if canTranslate {
|
||||||
actions.append(ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuTranslate, accessibilityLabel: strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
actions.append(ContextMenuAction(content: .text(title: strings.Conversation_ContextMenuTranslate, accessibilityLabel: strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
||||||
let controller = TranslateScreen(context: context, text: text, fromLanguage: language)
|
let controller = TranslateScreen(context: context, text: text, fromLanguage: language)
|
||||||
|
@ -131,7 +131,7 @@ private func filterMessageAttributesForOutgoingMessage(_ attributes: [MessageAtt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func filterMessageAttributesForForwardedMessage(_ attributes: [MessageAttribute], forwardedMessageIds: [MessageId]? = nil) -> [MessageAttribute] {
|
private func filterMessageAttributesForForwardedMessage(_ attributes: [MessageAttribute], forwardedMessageIds: Set<MessageId>? = nil) -> [MessageAttribute] {
|
||||||
return attributes.filter { attribute in
|
return attributes.filter { attribute in
|
||||||
switch attribute {
|
switch attribute {
|
||||||
case _ as TextEntitiesMessageAttribute:
|
case _ as TextEntitiesMessageAttribute:
|
||||||
@ -285,10 +285,10 @@ public func resendMessages(account: Account, messageIds: [MessageId]) -> Signal<
|
|||||||
}
|
}
|
||||||
|
|
||||||
func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, messages: [(Bool, EnqueueMessage)], disableAutoremove: Bool = false, transformGroupingKeysWithPeerId: Bool = false) -> [MessageId?] {
|
func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, messages: [(Bool, EnqueueMessage)], disableAutoremove: Bool = false, transformGroupingKeysWithPeerId: Bool = false) -> [MessageId?] {
|
||||||
var forwardedMessageIds: [MessageId] = []
|
var forwardedMessageIds = Set<MessageId>()
|
||||||
for (_, message) in messages {
|
for (_, message) in messages {
|
||||||
if case let .forward(sourceId, _, _, _) = message {
|
if case let .forward(sourceId, _, _, _) = message {
|
||||||
forwardedMessageIds.append(sourceId)
|
forwardedMessageIds.insert(sourceId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2940,12 +2940,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
translationSettings = TranslationSettings.defaultSettings
|
translationSettings = TranslationSettings.defaultSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
var showTranslateIfTopical = false
|
let (_, language) = canTranslateText(context: context, text: text.string, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: true, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||||
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case .broadcast = peer.info, !(peer.addressName ?? "").isEmpty {
|
|
||||||
showTranslateIfTopical = true
|
|
||||||
}
|
|
||||||
|
|
||||||
let (_, language) = canTranslateText(context: context, text: text.string, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: showTranslateIfTopical, ignoredLanguages: translationSettings.ignoredLanguages)
|
|
||||||
|
|
||||||
let controller = TranslateScreen(context: context, text: text.string, fromLanguage: language)
|
let controller = TranslateScreen(context: context, text: text.string, fromLanguage: language)
|
||||||
controller.pushController = { [weak self] c in
|
controller.pushController = { [weak self] c in
|
||||||
|
@ -253,6 +253,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
let messages = combineLatest(context.account.postbox.messagesAtIds(messageIds), context.account.postbox.loadedPeerWithId(context.account.peerId), options)
|
let messages = combineLatest(context.account.postbox.messagesAtIds(messageIds), context.account.postbox.loadedPeerWithId(context.account.peerId), options)
|
||||||
|> map { messages, accountPeer, options -> ([Message], Int32, Bool) in
|
|> map { messages, accountPeer, options -> ([Message], Int32, Bool) in
|
||||||
var messages = messages
|
var messages = messages
|
||||||
|
let forwardedMessageIds = Set(messages.map { $0.id })
|
||||||
messages.sort(by: { lhsMessage, rhsMessage in
|
messages.sort(by: { lhsMessage, rhsMessage in
|
||||||
return lhsMessage.timestamp > rhsMessage.timestamp
|
return lhsMessage.timestamp > rhsMessage.timestamp
|
||||||
})
|
})
|
||||||
@ -261,13 +262,20 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
flags.remove(.Incoming)
|
flags.remove(.Incoming)
|
||||||
flags.remove(.IsIncomingMask)
|
flags.remove(.IsIncomingMask)
|
||||||
|
|
||||||
|
var hideNames = options.hideNames
|
||||||
|
if message.id.peerId == accountPeer.id && message.forwardInfo == nil {
|
||||||
|
hideNames = true
|
||||||
|
}
|
||||||
|
|
||||||
var attributes = message.attributes
|
var attributes = message.attributes
|
||||||
attributes = attributes.filter({ attribute in
|
attributes = attributes.filter({ attribute in
|
||||||
if attribute is EditedMessageAttribute {
|
if attribute is EditedMessageAttribute {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if attribute is ReplyMessageAttribute {
|
if let attribute = attribute as? ReplyMessageAttribute {
|
||||||
return false
|
if !forwardedMessageIds.contains(attribute.messageId) || hideNames {
|
||||||
|
return false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if attribute is ReplyMarkupMessageAttribute {
|
if attribute is ReplyMarkupMessageAttribute {
|
||||||
return false
|
return false
|
||||||
@ -287,11 +295,6 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
|
||||||
var hideNames = options.hideNames
|
|
||||||
if message.id.peerId == accountPeer.id && message.forwardInfo == nil {
|
|
||||||
hideNames = true
|
|
||||||
}
|
|
||||||
|
|
||||||
var messageText = message.text
|
var messageText = message.text
|
||||||
var messageMedia = message.media
|
var messageMedia = message.media
|
||||||
var hasDice = false
|
var hasDice = false
|
||||||
|
@ -857,12 +857,7 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState
|
|||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
var showTranslateIfTopical = false
|
let (canTranslate, _) = canTranslateText(context: context, text: messageText, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: true, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||||
if let peer = chatPresentationInterfaceState.renderedPeer?.chatMainPeer as? TelegramChannel, case .broadcast = peer.info, !(peer.addressName ?? "").isEmpty {
|
|
||||||
showTranslateIfTopical = true
|
|
||||||
}
|
|
||||||
|
|
||||||
let (canTranslate, _) = canTranslateText(context: context, text: messageText, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: showTranslateIfTopical, ignoredLanguages: translationSettings.ignoredLanguages)
|
|
||||||
if canTranslate {
|
if canTranslate {
|
||||||
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuTranslate, icon: { theme in
|
actions.append(.action(ContextMenuActionItem(text: chatPresentationInterfaceState.strings.Conversation_ContextMenuTranslate, icon: { theme in
|
||||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Translate"), color: theme.actionSheet.primaryTextColor)
|
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Translate"), color: theme.actionSheet.primaryTextColor)
|
||||||
|
@ -974,7 +974,7 @@ class ChatMessageAnimatedStickerItemNode: ChatMessageItemView {
|
|||||||
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
||||||
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
||||||
} else {
|
} else {
|
||||||
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, CGSize(width: availableContentWidth, height: CGFloat.greatestFiniteMagnitude))
|
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, item.message, CGSize(width: availableContentWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||||
}
|
}
|
||||||
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
||||||
replyMarkup = attribute
|
replyMarkup = attribute
|
||||||
|
@ -994,7 +994,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
authorNameLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
|
authorNameLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
|
||||||
adminBadgeLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
|
adminBadgeLayout: (TextNodeLayoutArguments) -> (TextNodeLayout, () -> TextNode),
|
||||||
forwardInfoLayout: (ChatPresentationData, PresentationStrings, ChatMessageForwardInfoType, Peer?, String?, String?, CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode),
|
forwardInfoLayout: (ChatPresentationData, PresentationStrings, ChatMessageForwardInfoType, Peer?, String?, String?, CGSize) -> (CGSize, (CGFloat) -> ChatMessageForwardInfoNode),
|
||||||
replyInfoLayout: (ChatPresentationData, PresentationStrings, AccountContext, ChatMessageReplyInfoType, Message, CGSize) -> (CGSize, () -> ChatMessageReplyInfoNode),
|
replyInfoLayout: (ChatPresentationData, PresentationStrings, AccountContext, ChatMessageReplyInfoType, Message, Message, CGSize) -> (CGSize, () -> ChatMessageReplyInfoNode),
|
||||||
actionButtonsLayout: (AccountContext, ChatPresentationThemeData, PresentationChatBubbleCorners, PresentationStrings, ReplyMarkupMessageAttribute, Message, CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)),
|
actionButtonsLayout: (AccountContext, ChatPresentationThemeData, PresentationChatBubbleCorners, PresentationStrings, ReplyMarkupMessageAttribute, Message, CGFloat) -> (minWidth: CGFloat, layout: (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageActionButtonsNode)),
|
||||||
reactionButtonsLayout: (ChatMessageReactionButtonsNode.Arguments) -> (minWidth: CGFloat, layout: (CGFloat) -> (size: CGSize, apply: (ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode)),
|
reactionButtonsLayout: (ChatMessageReactionButtonsNode.Arguments) -> (minWidth: CGFloat, layout: (CGFloat) -> (size: CGSize, apply: (ListViewItemUpdateAnimation) -> ChatMessageReactionButtonsNode)),
|
||||||
mosaicStatusLayout: (ChatMessageDateAndStatusNode.Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)),
|
mosaicStatusLayout: (ChatMessageDateAndStatusNode.Arguments) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation) -> ChatMessageDateAndStatusNode)),
|
||||||
@ -1757,7 +1757,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
|||||||
} else {
|
} else {
|
||||||
headerSize.height += 2.0
|
headerSize.height += 2.0
|
||||||
}
|
}
|
||||||
let sizeAndApply = replyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .bubble(incoming: incoming), replyMessage, CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
let sizeAndApply = replyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .bubble(incoming: incoming), replyMessage, item.message, CGSize(width: maximumNodeWidth - layoutConstants.text.bubbleInsets.left - layoutConstants.text.bubbleInsets.right, height: CGFloat.greatestFiniteMagnitude))
|
||||||
replyInfoSizeApply = (sizeAndApply.0, { sizeAndApply.1() })
|
replyInfoSizeApply = (sizeAndApply.0, { sizeAndApply.1() })
|
||||||
|
|
||||||
replyInfoOriginY = headerSize.height
|
replyInfoOriginY = headerSize.height
|
||||||
|
@ -458,7 +458,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
|
|||||||
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
||||||
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
||||||
} else {
|
} else {
|
||||||
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, item.message, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||||
}
|
}
|
||||||
} else if let _ = attribute as? InlineBotMessageAttribute {
|
} else if let _ = attribute as? InlineBotMessageAttribute {
|
||||||
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
||||||
|
@ -45,13 +45,13 @@ class ChatMessageReplyInfoNode: ASDisplayNode {
|
|||||||
self.contentNode.addSubnode(self.lineNode)
|
self.contentNode.addSubnode(self.lineNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
class func asyncLayout(_ maybeNode: ChatMessageReplyInfoNode?) -> (_ theme: ChatPresentationData, _ strings: PresentationStrings, _ context: AccountContext, _ type: ChatMessageReplyInfoType, _ message: Message, _ constrainedSize: CGSize) -> (CGSize, () -> ChatMessageReplyInfoNode) {
|
class func asyncLayout(_ maybeNode: ChatMessageReplyInfoNode?) -> (_ theme: ChatPresentationData, _ strings: PresentationStrings, _ context: AccountContext, _ type: ChatMessageReplyInfoType, _ message: Message, _ parentMessage: Message, _ constrainedSize: CGSize) -> (CGSize, () -> ChatMessageReplyInfoNode) {
|
||||||
let titleNodeLayout = TextNode.asyncLayout(maybeNode?.titleNode)
|
let titleNodeLayout = TextNode.asyncLayout(maybeNode?.titleNode)
|
||||||
let textNodeLayout = TextNode.asyncLayout(maybeNode?.textNode)
|
let textNodeLayout = TextNode.asyncLayout(maybeNode?.textNode)
|
||||||
let imageNodeLayout = TransformImageNode.asyncLayout(maybeNode?.imageNode)
|
let imageNodeLayout = TransformImageNode.asyncLayout(maybeNode?.imageNode)
|
||||||
let previousMediaReference = maybeNode?.previousMediaReference
|
let previousMediaReference = maybeNode?.previousMediaReference
|
||||||
|
|
||||||
return { presentationData, strings, context, type, message, constrainedSize in
|
return { presentationData, strings, context, type, message, parentMessage, constrainedSize in
|
||||||
let fontSize = floor(presentationData.fontSize.baseDisplaySize * 14.0 / 17.0)
|
let fontSize = floor(presentationData.fontSize.baseDisplaySize * 14.0 / 17.0)
|
||||||
let titleFont = Font.medium(fontSize)
|
let titleFont = Font.medium(fontSize)
|
||||||
let textFont = Font.regular(fontSize)
|
let textFont = Font.regular(fontSize)
|
||||||
@ -59,7 +59,7 @@ class ChatMessageReplyInfoNode: ASDisplayNode {
|
|||||||
let author = message.effectiveAuthor
|
let author = message.effectiveAuthor
|
||||||
var titleString = author.flatMap(EnginePeer.init)?.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder) ?? strings.User_DeletedAccount
|
var titleString = author.flatMap(EnginePeer.init)?.displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder) ?? strings.User_DeletedAccount
|
||||||
|
|
||||||
if let forwardInfo = message.forwardInfo {
|
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported) || parentMessage.forwardInfo != nil {
|
||||||
if let author = forwardInfo.author {
|
if let author = forwardInfo.author {
|
||||||
titleString = EnginePeer(author).displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)
|
titleString = EnginePeer(author).displayTitle(strings: strings, displayOrder: presentationData.nameDisplayOrder)
|
||||||
} else if let authorSignature = forwardInfo.authorSignature {
|
} else if let authorSignature = forwardInfo.authorSignature {
|
||||||
|
@ -570,7 +570,7 @@ class ChatMessageStickerItemNode: ChatMessageItemView {
|
|||||||
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
if let replyAttribute = attribute as? ReplyMessageAttribute, let replyMessage = item.message.associatedMessages[replyAttribute.messageId] {
|
||||||
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
if case let .replyThread(replyThreadMessage) = item.chatLocation, replyThreadMessage.messageId == replyAttribute.messageId {
|
||||||
} else {
|
} else {
|
||||||
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
replyInfoApply = makeReplyInfoLayout(item.presentationData, item.presentationData.strings, item.context, .standalone, replyMessage, item.message, CGSize(width: availableWidth, height: CGFloat.greatestFiniteMagnitude))
|
||||||
}
|
}
|
||||||
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
} else if let attribute = attribute as? ReplyMarkupMessageAttribute, attribute.flags.contains(.inline), !attribute.rows.isEmpty {
|
||||||
replyMarkup = attribute
|
replyMarkup = attribute
|
||||||
|
@ -5411,7 +5411,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate
|
|||||||
self?.controller?.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
|
self?.controller?.present(UndoOverlayController(presentationData: presentationData, content: .copy(text: presentationData.strings.Conversation_TextCopied), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), in: .window(.root))
|
||||||
})]
|
})]
|
||||||
|
|
||||||
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, ignoredLanguages: translationSettings.ignoredLanguages)
|
let (canTranslate, language) = canTranslateText(context: context, text: text, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: true, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||||
if canTranslate {
|
if canTranslate {
|
||||||
actions.append(ContextMenuAction(content: .text(title: presentationData.strings.Conversation_ContextMenuTranslate, accessibilityLabel: presentationData.strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
actions.append(ContextMenuAction(content: .text(title: presentationData.strings.Conversation_ContextMenuTranslate, accessibilityLabel: presentationData.strings.Conversation_ContextMenuTranslate), action: { [weak self] in
|
||||||
|
|
||||||
|
@ -282,7 +282,9 @@ public final class WebAppController: ViewController, AttachmentContainable {
|
|||||||
self.handleSendData(data: eventData)
|
self.handleSendData(data: eventData)
|
||||||
}
|
}
|
||||||
case "web_app_setup_main_button":
|
case "web_app_setup_main_button":
|
||||||
if let eventData = (body["eventData"] as? String)?.data(using: .utf8), let json = try? JSONSerialization.jsonObject(with: eventData, options: []) as? [String: Any] {
|
if let webView = self.webView, !webView.didTouchOnce {
|
||||||
|
|
||||||
|
} else if let eventData = (body["eventData"] as? String)?.data(using: .utf8), let json = try? JSONSerialization.jsonObject(with: eventData, options: []) as? [String: Any] {
|
||||||
if let isVisible = json["is_visible"] as? Bool {
|
if let isVisible = json["is_visible"] as? Bool {
|
||||||
let text = json["text"] as? String
|
let text = json["text"] as? String
|
||||||
let backgroundColorString = json["color"] as? String
|
let backgroundColorString = json["color"] as? String
|
||||||
|
@ -18,6 +18,12 @@ private class WeakGameScriptMessageHandler: NSObject, WKScriptMessageHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class WebViewTouchGestureRecognizer: UITapGestureRecognizer {
|
||||||
|
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
|
||||||
|
self.state = .began
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final class WebAppWebView: WKWebView {
|
final class WebAppWebView: WKWebView {
|
||||||
var handleScriptMessage: (WKScriptMessage) -> Void = { _ in }
|
var handleScriptMessage: (WKScriptMessage) -> Void = { _ in }
|
||||||
|
|
||||||
@ -76,6 +82,10 @@ final class WebAppWebView: WKWebView {
|
|||||||
strongSelf.handleScriptMessage(message)
|
strongSelf.handleScriptMessage(message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// let tapGestureRecognizer = WebViewTouchGestureRecognizer(target: self, action: #selector(self.handleTap))
|
||||||
|
// tapGestureRecognizer.delegate = self
|
||||||
|
// self.addGestureRecognizer(tapGestureRecognizer)
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
@ -106,4 +116,9 @@ final class WebAppWebView: WKWebView {
|
|||||||
func updateFrame(frame: CGRect, transition: ContainedViewLayoutTransition) {
|
func updateFrame(frame: CGRect, transition: ContainedViewLayoutTransition) {
|
||||||
self.sendEvent(name: "viewport_changed", data: "{height:\(frame.height)}")
|
self.sendEvent(name: "viewport_changed", data: "{height:\(frame.height)}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private(set) var didTouchOnce = true
|
||||||
|
@objc func handleTap() {
|
||||||
|
self.didTouchOnce = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user