Update contacts cells' dependencies.
This commit is contained in:
parent
08518c66bf
commit
28f37a7a34
|
@ -95,7 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
addItem:[OWSTableItem
|
||||
itemWithCustomCellBlock:^{
|
||||
ContactTableViewCell *cell = [ContactTableViewCell new];
|
||||
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:phoneNumber];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
|
|
@ -228,7 +228,7 @@ class ConversationSearchViewController: UITableViewController, BlockListCacheDel
|
|||
owsFailDebug("searchResult was unexpectedly nil")
|
||||
return UITableViewCell()
|
||||
}
|
||||
cell.configure(withRecipientId: searchResult.signalAccount.recipientId, contactsManager: contactsManager)
|
||||
cell.configure(withRecipientId: searchResult.signalAccount.recipientId)
|
||||
return cell
|
||||
case .messages:
|
||||
guard let cell = tableView.dequeueReusableCell(withIdentifier: HomeViewCell.cellReuseIdentifier()) as? HomeViewCell else {
|
||||
|
|
|
@ -274,7 +274,7 @@ class MessageDetailViewController: OWSViewController, MediaGalleryDataSourceDele
|
|||
} else {
|
||||
cellView.accessoryMessage = shortStatusMessage
|
||||
}
|
||||
cellView.configure(withRecipientId: recipientId, contactsManager: self.contactsManager)
|
||||
cellView.configure(withRecipientId: recipientId)
|
||||
|
||||
let wrapper = UIView()
|
||||
wrapper.layoutMargins = UIEdgeInsets(top: 8, left: 20, bottom: 8, right: 20)
|
||||
|
|
|
@ -470,8 +470,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"An indicator that a contact has been blocked.");
|
||||
}
|
||||
|
||||
[cell configureWithRecipientId:signalAccount.recipientId
|
||||
contactsManager:self.contactsViewHelper.contactsManager];
|
||||
[cell configureWithRecipientId:signalAccount.recipientId];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
@ -518,7 +517,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
cell.accessoryMessage = NSLocalizedString(
|
||||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
[cell configureWithRecipientId:phoneNumber contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:phoneNumber];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
@ -566,8 +565,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
|
||||
[cell configureWithRecipientId:signalAccount.recipientId
|
||||
contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:signalAccount.recipientId];
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
|
|
@ -243,8 +243,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
cell.accessoryMessage = NSLocalizedString(
|
||||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
[cell configureWithRecipientId:recipientId
|
||||
contactsManager:contactsViewHelper.contactsManager];
|
||||
[cell configureWithRecipientId:recipientId];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
@ -332,8 +331,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
|
||||
[cell configureWithRecipientId:signalAccount.recipientId
|
||||
contactsManager:contactsViewHelper.contactsManager];
|
||||
[cell configureWithRecipientId:signalAccount.recipientId];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
|
|
@ -188,7 +188,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
|
||||
[cell configureWithRecipientId:recipientId contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:recipientId];
|
||||
|
||||
if (isVerified) {
|
||||
[cell setAttributedSubtitle:cell.verifiedSubtitle];
|
||||
|
|
|
@ -283,8 +283,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"An indicator that a user is a new member of the group.");
|
||||
}
|
||||
|
||||
[cell configureWithRecipientId:recipientId
|
||||
contactsManager:contactsViewHelper.contactsManager];
|
||||
[cell configureWithRecipientId:recipientId];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#import <SignalMessaging/ContactTableViewCell.h>
|
||||
#import <SignalMessaging/ContactsViewHelper.h>
|
||||
#import <SignalMessaging/Environment.h>
|
||||
#import <SignalMessaging/OWSContactsManager.h>
|
||||
#import <SignalMessaging/OWSTableViewController.h>
|
||||
#import <SignalMessaging/SignalMessaging-Swift.h>
|
||||
#import <SignalMessaging/UIFont+OWS.h>
|
||||
|
@ -549,8 +548,7 @@ NSString *const kSelectRecipientViewControllerCellIdentifier = @"kSelectRecipien
|
|||
cell.accessoryMessage =
|
||||
[weakSelf.delegate accessoryMessageForSignalAccount:signalAccount];
|
||||
}
|
||||
[cell configureWithRecipientId:signalAccount.recipientId
|
||||
contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:signalAccount.recipientId];
|
||||
|
||||
if (![weakSelf.delegate canSignalAccountBeSelected:signalAccount]) {
|
||||
cell.selectionStyle = UITableViewCellSelectionStyleNone;
|
||||
|
|
|
@ -203,7 +203,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
|
||||
[cell configureWithThread:thread contactsManager:helper.contactsManager];
|
||||
[cell configureWithThread:thread];
|
||||
|
||||
if (!cell.hasAccessoryText) {
|
||||
// Don't add a disappearing messages indicator if we've already added a "blocked" label.
|
||||
|
@ -277,8 +277,7 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
cell.accessoryMessage = NSLocalizedString(
|
||||
@"CONTACT_CELL_IS_BLOCKED", @"An indicator that a contact has been blocked.");
|
||||
}
|
||||
[cell configureWithRecipientId:signalAccount.recipientId
|
||||
contactsManager:helper.contactsManager];
|
||||
[cell configureWithRecipientId:signalAccount.recipientId];
|
||||
return cell;
|
||||
}
|
||||
customRowHeight:UITableViewAutomaticDimension
|
||||
|
|
|
@ -6,16 +6,15 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
extern const CGFloat kContactCellAvatarTextMargin;
|
||||
|
||||
@class OWSContactsManager;
|
||||
@class TSThread;
|
||||
|
||||
@interface ContactCellView : UIStackView
|
||||
|
||||
@property (nonatomic, nullable) NSString *accessoryMessage;
|
||||
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId;
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;
|
||||
- (void)configureWithThread:(TSThread *)thread;
|
||||
|
||||
- (void)prepareForReuse;
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#import "UIFont+OWS.h"
|
||||
#import "UIView+OWS.h"
|
||||
#import <SignalMessaging/SignalMessaging-Swift.h>
|
||||
#import <SignalServiceKit/OWSPrimaryStorage.h>
|
||||
#import <SignalServiceKit/SignalAccount.h>
|
||||
#import <SignalServiceKit/TSContactThread.h>
|
||||
#import <SignalServiceKit/TSGroupThread.h>
|
||||
|
@ -27,7 +28,6 @@ const CGFloat kContactCellAvatarTextMargin = 12;
|
|||
@property (nonatomic) UIStackView *nameContainerView;
|
||||
@property (nonatomic) UIView *accessoryViewContainer;
|
||||
|
||||
@property (nonatomic) OWSContactsManager *contactsManager;
|
||||
@property (nonatomic, nullable) TSThread *thread;
|
||||
@property (nonatomic) NSString *recipientId;
|
||||
|
||||
|
@ -45,6 +45,24 @@ const CGFloat kContactCellAvatarTextMargin = 12;
|
|||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Dependencies
|
||||
|
||||
- (OWSContactsManager *)contactsManager
|
||||
{
|
||||
OWSAssertDebug(Environment.shared.contactsManager);
|
||||
|
||||
return Environment.shared.contactsManager;
|
||||
}
|
||||
|
||||
- (OWSPrimaryStorage *)primaryStorage
|
||||
{
|
||||
OWSAssertDebug(SSKEnvironment.shared.primaryStorage);
|
||||
|
||||
return SSKEnvironment.shared.primaryStorage;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
- (void)configure
|
||||
{
|
||||
OWSAssertDebug(!self.nameLabel);
|
||||
|
@ -102,19 +120,17 @@ const CGFloat kContactCellAvatarTextMargin = 12;
|
|||
self.accessoryLabel.textColor = Theme.middleGrayColor;
|
||||
}
|
||||
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId
|
||||
{
|
||||
OWSAssertDebug(recipientId.length > 0);
|
||||
OWSAssertDebug(contactsManager);
|
||||
|
||||
// Update fonts to reflect changes to dynamic type.
|
||||
[self configureFontsAndColors];
|
||||
|
||||
self.recipientId = recipientId;
|
||||
self.contactsManager = contactsManager;
|
||||
|
||||
self.nameLabel.attributedText =
|
||||
[contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font];
|
||||
[self.contactsManager formattedFullNameForRecipientId:recipientId font:self.nameLabel.font];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(otherUsersProfileDidChange:)
|
||||
|
@ -132,7 +148,7 @@ const CGFloat kContactCellAvatarTextMargin = 12;
|
|||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
|
||||
- (void)configureWithThread:(TSThread *)thread
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
self.thread = thread;
|
||||
|
@ -140,8 +156,6 @@ const CGFloat kContactCellAvatarTextMargin = 12;
|
|||
// Update fonts to reflect changes to dynamic type.
|
||||
[self configureFontsAndColors];
|
||||
|
||||
self.contactsManager = contactsManager;
|
||||
|
||||
NSString *threadName = thread.name;
|
||||
if (threadName.length == 0 && [thread isKindOfClass:[TSGroupThread class]]) {
|
||||
threadName = [MessageStrings newGroupDefaultTitle];
|
||||
|
|
|
@ -2,20 +2,17 @@
|
|||
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
||||
//
|
||||
|
||||
#import "OWSContactsManager.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@class OWSContactsManager;
|
||||
@class TSThread;
|
||||
|
||||
@interface ContactTableViewCell : UITableViewCell
|
||||
|
||||
+ (NSString *)reuseIdentifier;
|
||||
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager;
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId;
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager;
|
||||
- (void)configureWithThread:(TSThread *)thread;
|
||||
|
||||
// This method should be called _before_ the configure... methods.
|
||||
- (void)setAccessoryMessage:(nullable NSString *)accessoryMessage;
|
||||
|
|
|
@ -53,23 +53,23 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
self.cellView.userInteractionEnabled = NO;
|
||||
}
|
||||
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId contactsManager:(OWSContactsManager *)contactsManager
|
||||
- (void)configureWithRecipientId:(NSString *)recipientId
|
||||
{
|
||||
[OWSTableItem configureCell:self];
|
||||
|
||||
[self.cellView configureWithRecipientId:recipientId contactsManager:contactsManager];
|
||||
[self.cellView configureWithRecipientId:recipientId];
|
||||
|
||||
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
|
||||
[self layoutSubviews];
|
||||
}
|
||||
|
||||
- (void)configureWithThread:(TSThread *)thread contactsManager:(OWSContactsManager *)contactsManager
|
||||
- (void)configureWithThread:(TSThread *)thread
|
||||
{
|
||||
OWSAssertDebug(thread);
|
||||
|
||||
[OWSTableItem configureCell:self];
|
||||
|
||||
[self.cellView configureWithThread:thread contactsManager:contactsManager];
|
||||
[self.cellView configureWithThread:thread];
|
||||
|
||||
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
|
||||
[self layoutSubviews];
|
||||
|
|
|
@ -100,11 +100,12 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
- (nullable UIImage *)buildDefaultImage
|
||||
{
|
||||
UIImage *_Nullable cachedAvatar =
|
||||
[OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey diameter:(CGFloat)self.diameter];
|
||||
if (cachedAvatar) {
|
||||
return cachedAvatar;
|
||||
}
|
||||
UIImage *_Nullable cachedAvatar = nil;
|
||||
// [OWSContactAvatarBuilder.contactsManager.avatarCache imageForKey:self.cacheKey
|
||||
// diameter:(CGFloat)self.diameter];
|
||||
// if (cachedAvatar) {
|
||||
// return cachedAvatar;
|
||||
// }
|
||||
|
||||
NSMutableString *initials = [NSMutableString string];
|
||||
|
||||
|
|
Loading…
Reference in New Issue