profile name vs. verified in ContactTableViewCell

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent e54e1d11c0
commit fd99354673

@ -1126,9 +1126,10 @@ typedef NS_ENUM(NSInteger, MessagesRangeSizeMode) {
name = [[NSAttributedString alloc] initWithString:self.thread.name];
}
} else {
name = [self.contactsManager attributedStringForConversationTitleWithPhoneIdentifier:self.thread.contactIdentifier
primaryFont:self.navigationBarTitleLabel.font
secondaryFont:[UIFont ows_footnoteFont]];
name = [self.contactsManager
attributedStringForConversationTitleWithPhoneIdentifier:self.thread.contactIdentifier
primaryFont:self.navigationBarTitleLabel.font
secondaryFont:[UIFont ows_footnoteFont]];
}
self.title = nil;

@ -163,7 +163,7 @@ const NSUInteger kAvatarViewDiameter = 52;
NSString *contactIdentifier = thread.contactIdentifier;
isBlocked = [blockedPhoneNumberSet containsObject:contactIdentifier];
}
self.threadId = thread.uniqueId;
NSMutableAttributedString *snippetText = [NSMutableAttributedString new];
if (isBlocked) {
@ -215,7 +215,7 @@ const NSUInteger kAvatarViewDiameter = 52;
primaryFont:self.nameLabel.font
secondaryFont:[UIFont ows_footnoteFont]];
}
self.nameLabel.attributedText = name;
self.snippetLabel.attributedText = snippetText;
self.timeLabel.attributedText = attributedDate;
@ -223,8 +223,8 @@ const NSUInteger kAvatarViewDiameter = 52;
self.separatorInset = UIEdgeInsetsMake(0, self.avatarSize * 1.5f, 0, 0);
_timeLabel.textColor = thread.hasUnreadMessages ? [UIColor ows_materialBlueColor] : [UIColor ows_darkGrayColor];
_timeLabel.textColor = thread.hasUnreadMessages ? [UIColor ows_materialBlueColor] : [UIColor ows_darkGrayColor];
if (unreadCount > 0) {
self.unreadBadge.hidden = NO;
self.unreadLabel.hidden = NO;

@ -670,6 +670,11 @@ NS_ASSUME_NONNULL_BEGIN
initWithString:[PhoneNumber
bestEffortFormatPartialUserSpecifiedTextToLookLikeAPhoneNumber:recipientId]];
addSubtitle(subtitle);
} else {
NSString *_Nullable profileName = [self.contactsManager formattedProfileNameForRecipientId:recipientId];
if (profileName) {
addSubtitle([[NSAttributedString alloc] initWithString:profileName]);
}
}
BOOL isVerified = [[OWSIdentityManager sharedManager] verificationStateForRecipientId:recipientId]

@ -193,7 +193,9 @@ NS_ASSUME_NONNULL_BEGIN
}
if (isVerified) {
[cell addVerifiedSubtitle];
cell.subtitle.attributedText = cell.verifiedSubtitle;
} else {
cell.subtitle.attributedText = nil;
}
return cell;

@ -559,25 +559,26 @@ NSString *const kTSStorageManager_AccountLastNames = @"kTSStorageManager_Account
if (savedContactName.length > 0) {
return [[NSAttributedString alloc] initWithString:savedContactName];
}
NSString *_Nullable profileName = [self.profileManager profileNameForRecipientId:recipientId];
if (profileName.length > 0) {
NSString *numberAndProfileNameFormat = NSLocalizedString(@"PROFILE_NAME_AND_PHONE_NUMBER_LABEL_FORMAT",
@"Label text combining the phone number and profile name separated by a simple demarcation character. "
@"Phone number should be most prominent. '%1$@' is replaced with {{phone number}} and '%2$@' is replaced "
@"with {{profile name}}");
@"Label text combining the phone number and profile name separated by a simple demarcation character. "
@"Phone number should be most prominent. '%1$@' is replaced with {{phone number}} and '%2$@' is replaced "
@"with {{profile name}}");
NSString *numberAndProfileName =
[NSString stringWithFormat:numberAndProfileNameFormat, recipientId, profileName];
NSRange recipientIdRange = [numberAndProfileName rangeOfString:recipientId];
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:numberAndProfileName
attributes:@{ NSFontAttributeName: secondaryFont }];
NSMutableAttributedString *attributedString =
[[NSMutableAttributedString alloc] initWithString:numberAndProfileName
attributes:@{ NSFontAttributeName : secondaryFont }];
[attributedString addAttribute:NSFontAttributeName value:primaryFont range:recipientIdRange];
return [attributedString copy];
}
// else fall back to recipient id
return [[NSAttributedString alloc] initWithString:recipientId];
}

@ -22,6 +22,7 @@ extern NSString *const kContactsTable_CellReuseIdentifier;
@interface ContactTableViewCell : UITableViewCell
@property (nonatomic, nullable) NSString *accessoryMessage;
@property (nonatomic, readonly) UILabel *subtitle;
+ (nullable NSString *)reuseIdentifier;
@ -33,7 +34,7 @@ extern NSString *const kContactsTable_CellReuseIdentifier;
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;
- (void)addVerifiedSubtitle;
- (NSAttributedString *)verifiedSubtitle;
@end

@ -21,10 +21,11 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
@interface ContactTableViewCell ()
@property (nonatomic) IBOutlet UILabel *nameLabel;
@property (nonatomic) IBOutlet UILabel *profileNameLabel;
@property (nonatomic) IBOutlet UIImageView *avatarView;
@property (nonatomic, nullable) UILabel *subtitle;
@property (nonatomic) UILabel *nameLabel;
@property (nonatomic) UILabel *profileNameLabel;
@property (nonatomic) UIImageView *avatarView;
@property (nonatomic) UILabel *subtitle;
@property (nonatomic) UIView *nameContainerView;
@end
@ -61,19 +62,24 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
_avatarView = [AvatarImageView new];
[self.contentView addSubview:_avatarView];
UIView *nameContainerView = [UIView containerView];
[self.contentView addSubview:nameContainerView];
_nameContainerView = [UIView containerView];
[self.contentView addSubview:_nameContainerView];
_nameLabel = [UILabel new];
_nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_nameLabel.font = [UIFont ows_dynamicTypeBodyFont];
[nameContainerView addSubview:_nameLabel];
[_nameContainerView addSubview:_nameLabel];
_profileNameLabel = [UILabel new];
_profileNameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_profileNameLabel.font = [UIFont ows_footnoteFont];
_profileNameLabel.textColor = [UIColor grayColor];
[nameContainerView addSubview:_profileNameLabel];
[_nameContainerView addSubview:_profileNameLabel];
_subtitle = [UILabel new];
_subtitle.font = [UIFont ows_footnoteFont];
_subtitle.textColor = [UIColor ows_darkGrayColor];
[_nameContainerView addSubview:self.subtitle];
[_avatarView autoVCenterInSuperview];
[_avatarView autoPinLeadingToSuperView];
@ -86,12 +92,15 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
// profileNameLabel can be zero sized, in which case nameLabel essentially occupies the totality of
// nameContainerView's frame.
[_profileNameLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_nameLabel];
[_profileNameLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom];
[_profileNameLabel autoPinWidthToSuperview];
[nameContainerView autoVCenterInSuperview];
[nameContainerView autoPinLeadingToTrailingOfView:_avatarView margin:12.f];
[nameContainerView autoPinTrailingToSuperView];
[_subtitle autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:_profileNameLabel];
[_subtitle autoPinWidthToSuperview];
[_subtitle autoPinEdgeToSuperviewEdge:ALEdgeBottom];
[_nameContainerView autoVCenterInSuperview];
[_nameContainerView autoPinLeadingToTrailingOfView:_avatarView margin:12.f];
[_nameContainerView autoPinTrailingToSuperView];
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
[self layoutSubviews];
@ -160,30 +169,20 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
[self layoutSubviews];
}
- (void)addVerifiedSubtitle
- (NSAttributedString *)verifiedSubtitle
{
[self.subtitle removeFromSuperview];
const CGFloat kSubtitlePointSize = 10.f;
NSMutableAttributedString *text = [NSMutableAttributedString new];
// "checkmark"
[text appendAttributedString:[[NSAttributedString alloc]
initWithString:@"\uf00c "
attributes:@{
NSFontAttributeName : [UIFont ows_fontAwesomeFont:kSubtitlePointSize],
NSFontAttributeName :
[UIFont ows_fontAwesomeFont:self.subtitle.font.pointSize],
}]];
[text appendAttributedString:[[NSAttributedString alloc]
initWithString:NSLocalizedString(@"PRIVACY_IDENTITY_IS_VERIFIED_BADGE",
@"Badge indicating that the user is verified.")]];
self.subtitle = [UILabel new];
self.subtitle.font = [UIFont ows_regularFontWithSize:kSubtitlePointSize];
self.subtitle.textColor = [UIColor ows_darkGrayColor];
self.subtitle.attributedText = text;
[self.subtitle sizeToFit];
[self.contentView addSubview:self.subtitle];
[self.subtitle autoPinLeadingToView:self.nameLabel];
[self.subtitle autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.nameLabel];
[self.subtitle autoPinEdgeToSuperviewEdge:ALEdgeBottom];
return [text copy];
}
- (void)prepareForReuse

Loading…
Cancel
Save