Merge branch 'charlesmchen/tweakCells'

pull/1/head
Matthew Chen 7 years ago
commit 06d8e8cb4f

@ -130,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN
+ (CGFloat)iconSize + (CGFloat)iconSize
{ {
return 44.f; return 48.f;
} }
- (CGFloat)iconSize - (CGFloat)iconSize

@ -447,6 +447,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
[self.footerView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal], [self.footerView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal],
[self.footerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal], [self.footerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal],
[self.footerView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual],
[self.footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom], [self.footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom],
]]; ]];
} else { } else {

@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
// to always keep one around. // to always keep one around.
@property (nonatomic) OWSMessageBubbleView *messageBubbleView; @property (nonatomic) OWSMessageBubbleView *messageBubbleView;
@property (nonatomic) UIView *dateHeaderView; @property (nonatomic) UIStackView *dateHeaderView;
@property (nonatomic) UIView *dateStrokeView; @property (nonatomic) UIView *dateStrokeView;
@property (nonatomic) UILabel *dateHeaderLabel; @property (nonatomic) UILabel *dateHeaderLabel;
@property (nonatomic) AvatarImageView *avatarView; @property (nonatomic) AvatarImageView *avatarView;
@ -51,23 +51,21 @@ NS_ASSUME_NONNULL_BEGIN
self.messageBubbleView = [OWSMessageBubbleView new]; self.messageBubbleView = [OWSMessageBubbleView new];
[self.contentView addSubview:self.messageBubbleView]; [self.contentView addSubview:self.messageBubbleView];
self.dateHeaderView = [UIView new];
self.dateStrokeView = [UIView new]; self.dateStrokeView = [UIView new];
self.dateStrokeView.backgroundColor = [UIColor lightGrayColor]; self.dateStrokeView.backgroundColor = [UIColor ows_light45Color];
[self.dateHeaderView addSubview:self.dateStrokeView]; [self.dateStrokeView autoSetDimension:ALDimensionHeight toSize:self.dateHeaderStrokeThickness];
[self.dateStrokeView setContentHuggingHigh];
self.dateHeaderLabel = [UILabel new]; self.dateHeaderLabel = [UILabel new];
self.dateHeaderLabel.font = self.dateHeaderDateFont; self.dateHeaderLabel.font = self.dateHeaderFont;
self.dateHeaderLabel.textAlignment = NSTextAlignmentCenter; self.dateHeaderLabel.textAlignment = NSTextAlignmentCenter;
self.dateHeaderLabel.textColor = [UIColor lightGrayColor]; self.dateHeaderLabel.textColor = [UIColor ows_light60Color];
[self.dateHeaderView addSubview:self.dateHeaderLabel];
[self.dateStrokeView autoPinWidthToSuperview]; self.dateHeaderView = [[UIStackView alloc] initWithArrangedSubviews:@[
[self.dateStrokeView autoPinEdgeToSuperviewEdge:ALEdgeTop]; self.dateStrokeView,
[self.dateStrokeView autoSetDimension:ALDimensionHeight toSize:1.f]; self.dateHeaderLabel,
[self.dateHeaderLabel autoPinWidthToSuperview]; ]];
[self.dateHeaderLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.dateStrokeView]; self.dateHeaderView.axis = NSTextLayoutOrientationVertical;
self.avatarView = [[AvatarImageView alloc] init]; self.avatarView = [[AvatarImageView alloc] init];
[self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize]; [self.avatarView autoSetDimension:ALDimensionWidth toSize:self.avatarSize];
@ -148,7 +146,7 @@ NS_ASSUME_NONNULL_BEGIN
[self.messageBubbleView loadContent]; [self.messageBubbleView loadContent];
// Update label fonts to honor dynamic type size. // Update label fonts to honor dynamic type size.
self.dateHeaderLabel.font = self.dateHeaderDateFont; self.dateHeaderLabel.font = self.dateHeaderFont;
if (self.isIncoming) { if (self.isIncoming) {
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
@ -227,18 +225,18 @@ NS_ASSUME_NONNULL_BEGIN
NSAttributedString *attributedText = [NSAttributedString new]; NSAttributedString *attributedText = [NSAttributedString new];
attributedText = [attributedText rtlSafeAppend:dateString.uppercaseString attributedText = [attributedText rtlSafeAppend:dateString.uppercaseString
attributes:@{ attributes:@{
NSFontAttributeName : self.dateHeaderDateFont, NSFontAttributeName : self.dateHeaderFont,
NSForegroundColorAttributeName : [UIColor lightGrayColor], NSForegroundColorAttributeName : [UIColor lightGrayColor],
} }
referenceView:self]; referenceView:self];
attributedText = [attributedText rtlSafeAppend:@" " attributedText = [attributedText rtlSafeAppend:@" "
attributes:@{ attributes:@{
NSFontAttributeName : self.dateHeaderDateFont, NSFontAttributeName : self.dateHeaderFont,
} }
referenceView:self]; referenceView:self];
attributedText = [attributedText rtlSafeAppend:timeString attributedText = [attributedText rtlSafeAppend:timeString
attributes:@{ attributes:@{
NSFontAttributeName : self.dateHeaderTimeFont, NSFontAttributeName : self.dateHeaderFont,
NSForegroundColorAttributeName : [UIColor lightGrayColor], NSForegroundColorAttributeName : [UIColor lightGrayColor],
} }
referenceView:self]; referenceView:self];
@ -250,9 +248,16 @@ NS_ASSUME_NONNULL_BEGIN
[self.dateHeaderView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.gutterLeading], [self.dateHeaderView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.gutterLeading],
[self.dateHeaderView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.gutterTrailing], [self.dateHeaderView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.gutterTrailing],
[self.dateHeaderView autoPinEdgeToSuperviewEdge:ALEdgeTop], [self.dateHeaderView autoPinEdgeToSuperviewEdge:ALEdgeTop],
[self.dateHeaderView autoSetDimension:ALDimensionHeight toSize:self.dateHeaderHeight],
[self.messageBubbleView autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.dateHeaderView], // DO NOT pin to the bottom of dateHeaderView.
//
// Being a UIStackView, it doesn't reflect the spacing below the date
// header contents. Instead pin using dateHeaderHeight which includes
// the spacing.
[self.messageBubbleView autoPinEdge:ALEdgeTop
toEdge:ALEdgeTop
ofView:self.dateHeaderView
withOffset:self.dateHeaderHeight],
]]; ]];
} else { } else {
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
@ -261,12 +266,7 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
- (UIFont *)dateHeaderDateFont - (UIFont *)dateHeaderFont
{
return UIFont.ows_dynamicTypeCaption1Font.ows_mediumWeight;
}
- (UIFont *)dateHeaderTimeFont
{ {
return UIFont.ows_dynamicTypeCaption1Font; return UIFont.ows_dynamicTypeCaption1Font;
} }
@ -368,16 +368,21 @@ NS_ASSUME_NONNULL_BEGIN
return cellSize; return cellSize;
} }
- (CGFloat)dateHeaderStrokeThickness
{
return CGHairlineWidth();
}
- (CGFloat)dateHeaderBottomMargin - (CGFloat)dateHeaderBottomMargin
{ {
return 24.f; return 20.f;
} }
- (CGFloat)dateHeaderHeight - (CGFloat)dateHeaderHeight
{ {
if (self.viewItem.shouldShowDate) { if (self.viewItem.shouldShowDate) {
CGFloat textHeight = MAX(self.dateHeaderDateFont.capHeight, self.dateHeaderTimeFont.capHeight); CGFloat textHeight = self.dateHeaderFont.capHeight;
return (CGFloat)ceil(textHeight + self.dateHeaderBottomMargin); return (CGFloat)ceil(self.dateHeaderStrokeThickness + textHeight + self.dateHeaderBottomMargin);
} else { } else {
return 0.f; return 0.f;
} }

@ -55,7 +55,6 @@ NS_ASSUME_NONNULL_BEGIN
[self.imageView setContentHuggingHigh]; [self.imageView setContentHuggingHigh];
self.titleLabel = [UILabel new]; self.titleLabel = [UILabel new];
self.titleLabel.textColor = [UIColor colorWithRGBHex:0x403e3b];
self.titleLabel.numberOfLines = 0; self.titleLabel.numberOfLines = 0;
self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; self.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
@ -80,7 +79,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureFonts - (void)configureFonts
{ {
// Update cell to reflect changes in dynamic text. // Update cell to reflect changes in dynamic text.
self.titleLabel.font = UIFont.ows_dynamicTypeFootnoteFont; self.titleLabel.font = UIFont.ows_dynamicTypeSubheadlineFont;
} }
+ (NSString *)cellReuseIdentifier + (NSString *)cellReuseIdentifier
@ -122,14 +121,14 @@ NS_ASSUME_NONNULL_BEGIN
- (UIColor *)textColor - (UIColor *)textColor
{ {
return [UIColor colorWithRGBHex:0x303030]; return [UIColor ows_light60Color];
} }
- (UIColor *)iconColorForInteraction:(TSInteraction *)interaction - (UIColor *)iconColorForInteraction:(TSInteraction *)interaction
{ {
// "Phone", "Shield" and "Hourglass" icons have a lot of "ink" so they // "Phone", "Shield" and "Hourglass" icons have a lot of "ink" so they
// are less dark for balance. // are less dark for balance.
return [UIColor colorWithRGBHex:0x404040]; return [UIColor ows_light60Color];
} }
- (UIImage *)iconForInteraction:(TSInteraction *)interaction - (UIImage *)iconForInteraction:(TSInteraction *)interaction

@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) UILabel *subtitleLabel; @property (nonatomic) UILabel *subtitleLabel;
@property (nonatomic) UIView *strokeView; @property (nonatomic) UIView *strokeView;
@property (nonatomic) NSArray<NSLayoutConstraint *> *layoutConstraints; @property (nonatomic) NSArray<NSLayoutConstraint *> *layoutConstraints;
@property (nonatomic) UIStackView *stackView;
@end @end
@ -45,24 +46,28 @@ NS_ASSUME_NONNULL_BEGIN
self.contentView.layoutMargins = UIEdgeInsetsZero; self.contentView.layoutMargins = UIEdgeInsetsZero;
self.strokeView = [UIView new]; self.strokeView = [UIView new];
// TODO: color. self.strokeView.backgroundColor = [UIColor ows_light60Color];
self.strokeView.backgroundColor = [UIColor blackColor]; [self.strokeView autoSetDimension:ALDimensionHeight toSize:self.strokeThickness];
[self.contentView addSubview:self.strokeView]; [self.strokeView setContentHuggingHigh];
self.titleLabel = [UILabel new]; self.titleLabel = [UILabel new];
// TODO: color. self.titleLabel.textColor = [UIColor ows_light90Color];
self.titleLabel.textColor = [UIColor blackColor];
self.titleLabel.textAlignment = NSTextAlignmentCenter; self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.titleLabel];
self.subtitleLabel = [UILabel new]; self.subtitleLabel = [UILabel new];
// TODO: color. self.subtitleLabel.textColor = [UIColor ows_light90Color];
self.subtitleLabel.textColor = [UIColor lightGrayColor];
// The subtitle may wrap to a second line. // The subtitle may wrap to a second line.
self.subtitleLabel.numberOfLines = 0; self.subtitleLabel.numberOfLines = 0;
self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping; self.subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
self.subtitleLabel.textAlignment = NSTextAlignmentCenter; self.subtitleLabel.textAlignment = NSTextAlignmentCenter;
[self.contentView addSubview:self.subtitleLabel];
self.stackView = [[UIStackView alloc] initWithArrangedSubviews:@[
self.strokeView,
self.titleLabel,
self.subtitleLabel,
]];
self.stackView.axis = NSTextLayoutOrientationVertical;
[self.contentView addSubview:self.stackView];
[self configureFonts]; [self configureFonts];
} }
@ -70,8 +75,6 @@ NS_ASSUME_NONNULL_BEGIN
- (void)configureFonts - (void)configureFonts
{ {
// Update cell to reflect changes in dynamic text. // Update cell to reflect changes in dynamic text.
//
// TODO: Font size.
self.titleLabel.font = UIFont.ows_dynamicTypeCaption1Font.ows_mediumWeight; self.titleLabel.font = UIFont.ows_dynamicTypeCaption1Font.ows_mediumWeight;
self.subtitleLabel.font = UIFont.ows_dynamicTypeCaption1Font; self.subtitleLabel.font = UIFont.ows_dynamicTypeCaption1Font;
} }
@ -94,26 +97,16 @@ NS_ASSUME_NONNULL_BEGIN
self.titleLabel.text = [self titleForInteraction:interaction]; self.titleLabel.text = [self titleForInteraction:interaction];
self.subtitleLabel.text = [self subtitleForInteraction:interaction]; self.subtitleLabel.text = [self subtitleForInteraction:interaction];
self.backgroundColor = [UIColor whiteColor]; self.subtitleLabel.hidden = self.subtitleLabel.text.length < 1;
[NSLayoutConstraint deactivateConstraints:self.layoutConstraints]; [NSLayoutConstraint deactivateConstraints:self.layoutConstraints];
self.layoutConstraints = @[ self.layoutConstraints = @[
[self.strokeView autoPinEdgeToSuperviewEdge:ALEdgeTop], [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTop],
[self.strokeView autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading], [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeBottom],
[self.strokeView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing], [self.stackView autoPinEdgeToSuperviewEdge:ALEdgeLeading
[self.strokeView autoSetDimension:ALDimensionHeight toSize:self.strokeHeight], withInset:self.conversationStyle.fullWidthGutterLeading],
[self.stackView autoPinEdgeToSuperviewEdge:ALEdgeTrailing
[self.titleLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.strokeView], withInset:self.conversationStyle.fullWidthGutterTrailing],
[self.titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop],
[self.titleLabel autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading],
[self.titleLabel autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing],
[self.subtitleLabel autoPinEdge:ALEdgeTop
toEdge:ALEdgeBottom
ofView:self.titleLabel
withOffset:self.subtitleVSpacing],
[self.subtitleLabel autoPinLeadingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterLeading],
[self.subtitleLabel autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.fullWidthGutterTrailing],
]; ];
} }
@ -135,14 +128,9 @@ NS_ASSUME_NONNULL_BEGIN
@"Messages that indicates that there are more unseen messages including safety number changes.")); @"Messages that indicates that there are more unseen messages including safety number changes."));
} }
- (CGFloat)strokeHeight - (CGFloat)strokeThickness
{
return 1.f;
}
- (CGFloat)subtitleVSpacing
{ {
return 3.f; return CGHairlineWidth();
} }
- (CGSize)cellSizeWithTransaction:(YapDatabaseReadTransaction *)transaction - (CGSize)cellSizeWithTransaction:(YapDatabaseReadTransaction *)transaction
@ -153,13 +141,12 @@ NS_ASSUME_NONNULL_BEGIN
[self configureFonts]; [self configureFonts];
CGSize result CGSize result = CGSizeMake(
= CGSizeMake(self.conversationStyle.fullWidthContentWidth, self.strokeHeight + self.titleLabel.font.lineHeight); self.conversationStyle.fullWidthContentWidth, self.strokeThickness + self.titleLabel.font.lineHeight);
TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction; TSUnreadIndicatorInteraction *interaction = (TSUnreadIndicatorInteraction *)self.viewItem.interaction;
self.subtitleLabel.text = [self subtitleForInteraction:interaction]; self.subtitleLabel.text = [self subtitleForInteraction:interaction];
if (self.subtitleLabel.text.length > 0) { if (self.subtitleLabel.text.length > 0) {
result.height += self.subtitleVSpacing;
result.height += ceil( result.height += ceil(
[self.subtitleLabel sizeThatFits:CGSizeMake(self.conversationStyle.fullWidthContentWidth, CGFLOAT_MAX)] [self.subtitleLabel sizeThatFits:CGSizeMake(self.conversationStyle.fullWidthContentWidth, CGFLOAT_MAX)]
.height); .height);

@ -170,4 +170,6 @@ CG_INLINE CGSize CGSizeMax(CGSize size1, CGSize size2)
return CGSizeMake(MAX(size1.width, size2.width), MAX(size1.height, size2.height)); return CGSizeMake(MAX(size1.width, size2.width), MAX(size1.height, size2.height));
} }
CGFloat CGHairlineWidth();
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -542,4 +542,9 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
@end @end
CGFloat CGHairlineWidth()
{
return 1.f / UIScreen.mainScreen.scale;
}
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

Loading…
Cancel
Save