Auto-size contact cells everywhere.

pull/1/head
Matthew Chen 7 years ago
parent f8e785ef72
commit dd49c6225f

@ -43,6 +43,8 @@ NS_ASSUME_NONNULL_BEGIN
[_tableViewController.view autoPinWidthToSuperview]; [_tableViewController.view autoPinWidthToSuperview];
[_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0]; [_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0];
[_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom]; [_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom];
self.tableViewController.tableView.rowHeight = UITableViewAutomaticDimension;
// self.tableView.estimatedRowHeight = 60;
[self updateTableContents]; [self updateTableContents];
} }
@ -78,18 +80,22 @@ NS_ASSUME_NONNULL_BEGIN
NSArray<NSString *> *blockedPhoneNumbers = NSArray<NSString *> *blockedPhoneNumbers =
[helper.blockedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)]; [helper.blockedPhoneNumbers sortedArrayUsingSelector:@selector(compare:)];
for (NSString *phoneNumber in blockedPhoneNumbers) { for (NSString *phoneNumber in blockedPhoneNumbers) {
[blocklistSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [blocklistSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber]; SignalAccount *signalAccount =
[helper signalAccountForRecipientId:phoneNumber];
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else { } else {
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; [cell configureWithRecipientId:phoneNumber
contactsManager:helper.contactsManager];
} }
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber [BlockListUIUtils showUnblockPhoneNumberActionSheet:phoneNumber
fromViewController:weakSelf fromViewController:weakSelf

@ -248,7 +248,6 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
statusLabel.adjustsFontSizeToFitWidth = true statusLabel.adjustsFontSizeToFitWidth = true
statusLabel.sizeToFit() statusLabel.sizeToFit()
cell.accessoryView = statusLabel cell.accessoryView = statusLabel
cell.autoSetDimension(.height, toSize: ContactTableViewCell.rowHeight())
cell.setContentHuggingLow() cell.setContentHuggingLow()
cell.isUserInteractionEnabled = false cell.isUserInteractionEnabled = false
groupRows.append(cell) groupRows.append(cell)

@ -284,12 +284,6 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Table Contents #pragma mark - Table Contents
- (CGFloat)actionCellHeight
{
return ScaleFromIPhone5To7Plus(round((kOWSTable_DefaultCellHeight + [ContactTableViewCell rowHeight]) * 0.5f),
[ContactTableViewCell rowHeight]);
}
- (void)updateTableContents - (void)updateTableContents
{ {
OWSTableContents *contents = [OWSTableContents new]; OWSTableContents *contents = [OWSTableContents new];
@ -307,7 +301,7 @@ NS_ASSUME_NONNULL_BEGIN
[staticSection [staticSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER",
@"A label the cell that lets you add a new member to a group.") @"A label the cell that lets you add a new member to a group.")
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NewNonContactConversationViewController *viewController = NewNonContactConversationViewController *viewController =
[NewNonContactConversationViewController new]; [NewNonContactConversationViewController new];
@ -322,7 +316,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON", disclosureItemWithText:NSLocalizedString(@"INVITE_FRIENDS_CONTACT_TABLE_BUTTON",
@"Label for the cell that presents the 'invite contacts' workflow.") @"Label for the cell that presents the 'invite contacts' workflow.")
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf presentInviteFlow]; [weakSelf presentInviteFlow];
}]]; }]];
@ -382,7 +376,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem softCenterLabelItemWithText: addItem:[OWSTableItem softCenterLabelItemWithText:
NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS", 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.")
customRowHeight:self.actionCellHeight]]; customRowHeight:UITableViewAutomaticDimension]];
} else { } else {
UITableViewCell *loadingCell = [UITableViewCell new]; UITableViewCell *loadingCell = [UITableViewCell new];
OWSAssert(loadingCell.contentView); OWSAssert(loadingCell.contentView);
@ -481,7 +475,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(phoneNumber.length > 0); OWSAssert(phoneNumber.length > 0);
if ([self.nonContactAccountSet containsObject:phoneNumber]) { if ([self.nonContactAccountSet containsObject:phoneNumber]) {
[phoneNumbersSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [phoneNumbersSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:phoneNumber]; BOOL isBlocked = [helper isRecipientIdBlocked:phoneNumber];
if (isBlocked) { if (isBlocked) {
@ -491,14 +487,15 @@ NS_ASSUME_NONNULL_BEGIN
SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber]; SignalAccount *signalAccount = [helper signalAccountForRecipientId:phoneNumber];
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else { } else {
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager]; [cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
} }
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf newConversationWithRecipientId:phoneNumber]; [weakSelf newConversationWithRecipientId:phoneNumber];
}]]; }]];
@ -508,7 +505,7 @@ NS_ASSUME_NONNULL_BEGIN
@"placeholder for the recipient's phone number."), @"placeholder for the recipient's phone number."),
phoneNumber]; phoneNumber];
[phoneNumbersSection addItem:[OWSTableItem disclosureItemWithText:text [phoneNumbersSection addItem:[OWSTableItem disclosureItemWithText:text
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf sendTextToPhoneNumber:phoneNumber]; [weakSelf sendTextToPhoneNumber:phoneNumber];
}]]; }]];
@ -533,19 +530,21 @@ NS_ASSUME_NONNULL_BEGIN
// results. // results.
continue; continue;
} }
[contactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [contactsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId]; BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) { if (isBlocked) {
cell.accessoryMessage cell.accessoryMessage = NSLocalizedString(
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf newConversationWithRecipientId:signalAccount.recipientId]; [weakSelf newConversationWithRecipientId:signalAccount.recipientId];
}]]; }]];
@ -562,12 +561,13 @@ NS_ASSUME_NONNULL_BEGIN
for (TSGroupThread *thread in filteredGroupThreads) { for (TSGroupThread *thread in filteredGroupThreads) {
hasSearchResults = YES; hasSearchResults = YES;
[groupSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [groupSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{
GroupTableViewCell *cell = [GroupTableViewCell new]; GroupTableViewCell *cell = [GroupTableViewCell new];
[cell configureWithThread:thread contactsManager:helper.contactsManager]; [cell configureWithThread:thread contactsManager:helper.contactsManager];
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf newConversationWithThread:thread]; [weakSelf newConversationWithThread:thread];
}]]; }]];
@ -597,7 +597,7 @@ NS_ASSUME_NONNULL_BEGIN
@"placeholder for the recipient's phone number."), @"placeholder for the recipient's phone number."),
displayName]; displayName];
[inviteeSection addItem:[OWSTableItem disclosureItemWithText:text [inviteeSection addItem:[OWSTableItem disclosureItemWithText:text
customRowHeight:self.actionCellHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf sendTextToPhoneNumber:phoneNumber.toE164]; [weakSelf sendTextToPhoneNumber:phoneNumber.toE164];
}]]; }]];
@ -614,7 +614,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem softCenterLabelItemWithText: addItem:[OWSTableItem softCenterLabelItemWithText:
NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_SEARCH_RESULTS", NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_SEARCH_RESULTS",
@"A label that indicates the user's search has no matching results.") @"A label that indicates the user's search has no matching results.")
customRowHeight:self.actionCellHeight]]; customRowHeight:UITableViewAutomaticDimension]];
[sections addObject:noResultsSection]; [sections addObject:noResultsSection];
} }

@ -216,18 +216,21 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
[nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) { [nonContactMemberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[nonContactsSection [nonContactsSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf; NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; SignalAccount *signalAccount =
[contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isCurrentMember) { if (isCurrentMember) {
// In the "contacts" section, we label members as such when editing an existing group. // In the "contacts" section, we label members as such when editing an existing
cell.accessoryMessage = NSLocalizedString( // group.
@"NEW_GROUP_MEMBER_LABEL", @"An indicator that a user is a member of the new group."); cell.accessoryMessage = NSLocalizedString(@"NEW_GROUP_MEMBER_LABEL",
@"An indicator that a user is a member of the new group.");
} else if (isBlocked) { } else if (isBlocked) {
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
@ -239,12 +242,13 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
[cell configureWithSignalAccount:signalAccount [cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager]; contactsManager:contactsViewHelper.contactsManager];
} else { } else {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager]; [cell configureWithRecipientId:recipientId
contactsManager:contactsViewHelper.contactsManager];
} }
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
@ -309,7 +313,8 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
for (SignalAccount *signalAccount in signalAccounts) { for (SignalAccount *signalAccount in signalAccounts) {
[signalAccountSection [signalAccountSection
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
itemWithCustomCellBlock:^{
NewGroupViewController *strongSelf = weakSelf; NewGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -319,9 +324,10 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [strongSelf.memberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isCurrentMember) { if (isCurrentMember) {
// In the "contacts" section, we label members as such when editing an existing group. // In the "contacts" section, we label members as such when editing an existing
cell.accessoryMessage = NSLocalizedString( // group.
@"NEW_GROUP_MEMBER_LABEL", @"An indicator that a user is a member of the new group."); cell.accessoryMessage = NSLocalizedString(@"NEW_GROUP_MEMBER_LABEL",
@"An indicator that a user is a member of the new group.");
} else if (isBlocked) { } else if (isBlocked) {
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
@ -329,11 +335,12 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
OWSAssert(cell.accessoryMessage == nil); OWSAssert(cell.accessoryMessage == nil);
} }
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager];
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NSString *recipientId = signalAccount.recipientId; NSString *recipientId = signalAccount.recipientId;
BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId]; BOOL isCurrentMember = [weakSelf.memberRecipientIds containsObject:recipientId];
@ -392,7 +399,7 @@ const NSUInteger kNewGroupViewControllerAvatarWidth = 68;
return [OWSTableItem return [OWSTableItem
disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT", disclosureItemWithText:NSLocalizedString(@"NEW_GROUP_ADD_NON_CONTACT",
@"A label for the cell that lets you add a new non-contact member to a group.") @"A label for the cell that lets you add a new non-contact member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
AddToGroupViewController *viewController = [AddToGroupViewController new]; AddToGroupViewController *viewController = [AddToGroupViewController new];
viewController.addToGroupDelegate = weakSelf; viewController.addToGroupDelegate = weakSelf;

@ -138,7 +138,7 @@ NS_ASSUME_NONNULL_BEGIN
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"GROUP_MEMBERS_RESET_NO_LONGER_VERIFIED",
@"Label for the button that clears all verification " @"Label for the button that clears all verification "
@"errors in the 'group members' view.") @"errors in the 'group members' view.")
customRowHeight:ContactTableViewCell.rowHeight customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf offerResetAllNoLongerVerified]; [weakSelf offerResetAllNoLongerVerified];
}]]; }]];
@ -171,7 +171,8 @@ NS_ASSUME_NONNULL_BEGIN
return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB]; return [helper.contactsManager compareSignalAccount:signalAccountA withSignalAccount:signalAccountB];
}]; }];
for (NSString *recipientId in sortedRecipientIds) { for (NSString *recipientId in sortedRecipientIds) {
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{ [section addItem:[OWSTableItem
itemWithCustomCellBlock:^{
ShowGroupMembersViewController *strongSelf = weakSelf; ShowGroupMembersViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -183,15 +184,16 @@ NS_ASSUME_NONNULL_BEGIN
BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified; BOOL isNoLongerVerified = verificationState == OWSVerificationStateNoLongerVerified;
BOOL isBlocked = [helper isRecipientIdBlocked:recipientId]; BOOL isBlocked = [helper isRecipientIdBlocked:recipientId];
if (isNoLongerVerified) { if (isNoLongerVerified) {
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_NO_LONGER_VERIFIED",
@"CONTACT_CELL_IS_NO_LONGER_VERIFIED", @"An indicator that a contact is no longer verified."); @"An indicator that a contact is no longer verified.");
} else if (isBlocked) { } else if (isBlocked) {
cell.accessoryMessage cell.accessoryMessage = NSLocalizedString(
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
} else { } else {
[cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager]; [cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
} }
@ -204,7 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
if (useVerifyAction) { if (useVerifyAction) {
[weakSelf showSafetyNumberView:recipientId]; [weakSelf showSafetyNumberView:recipientId];

@ -245,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem [section addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"EDIT_GROUP_MEMBERS_ADD_MEMBER", disclosureItemWithText:NSLocalizedString(@"EDIT_GROUP_MEMBERS_ADD_MEMBER",
@"Label for the cell that lets you add a new member to a group.") @"Label for the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
AddToGroupViewController *viewController = [AddToGroupViewController new]; AddToGroupViewController *viewController = [AddToGroupViewController new];
viewController.addToGroupDelegate = weakSelf; viewController.addToGroupDelegate = weakSelf;
@ -256,7 +256,8 @@ NS_ASSUME_NONNULL_BEGIN
[memberRecipientIds removeObject:[contactsViewHelper localNumber]]; [memberRecipientIds removeObject:[contactsViewHelper localNumber]];
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) { for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[section [section
addItem:[OWSTableItem itemWithCustomCellBlock:^{ addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UpdateGroupViewController *strongSelf = weakSelf; UpdateGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -272,23 +273,26 @@ NS_ASSUME_NONNULL_BEGIN
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
} }
} else { } else {
// In the "members" section, we label "new" members as such when editing an existing group. // In the "members" section, we label "new" members as such when editing an existing
// group.
// //
// The only way a "new" member could be blocked is if we blocked them on a linked device // The only way a "new" member could be blocked is if we blocked them on a linked device
// while in this dialog. We don't need to worry about that edge case. // while in this dialog. We don't need to worry about that edge case.
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(@"EDIT_GROUP_NEW_MEMBER_LABEL",
@"EDIT_GROUP_NEW_MEMBER_LABEL", @"An indicator that a user is a new member of the group."); @"An indicator that a user is a new member of the group.");
} }
if (signalAccount) { if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager];
} else { } else {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager]; [cell configureWithRecipientId:recipientId
contactsManager:contactsViewHelper.contactsManager];
} }
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId]; SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId]; BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId];

@ -26,8 +26,6 @@ extern const CGFloat kContactTableViewCellAvatarTextMargin;
+ (NSString *)reuseIdentifier; + (NSString *)reuseIdentifier;
+ (CGFloat)rowHeight;
- (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithSignalAccount:(SignalAccount *)signalAccount contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager; - (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;

@ -49,16 +49,6 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12;
return NSStringFromClass(self.class); return NSStringFromClass(self.class);
} }
- (CGSize)intrinsicContentSize
{
return CGSizeMake(self.width, ContactTableViewCell.rowHeight);
}
+ (CGFloat)rowHeight
{
return 60.f;
}
- (void)configureProgrammatically - (void)configureProgrammatically
{ {
OWSAssert(!self.nameLabel); OWSAssert(!self.nameLabel);

@ -521,19 +521,23 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
// Contacts // Contacts
for (SignalAccount *signalAccount in signalAccounts) { for (SignalAccount *signalAccount in signalAccounts) {
[contactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [contactsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectRecipientViewController *strongSelf = weakSelf; SelectRecipientViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId]; BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) { if (isBlocked) {
cell.accessoryMessage = NSLocalizedString( cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED",
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"An indicator that a contact has been blocked.");
} else { } else {
cell.accessoryMessage = [weakSelf.delegate accessoryMessageForSignalAccount:signalAccount]; cell.accessoryMessage =
[weakSelf.delegate accessoryMessageForSignalAccount:signalAccount];
} }
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount
contactsManager:helper.contactsManager];
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
@ -541,7 +545,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) { if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
return; return;

@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
[findByPhoneSection [findByPhoneSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER", addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER",
@"A label the cell that lets you add a new member to a group.") @"A label the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
NewNonContactConversationViewController *viewController = NewNonContactConversationViewController *viewController =
[NewNonContactConversationViewController new]; [NewNonContactConversationViewController new];
@ -186,7 +186,9 @@ NS_ASSUME_NONNULL_BEGIN
recentChatsSection.headerTitle = NSLocalizedString( recentChatsSection.headerTitle = NSLocalizedString(
@"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE", @"Table section header for recently active conversations"); @"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]) {
[recentChatsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [recentChatsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf; SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
@ -197,7 +199,8 @@ NS_ASSUME_NONNULL_BEGIN
if ([thread isKindOfClass:[TSContactThread class]]) { if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier]; BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked) { if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} }
} }
@ -206,9 +209,10 @@ NS_ASSUME_NONNULL_BEGIN
if (cell.accessoryView == nil) { if (cell.accessoryView == nil) {
// Don't add a disappearing messages indicator if we've already added a "blocked" label. // Don't add a disappearing messages indicator if we've already added a "blocked" label.
__block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration; __block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) { [self.uiDatabaseConnection
disappearingMessagesConfiguration = readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId disappearingMessagesConfiguration = [OWSDisappearingMessagesConfiguration
fetchObjectWithUniqueID:thread.uniqueId
transaction:transaction]; transaction:transaction];
}]; }];
@ -218,7 +222,8 @@ NS_ASSUME_NONNULL_BEGIN
initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds]; initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds];
disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44); disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44);
disappearingTimerConfigurationView.tintColor = [UIColor colorWithWhite:0.5f alpha:1.f]; disappearingTimerConfigurationView.tintColor =
[UIColor colorWithWhite:0.5f alpha:1.f];
cell.accessoryView = disappearingTimerConfigurationView; cell.accessoryView = disappearingTimerConfigurationView;
} }
@ -226,7 +231,7 @@ NS_ASSUME_NONNULL_BEGIN
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
typeof(self) strongSelf = weakSelf; typeof(self) strongSelf = weakSelf;
if (!strongSelf) { if (!strongSelf) {
@ -235,10 +240,8 @@ NS_ASSUME_NONNULL_BEGIN
if ([thread isKindOfClass:[TSContactThread class]]) { if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier]; BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked if (isBlocked && ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) {
&& ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) { [BlockListUIUtils showUnblockPhoneNumberActionSheet:thread.contactIdentifier
[BlockListUIUtils
showUnblockPhoneNumberActionSheet:thread.contactIdentifier
fromViewController:strongSelf fromViewController:strongSelf
blockingManager:helper.blockingManager blockingManager:helper.blockingManager
contactsManager:helper.contactsManager contactsManager:helper.contactsManager
@ -266,22 +269,24 @@ NS_ASSUME_NONNULL_BEGIN
@"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE", @"Table section header for conversations you haven't recently used."); @"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) {
[otherContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{ [otherContactsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf; SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf); OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new]; ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId]; BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) { if (isBlocked) {
cell.accessoryMessage cell.accessoryMessage = NSLocalizedString(
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked."); @"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else { } else {
OWSAssert(cell.accessoryMessage == nil); OWSAssert(cell.accessoryMessage == nil);
} }
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager]; [cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
return cell; return cell;
} }
customRowHeight:[ContactTableViewCell rowHeight] customRowHeight:UITableViewAutomaticDimension
actionBlock:^{ actionBlock:^{
[weakSelf signalAccountWasSelected:signalAccount]; [weakSelf signalAccountWasSelected:signalAccount];
}]]; }]];

@ -450,7 +450,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
if (result == nil) { if (result == nil) {
OWSFail(@"%@ Unable to build thumnail for attachmentId: %@", self.logTag, self.uniqueId); DDLogError(@"%@ Unable to build thumbnail for attachmentId: %@", self.logTag, self.uniqueId);
return; return;
} }

Loading…
Cancel
Save