Respond to CR.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent e75ed5e477
commit 5c0c9b533e

@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)canSelectBlockedContact;
- (nullable UIView *)createHeader:(UIView *)superview;
@end
#pragma mark -

@ -90,13 +90,19 @@ NS_ASSUME_NONNULL_BEGIN
- (void)createViews
{
UIView *header = [self.delegate createHeader:self.view];
// Table
_tableViewController = [OWSTableViewController new];
_tableViewController.delegate = self;
_tableViewController.contents = [OWSTableContents new];
[self.view addSubview:self.tableViewController.view];
[_tableViewController.view autoPinWidthToSuperview];
[_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0];
if (header) {
[_tableViewController.view autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:header];
} else {
[_tableViewController.view autoPinToTopLayoutGuideOfViewController:self withInset:0];
}
[_tableViewController.view autoPinEdgeToSuperviewEdge:ALEdgeBottom];
// Search
@ -149,18 +155,16 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (InboxTableViewCell *)nil;
return (ContactTableViewCell *)nil;
}
InboxTableViewCell *cell = [InboxTableViewCell inboxTableViewCell];
[cell configureWithThread:thread
contactsManager:strongSelf.contactsManager
blockedPhoneNumberSet:strongSelf.blockedPhoneNumberSet];
// To be consistent with the threads (above), we use ContactTableViewCell
// instead of InboxTableViewCell to present contacts and threads.
ContactTableViewCell *cell = [ContactTableViewCell new];
[cell configureWithThread:thread contactsManager:strongSelf.contactsManager];
return cell;
}
customRowHeight:[InboxTableViewCell rowHeight]
customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{
[weakSelf.delegate threadWasSelected:thread];
}]];
@ -172,25 +176,21 @@ NS_ASSUME_NONNULL_BEGIN
[section addItem:[OWSTableItem itemWithCustomCellBlock:^{
SelectThreadViewController *strongSelf = weakSelf;
if (!strongSelf) {
return (InboxTableViewCell *)nil;
return (ContactTableViewCell *)nil;
}
// To be consistent with the threads (above), we use InboxTableViewCell
// instead of ContactTableViewCell to present contacts.
InboxTableViewCell *cell = [InboxTableViewCell inboxTableViewCell];
// TODO: Use ContactAccount.
NSString *recipientId = contact.textSecureIdentifiers.firstObject;
ContactTableViewCell *cell = [ContactTableViewCell new];
BOOL isBlocked = [strongSelf isContactBlocked:contact];
[cell configureWithContact:contact
recipientId:recipientId
contactsManager:strongSelf.contactsManager
isBlocked:isBlocked];
if (isBlocked) {
cell.accessoryMessage
= NSLocalizedString(@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
} else {
OWSAssert(cell.accessoryMessage == nil);
}
[cell configureWithContact:contact contactsManager:strongSelf.contactsManager];
return cell;
}
customRowHeight:[InboxTableViewCell rowHeight]
customRowHeight:[ContactTableViewCell rowHeight]
actionBlock:^{
[weakSelf contactWasSelected:contact];
}]];

@ -49,6 +49,11 @@ NS_ASSUME_NONNULL_BEGIN
return NO;
}
- (nullable UIView *)createHeader:(UIView *)superview
{
return nil;
}
@end
NS_ASSUME_NONNULL_END

@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
extern NSString *const kContactsTable_CellReuseIdentifier;
@class OWSContactsManager;
@class TSThread;
@interface ContactTableViewCell : UITableViewCell
@ -29,6 +30,8 @@ extern NSString *const kContactsTable_CellReuseIdentifier;
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;
@end
NS_ASSUME_NONNULL_END

@ -9,6 +9,8 @@
#import "UIFont+OWS.h"
#import "UIUtil.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/TSGroupThread.h>
#import <SignalServiceKit/TSThread.h>
NS_ASSUME_NONNULL_BEGIN
@ -50,11 +52,11 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
{
const CGFloat kAvatarSize = 40.f;
_avatarView = [UIImageView new];
_avatarView.contentMode = UIViewContentModeScaleToFill;
_avatarView.image = [UIImage imageNamed:@"empty-group-avatar"];
// applyRoundedBorderToImageView requires the avatar to have
// the correct size.
_avatarView.frame = CGRectMake(0, 0, kAvatarSize, kAvatarSize);
_avatarView.contentMode = UIViewContentModeScaleToFill;
_avatarView.layer.minificationFilter = kCAFilterTrilinear;
_avatarView.layer.magnificationFilter = kCAFilterTrilinear;
[self.contentView addSubview:_avatarView];
@ -121,6 +123,28 @@ NSString *const kContactsTable_CellReuseIdentifier = @"kContactsTable_CellReuseI
[self layoutSubviews];
}
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
{
OWSAssert(thread);
NSString *threadName = thread.name;
if (threadName.length == 0 && [thread isKindOfClass:[TSGroupThread class]]) {
threadName = NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"");
}
NSAttributedString *attributedText = [[NSAttributedString alloc]
initWithString:threadName
attributes:@{
NSForegroundColorAttributeName : [UIColor blackColor],
}];
self.nameLabel.attributedText = attributedText;
self.avatarView.image = [OWSAvatarBuilder buildImageForThread:thread contactsManager:contactsManager];
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
[self layoutSubviews];
}
- (void)layoutSubviews
{
[super layoutSubviews];

Loading…
Cancel
Save