Various improvements

This commit is contained in:
Isaac
2025-06-06 15:13:43 +08:00
parent e53af6f87d
commit cd3c27fcc2
11 changed files with 103 additions and 35 deletions

View File

@@ -74,6 +74,13 @@ func leftNavigationButtonForChatInterfaceState(_ presentationInterfaceState: Cha
}
func rightNavigationButtonForChatInterfaceState(context: AccountContext, presentationInterfaceState: ChatPresentationInterfaceState, strings: PresentationStrings, currentButton: ChatNavigationButton?, target: Any?, selector: Selector?, chatInfoNavigationButton: ChatNavigationButton?, moreInfoNavigationButton: ChatNavigationButton?) -> ChatNavigationButton? {
var hasMessages = false
if let chatHistoryState = presentationInterfaceState.chatHistoryState {
if case .loaded(false, _) = chatHistoryState {
hasMessages = true
}
}
if let _ = presentationInterfaceState.interfaceState.selectionState {
if case .messageOptions = presentationInterfaceState.subject {
return nil
@@ -100,12 +107,18 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present
}
if let channel = presentationInterfaceState.renderedPeer?.peer as? TelegramChannel, channel.isMonoForum, case .peer = presentationInterfaceState.chatLocation {
if case .search(false) = currentButton?.action {
return currentButton
let displaySearch = hasMessages
if displaySearch {
if case .search(false) = currentButton?.action {
return currentButton
} else {
let buttonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector)
buttonItem.accessibilityLabel = strings.Conversation_Search
return ChatNavigationButton(action: .search(hasTags: false), buttonItem: buttonItem)
}
} else {
let buttonItem = UIBarButtonItem(image: PresentationResourcesRootController.navigationCompactSearchIcon(presentationInterfaceState.theme), style: .plain, target: target, action: selector)
buttonItem.accessibilityLabel = strings.Conversation_Search
return ChatNavigationButton(action: .search(hasTags: false), buttonItem: buttonItem)
return nil
}
}
@@ -119,13 +132,6 @@ func rightNavigationButtonForChatInterfaceState(context: AccountContext, present
}
}
var hasMessages = false
if let chatHistoryState = presentationInterfaceState.chatHistoryState {
if case .loaded(false, _) = chatHistoryState {
hasMessages = true
}
}
if case .messageOptions = presentationInterfaceState.subject {
return nil
}