From 8f9f7185af669dff4787e20db2c9a84821a06030 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Tue, 16 Aug 2022 15:03:27 +0300 Subject: [PATCH] Various fixes --- submodules/AttachmentUI/BUILD | 1 + .../AttachmentUI/Sources/AttachmentPanel.swift | 16 +++++++++++----- submodules/Display/Source/WindowContent.swift | 15 ++++++++++++++- .../TelegramUI/Sources/ChatController.swift | 3 +-- .../TelegramUI/Sources/ChatControllerNode.swift | 2 +- .../ChatMessageAnimatedStickerItemNode.swift | 1 + .../ChatPinnedMessageTitlePanelNode.swift | 3 +++ 7 files changed, 32 insertions(+), 9 deletions(-) diff --git a/submodules/AttachmentUI/BUILD b/submodules/AttachmentUI/BUILD index d74a51a6ae..5c773e805d 100644 --- a/submodules/AttachmentUI/BUILD +++ b/submodules/AttachmentUI/BUILD @@ -34,6 +34,7 @@ swift_library( "//submodules/SemanticStatusNode:SemanticStatusNode", "//submodules/MoreButtonNode:MoreButtonNode", "//submodules/Components/AnimatedStickerComponent:AnimatedStickerComponent", + "//submodules/Components/MultilineTextComponent:MultilineTextComponent", ], visibility = [ "//visibility:public", diff --git a/submodules/AttachmentUI/Sources/AttachmentPanel.swift b/submodules/AttachmentUI/Sources/AttachmentPanel.swift index bdc2e56aca..ca9f74c8b7 100644 --- a/submodules/AttachmentUI/Sources/AttachmentPanel.swift +++ b/submodules/AttachmentUI/Sources/AttachmentPanel.swift @@ -16,6 +16,7 @@ import PhotoResources import AnimatedStickerComponent import SemanticStatusNode import MediaResources +import MultilineTextComponent private let buttonSize = CGSize(width: 88.0, height: 49.0) private let smallButtonWidth: CGFloat = 69.0 @@ -162,7 +163,7 @@ private final class AttachButtonComponent: CombinedComponent { static var body: Body { let icon = Child(IconComponent.self) let animatedIcon = Child(AnimatedStickerComponent.self) - let title = Child(Text.self) + let title = Child(MultilineTextComponent.self) let button = Child(Rectangle.self) return { context in @@ -257,10 +258,15 @@ private final class AttachButtonComponent: CombinedComponent { } let title = title.update( - component: Text( - text: name, - font: Font.regular(10.0), - color: context.component.isSelected ? component.theme.rootController.tabBar.selectedTextColor : component.theme.rootController.tabBar.textColor + component: MultilineTextComponent( + text: .plain(NSAttributedString( + string: name, + font: Font.regular(10.0), + textColor: context.component.isSelected ? component.theme.rootController.tabBar.selectedTextColor : component.theme.rootController.tabBar.textColor, + paragraphAlignment: .center)), + horizontalAlignment: .center, + truncationType: .end, + maximumNumberOfLines: 1 ), availableSize: context.availableSize, transition: .immediate diff --git a/submodules/Display/Source/WindowContent.swift b/submodules/Display/Source/WindowContent.swift index d900abbbf7..186bf3489b 100644 --- a/submodules/Display/Source/WindowContent.swift +++ b/submodules/Display/Source/WindowContent.swift @@ -490,7 +490,16 @@ public class Window1 { self.keyboardFrameChangeObserver = NotificationCenter.default.addObserver(forName: UIResponder.keyboardWillChangeFrameNotification, object: nil, queue: nil, using: { [weak self] notification in if let strongSelf = self { + var isTablet = false + if case .regular = strongSelf.windowLayout.metrics.widthClass { + isTablet = true + } + var keyboardFrame: CGRect = (notification.userInfo?[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue ?? CGRect() + if isTablet && keyboardFrame.isEmpty { + return + } + if #available(iOSApplicationExtension 14.2, iOS 14.2, *), UIAccessibility.prefersCrossFadeTransitions { } else if let keyboardView = strongSelf.statusBarHost?.keyboardView { if keyboardFrame.width.isEqual(to: keyboardView.bounds.width) && keyboardFrame.height.isEqual(to: keyboardView.bounds.height) && keyboardFrame.minX.isEqual(to: keyboardView.frame.minX) { @@ -540,7 +549,11 @@ public class Window1 { var keyboardHeight: CGFloat if keyboardFrame.isEmpty || keyboardFrame.maxY < screenHeight { - keyboardHeight = 0.0 + if isTablet && screenHeight - keyboardFrame.maxY < 5.0 { + keyboardHeight = max(0.0, screenHeight - keyboardFrame.minY) + } else { + keyboardHeight = 0.0 + } } else { keyboardHeight = max(0.0, screenHeight - keyboardFrame.minY) if inPopover && !keyboardHeight.isZero { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 3a5fe4f4dc..8213737cda 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -15498,8 +15498,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G if let strongSelf = self { strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, { $0.updatedInterfaceState { $0.withoutSelectionState() } }) if actions.contains(3) { - let context = strongSelf.context - let _ = context.engine.messages.deleteAllMessagesWithAuthor(peerId: peerId, authorId: author.id, namespace: Namespaces.Message.Cloud).start() + let _ = strongSelf.context.engine.messages.deleteAllMessagesWithAuthor(peerId: peerId, authorId: author.id, namespace: Namespaces.Message.Cloud).start() let _ = strongSelf.context.engine.messages.clearAuthorHistory(peerId: peerId, memberId: author.id).start() } else if actions.contains(0) { let _ = strongSelf.context.engine.messages.deleteMessagesInteractively(messageIds: Array(messageIds), type: .forEveryone).start() diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index b769d46098..1243c3130f 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -1482,7 +1482,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { let inputBackgroundInset: CGFloat if cleanInsets.bottom < insets.bottom { - if case .regular = layout.metrics.widthClass, let inputHeight = layout.inputHeight, inputHeight < 88.0 { + if case .regular = layout.metrics.widthClass, insets.bottom < 88.0 { inputBackgroundInset = insets.bottom } else { inputBackgroundInset = 0.0 diff --git a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift index d68ed525c6..8a259a6c76 100644 --- a/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageAnimatedStickerItemNode.swift @@ -109,6 +109,7 @@ class ChatMessageShareButton: HighlightableButtonNode { var updatedIconOffset = CGPoint() if case .pinnedMessages = subject { updatedIconImage = PresentationResourcesChat.chatFreeNavigateButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) + updatedIconOffset = CGPoint(x: UIScreenPixel, y: 1.0) } else if isReplies { updatedIconImage = PresentationResourcesChat.chatFreeCommentButtonIcon(presentationData.theme.theme, wallpaper: presentationData.theme.wallpaper) } else if message.id.peerId.isRepliesOrSavedMessages(accountPeerId: account.peerId) { diff --git a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift index c07d3aa24c..cb4bcc5e94 100644 --- a/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatPinnedMessageTitlePanelNode.swift @@ -83,6 +83,9 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode { private let queue = Queue() override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { + if let buttonResult = self.buttonsContainer.hitTest(point.offsetBy(dx: -self.buttonsContainer.frame.minX, dy: -self.buttonsContainer.frame.minY), with: event) { + return buttonResult + } let containerResult = self.contentTextContainer.hitTest(point.offsetBy(dx: -self.contentTextContainer.frame.minX, dy: -self.contentTextContainer.frame.minY), with: event) if containerResult?.asyncdisplaykit_node === self.dustNode, self.dustNode?.isRevealed == false { return containerResult