diff --git a/submodules/AccountContext/Sources/ChatController.swift b/submodules/AccountContext/Sources/ChatController.swift index 3e9c3644abd..6aab17668a6 100644 --- a/submodules/AccountContext/Sources/ChatController.swift +++ b/submodules/AccountContext/Sources/ChatController.swift @@ -1083,6 +1083,8 @@ public protocol ChatController: ViewController { var isSendButtonVisible: Bool { get } var isSelectingMessagesUpdated: ((Bool) -> Void)? { get set } + var onGalleryPresentationInContextChanged: ((Bool) -> Void)? { get set } + func cancelSelectingMessages() func activateSearch(domain: ChatSearchDomain, query: String) func activateInput(type: ChatControllerActivateInput) diff --git a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift index 1ddedfee3db..90a1686aedf 100644 --- a/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift +++ b/submodules/HashtagSearchUI/Sources/HashtagSearchControllerNode.swift @@ -192,6 +192,21 @@ final class HashtagSearchControllerNode: ASDisplayNode, ASGestureRecognizerDeleg } } + var galleryPresentationCount = 0 + let updateSearchBarVisibility: (Bool) -> Void = { [weak self] isPresented in + guard let self else { return } + if isPresented { + galleryPresentationCount += 1 + } else { + galleryPresentationCount -= 1 + } + let shouldHide = galleryPresentationCount > 0 + self.controller?.navigationBar?.setContentNode(shouldHide ? nil : self.searchContentNode, animated: true) + } + self.currentController?.onGalleryPresentationInContextChanged = updateSearchBarVisibility + self.myController?.onGalleryPresentationInContextChanged = updateSearchBarVisibility + self.globalController?.onGalleryPresentationInContextChanged = updateSearchBarVisibility + if controller.mode != .chatOnly { navigationBar?.setContentNode(self.searchContentNode, animated: false) } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index f344f3ce9cb..d00e806f0ec 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -311,6 +311,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G let temporaryHiddenGalleryMediaDisposable = MetaDisposable() let galleryPresentationContext = PresentationContext() + public var onGalleryPresentationInContextChanged: ((Bool) -> Void)? let chatBackgroundNode: WallpaperBackgroundNode public private(set) var controllerInteraction: ChatControllerInteraction? @@ -6792,11 +6793,12 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G override public func loadDisplayNode() { self.loadDisplayNodeImpl() self.galleryPresentationContext.view = self.view - self.galleryPresentationContext.controllersUpdated = { [weak self] _ in + self.galleryPresentationContext.controllersUpdated = { [weak self] controllers in guard let self else { return } self.updateStatusBarPresentation() + self.onGalleryPresentationInContextChanged?(!controllers.isEmpty) } }