2017-03-23 14:55:39 +01:00
|
|
|
//
|
2018-01-17 23:45:47 +01:00
|
|
|
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
|
2017-03-23 14:55:39 +01:00
|
|
|
//
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
#import "ContactTableViewCell.h"
|
2018-06-21 20:49:19 +02:00
|
|
|
#import "ContactCellView.h"
|
2018-07-13 00:38:55 +02:00
|
|
|
#import "OWSTableViewController.h"
|
|
|
|
#import "UIColor+OWS.h"
|
2017-03-31 23:43:42 +02:00
|
|
|
#import "UIFont+OWS.h"
|
|
|
|
#import "UIView+OWS.h"
|
2017-05-05 18:33:10 +02:00
|
|
|
#import <SignalServiceKit/SignalAccount.h>
|
2014-11-29 19:54:33 +01:00
|
|
|
|
2016-11-22 21:19:49 +01:00
|
|
|
NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
2016-06-28 02:07:18 +02:00
|
|
|
@interface ContactTableViewCell ()
|
2014-05-06 19:41:08 +02:00
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
@property (nonatomic) ContactCellView *cellView;
|
2017-08-23 23:09:43 +02:00
|
|
|
|
2014-10-29 21:58:58 +01:00
|
|
|
@end
|
|
|
|
|
2018-06-21 16:31:39 +02:00
|
|
|
#pragma mark -
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
@implementation ContactTableViewCell
|
|
|
|
|
2018-06-12 17:27:32 +02:00
|
|
|
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(nullable NSString *)reuseIdentifier
|
2017-03-31 23:43:42 +02:00
|
|
|
{
|
2018-06-12 17:27:32 +02:00
|
|
|
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
|
2018-06-21 20:49:19 +02:00
|
|
|
[self configure];
|
2017-03-31 23:43:42 +02:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2018-06-12 17:27:32 +02:00
|
|
|
+ (NSString *)reuseIdentifier
|
2016-11-22 21:19:49 +01:00
|
|
|
{
|
2014-09-08 01:31:05 +02:00
|
|
|
return NSStringFromClass(self.class);
|
2014-05-06 19:41:08 +02:00
|
|
|
}
|
|
|
|
|
2018-06-21 19:19:56 +02:00
|
|
|
- (void)setAccessoryView:(nullable UIView *)accessoryView
|
2017-03-31 23:43:42 +02:00
|
|
|
{
|
2018-08-27 18:51:32 +02:00
|
|
|
OWSFailDebug(@"use ows_setAccessoryView instead.");
|
2018-06-21 19:19:56 +02:00
|
|
|
}
|
2017-08-16 21:14:52 +02:00
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
- (void)configure
|
2018-06-21 19:19:56 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(!self.cellView);
|
2018-06-21 19:19:56 +02:00
|
|
|
|
2018-07-05 17:20:51 +02:00
|
|
|
self.preservesSuperviewLayoutMargins = YES;
|
|
|
|
self.contentView.preservesSuperviewLayoutMargins = YES;
|
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
self.cellView = [ContactCellView new];
|
|
|
|
[self.contentView addSubview:self.cellView];
|
|
|
|
[self.cellView autoPinEdgesToSuperviewMargins];
|
2018-06-28 19:16:59 +02:00
|
|
|
self.cellView.userInteractionEnabled = NO;
|
2018-05-16 22:12:13 +02:00
|
|
|
}
|
|
|
|
|
2018-10-25 15:35:08 +02:00
|
|
|
- (void)configureWithRecipientId:(NSString *)recipientId
|
2017-04-18 22:08:01 +02:00
|
|
|
{
|
2018-07-26 16:54:45 +02:00
|
|
|
[OWSTableItem configureCell:self];
|
|
|
|
|
2018-10-25 15:35:08 +02:00
|
|
|
[self.cellView configureWithRecipientId:recipientId];
|
2017-08-16 21:14:52 +02:00
|
|
|
|
2016-11-22 21:19:49 +01:00
|
|
|
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
|
|
|
|
[self layoutSubviews];
|
2016-11-18 23:11:56 +01:00
|
|
|
}
|
|
|
|
|
2018-10-25 15:35:08 +02:00
|
|
|
- (void)configureWithThread:(TSThread *)thread
|
2017-04-26 19:03:51 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(thread);
|
2018-05-16 22:12:13 +02:00
|
|
|
|
2018-07-26 16:54:45 +02:00
|
|
|
[OWSTableItem configureCell:self];
|
|
|
|
|
2018-10-25 15:35:08 +02:00
|
|
|
[self.cellView configureWithThread:thread];
|
2017-04-26 19:03:51 +02:00
|
|
|
|
|
|
|
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
|
|
|
|
[self layoutSubviews];
|
|
|
|
}
|
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
- (void)setAccessoryMessage:(nullable NSString *)accessoryMessage
|
2017-06-09 22:21:59 +02:00
|
|
|
{
|
2018-09-06 19:01:24 +02:00
|
|
|
OWSAssertDebug(self.cellView);
|
2018-06-21 20:49:19 +02:00
|
|
|
|
|
|
|
self.cellView.accessoryMessage = accessoryMessage;
|
2017-06-09 22:21:59 +02:00
|
|
|
}
|
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
- (NSAttributedString *)verifiedSubtitle
|
2017-08-25 18:39:27 +02:00
|
|
|
{
|
2018-06-21 20:49:19 +02:00
|
|
|
return self.cellView.verifiedSubtitle;
|
2017-08-25 18:39:27 +02:00
|
|
|
}
|
2017-12-04 17:26:17 +01:00
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
- (void)setAttributedSubtitle:(nullable NSAttributedString *)attributedSubtitle
|
2017-08-23 23:09:43 +02:00
|
|
|
{
|
2018-06-21 20:49:19 +02:00
|
|
|
[self.cellView setAttributedSubtitle:attributedSubtitle];
|
2017-08-23 23:09:43 +02:00
|
|
|
}
|
|
|
|
|
2017-04-06 17:44:03 +02:00
|
|
|
- (void)prepareForReuse
|
|
|
|
{
|
2017-11-08 18:56:55 +01:00
|
|
|
[super prepareForReuse];
|
|
|
|
|
2018-06-21 20:49:19 +02:00
|
|
|
[self.cellView prepareForReuse];
|
2017-08-23 23:09:43 +02:00
|
|
|
|
2017-04-06 17:44:03 +02:00
|
|
|
self.accessoryType = UITableViewCellAccessoryNone;
|
2017-08-23 23:09:43 +02:00
|
|
|
}
|
|
|
|
|
2018-06-21 21:45:15 +02:00
|
|
|
- (BOOL)hasAccessoryText
|
|
|
|
{
|
|
|
|
return [self.cellView hasAccessoryText];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)ows_setAccessoryView:(UIView *)accessoryView
|
|
|
|
{
|
2018-06-21 21:51:53 +02:00
|
|
|
return [self.cellView setAccessoryView:accessoryView];
|
2018-06-21 21:45:15 +02:00
|
|
|
}
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
@end
|
2016-11-22 21:19:49 +01:00
|
|
|
|
|
|
|
NS_ASSUME_NONNULL_END
|