Fix search bar visibility in HashtagSearchControllerNode

This commit is contained in:
Sergey Degtyar 2026-02-24 00:16:09 +03:00
parent 63a37c5bec
commit e88baeeeb5
3 changed files with 20 additions and 1 deletions

View file

@ -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)

View file

@ -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)
}

View file

@ -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)
}
}