|
|
|
@ -16,13 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
@property (nonatomic, nullable) TSUnreadIndicatorInteraction *interaction;
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
//@property (nonatomic) UIView *bannerView;
|
|
|
|
|
//@property (nonatomic) UIView *bannerTopHighlightView;
|
|
|
|
|
//@property (nonatomic) UIView *bannerBottomHighlightView1;
|
|
|
|
|
//@property (nonatomic) UIView *bannerBottomHighlightView2;
|
|
|
|
|
@property (nonatomic) UILabel *titleLabel;
|
|
|
|
|
//@property (nonatomic) UILabel *subtitleLabel;
|
|
|
|
|
@property (nonatomic) UIView *strokeView;
|
|
|
|
|
@property (nonatomic) NSArray<NSLayoutConstraint *> *layoutConstraints;
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@ -50,57 +45,26 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
self.layoutMargins = UIEdgeInsetsZero;
|
|
|
|
|
self.contentView.layoutMargins = UIEdgeInsetsZero;
|
|
|
|
|
|
|
|
|
|
// self.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
// self.bannerView = [UIView new];
|
|
|
|
|
// self.bannerView.backgroundColor = [UIColor colorWithRGBHex:0xf6eee3];
|
|
|
|
|
// [self.contentView addSubview:self.bannerView];
|
|
|
|
|
//
|
|
|
|
|
// self.bannerTopHighlightView = [UIView new];
|
|
|
|
|
// self.bannerTopHighlightView.backgroundColor = [UIColor colorWithRGBHex:0xf9f3eb];
|
|
|
|
|
// [self.bannerView addSubview:self.bannerTopHighlightView];
|
|
|
|
|
//
|
|
|
|
|
// self.bannerBottomHighlightView1 = [UIView new];
|
|
|
|
|
// self.bannerBottomHighlightView1.backgroundColor = [UIColor colorWithRGBHex:0xd1c6b8];
|
|
|
|
|
// [self.bannerView addSubview:self.bannerBottomHighlightView1];
|
|
|
|
|
//
|
|
|
|
|
// self.bannerBottomHighlightView2 = [UIView new];
|
|
|
|
|
// self.bannerBottomHighlightView2.backgroundColor = [UIColor colorWithRGBHex:0xdbcfc0];
|
|
|
|
|
// [self.bannerView addSubview:self.bannerBottomHighlightView2];
|
|
|
|
|
self.strokeView = [UIView new];
|
|
|
|
|
// TODO: color.
|
|
|
|
|
self.strokeView.backgroundColor = [UIColor colorWithRGBHex:0xf6eee3];
|
|
|
|
|
[self.contentView addSubview:self.strokeView];
|
|
|
|
|
|
|
|
|
|
self.titleLabel = [UILabel new];
|
|
|
|
|
// TODO: color.
|
|
|
|
|
self.titleLabel.textColor = [UIColor colorWithRGBHex:0x403e3b];
|
|
|
|
|
self.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
[self.contentView addSubview:self.titleLabel];
|
|
|
|
|
|
|
|
|
|
// self.subtitleLabel = [UILabel new];
|
|
|
|
|
// self.subtitleLabel.textColor = [UIColor ows_infoMessageBorderColor];
|
|
|
|
|
// self.subtitleLabel.font = [self subtitleFont];
|
|
|
|
|
// // The subtitle may wrap to a second line.
|
|
|
|
|
// self.subtitleLabel.numberOfLines = 0;
|
|
|
|
|
// self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
|
|
|
|
|
// self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
// [self.contentView addSubview:self.subtitleLabel];
|
|
|
|
|
|
|
|
|
|
[self configureFonts];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)configureFonts
|
|
|
|
|
{
|
|
|
|
|
// Update cell to reflect changes in dynamic text.
|
|
|
|
|
self.titleLabel.font = UIFont.ows_dynamicTypeBodyFont;
|
|
|
|
|
// self.subtitleLabel.font = [self subtitleFont];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// - (UIFont *)titleFont
|
|
|
|
|
// {
|
|
|
|
|
// return UIFont.ows_dynamicTypeBodyFont;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// - (UIFont *)subtitleFont
|
|
|
|
|
// {
|
|
|
|
|
// return UIFont.ows_dynamicTypeCaption1Font;
|
|
|
|
|
// }
|
|
|
|
|
// TODO: Font size.
|
|
|
|
|
self.titleLabel.font = UIFont.ows_dynamicTypeSubheadlineFont;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSString *)cellReuseIdentifier
|
|
|
|
@ -119,20 +83,21 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction;
|
|
|
|
|
|
|
|
|
|
self.titleLabel.text = [self titleForInteraction:interaction];
|
|
|
|
|
// self.subtitleLabel.text = [self subtitleForInteraction:interaction];
|
|
|
|
|
|
|
|
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
|
|
|
|
[NSLayoutConstraint deactivateConstraints:self.layoutConstraints];
|
|
|
|
|
self.layoutConstraints = @[
|
|
|
|
|
// TODO: Constants.
|
|
|
|
|
[self.titleLabel autoVCenterInSuperview],
|
|
|
|
|
[self.titleLabel autoPinLeadingToSuperviewMarginWithInset:self.layoutInfo.fullWidthGutterLeading],
|
|
|
|
|
[self.titleLabel autoPinTrailingToSuperviewMarginWithInset:self.layoutInfo.fullWidthGutterTrailing],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
// [self setNeedsLayout];
|
|
|
|
|
// TODO: offset.
|
|
|
|
|
[self.strokeView autoPinEdge:ALEdgeBottom toEdge:ALEdgeTop ofView:self.titleLabel withOffset:0.f],
|
|
|
|
|
[self.strokeView autoPinLeadingToSuperviewMarginWithInset:self.layoutInfo.fullWidthGutterLeading],
|
|
|
|
|
[self.strokeView autoPinTrailingToSuperviewMarginWithInset:self.layoutInfo.fullWidthGutterTrailing],
|
|
|
|
|
[self.strokeView autoSetDimension:ALDimensionHeight toSize:1.f],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *)titleForInteraction:(TSUnreadIndicatorInteraction *)interaction
|
|
|
|
@ -141,98 +106,6 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
.uppercaseString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//- (NSString *)subtitleForInteraction:(TSUnreadIndicatorInteraction *)interaction
|
|
|
|
|
//{
|
|
|
|
|
// if (!interaction.hasMoreUnseenMessages) {
|
|
|
|
|
// return nil;
|
|
|
|
|
// }
|
|
|
|
|
// NSString *subtitleFormat = (interaction.missingUnseenSafetyNumberChangeCount > 0
|
|
|
|
|
// ? NSLocalizedString(@"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_FORMAT",
|
|
|
|
|
// @"Messages that indicates that there are more unseen messages that be revealed by tapping the 'load
|
|
|
|
|
// "
|
|
|
|
|
// @"earlier messages' button. Embeds {{the name of the 'load earlier messages' button}}")
|
|
|
|
|
// : NSLocalizedString(
|
|
|
|
|
// @"MESSAGES_VIEW_UNREAD_INDICATOR_HAS_MORE_UNSEEN_MESSAGES_AND_SAFETY_NUMBER_CHANGES_FORMAT",
|
|
|
|
|
// @"Messages that indicates that there are more unseen messages including safety number changes that "
|
|
|
|
|
// @"be revealed by tapping the 'load earlier messages' button. Embeds {{the name of the 'load earlier
|
|
|
|
|
// "
|
|
|
|
|
// @"messages' button}}."));
|
|
|
|
|
// NSString *loadMoreButtonName = NSLocalizedString(
|
|
|
|
|
// @"load_earlier_messages", @"Label for button that loads more messages in conversation view.");
|
|
|
|
|
// return [NSString stringWithFormat:subtitleFormat, loadMoreButtonName];
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//- (CGFloat)subtitleHMargin
|
|
|
|
|
//{
|
|
|
|
|
// return 20.f;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//- (CGFloat)subtitleVSpacing
|
|
|
|
|
//{
|
|
|
|
|
// return 3.f;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//- (CGFloat)titleInnerHMargin
|
|
|
|
|
//{
|
|
|
|
|
// return 10.f;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//- (CGFloat)titleVMargin
|
|
|
|
|
//{
|
|
|
|
|
// return 5.5f;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//- (CGFloat)topVMargin
|
|
|
|
|
//{
|
|
|
|
|
// return 5.f;
|
|
|
|
|
//}
|
|
|
|
|
//
|
|
|
|
|
//- (CGFloat)bottomVMargin
|
|
|
|
|
//{
|
|
|
|
|
// return 5.f;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//- (void)layoutSubviews
|
|
|
|
|
//{
|
|
|
|
|
// [super layoutSubviews];
|
|
|
|
|
//
|
|
|
|
|
// [self.titleLabel sizeToFit];
|
|
|
|
|
//
|
|
|
|
|
// // It's a bit of a hack, but we use a view that extends _outside_ the cell's bounds
|
|
|
|
|
// // to draw its background, since we want the background to extend to the edges of the
|
|
|
|
|
// // collection view.
|
|
|
|
|
// //
|
|
|
|
|
// // This layout logic assumes that the cell insets are symmetrical and can be deduced
|
|
|
|
|
// // from the cell frame.
|
|
|
|
|
// CGRect bannerViewFrame = CGRectMake(-self.left,
|
|
|
|
|
// round(self.topVMargin),
|
|
|
|
|
// round(self.width + self.left * 2.f),
|
|
|
|
|
// round(self.titleLabel.height + self.titleVMargin * 2.f));
|
|
|
|
|
// self.bannerView.frame = [self convertRect:bannerViewFrame toView:self.contentView];
|
|
|
|
|
//
|
|
|
|
|
// // The highlights should be 1px (not 1pt), so adapt their thickness to
|
|
|
|
|
// // the device resolution.
|
|
|
|
|
// CGFloat kHighlightThickness = 1.f / [UIScreen mainScreen].scale;
|
|
|
|
|
// self.bannerTopHighlightView.frame = CGRectMake(0, 0, self.bannerView.width, kHighlightThickness);
|
|
|
|
|
// self.bannerBottomHighlightView1.frame
|
|
|
|
|
// = CGRectMake(0, self.bannerView.height - kHighlightThickness * 2.f, self.bannerView.width,
|
|
|
|
|
// kHighlightThickness);
|
|
|
|
|
// self.bannerBottomHighlightView2.frame
|
|
|
|
|
// = CGRectMake(0, self.bannerView.height - kHighlightThickness * 1.f, self.bannerView.width,
|
|
|
|
|
// kHighlightThickness);
|
|
|
|
|
//
|
|
|
|
|
// [self.titleLabel centerOnSuperview];
|
|
|
|
|
//
|
|
|
|
|
// if (self.subtitleLabel.text.length > 0) {
|
|
|
|
|
// CGSize subtitleSize = [self.subtitleLabel
|
|
|
|
|
// sizeThatFits:CGSizeMake(self.contentView.width - [self subtitleHMargin] * 2.f, CGFLOAT_MAX)];
|
|
|
|
|
// self.subtitleLabel.frame = CGRectMake(round((self.contentView.width - subtitleSize.width) * 0.5f),
|
|
|
|
|
// round(self.bannerView.bottom + self.subtitleVSpacing),
|
|
|
|
|
// ceil(subtitleSize.width),
|
|
|
|
|
// ceil(subtitleSize.height));
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
- (CGSize)cellSize
|
|
|
|
|
{
|
|
|
|
|
OWSAssert(self.layoutInfo);
|
|
|
|
@ -241,28 +114,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|
|
|
|
|
|
|
|
|
[self configureFonts];
|
|
|
|
|
|
|
|
|
|
// TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction;
|
|
|
|
|
|
|
|
|
|
// TODO:
|
|
|
|
|
CGSize result = CGSizeMake(self.layoutInfo.fullWidthContentWidth, self.titleLabel.font.lineHeight + 24.f * 2);
|
|
|
|
|
// result.height += self.titleVMargin * 2.f;
|
|
|
|
|
// result.height += self.topVMargin;
|
|
|
|
|
// result.height += self.bottomVMargin;
|
|
|
|
|
//
|
|
|
|
|
// NSString *title = [self titleForInteraction:interaction];
|
|
|
|
|
// NSString *subtitle = [self subtitleForInteraction:interaction];
|
|
|
|
|
//
|
|
|
|
|
// self.titleLabel.text = title;
|
|
|
|
|
// result.height += ceil([self.titleLabel sizeThatFits:CGSizeZero].height);
|
|
|
|
|
//
|
|
|
|
|
// if (subtitle.length > 0) {
|
|
|
|
|
// result.height += self.subtitleVSpacing;
|
|
|
|
|
//
|
|
|
|
|
// self.subtitleLabel.text = subtitle;
|
|
|
|
|
// result.height += ceil(
|
|
|
|
|
// [self.subtitleLabel sizeThatFits:CGSizeMake(self.layoutInfo.fullWidthContentWidth -
|
|
|
|
|
// self.subtitleHMargin * 2.f, CGFLOAT_MAX)].height);
|
|
|
|
|
// }
|
|
|
|
|
// TODO: offset.
|
|
|
|
|
CGFloat vOffset = 24.f;
|
|
|
|
|
CGSize result = CGSizeMake(self.layoutInfo.fullWidthContentWidth, self.titleLabel.font.lineHeight + vOffset * 2);
|
|
|
|
|
|
|
|
|
|
return CGSizeCeil(result);
|
|
|
|
|
}
|
|
|
|
|