session-ios/Signal/src/views/ContactTableViewCell.m
Michael Kirk 243ff190bc Fix crash in group listing / new group views
The broken code addressed in 8211d4584f
was duplicated a couple of places. This commit ferrets out the rest of
them and centralizes the logic in the ContactsManager.

// FREEBIE
2016-12-04 22:58:02 -05:00

44 lines
1.2 KiB
Objective-C

#import "ContactTableViewCell.h"
#import "Environment.h"
#import "OWSContactAvatarBuilder.h"
#import "OWSContactsManager.h"
#import "PhoneManager.h"
#import "UIUtil.h"
NS_ASSUME_NONNULL_BEGIN
@interface ContactTableViewCell ()
@property (nonatomic) IBOutlet UILabel *nameLabel;
@property (nonatomic) IBOutlet UIImageView *avatarView;
@end
@implementation ContactTableViewCell
- (nullable NSString *)reuseIdentifier
{
return NSStringFromClass(self.class);
}
- (void)configureWithContact:(Contact *)contact contactsManager:(OWSContactsManager *)contactsManager
{
self.nameLabel.attributedText = [contactsManager formattedFullNameForContact:contact font:self.nameLabel.font];
self.avatarView.image =
[[[OWSContactAvatarBuilder alloc] initWithContactId:contact.textSecureIdentifiers.firstObject
name:contact.fullName
contactsManager:contactsManager] build];
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
[self layoutSubviews];
}
- (void)layoutSubviews
{
[super layoutSubviews];
[UIUtil applyRoundedBorderToImageView:self.avatarView];
}
@end
NS_ASSUME_NONNULL_END