Disable search and Select All in Invite Friends while contacts are loading

This commit is contained in:
Ilya Laktyushin
2019-07-02 22:36:16 +02:00
parent cc5f543ed3
commit 5ff62cf99d
2 changed files with 16 additions and 2 deletions

View File

@@ -39,7 +39,6 @@ public class InviteContactsController: ViewController, MFMessageComposeViewContr
self.title = self.presentationData.strings.Contacts_InviteFriends
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: presentationData.strings.Contacts_SelectAll, style: .plain, target: self, action: #selector(self.selectAllPressed))
self.scrollToTop = { [weak self] in
if let strongSelf = self {
@@ -67,6 +66,7 @@ public class InviteContactsController: ViewController, MFMessageComposeViewContr
self.searchContentNode = NavigationBarSearchContentNode(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search, activate: { [weak self] in
self?.activateSearch()
})
self.searchContentNode?.setIsEnabled(false)
self.navigationBar?.setContentNode(self.searchContentNode, animated: false)
}
@@ -84,6 +84,7 @@ public class InviteContactsController: ViewController, MFMessageComposeViewContr
self.searchContentNode?.updateThemeAndPlaceholder(theme: self.presentationData.theme, placeholder: self.presentationData.strings.Common_Search)
self.title = self.presentationData.strings.Contacts_InviteFriends
self.navigationItem.backBarButtonItem = UIBarButtonItem(title: self.presentationData.strings.Common_Back, style: .plain, target: nil, action: nil)
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: presentationData.strings.Contacts_SelectAll, style: .plain, target: self, action: #selector(self.selectAllPressed))
}
override public func loadDisplayNode() {
@@ -92,6 +93,14 @@ public class InviteContactsController: ViewController, MFMessageComposeViewContr
self.contactsNode.navigationBar = self.navigationBar
self.contactsNode.loadedContacts = { [weak self] in
if let strongSelf = self {
self?.searchContentNode?.setIsEnabled(true)
strongSelf.navigationItem.rightBarButtonItem = UIBarButtonItem(title: strongSelf.presentationData.strings.Contacts_SelectAll, style: .plain, target: self, action: #selector(strongSelf.selectAllPressed))
}
}
self.contactsNode.requestDeactivateSearch = { [weak self] in
self?.deactivateSearch()
}

View File

@@ -265,6 +265,8 @@ final class InviteContactsControllerNode: ASDisplayNode {
return self._ready.get()
}
var loadedContacts: (() -> Void)?
private var disposable: Disposable?
private let currentContactIds = Atomic<[String]>(value: [])
@@ -578,7 +580,10 @@ final class InviteContactsControllerNode: ASDisplayNode {
activityIndicator.removeFromSupernode()
}
let _ = strongSelf.currentSortedContacts.swap(transition.sortedContacts)
let previous = strongSelf.currentSortedContacts.swap(transition.sortedContacts)
if previous == nil && transition.sortedContacts != nil {
strongSelf.loadedContacts?()
}
}
})
}