mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various fixes
This commit is contained in:
@@ -14,6 +14,7 @@ import AttachmentUI
|
||||
import SearchBarNode
|
||||
import ChatSendAudioMessageContextPreview
|
||||
import ChatSendMessageActionUI
|
||||
import ContextUI
|
||||
|
||||
class ContactSelectionControllerImpl: ViewController, ContactSelectionController, PresentableController, AttachmentContainable {
|
||||
private let context: AccountContext
|
||||
@@ -42,6 +43,9 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController
|
||||
private let multipleSelection: Bool
|
||||
private let requirePhoneNumbers: Bool
|
||||
|
||||
private let openProfile: ((EnginePeer) -> Void)?
|
||||
private let sendMessage: ((EnginePeer) -> Void)?
|
||||
|
||||
private var _ready = Promise<Bool>()
|
||||
override var ready: Promise<Bool> {
|
||||
return self._ready
|
||||
@@ -105,6 +109,9 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController
|
||||
self.multipleSelection = params.multipleSelection
|
||||
self.requirePhoneNumbers = params.requirePhoneNumbers
|
||||
|
||||
self.openProfile = params.openProfile
|
||||
self.sendMessage = params.sendMessage
|
||||
|
||||
self.presentationData = params.updatedPresentationData?.initial ?? params.context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
super.init(navigationBarPresentationData: NavigationBarPresentationData(presentationData: self.presentationData))
|
||||
@@ -219,15 +226,15 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController
|
||||
}
|
||||
|
||||
self.contactsNode.requestOpenPeerFromSearch = { [weak self] peer in
|
||||
self?.openPeer(peer: peer, action: .generic)
|
||||
self?.openPeer(peer: peer, action: .generic, node: nil, gesture: nil)
|
||||
}
|
||||
|
||||
self.contactsNode.contactListNode.activateSearch = { [weak self] in
|
||||
self?.activateSearch()
|
||||
}
|
||||
|
||||
self.contactsNode.contactListNode.openPeer = { [weak self] peer, action, _, _ in
|
||||
self?.openPeer(peer: peer, action: action)
|
||||
self.contactsNode.contactListNode.openPeer = { [weak self] peer, action, node, gesture in
|
||||
self?.openPeer(peer: peer, action: action, node: node, gesture: gesture)
|
||||
}
|
||||
|
||||
self.contactsNode.contactListNode.suppressPermissionWarning = { [weak self] in
|
||||
@@ -357,7 +364,40 @@ class ContactSelectionControllerImpl: ViewController, ContactSelectionController
|
||||
}
|
||||
}
|
||||
|
||||
private func openPeer(peer: ContactListPeer, action: ContactListAction) {
|
||||
private func openPeer(peer: ContactListPeer, action: ContactListAction, node: ASDisplayNode?, gesture: ContextGesture?) {
|
||||
if case .more = action {
|
||||
guard case let .peer(peer, _, _) = peer, let node = node as? ContextReferenceContentNode else {
|
||||
return
|
||||
}
|
||||
|
||||
let presentationData = self.presentationData
|
||||
|
||||
var items: [ContextMenuItem] = []
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Premium_Gift_ContactSelection_SendMessage, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/MessageBubble"), color: theme.contextMenu.primaryColor)
|
||||
}, iconPosition: .left, action: { [weak self] _, a in
|
||||
a(.default)
|
||||
|
||||
if let self {
|
||||
self.sendMessage?(EnginePeer(peer))
|
||||
}
|
||||
})))
|
||||
|
||||
items.append(.action(ContextMenuActionItem(text: presentationData.strings.Premium_Gift_ContactSelection_OpenProfile, icon: { theme in
|
||||
return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/User"), color: theme.contextMenu.primaryColor)
|
||||
}, iconPosition: .left, action: { [weak self] _, a in
|
||||
a(.default)
|
||||
|
||||
if let self {
|
||||
self.openProfile?(EnginePeer(peer))
|
||||
}
|
||||
})))
|
||||
|
||||
let contextController = ContextController(presentationData: presentationData, source: .reference(ContactContextReferenceContentSource(controller: self, sourceNode: node)), items: .single(ContextController.Items(content: .list(items))), gesture: gesture)
|
||||
self.present(contextController, in: .window(.root))
|
||||
return
|
||||
}
|
||||
|
||||
self.contactsNode.contactListNode.listNode.clearHighlightAnimated(true)
|
||||
self.confirmationDisposable.set((self.confirmation(peer) |> deliverOnMainQueue).startStrict(next: { [weak self] value in
|
||||
if let strongSelf = self {
|
||||
@@ -477,3 +517,17 @@ final class ContactsPickerContext: AttachmentMediaPickerContext {
|
||||
func mainButtonAction() {
|
||||
}
|
||||
}
|
||||
|
||||
private final class ContactContextReferenceContentSource: ContextReferenceContentSource {
|
||||
private let controller: ViewController
|
||||
private let sourceNode: ContextReferenceContentNode
|
||||
|
||||
init(controller: ViewController, sourceNode: ContextReferenceContentNode) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
}
|
||||
|
||||
func transitionInfo() -> ContextControllerReferenceViewInfo? {
|
||||
return ContextControllerReferenceViewInfo(referenceView: self.sourceNode.view, contentAreaInScreenSpace: UIScreen.main.bounds)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user