Use dynamic type everywhere in conversation view.

This commit is contained in:
Matthew Chen 2018-04-06 16:38:37 -04:00
parent ade2ee7216
commit c106a67a52
3 changed files with 10 additions and 34 deletions

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSContactOffersCell.h"
@ -100,12 +100,12 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)titleFont
{
return [UIFont ows_mediumFontWithSize:16.f];
return UIFont.ows_dynamicTypeBodyFont.ows_medium;
}
- (UIFont *)buttonFont
{
return [UIFont ows_regularFontWithSize:14.f];
return UIFont.ows_dynamicTypeBodyFont;
}
- (CGFloat)hMargin

View file

@ -25,18 +25,12 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) UIImageView *imageView;
@property (nonatomic) UILabel *titleLabel;
// override from JSQMessagesCollectionViewCell
@property (nonatomic) UILabel *cellTopLabel;
@end
#pragma mark -
@implementation OWSSystemMessageCell
// override from JSQMessagesCollectionViewCell
@synthesize cellTopLabel = _cellTopLabel;
// `[UIView init]` invokes `[self initWithFrame:...]`.
- (instancetype)initWithFrame:(CGRect)frame
{
@ -55,12 +49,6 @@ NS_ASSUME_NONNULL_BEGIN
self.backgroundColor = [UIColor whiteColor];
self.cellTopLabel = [UILabel new];
self.cellTopLabel.textAlignment = NSTextAlignmentCenter;
self.cellTopLabel.font = self.topLabelFont;
self.cellTopLabel.textColor = [UIColor lightGrayColor];
[self.contentView addSubview:self.cellTopLabel];
self.imageView = [UIImageView new];
[self.contentView addSubview:self.imageView];
@ -100,11 +88,6 @@ NS_ASSUME_NONNULL_BEGIN
[self setNeedsLayout];
}
- (UIFont *)topLabelFont
{
return [UIFont boldSystemFontOfSize:12.0f];
}
- (UIColor *)textColor
{
return [UIColor colorWithRGBHex:0x303030];
@ -223,7 +206,7 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)titleFont
{
return [UIFont ows_regularFontWithSize:13.f];
return UIFont.ows_dynamicTypeFootnoteFont;
}
- (CGFloat)hMargin
@ -260,22 +243,15 @@ NS_ASSUME_NONNULL_BEGIN
CGFloat contentWidth = ([self iconSize] + [self hSpacing] + titleSize.width);
CGSize topLabelSize = [self.cellTopLabel sizeThatFits:CGSizeMake(self.contentView.width, CGFLOAT_MAX)];
self.cellTopLabel.frame = CGRectMake(0, 0, self.contentView.frame.size.width, topLabelSize.height);
CGFloat topLabelSpacing = topLabelSize.height;
CGFloat contentLeft = round((self.contentView.width - contentWidth) * 0.5f);
CGFloat imageLeft = ([self isRTL] ? round(contentLeft + contentWidth - [self iconSize]) : contentLeft);
CGFloat titleLeft = ([self isRTL] ? contentLeft : round(imageLeft + [self iconSize] + [self hSpacing]));
self.imageView.frame = CGRectMake(imageLeft,
round((self.contentView.height - [self iconSize] + topLabelSpacing) * 0.5f),
[self iconSize],
[self iconSize]);
self.imageView.frame = CGRectMake(
imageLeft, round((self.contentView.height - [self iconSize]) * 0.5f), [self iconSize], [self iconSize]);
self.titleLabel.frame = CGRectMake(titleLeft,
round((self.contentView.height - titleSize.height + topLabelSpacing) * 0.5f),
round((self.contentView.height - titleSize.height) * 0.5f),
ceil(titleSize.width + 1.f),
ceil(titleSize.height + 1.f));
}

View file

@ -1,5 +1,5 @@
//
// Copyright (c) 2017 Open Whisper Systems. All rights reserved.
// Copyright (c) 2018 Open Whisper Systems. All rights reserved.
//
#import "OWSUnreadIndicatorCell.h"
@ -101,12 +101,12 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)titleFont
{
return [UIFont ows_regularFontWithSize:16.f];
return UIFont.ows_dynamicTypeBodyFont;
}
- (UIFont *)subtitleFont
{
return [UIFont ows_regularFontWithSize:12.f];
return UIFont.ows_dynamicTypeCaption1Font;
}
- (NSString *)titleForInteraction:(TSUnreadIndicatorInteraction *)interaction