diff --git a/Signal.xcodeproj/project.pbxproj b/Signal.xcodeproj/project.pbxproj index f302588cc..1748c937c 100644 --- a/Signal.xcodeproj/project.pbxproj +++ b/Signal.xcodeproj/project.pbxproj @@ -175,7 +175,6 @@ 34B0796D1FCF46B100E248C2 /* MainAppContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B0796B1FCF46B000E248C2 /* MainAppContext.m */; }; 34B3F8751E8DF1700035BE1A /* CallViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F83B1E8DF1700035BE1A /* CallViewController.swift */; }; 34B3F8771E8DF1700035BE1A /* ContactsPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F83E1E8DF1700035BE1A /* ContactsPicker.swift */; }; - 34B3F8781E8DF1700035BE1A /* ContactsPicker.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34B3F83F1E8DF1700035BE1A /* ContactsPicker.xib */; }; 34B3F87B1E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8441E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift */; }; 34B3F8801E8DF1700035BE1A /* InviteFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */; }; 34B3F8821E8DF1700035BE1A /* NewContactThreadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 34B3F8501E8DF1700035BE1A /* NewContactThreadViewController.m */; }; @@ -804,7 +803,6 @@ 34B3F83A1E8DF1700035BE1A /* AttachmentSharing.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentSharing.m; sourceTree = ""; }; 34B3F83B1E8DF1700035BE1A /* CallViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CallViewController.swift; sourceTree = ""; }; 34B3F83E1E8DF1700035BE1A /* ContactsPicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContactsPicker.swift; sourceTree = ""; }; - 34B3F83F1E8DF1700035BE1A /* ContactsPicker.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ContactsPicker.xib; sourceTree = ""; }; 34B3F8441E8DF1700035BE1A /* ExperienceUpgradesPageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExperienceUpgradesPageViewController.swift; sourceTree = ""; }; 34B3F84C1E8DF1700035BE1A /* InviteFlow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InviteFlow.swift; sourceTree = ""; }; 34B3F84F1E8DF1700035BE1A /* NewContactThreadViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NewContactThreadViewController.h; sourceTree = ""; }; @@ -1680,7 +1678,6 @@ 34B3F83B1E8DF1700035BE1A /* CallViewController.swift */, 348BB25C20A0C5530047AEC2 /* ContactShareViewHelper.swift */, 34B3F83E1E8DF1700035BE1A /* ContactsPicker.swift */, - 34B3F83F1E8DF1700035BE1A /* ContactsPicker.xib */, 34E88D252098C5AE00A608F4 /* ContactViewController.swift */, 3448BFC01EDF0EA7005B2D69 /* ConversationView */, 346B66301F4E29B200E5122F /* CropScaleImageViewController.swift */, @@ -2778,7 +2775,6 @@ AD83FF431A73426500B5C81A /* audio_play_button@2x.png in Resources */, 34661FB820C1C0D60056EDD6 /* message_sent.aiff in Resources */, 45CB2FA81CB7146C00E1B343 /* Launch Screen.storyboard in Resources */, - 34B3F8781E8DF1700035BE1A /* ContactsPicker.xib in Resources */, B633C5C31A1D190B0059AC12 /* mute_off@2x.png in Resources */, AD83FF411A73426500B5C81A /* audio_play_button_blue@2x.png in Resources */, 34C3C78D20409F320000134C /* Opening.m4r in Resources */, diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index fbd920cbb..f13dc76b8 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -28,12 +28,11 @@ public enum SubtitleCellValue: Int { @objc public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate { - @IBOutlet var tableView: UITableView! - @IBOutlet var searchBar: UISearchBar! + var tableView: UITableView! + var searchBar: UISearchBar! // MARK: - Properties - private let TAG = "[ContactsPicker]" private let contactCellReuseIdentifier = "contactCellReuseIdentifier" private var contactsManager: OWSContactsManager { @@ -84,7 +83,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView required public init(allowsMultipleSelection: Bool, subtitleCellType: SubtitleCellValue) { self.allowsMultipleSelection = allowsMultipleSelection self.subtitleCellType = subtitleCellType - super.init(nibName: "ContactsPicker", bundle: nil) + super.init(nibName: nil, bundle: nil) } required public init?(coder aDecoder: NSCoder) { @@ -93,12 +92,30 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView // MARK: - Lifecycle Methods + override public func loadView() { + self.view = UIView() + let tableView = UITableView() + self.tableView = tableView + + view.addSubview(tableView) + tableView.autoPinEdgesToSuperviewEdges() + tableView.delegate = self + tableView.dataSource = self + + let searchBar = UISearchBar() + self.searchBar = searchBar + searchBar.searchBarStyle = .minimal + searchBar.delegate = self + searchBar.backgroundColor = .white + searchBar.sizeToFit() + + tableView.tableHeaderView = searchBar + } + override open func viewDidLoad() { super.viewDidLoad() searchBar.placeholder = NSLocalizedString("INVITE_FRIENDS_PICKER_SEARCHBAR_PLACEHOLDER", comment: "Search") - // Prevent content from going under the navigation bar - self.edgesForExtendedLayout = [] // Auto size cells for dynamic type tableView.estimatedRowHeight = 60.0 @@ -140,7 +157,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView private func reloadContacts() { getContacts( onError: { error in - Logger.error("\(self.TAG) failed to reload contacts with error:\(error)") + Logger.error("\(self.logTag) failed to reload contacts with error:\(error)") }) } @@ -192,7 +209,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView } self.sections = collatedContacts(contacts) } catch let error as NSError { - Logger.error("\(self.TAG) Failed to fetch contacts with error:\(error)") + Logger.error("\(self.logTag) Failed to fetch contacts with error:\(error)") } } } @@ -331,7 +348,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView let filteredContacts = try contactStore.unifiedContacts(matching: predicate, keysToFetch: allowedContactKeys) filteredSections = collatedContacts(filteredContacts) } catch let error as NSError { - Logger.error("\(self.TAG) updating search results failed with error: \(error)") + Logger.error("\(self.logTag) updating search results failed with error: \(error)") } } self.tableView.reloadData() diff --git a/Signal/src/ViewControllers/ContactsPicker.xib b/Signal/src/ViewControllers/ContactsPicker.xib deleted file mode 100644 index a78eca718..000000000 --- a/Signal/src/ViewControllers/ContactsPicker.xib +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -