Thread picker adds sections for threads vs other contacts

pull/1/head
Michael Kirk 8 years ago
parent 71bafcc8f0
commit 286463bb22

@ -3,7 +3,7 @@
// //
#import "ContactsViewHelper.h" #import "ContactsViewHelper.h"
#import "ContactTableViewCell.h" //#import "ContactTableViewCell.h"
#import "Environment.h" #import "Environment.h"
#import "NSString+OWS.h" #import "NSString+OWS.h"
#import "OWSProfileManager.h" #import "OWSProfileManager.h"

@ -131,11 +131,13 @@ NS_ASSUME_NONNULL_BEGIN
__weak SelectThreadViewController *weakSelf = self; __weak SelectThreadViewController *weakSelf = self;
ContactsViewHelper *helper = self.contactsViewHelper; ContactsViewHelper *helper = self.contactsViewHelper;
OWSTableContents *contents = [OWSTableContents new]; OWSTableContents *contents = [OWSTableContents new];
OWSTableSection *section = [OWSTableSection new];
// Threads // Threads are listed, most recent first.
OWSTableSection *recentChatsSection = [OWSTableSection new];
recentChatsSection.headerTitle = NSLocalizedString(
@"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE", @"Table section header for recently active conversations");
for (TSThread *thread in [self filteredThreadsWithSearchText]) { for (TSThread *thread in [self filteredThreadsWithSearchText]) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [recentChatsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf; SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -151,10 +153,17 @@ NS_ASSUME_NONNULL_BEGIN
}]]; }]];
} }
// Contacts if (recentChatsSection.itemCount > 0) {
[contents addSection:recentChatsSection];
}
// Contacts who don't yet have a thread are listed last
OWSTableSection *otherContactsSection = [OWSTableSection new];
otherContactsSection.headerTitle = NSLocalizedString(
@"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE", @"Table section header for conversations you haven't recently used.");
NSArray<SignalAccount *> *filteredSignalAccounts = [self filteredSignalAccountsWithSearchText]; NSArray<SignalAccount *> *filteredSignalAccounts = [self filteredSignalAccountsWithSearchText];
for (SignalAccount *signalAccount in filteredSignalAccounts) { for (SignalAccount *signalAccount in filteredSignalAccounts) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [otherContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf; SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -175,13 +184,18 @@ NS_ASSUME_NONNULL_BEGIN
}]]; }]];
} }
if (section.itemCount < 1) { if (otherContactsSection.itemCount > 0) {
[section [contents addSection:otherContactsSection];
}
if (recentChatsSection.itemCount + otherContactsSection.itemCount < 1) {
OWSTableSection *emptySection = [OWSTableSection new];
[emptySection
addItem:[OWSTableItem addItem:[OWSTableItem
softCenterLabelItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS", softCenterLabelItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS",
@"A label that indicates the user has no Signal contacts.")]]; @"A label that indicates the user has no Signal contacts.")]];
[contents addSection:emptySection];
} }
[contents addSection:section];
self.tableViewController.contents = contents; self.tableViewController.contents = contents;
} }

@ -1342,6 +1342,12 @@
/* Label for 'select gif to attach' action sheet button */ /* Label for 'select gif to attach' action sheet button */
"SELECT_GIF_BUTTON" = "GIF"; "SELECT_GIF_BUTTON" = "GIF";
/* Table section header for conversations you haven't recently used. */
"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE" = "Other Contacts";
/* Table section header for recently active conversations */
"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE" = "Recent Chats";
/* No comment provided by engineer. */ /* No comment provided by engineer. */
"SEND_AGAIN_BUTTON" = "Send Again"; "SEND_AGAIN_BUTTON" = "Send Again";

Loading…
Cancel
Save