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

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

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

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

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

@ -245,7 +245,7 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem
disclosureItemWithText:NSLocalizedString(@"EDIT_GROUP_MEMBERS_ADD_MEMBER",
@"Label for the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight]
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
AddToGroupViewController *viewController = [AddToGroupViewController new];
viewController.addToGroupDelegate = weakSelf;
@ -256,39 +256,43 @@ NS_ASSUME_NONNULL_BEGIN
[memberRecipientIds removeObject:[contactsViewHelper localNumber]];
for (NSString *recipientId in [memberRecipientIds.allObjects sortedArrayUsingSelector:@selector(compare:)]) {
[section
addItem:[OWSTableItem itemWithCustomCellBlock:^{
UpdateGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isPreviousMember) {
if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else {
// 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
// while in this dialog. We don't need to worry about that edge case.
cell.accessoryMessage = NSLocalizedString(
@"EDIT_GROUP_NEW_MEMBER_LABEL", @"An indicator that a user is a new member of the group.");
}
if (signalAccount) {
[cell configureWithSignalAccount:signalAccount contactsManager:contactsViewHelper.contactsManager];
} else {
[cell configureWithRecipientId:recipientId contactsManager:contactsViewHelper.contactsManager];
}
return cell;
}
customRowHeight:[ContactTableViewCell rowHeight]
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
UpdateGroupViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [strongSelf.previousMemberRecipientIds containsObject:recipientId];
BOOL isBlocked = [contactsViewHelper isRecipientIdBlocked:recipientId];
if (isPreviousMember) {
if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
} else {
// 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
// while in this dialog. We don't need to worry about that edge case.
cell.accessoryMessage = NSLocalizedString(@"EDIT_GROUP_NEW_MEMBER_LABEL",
@"An indicator that a user is a new member of the group.");
}
if (signalAccount) {
[cell configureWithSignalAccount:signalAccount
contactsManager:contactsViewHelper.contactsManager];
} else {
[cell configureWithRecipientId:recipientId
contactsManager:contactsViewHelper.contactsManager];
}
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
SignalAccount *signalAccount = [contactsViewHelper signalAccountForRecipientId:recipientId];
BOOL isPreviousMember = [weakSelf.previousMemberRecipientIds containsObject:recipientId];

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

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

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

@ -170,7 +170,7 @@ NS_ASSUME_NONNULL_BEGIN
[findByPhoneSection
addItem:[OWSTableItem disclosureItemWithText:NSLocalizedString(@"NEW_CONVERSATION_FIND_BY_PHONE_NUMBER",
@"A label the cell that lets you add a new member to a group.")
customRowHeight:[ContactTableViewCell rowHeight]
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
NewNonContactConversationViewController *viewController =
[NewNonContactConversationViewController new];
@ -186,74 +186,77 @@ NS_ASSUME_NONNULL_BEGIN
recentChatsSection.headerTitle = NSLocalizedString(
@"SELECT_THREAD_TABLE_RECENT_CHATS_TITLE", @"Table section header for recently active conversations");
for (TSThread *thread in [self filteredThreadsWithSearchText]) {
[recentChatsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
// To be consistent with the threads (above), we use ContactTableViewCell
// instead of HomeViewCell to present contacts and threads.
ContactTableViewCell *cell = [ContactTableViewCell new];
if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
}
}
[cell configureWithThread:thread contactsManager:helper.contactsManager];
if (cell.accessoryView == nil) {
// Don't add a disappearing messages indicator if we've already added a "blocked" label.
__block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
disappearingMessagesConfiguration =
[OWSDisappearingMessagesConfiguration fetchObjectWithUniqueID:thread.uniqueId
transaction:transaction];
}];
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) {
DisappearingTimerConfigurationView *disappearingTimerConfigurationView =
[[DisappearingTimerConfigurationView alloc]
initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds];
disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44);
disappearingTimerConfigurationView.tintColor = [UIColor colorWithWhite:0.5f alpha:1.f];
cell.accessoryView = disappearingTimerConfigurationView;
}
}
return cell;
}
customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{
typeof(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked
&& ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) {
[BlockListUIUtils
showUnblockPhoneNumberActionSheet:thread.contactIdentifier
fromViewController:strongSelf
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:^(BOOL isStillBlocked) {
if (!isStillBlocked) {
[strongSelf.selectThreadViewDelegate
threadWasSelected:thread];
}
}];
return;
}
}
[strongSelf.selectThreadViewDelegate threadWasSelected:thread];
}]];
[recentChatsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
// To be consistent with the threads (above), we use ContactTableViewCell
// instead of HomeViewCell to present contacts and threads.
ContactTableViewCell *cell = [ContactTableViewCell new];
if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
}
}
[cell configureWithThread:thread contactsManager:helper.contactsManager];
if (cell.accessoryView == nil) {
// Don't add a disappearing messages indicator if we've already added a "blocked" label.
__block OWSDisappearingMessagesConfiguration *disappearingMessagesConfiguration;
[self.uiDatabaseConnection
readWithBlock:^(YapDatabaseReadTransaction *_Nonnull transaction) {
disappearingMessagesConfiguration = [OWSDisappearingMessagesConfiguration
fetchObjectWithUniqueID:thread.uniqueId
transaction:transaction];
}];
if (disappearingMessagesConfiguration && disappearingMessagesConfiguration.isEnabled) {
DisappearingTimerConfigurationView *disappearingTimerConfigurationView =
[[DisappearingTimerConfigurationView alloc]
initWithDurationSeconds:disappearingMessagesConfiguration.durationSeconds];
disappearingTimerConfigurationView.frame = CGRectMake(0, 0, 44, 44);
disappearingTimerConfigurationView.tintColor =
[UIColor colorWithWhite:0.5f alpha:1.f];
cell.accessoryView = disappearingTimerConfigurationView;
}
}
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
typeof(self) strongSelf = weakSelf;
if (!strongSelf) {
return;
}
if ([thread isKindOfClass:[TSContactThread class]]) {
BOOL isBlocked = [helper isRecipientIdBlocked:thread.contactIdentifier];
if (isBlocked && ![strongSelf.selectThreadViewDelegate canSelectBlockedContact]) {
[BlockListUIUtils showUnblockPhoneNumberActionSheet:thread.contactIdentifier
fromViewController:strongSelf
blockingManager:helper.blockingManager
contactsManager:helper.contactsManager
completionBlock:^(BOOL isStillBlocked) {
if (!isStillBlocked) {
[strongSelf.selectThreadViewDelegate
threadWasSelected:thread];
}
}];
return;
}
}
[strongSelf.selectThreadViewDelegate threadWasSelected:thread];
}]];
}
if (recentChatsSection.itemCount > 0) {
@ -266,25 +269,27 @@ NS_ASSUME_NONNULL_BEGIN
@"SELECT_THREAD_TABLE_OTHER_CHATS_TITLE", @"Table section header for conversations you haven't recently used.");
NSArray<SignalAccount *> *filteredSignalAccounts = [self filteredSignalAccountsWithSearchText];
for (SignalAccount *signalAccount in filteredSignalAccounts) {
[otherContactsSection addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) {
cell.accessoryMessage
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
OWSAssert(cell.accessoryMessage == nil);
}
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
return cell;
}
customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{
[weakSelf signalAccountWasSelected:signalAccount];
}]];
[otherContactsSection
addItem:[OWSTableItem
itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
OWSCAssert(strongSelf);
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [helper isRecipientIdBlocked:signalAccount.recipientId];
if (isBlocked) {
cell.accessoryMessage = NSLocalizedString(
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
OWSAssert(cell.accessoryMessage == nil);
}
[cell configureWithSignalAccount:signalAccount contactsManager:helper.contactsManager];
return cell;
}
customRowHeight:UITableViewAutomaticDimension
actionBlock:^{
[weakSelf signalAccountWasSelected:signalAccount];
}]];
}
if (otherContactsSection.itemCount > 0) {

@ -450,7 +450,7 @@ NS_ASSUME_NONNULL_BEGIN
}
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;
}

Loading…
Cancel
Save