Rework archived conversations mode of home view.

pull/1/head
Matthew Chen 8 years ago
parent af2539f473
commit 9c7e9b795a

@ -182,11 +182,6 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
// TODO: Remove this. // TODO: Remove this.
[SignalApp.sharedApp setHomeViewController:self]; [SignalApp.sharedApp setHomeViewController:self];
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self
action:@selector(showNewConversationView)];
ReminderView *archiveReminderView = [ReminderView new]; ReminderView *archiveReminderView = [ReminderView new];
archiveReminderView.text = NSLocalizedString( archiveReminderView.text = NSLocalizedString(
@"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode."); @"INBOX_VIEW_ARCHIVE_MODE_REMINDER", @"Label reminding the user that they are in archive mode.");
@ -265,17 +260,23 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
// Create the database connection. // Create the database connection.
[self uiDatabaseConnection]; [self uiDatabaseConnection];
[self showInboxGrouping]; [self updateMappings];
[self checkIfEmptyView];
[self updateReminderViews];
// because this uses the table data source, `tableViewSetup` must happen // because this uses the table data source, `tableViewSetup` must happen
// after mappings have been set up in `showInboxGrouping` // after mappings have been set up in `showInboxGrouping`
[self tableViewSetUp]; [self tableViewSetUp];
// TODO: Should our app name be translated? Probably not. switch (self.homeViewMode) {
self.title = NSLocalizedString(@"HOME_VIEW_TITLE", @"Title for the home view."); case HomeViewMode_Inbox:
// TODO: Should our app name be translated? Probably not.
self.navigationItem.leftBarButtonItem.accessibilityLabel self.title = NSLocalizedString(@"HOME_VIEW_TITLE_INBOX", @"Title for the home view's default mode.");
= NSLocalizedString(@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button"); break;
case HomeViewMode_Archive:
self.title = NSLocalizedString(@"HOME_VIEW_TITLE_ARCHIVE", @"Title for the home view's 'archive' mode.");
break;
}
if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)] if ([self.traitCollection respondsToSelector:@selector(forceTouchCapability)]
&& (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) { && (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable)) {
@ -294,6 +295,9 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)updateBarButtonItems - (void)updateBarButtonItems
{ {
if (self.homeViewMode != HomeViewMode_Inbox) {
return;
}
const CGFloat kBarButtonSize = 44; const CGFloat kBarButtonSize = 44;
// We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of // We use UIButtons with [UIBarButtonItem initWithCustomView:...] instead of
// UIBarButtonItem in order to ensure that these buttons are spaced tightly. // UIBarButtonItem in order to ensure that these buttons are spaced tightly.
@ -325,7 +329,15 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
0, 0,
round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right), round(image.size.width + imageEdgeInsets.left + imageEdgeInsets.right),
round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom)); round(image.size.height + imageEdgeInsets.top + imageEdgeInsets.bottom));
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; UIBarButtonItem *settingsButton = [[UIBarButtonItem alloc] initWithCustomView:button];
settingsButton.accessibilityLabel
= NSLocalizedString(@"SETTINGS_BUTTON_ACCESSIBILITY", @"Accessibility hint for the settings button");
self.navigationItem.leftBarButtonItem = settingsButton;
self.navigationItem.rightBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCompose
target:self
action:@selector(showNewConversationView)];
} }
- (void)settingsButtonPressed:(id)sender - (void)settingsButtonPressed:(id)sender
@ -847,7 +859,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if ([self isIndexPathForArchivedConversations:indexPath]) { if ([self isIndexPathForArchivedConversations:indexPath]) {
[self showArchiveGrouping]; [self showArchivedConversations];
return; return;
} }
@ -953,29 +965,21 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations
return _threadMappings; return _threadMappings;
} }
// TODO: Rework.
- (void)showInboxGrouping - (void)showInboxGrouping
{ {
self.homeViewMode = HomeViewMode_Inbox; OWSAssert(self.homeViewMode == HomeViewMode_Archive);
}
// TODO: Rework. [self.navigationController popToRootViewControllerAnimated:YES];
- (void)showArchiveGrouping
{
self.homeViewMode = HomeViewMode_Archive;
} }
// TODO: Rework. - (void)showArchivedConversations
- (void)setHomeViewMode:(HomeViewMode)homeViewMode
{ {
BOOL didChange = _homeViewMode != homeViewMode; OWSAssert(self.homeViewMode == HomeViewMode_Inbox);
_homeViewMode = homeViewMode;
if (didChange || !_threadMappings) { // Push a separate instance of this view using "archive" mode.
[self updateMappings]; HomeViewController *homeView = [HomeViewController new];
} else { homeView.homeViewMode = HomeViewMode_Archive;
[self checkIfEmptyView]; [self.navigationController pushViewController:homeView animated:YES];
[self updateReminderViews];
}
} }
- (NSString *)currentGrouping - (NSString *)currentGrouping

@ -872,8 +872,11 @@
/* A label for conversations with blocked users. */ /* A label for conversations with blocked users. */
"HOME_VIEW_BLOCKED_CONTACT_CONVERSATION" = "Blocked"; "HOME_VIEW_BLOCKED_CONTACT_CONVERSATION" = "Blocked";
/* Title for the home view. */ /* Title for the home view's 'archive' mode. */
"HOME_VIEW_TITLE" = "Signal"; "HOME_VIEW_TITLE_ARCHIVE" = "Archive";
/* Title for the home view's default mode. */
"HOME_VIEW_TITLE_INBOX" = "Signal";
/* Call setup status label */ /* Call setup status label */
"IN_CALL_CONNECTING" = "Connecting…"; "IN_CALL_CONNECTING" = "Connecting…";

Loading…
Cancel
Save