session-ios/SignalMessaging/Views/ContactTableViewCell.m

117 lines
2.5 KiB
Mathematica
Raw Normal View History

2017-03-23 14:55:39 +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"
#import "ContactCellView.h"
2018-07-13 00:38:55 +02:00
#import "OWSTableViewController.h"
#import "UIColor+OWS.h"
#import "UIFont+OWS.h"
#import "UIView+OWS.h"
#import <SignalServiceKit/SignalAccount.h>
NS_ASSUME_NONNULL_BEGIN
@interface ContactTableViewCell ()
2014-05-06 19:41:08 +02:00
@property (nonatomic) ContactCellView *cellView;
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
{
2018-06-12 17:27:32 +02:00
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
[self configure];
}
return self;
}
2018-06-12 17:27:32 +02:00
+ (NSString *)reuseIdentifier
{
return NSStringFromClass(self.class);
2014-05-06 19:41:08 +02:00
}
- (void)setAccessoryView:(nullable UIView *)accessoryView
{
OWSFailDebug(@"use ows_setAccessoryView instead.");
}
- (void)configure
{
OWSAssertDebug(!self.cellView);
2018-07-05 17:20:51 +02:00
self.preservesSuperviewLayoutMargins = YES;
self.contentView.preservesSuperviewLayoutMargins = YES;
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];
// Force layout, since imageView isn't being initally rendered on App Store optimized build.
[self layoutSubviews];
}
2018-10-25 15:35:08 +02:00
- (void)configureWithThread:(TSThread *)thread
2017-04-26 19:03:51 +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];
}
- (void)setAccessoryMessage:(nullable NSString *)accessoryMessage
{
OWSAssertDebug(self.cellView);
self.cellView.accessoryMessage = accessoryMessage;
}
- (NSAttributedString *)verifiedSubtitle
{
return self.cellView.verifiedSubtitle;
}
- (void)setAttributedSubtitle:(nullable NSAttributedString *)attributedSubtitle
{
[self.cellView setAttributedSubtitle:attributedSubtitle];
}
- (void)prepareForReuse
{
2017-11-08 18:56:55 +01:00
[super prepareForReuse];
[self.cellView prepareForReuse];
self.accessoryType = UITableViewCellAccessoryNone;
}
- (BOOL)hasAccessoryText
{
return [self.cellView hasAccessoryText];
}
- (void)ows_setAccessoryView:(UIView *)accessoryView
{
return [self.cellView setAccessoryView:accessoryView];
}
2014-05-06 19:41:08 +02:00
@end
NS_ASSUME_NONNULL_END