From ce5053c6ff2cc5dfcf1da91a8771725257553e78 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 5 Mar 2023 17:30:36 +0400 Subject: [PATCH] Various fixes --- .../Sources/ChatListController.swift | 1 + .../ChatListFilterPresetCategoryItem.swift | 18 ++++++------ .../ChatListFilterTabContainerNode.swift | 5 ++-- .../ReactionListContextMenuContent.swift | 14 ++++----- .../Sources/ContactsController.swift | 1 + submodules/Display/Source/ListView.swift | 5 ++++ .../MediaNavigationAccessoryHeaderNode.swift | 12 +++++--- .../Sources/TelegramBaseController.swift | 29 ++++++++++--------- .../TelegramUI/Sources/ChatController.swift | 4 +-- .../ChatInterfaceStateContextMenus.swift | 4 +-- 10 files changed, 54 insertions(+), 39 deletions(-) diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 28da92f370..7f6796980f 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -414,6 +414,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController } self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: placeholder, compactPlaceholder: compactPlaceholder, activate: { [weak self] in + self?.chatListDisplayNode.mainContainerNode.currentItemNode.cancelTracking() self?.activateSearch(filter: isForum ? .topics : .chats) }) self.searchContentNode?.updateExpansionProgress(0.0) diff --git a/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift b/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift index 92232725b7..bd6f470bbb 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterPresetCategoryItem.swift @@ -235,30 +235,30 @@ class ChatListFilterPresetCategoryItemNode: ItemListRevealOptionsItemNode, ItemL switch item.icon { case .contacts: color = .blue - imageName = "Chat/Context Menu/User" + imageName = "Chat List/Filters/Contact" case .nonContacts: color = .yellow - imageName = "Chat/Context Menu/UnknownUser" + imageName = "Chat List/Filters/User" case .groups: color = .green - imageName = "Chat/Context Menu/Groups" + imageName = "Chat List/Filters/Group" case .channels: color = .red - imageName = "Chat/Context Menu/Channels" + imageName = "Chat List/Filters/Channel" case .bots: color = .violet - imageName = "Chat/Context Menu/Bots" + imageName = "Chat List/Filters/Bot" case .muted: color = .red - imageName = "Chat/Context Menu/Muted" + imageName = "Chat List/Filters/Muted" case .read: color = .blue - imageName = "Chat/Context Menu/Message" + imageName = "Chat List/Filters/Read" case .archived: color = .yellow - imageName = "Chat/Context Menu/Archive" + imageName = "Chat List/Filters/Archive" } - updatedAvatarImage = generateAvatarImage(size: CGSize(width: avatarSize, height: avatarSize), icon: generateTintedImage(image: UIImage(bundleImageName: imageName), color: .white), color: color) + updatedAvatarImage = generateAvatarImage(size: CGSize(width: avatarSize, height: avatarSize), icon: generateTintedImage(image: UIImage(bundleImageName: imageName), color: .white), cornerRadius: 12.0, color: color) } let revealOffset = strongSelf.revealOffset diff --git a/submodules/ChatListUI/Sources/ChatListFilterTabContainerNode.swift b/submodules/ChatListUI/Sources/ChatListFilterTabContainerNode.swift index 8918c05f3d..f1a210d73e 100644 --- a/submodules/ChatListUI/Sources/ChatListFilterTabContainerNode.swift +++ b/submodules/ChatListUI/Sources/ChatListFilterTabContainerNode.swift @@ -157,7 +157,8 @@ private final class ItemNode: ASDisplayNode { self.containerNode.addSubnode(self.extractedContainerNode) self.containerNode.targetNodeForActivationProgress = self.extractedContainerNode.contentNode self.addSubnode(self.containerNode) - + + self.buttonNode.isExclusiveTouch = true self.buttonNode.addTarget(self, action: #selector(self.buttonPressed), forControlEvents: .touchUpInside) self.containerNode.activated = { [weak self] gesture, _ in @@ -185,7 +186,7 @@ private final class ItemNode: ASDisplayNode { override func didLoad() { super.didLoad() - + self.pointerInteraction = PointerInteraction(view: self.containerNode.view, customInteractionView: nil, style: .insetRectangle(-10.0, 4.0)) } diff --git a/submodules/Components/ReactionListContextMenuContent/Sources/ReactionListContextMenuContent.swift b/submodules/Components/ReactionListContextMenuContent/Sources/ReactionListContextMenuContent.swift index 7fb923d3b1..624fab38f2 100644 --- a/submodules/Components/ReactionListContextMenuContent/Sources/ReactionListContextMenuContent.swift +++ b/submodules/Components/ReactionListContextMenuContent/Sources/ReactionListContextMenuContent.swift @@ -740,7 +740,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent let reaction: MessageReaction.Reaction? private let requestUpdate: (ReactionsTabNode, ContainedViewLayoutTransition) -> Void private let requestUpdateApparentHeight: (ReactionsTabNode, ContainedViewLayoutTransition) -> Void - private let openPeer: (EnginePeer) -> Void + private let openPeer: (EnginePeer, Bool) -> Void private var hasMore: Bool = false @@ -773,7 +773,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent readStats: MessageReadStats?, requestUpdate: @escaping (ReactionsTabNode, ContainedViewLayoutTransition) -> Void, requestUpdateApparentHeight: @escaping (ReactionsTabNode, ContainedViewLayoutTransition) -> Void, - openPeer: @escaping (EnginePeer) -> Void + openPeer: @escaping (EnginePeer, Bool) -> Void ) { self.context = context self.displayReadTimestamps = displayReadTimestamps @@ -888,7 +888,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent let openPeer = self.openPeer let peer = item.peer itemNode = ItemNode(context: self.context, displayReadTimestamps: self.displayReadTimestamps, availableReactions: self.availableReactions, animationCache: self.animationCache, animationRenderer: self.animationRenderer, action: { - openPeer(peer) + openPeer(peer, item.reaction != nil) }) self.itemNodes[index] = itemNode self.scrollNode.addSubnode(itemNode) @@ -1060,7 +1060,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent } private var interactiveTransitionState: InteractiveTransitionState? - private let openPeer: (EnginePeer) -> Void + private let openPeer: (EnginePeer, Bool) -> Void private(set) var apparentHeight: CGFloat = 0.0 @@ -1076,7 +1076,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent requestUpdate: @escaping (ContainedViewLayoutTransition) -> Void, requestUpdateApparentHeight: @escaping (ContainedViewLayoutTransition) -> Void, back: (() -> Void)?, - openPeer: @escaping (EnginePeer) -> Void + openPeer: @escaping (EnginePeer, Bool) -> Void ) { self.context = context self.displayReadTimestamps = displayReadTimestamps @@ -1426,7 +1426,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent let reaction: MessageReaction.Reaction? let readStats: MessageReadStats? let back: (() -> Void)? - let openPeer: (EnginePeer) -> Void + let openPeer: (EnginePeer, Bool) -> Void public init( context: AccountContext, @@ -1438,7 +1438,7 @@ public final class ReactionListContextMenuContent: ContextControllerItemsContent reaction: MessageReaction.Reaction?, readStats: MessageReadStats?, back: (() -> Void)?, - openPeer: @escaping (EnginePeer) -> Void + openPeer: @escaping (EnginePeer, Bool) -> Void ) { self.context = context self.displayReadTimestamps = displayReadTimestamps diff --git a/submodules/ContactListUI/Sources/ContactsController.swift b/submodules/ContactListUI/Sources/ContactsController.swift index d1cb89b843..00b02ea55d 100644 --- a/submodules/ContactListUI/Sources/ContactsController.swift +++ b/submodules/ContactListUI/Sources/ContactsController.swift @@ -265,6 +265,7 @@ public class ContactsController: ViewController { } self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search, activate: { [weak self] in + self?.contactsNode.contactListNode.listNode.cancelTracking() self?.activateSearch() }) self.navigationBar?.setContentNode(self.searchContentNode, animated: false) diff --git a/submodules/Display/Source/ListView.swift b/submodules/Display/Source/ListView.swift index b01493bee6..0832ceeb75 100644 --- a/submodules/Display/Source/ListView.swift +++ b/submodules/Display/Source/ListView.swift @@ -1362,6 +1362,11 @@ open class ListView: ASDisplayNode, UIScrollViewAccessibilityDelegate, UIGesture self.ignoreScrollingEvents = wasIgnoringScrollingEvents } + public func cancelTracking() { + self.scroller.panGestureRecognizer.isEnabled = false + self.scroller.panGestureRecognizer.isEnabled = true + } + private func updateTopItemOverscrollBackground(transition: ContainedViewLayoutTransition) { if let value = self.keepTopItemOverscrollBackground { var applyTransition = transition diff --git a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift index fb9bcb5462..87222f20e4 100644 --- a/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift +++ b/submodules/TelegramBaseController/Sources/MediaNavigationAccessoryHeaderNode.swift @@ -213,6 +213,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi } } + private weak var tooltipController: TooltipScreen? private let dismissedPromise = ValuePromise(false) public init(context: AccountContext, presentationData: PresentationData) { @@ -424,6 +425,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi return } + self.tooltipController?.dismiss() self.dismissedPromise.set(true) transition.updatePosition(node: self.separatorNode, position: self.separatorNode.position.offsetBy(dx: 0.0, dy: size.height)) @@ -434,7 +436,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi let minHeight = MediaNavigationAccessoryHeaderNode.minimizedHeight - let inset: CGFloat = 40.0 + leftInset + let inset: CGFloat = 45.0 + leftInset let constrainedSize = CGSize(width: size.width - inset * 2.0, height: size.height) let (titleString, subtitleString, rateButtonHidden) = self.currentItemNode.updateLayout(size: constrainedSize, leftInset: leftInset, rightInset: rightInset, theme: self.theme, strings: self.strings, dateTimeFormat: self.dateTimeFormat, nameDisplayOrder: self.nameDisplayOrder, playbackItem: self.playbackItems?.0, transition: transition) self.accessibilityAreaNode.accessibilityLabel = "\(titleString?.string ?? ""). \(subtitleString?.string ?? "")" @@ -474,7 +476,7 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi let closeButtonSize = self.closeButton.measure(CGSize(width: 100.0, height: 100.0)) transition.updateFrame(node: self.closeButton, frame: CGRect(origin: CGPoint(x: bounds.size.width - 44.0 - rightInset, y: 0.0), size: CGSize(width: 44.0, height: minHeight))) let rateButtonSize = CGSize(width: 30.0, height: minHeight) - transition.updateFrame(node: self.rateButton, frame: CGRect(origin: CGPoint(x: bounds.size.width - 33.0 - closeButtonSize.width - rateButtonSize.width - rightInset, y: -4.0), size: rateButtonSize)) + transition.updateFrame(node: self.rateButton, frame: CGRect(origin: CGPoint(x: bounds.size.width - 27.0 - closeButtonSize.width - rateButtonSize.width - rightInset, y: -4.0), size: rateButtonSize)) transition.updateFrame(node: self.playPauseIconNode, frame: CGRect(origin: CGPoint(x: 6.0, y: 4.0 + UIScreenPixel), size: CGSize(width: 28.0, height: 28.0))) transition.updateFrame(node: self.actionButton, frame: CGRect(origin: CGPoint(x: leftInset, y: 0.0), size: CGSize(width: 40.0, height: 37.0))) @@ -524,9 +526,11 @@ public final class MediaNavigationAccessoryHeaderNode: ASDisplayNode, UIScrollVi let _ = (ApplicationSpecificNotice.incrementAudioRateOptionsTip(accountManager: self.context.sharedContext.accountManager) |> deliverOnMainQueue).start(next: { [weak self] value in if let strongSelf = self, let controller = strongSelf.getController?(), value == 2 { - controller.present(TooltipScreen(account: strongSelf.context.account, text: strongSelf.strings.Conversation_AudioRateOptionsTooltip, style: .default, icon: nil, location: .point(frame.offsetBy(dx: 0.0, dy: 4.0), .bottom), displayDuration: .custom(3.0), inset: 3.0, shouldDismissOnTouch: { _ in + let tooltipController = TooltipScreen(account: strongSelf.context.account, text: strongSelf.strings.Conversation_AudioRateOptionsTooltip, style: .default, icon: nil, location: .point(frame.offsetBy(dx: 0.0, dy: 4.0), .bottom), displayDuration: .custom(3.0), inset: 3.0, shouldDismissOnTouch: { _ in return .dismiss(consume: false) - }), in: .window(.root)) + }) + controller.present(tooltipController, in: .window(.root)) + strongSelf.tooltipController = tooltipController } }) } diff --git a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift index d9a0790e70..5d344a7a3c 100644 --- a/submodules/TelegramBaseController/Sources/TelegramBaseController.swift +++ b/submodules/TelegramBaseController/Sources/TelegramBaseController.swift @@ -88,6 +88,8 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { private var dismissingPanel: ASDisplayNode? + private weak var audioRateTooltipController: UndoOverlayController? + private var presentationData: PresentationData private var presentationDataDisposable: Disposable? private var playlistPreloadDisposable: Disposable? @@ -648,6 +650,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { if let (mediaAccessoryPanel, _) = self.mediaAccessoryPanel { self.mediaAccessoryPanel = nil self.dismissingPanel = mediaAccessoryPanel + self.audioRateTooltipController?.dismissWithCommitAction() mediaAccessoryPanel.animateOut(transition: transition, completion: { [weak self, weak mediaAccessoryPanel] in mediaAccessoryPanel?.removeFromSupernode() if let strongSelf = self, strongSelf.dismissingPanel === mediaAccessoryPanel { @@ -731,21 +734,20 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { showTooltip = false } if let rate, let text, showTooltip { - strongSelf.present( - UndoOverlayController( - presentationData: presentationData, - content: .audioRate( - rate: rate, - text: text - ), - elevatedLayout: false, - animateInAsReplacement: hasTooltip, - action: { action in - return true - } + let controller = UndoOverlayController( + presentationData: presentationData, + content: .audioRate( + rate: rate, + text: text ), - in: .current + elevatedLayout: false, + animateInAsReplacement: hasTooltip, + action: { action in + return true + } ) + strongSelf.audioRateTooltipController = controller + strongSelf.present(controller, in: .current) } }) } @@ -867,6 +869,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder { } else if let (mediaAccessoryPanel, _) = self.mediaAccessoryPanel { self.mediaAccessoryPanel = nil self.dismissingPanel = mediaAccessoryPanel + self.audioRateTooltipController?.dismissWithCommitAction() mediaAccessoryPanel.animateOut(transition: transition, completion: { [weak self, weak mediaAccessoryPanel] in mediaAccessoryPanel?.removeFromSupernode() if let strongSelf = self, strongSelf.dismissingPanel === mediaAccessoryPanel { diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 9b592a150d..887fe142c7 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -1511,13 +1511,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G availableReactions: availableReactions, animationCache: strongSelf.controllerInteraction!.presentationContext.animationCache, animationRenderer: strongSelf.controllerInteraction!.presentationContext.animationRenderer, - message: EngineMessage(message), reaction: value, readStats: nil, back: nil, openPeer: { peer in + message: EngineMessage(message), reaction: value, readStats: nil, back: nil, openPeer: { peer, hasReaction in dismissController?({ guard let strongSelf = self else { return } - strongSelf.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message), fromReactionMessageId: message.id) + strongSelf.openPeer(peer: peer, navigation: .default, fromMessage: MessageReference(message), fromReactionMessageId: hasReaction ? message.id : nil) }) }))) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift index 8c235f8f6e..1b559b012e 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceStateContextMenus.swift @@ -1800,9 +1800,9 @@ func contextMenuForChatPresentationInterfaceState(chatPresentationInterfaceState back: { [weak c] in c?.popItems() }, - openPeer: { [weak c] peer in + openPeer: { [weak c] peer, hasReaction in c?.dismiss(completion: { - controllerInteraction.openPeer(peer, .default, MessageReference(message), .reaction) + controllerInteraction.openPeer(peer, .default, MessageReference(message), hasReaction ? .reaction : .default) }) } )), tip: tip)))