mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Attachment menu improvements
This commit is contained in:
@@ -50,6 +50,8 @@ final class ContactSelectionControllerNode: ASDisplayNode {
|
||||
|
||||
private var selectionState: ContactListNodeGroupSelectionState?
|
||||
|
||||
var searchContainerNode: ContactsSearchContainerNode?
|
||||
|
||||
init(context: AccountContext, presentationData: PresentationData, options: [ContactListAdditionalOption], displayDeviceContacts: Bool, displayCallIcons: Bool, multipleSelection: Bool) {
|
||||
self.context = context
|
||||
self.presentationData = presentationData
|
||||
@@ -143,6 +145,80 @@ final class ContactSelectionControllerNode: ASDisplayNode {
|
||||
if let searchDisplayController = self.searchDisplayController {
|
||||
searchDisplayController.containerLayoutUpdated(layout, navigationBarHeight: navigationBarHeight, transition: transition)
|
||||
}
|
||||
|
||||
if let searchContainerNode = self.searchContainerNode {
|
||||
searchContainerNode.frame = CGRect(origin: CGPoint(), size: layout.size)
|
||||
searchContainerNode.containerLayoutUpdated(ContainerViewLayout(size: layout.size, metrics: LayoutMetrics(), deviceMetrics: layout.deviceMetrics, intrinsicInsets: layout.intrinsicInsets, safeInsets: layout.safeInsets, additionalInsets: layout.additionalInsets, statusBarHeight: nil, inputHeight: layout.inputHeight, inputHeightIsInteractivellyChanging: layout.inputHeightIsInteractivellyChanging, inVoiceOver: layout.inVoiceOver), navigationBarHeight: navigationBarHeight, transition: transition)
|
||||
}
|
||||
}
|
||||
|
||||
func scrollToTop() {
|
||||
if let searchContainerNode = self.searchContainerNode {
|
||||
searchContainerNode.scrollToTop()
|
||||
} else {
|
||||
self.contactListNode.scrollToTop()
|
||||
}
|
||||
}
|
||||
|
||||
func activateOverlaySearch() {
|
||||
guard let (containerLayout, navigationBarHeight, actualNavigationBarHeight) = self.containerLayout, let navigationBar = self.navigationBar, self.searchDisplayController == nil else {
|
||||
return
|
||||
}
|
||||
|
||||
var categories: ContactsSearchCategories = [.cloudContacts]
|
||||
if self.displayDeviceContacts {
|
||||
categories.insert(.deviceContacts)
|
||||
} else {
|
||||
categories.insert(.global)
|
||||
}
|
||||
|
||||
let searchContainerNode = ContactsSearchContainerNode(context: self.context, updatedPresentationData: (self.presentationData, self.presentationDataPromise.get()), onlyWriteable: false, categories: categories, addContact: nil, openPeer: { [weak self] peer in
|
||||
if let strongSelf = self {
|
||||
var updated = false
|
||||
strongSelf.contactListNode.updateSelectionState { state -> ContactListNodeGroupSelectionState? in
|
||||
if let state = state {
|
||||
updated = true
|
||||
var foundPeers = state.foundPeers
|
||||
var selectedPeerMap = state.selectedPeerMap
|
||||
selectedPeerMap[peer.id] = peer
|
||||
var exists = false
|
||||
for foundPeer in foundPeers {
|
||||
if peer.id == foundPeer.id {
|
||||
exists = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
foundPeers.insert(peer, at: 0)
|
||||
}
|
||||
return state.withToggledPeerId(peer.id).withFoundPeers(foundPeers).withSelectedPeerMap(selectedPeerMap)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
if updated {
|
||||
strongSelf.requestDeactivateSearch?()
|
||||
} else {
|
||||
strongSelf.requestOpenPeerFromSearch?(peer)
|
||||
}
|
||||
}
|
||||
}, contextAction: nil)
|
||||
self.insertSubnode(searchContainerNode, belowSubnode: navigationBar)
|
||||
self.searchContainerNode = searchContainerNode
|
||||
|
||||
searchContainerNode.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.3)
|
||||
|
||||
self.containerLayoutUpdated(containerLayout, navigationBarHeight: navigationBarHeight, actualNavigationBarHeight: actualNavigationBarHeight, transition: .immediate)
|
||||
}
|
||||
|
||||
func deactivateOverlaySearch() {
|
||||
guard let searchContainerNode = self.searchContainerNode else {
|
||||
return
|
||||
}
|
||||
searchContainerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false, completion: { [weak searchContainerNode] _ in
|
||||
searchContainerNode?.removeFromSupernode()
|
||||
})
|
||||
self.searchContainerNode = nil
|
||||
}
|
||||
|
||||
func activateSearch(placeholderNode: SearchBarPlaceholderNode) {
|
||||
|
||||
Reference in New Issue
Block a user