From 261719e53bf61e03a547160333344eb604426843 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 14 Jun 2018 16:15:44 -0400 Subject: [PATCH 1/4] Unify the cell and avatar sizes. --- .../ViewControllers/HomeView/HomeViewCell.m | 30 ++++--------------- SignalMessaging/Views/ContactTableViewCell.m | 22 ++++---------- 2 files changed, 11 insertions(+), 41 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index bef284b6c..02705e9c8 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -59,11 +59,8 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(!self.avatarView); - const CGFloat kMinVMargin = 5; - [self setTranslatesAutoresizingMaskIntoConstraints:NO]; - self.layoutMargins = UIEdgeInsetsMake(0, self.cellHMargin, 0, self.cellHMargin); - self.contentView.layoutMargins = UIEdgeInsetsZero; + self.preservesSuperviewLayoutMargins = YES; self.contentView.preservesSuperviewLayoutMargins = YES; self.backgroundColor = [UIColor whiteColor]; @@ -79,13 +76,9 @@ NS_ASSUME_NONNULL_BEGIN [self.avatarView autoVCenterInSuperview]; [self.avatarView setContentHuggingHigh]; [self.avatarView setCompressionResistanceHigh]; - const CGFloat kAvatarMinVMargin = 10; - [self.avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop - withInset:kAvatarMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [self.avatarView autoPinEdgeToSuperviewEdge:ALEdgeBottom - withInset:kAvatarMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; + // Ensure that the cell's contents never overflow the cell bounds. + [self.avatarView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [self.avatarView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; self.payloadView = [UIStackView new]; self.payloadView.axis = UILayoutConstraintAxisVertical; @@ -93,14 +86,8 @@ NS_ASSUME_NONNULL_BEGIN [self.payloadView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:self.avatarHSpacing]; [self.payloadView autoVCenterInSuperview]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin to the superview _edge_ and not _margin_ for the purposes - // of overflow, so that changes to the margins do not trip these safe guards. - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeTop - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [self.payloadView autoPinEdgeToSuperviewEdge:ALEdgeBottom - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; + [self.payloadView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [self.payloadView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; // We pin the payloadView traillingEdge later, as part of the "Unread Badge" logic. self.nameLabel = [UILabel new]; @@ -410,11 +397,6 @@ NS_ASSUME_NONNULL_BEGIN return minValue * alpha; } -- (NSUInteger)cellHMargin -{ - return 16; -} - - (NSUInteger)avatarSize { return 48.f; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 3e0d3e886..87b9d3333 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN -const NSUInteger kContactTableViewCellAvatarSize = 40; +const NSUInteger kContactTableViewCellAvatarSize = 48; const CGFloat kContactTableViewCellAvatarTextMargin = 12; @interface ContactTableViewCell () @@ -53,8 +53,6 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; { OWSAssert(!self.nameLabel); - const CGFloat kMinVMargin = 5; - self.preservesSuperviewLayoutMargins = YES; self.contentView.preservesSuperviewLayoutMargins = YES; @@ -99,20 +97,10 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; [_nameContainerView autoPinTrailingToSuperviewMargin]; // Ensure that the cell's contents never overflow the cell bounds. - // We pin to the superview _edge_ and not _margin_ for the purposes - // of overflow, so that changes to the margins do not trip these safe guards. - [_avatarView autoPinEdgeToSuperviewEdge:ALEdgeTop - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [_avatarView autoPinEdgeToSuperviewEdge:ALEdgeBottom - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [_nameContainerView autoPinEdgeToSuperviewEdge:ALEdgeTop - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; - [_nameContainerView autoPinEdgeToSuperviewEdge:ALEdgeBottom - withInset:kMinVMargin - relation:NSLayoutRelationGreaterThanOrEqual]; + [self.avatarView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [self.avatarView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; + [self.nameContainerView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [self.nameContainerView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; [self configureFonts]; From 1acf51ea5c22dc564f33fff2fb7ccb436ca28c2a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 15 Jun 2018 11:08:01 -0400 Subject: [PATCH 2/4] Unify the cell and avatar sizes. --- .../src/ViewControllers/AppSettings/BlockListViewController.m | 1 + .../AppSettings/OWSLinkedDevicesTableViewController.m | 1 + Signal/src/ViewControllers/ContactsPicker.swift | 1 + .../HomeView/ConversationSearchViewController.swift | 1 + Signal/src/ViewControllers/HomeView/HomeViewController.m | 1 + Signal/src/ViewControllers/NewContactThreadViewController.m | 1 + SignalMessaging/Views/ContactTableViewCell.m | 3 --- 7 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m index 7cd5d24de..c2bdb4c75 100644 --- a/Signal/src/ViewControllers/AppSettings/BlockListViewController.m +++ b/Signal/src/ViewControllers/AppSettings/BlockListViewController.m @@ -44,6 +44,7 @@ NS_ASSUME_NONNULL_BEGIN [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m index b268926b4..928adc51a 100644 --- a/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m +++ b/Signal/src/ViewControllers/AppSettings/OWSLinkedDevicesTableViewController.m @@ -44,6 +44,7 @@ int const OWSLinkedDevicesTableViewControllerSectionAddDevice = 1; self.isExpectingMoreDevices = NO; self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.estimatedRowHeight = 60; [self.tableView applyScrollViewInsetsFix]; diff --git a/Signal/src/ViewControllers/ContactsPicker.swift b/Signal/src/ViewControllers/ContactsPicker.swift index 2ed0e49e7..fbd920cbb 100644 --- a/Signal/src/ViewControllers/ContactsPicker.swift +++ b/Signal/src/ViewControllers/ContactsPicker.swift @@ -103,6 +103,7 @@ public class ContactsPicker: OWSViewController, UITableViewDelegate, UITableView // Auto size cells for dynamic type tableView.estimatedRowHeight = 60.0 tableView.rowHeight = UITableViewAutomaticDimension + tableView.estimatedRowHeight = 60 tableView.allowsMultipleSelection = allowsMultipleSelection diff --git a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift index 36dd8dfa0..2039b8372 100644 --- a/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift +++ b/Signal/src/ViewControllers/HomeView/ConversationSearchViewController.swift @@ -49,6 +49,7 @@ class ConversationSearchViewController: UITableViewController { blockedPhoneNumberSet = Set(blockingManager.blockedPhoneNumbers()) tableView.rowHeight = UITableViewAutomaticDimension + tableView.estimatedRowHeight = 60 tableView.register(EmptySearchResultCell.self, forCellReuseIdentifier: EmptySearchResultCell.reuseIdentifier) tableView.register(HomeViewCell.self, forCellReuseIdentifier: HomeViewCell.cellReuseIdentifier()) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewController.m b/Signal/src/ViewControllers/HomeView/HomeViewController.m index e8fb3743d..00738aa84 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewController.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewController.m @@ -230,6 +230,7 @@ NSString *const kArchivedConversationsReuseIdentifier = @"kArchivedConversations [self.tableView autoPinEdgeToSuperviewEdge:ALEdgeBottom]; [self.tableView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:missingContactsPermissionView]; self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.estimatedRowHeight = 60; UILabel *emptyBoxLabel = [UILabel new]; self.emptyBoxLabel = emptyBoxLabel; diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 5b5f6ca26..53df870f0 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -125,6 +125,7 @@ NS_ASSUME_NONNULL_BEGIN [_tableViewController.view autoPinWidthToSuperview]; self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; [_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:contactsPermissionReminderView]; [self autoPinViewToBottomOfViewControllerOrKeyboard:self.tableViewController.view]; diff --git a/SignalMessaging/Views/ContactTableViewCell.m b/SignalMessaging/Views/ContactTableViewCell.m index 87b9d3333..aca1d301e 100644 --- a/SignalMessaging/Views/ContactTableViewCell.m +++ b/SignalMessaging/Views/ContactTableViewCell.m @@ -53,9 +53,6 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12; { OWSAssert(!self.nameLabel); - self.preservesSuperviewLayoutMargins = YES; - self.contentView.preservesSuperviewLayoutMargins = YES; - _avatarView = [AvatarImageView new]; [self.contentView addSubview:_avatarView]; From 647d80d79dc4b8fc6f7f4f487e6faeb00ad5ce78 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 15 Jun 2018 11:15:21 -0400 Subject: [PATCH 3/4] Unify the cell and avatar sizes. --- Signal/src/ViewControllers/HomeView/HomeViewCell.m | 2 -- Signal/src/ViewControllers/NewGroupViewController.m | 2 ++ .../ThreadSettings/ShowGroupMembersViewController.m | 3 +++ .../ViewControllers/ThreadSettings/UpdateGroupViewController.m | 2 ++ SignalMessaging/contacts/SelectRecipientViewController.m | 2 ++ SignalMessaging/contacts/SelectThreadViewController.m | 2 ++ 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 02705e9c8..b39228308 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -60,8 +60,6 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(!self.avatarView); [self setTranslatesAutoresizingMaskIntoConstraints:NO]; - self.preservesSuperviewLayoutMargins = YES; - self.contentView.preservesSuperviewLayoutMargins = YES; self.backgroundColor = [UIColor whiteColor]; diff --git a/Signal/src/ViewControllers/NewGroupViewController.m b/Signal/src/ViewControllers/NewGroupViewController.m index 35670a5b7..20b67be6e 100644 --- a/Signal/src/ViewControllers/NewGroupViewController.m +++ b/Signal/src/ViewControllers/NewGroupViewController.m @@ -125,6 +125,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68; [_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:firstSection]; [self autoPinViewToBottomOfViewControllerOrKeyboard:self.tableViewController.view]; + self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; [self updateTableContents]; } diff --git a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m index 175409bad..414f844b4 100644 --- a/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/ShowGroupMembersViewController.m @@ -63,6 +63,9 @@ NS_ASSUME_NONNULL_BEGIN { _contactsViewHelper = [[ContactsViewHelper alloc] initWithDelegate:self]; + self.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableView.estimatedRowHeight = 60; + [self observeNotifications]; } diff --git a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m index 6861cd334..c76d00467 100644 --- a/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/UpdateGroupViewController.m @@ -121,6 +121,8 @@ NS_ASSUME_NONNULL_BEGIN [_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:firstSection]; [self autoPinViewToBottomOfViewControllerOrKeyboard:self.tableViewController.view]; + self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; [self updateTableContents]; } diff --git a/SignalMessaging/contacts/SelectRecipientViewController.m b/SignalMessaging/contacts/SelectRecipientViewController.m index d8b89e5d6..1251615df 100644 --- a/SignalMessaging/contacts/SelectRecipientViewController.m +++ b/SignalMessaging/contacts/SelectRecipientViewController.m @@ -94,6 +94,8 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien [_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; + self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; [self updateTableContents]; diff --git a/SignalMessaging/contacts/SelectThreadViewController.m b/SignalMessaging/contacts/SelectThreadViewController.m index d14d8ac8f..a14e2d5c4 100644 --- a/SignalMessaging/contacts/SelectThreadViewController.m +++ b/SignalMessaging/contacts/SelectThreadViewController.m @@ -111,6 +111,8 @@ NS_ASSUME_NONNULL_BEGIN [_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header]; [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; + self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension; + self.tableViewController.tableView.estimatedRowHeight = 60; } - (void)yapDatabaseModifiedExternally:(NSNotification *)notification From 7e1c0102b74ed46f1c27ec357217433df90aeaa7 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 15 Jun 2018 11:18:34 -0400 Subject: [PATCH 4/4] Unify the cell and avatar sizes. --- Signal/src/ViewControllers/HomeView/HomeViewCell.m | 2 -- 1 file changed, 2 deletions(-) diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index b39228308..d43d36c7e 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -59,8 +59,6 @@ NS_ASSUME_NONNULL_BEGIN { OWSAssert(!self.avatarView); - [self setTranslatesAutoresizingMaskIntoConstraints:NO]; - self.backgroundColor = [UIColor whiteColor]; _viewConstraints = [NSMutableArray new];