Use dynamic type everywhere in conversation view.

pull/1/head
Matthew Chen 7 years ago
parent 37966986fe
commit ade2ee7216

@ -91,7 +91,7 @@ NS_ASSUME_NONNULL_BEGIN
{
OWSAssert(DisplayableText.kMaxJumbomojiCount == 5);
CGFloat basePointSize = [UIFont ows_dynamicTypeBodyFont].pointSize;
CGFloat basePointSize = UIFont.ows_dynamicTypeBodyFont.pointSize;
switch (self.displayableBodyText.jumbomojiCount) {
case 0:
break;
@ -108,7 +108,7 @@ NS_ASSUME_NONNULL_BEGIN
break;
}
return [UIFont ows_dynamicTypeBodyFont];
return UIFont.ows_dynamicTypeBodyFont;
}
#pragma mark - Convenience Accessors
@ -946,7 +946,7 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)tapForMoreFont
{
return [UIFont ows_regularFontWithSize:12.f];
return UIFont.ows_dynamicTypeCaption1Font;
}
- (CGFloat)tapForMoreHeight

@ -62,13 +62,13 @@ NS_ASSUME_NONNULL_BEGIN
[self.contentView addSubview:self.footerView];
self.dateHeaderLabel = [UILabel new];
self.dateHeaderLabel.font = [UIFont ows_regularFontWithSize:12.f];
self.dateHeaderLabel.font = self.dateHeaderDateFont;
self.dateHeaderLabel.textAlignment = NSTextAlignmentCenter;
self.dateHeaderLabel.textColor = [UIColor lightGrayColor];
[self.contentView addSubview:self.dateHeaderLabel];
self.footerLabel = [UILabel new];
self.footerLabel.font = [UIFont ows_regularFontWithSize:12.f];
self.footerLabel.font = UIFont.ows_dynamicTypeCaption1Font;
self.footerLabel.textColor = [UIColor lightGrayColor];
[self.footerView addSubview:self.footerLabel];
@ -362,12 +362,12 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)dateHeaderDateFont
{
return [UIFont boldSystemFontOfSize:12.0f];
return UIFont.ows_dynamicTypeCaption1Font.ows_medium;
}
- (UIFont *)dateHeaderTimeFont
{
return [UIFont systemFontOfSize:12.0f];
return UIFont.ows_dynamicTypeCaption1Font;
}
#pragma mark - Measurement

@ -368,7 +368,7 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)quotedAuthorFont
{
return [UIFont ows_mediumFontWithSize:11.f];
return UIFont.ows_dynamicTypeCaption1Font.ows_medium;
}
- (UIColor *)quotedAuthorColor
@ -383,8 +383,6 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)quotedTextFont
{
// Honor dynamic type in the text.
// TODO: ?
return [UIFont ows_dynamicTypeBodyFont];
}
@ -395,11 +393,7 @@ NS_ASSUME_NONNULL_BEGIN
- (UIFont *)fileTypeFont
{
UIFontDescriptor *fontD =
[self.quotedTextFont.fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];
UIFont *font = [UIFont fontWithDescriptor:fontD size:0];
OWSAssert(font);
return font ?: self.quotedTextFont;
return self.quotedTextFont.ows_italic;
}
- (UIColor *)filenameTextColor

@ -1101,7 +1101,7 @@ typedef enum : NSUInteger {
name = [self.contactsManager
attributedStringForConversationTitleWithPhoneIdentifier:self.thread.contactIdentifier
primaryFont:[self navigationBarTitleLabelFont]
secondaryFont:[UIFont ows_footnoteFont]];
secondaryFont:[UIFont ows_dynamicTypeFootnoteFont]];
}
self.title = nil;

@ -341,9 +341,10 @@ const NSUInteger kAvatarViewDiameter = 52;
name = [[NSAttributedString alloc] initWithString:thread.name];
}
} else {
name = [contactsManager attributedStringForConversationTitleWithPhoneIdentifier:thread.contactIdentifier
primaryFont:self.nameLabel.font
secondaryFont:[UIFont ows_footnoteFont]];
name = [contactsManager
attributedStringForConversationTitleWithPhoneIdentifier:thread.contactIdentifier
primaryFont:self.nameLabel.font
secondaryFont:[UIFont ows_dynamicTypeFootnoteFont]];
}
self.nameLabel.attributedText = name;

@ -232,7 +232,7 @@ class MessageDetailViewController: OWSViewController, MediaDetailPresenter, Medi
// We use the "short" status message to avoid being redundant with the section title.
statusLabel.text = shortStatusMessage
statusLabel.textColor = UIColor.ows_darkGray
statusLabel.font = UIFont.ows_footnote
statusLabel.font = .ows_dynamicTypeFootnote
statusLabel.adjustsFontSizeToFitWidth = true
statusLabel.sizeToFit()
cell.accessoryView = statusLabel

@ -179,7 +179,7 @@ NSString *const kProfileView_LastPresentedDate = @"kProfileView_LastPresentedDat
UILabel *infoLabel = [UILabel new];
infoLabel.textColor = [UIColor ows_darkGrayColor];
infoLabel.font = [UIFont ows_footnoteFont];
infoLabel.font = [UIFont ows_dynamicTypeFootnoteFont];
infoLabel.textAlignment = NSTextAlignmentCenter;
NSMutableAttributedString *text = [NSMutableAttributedString new];
[text appendAttributedString:[[NSAttributedString alloc]

@ -382,7 +382,7 @@ NS_ASSUME_NONNULL_BEGIN
subtitleLabel.text
= NSLocalizedString(@"DISAPPEARING_MESSAGES_DESCRIPTION", @"subheading in conversation settings");
subtitleLabel.textColor = [UIColor blackColor];
subtitleLabel.font = [UIFont ows_footnoteFont];
subtitleLabel.font = [UIFont ows_dynamicTypeFootnoteFont];
subtitleLabel.numberOfLines = 0;
subtitleLabel.lineBreakMode = NSLineBreakByWordWrapping;
[cell.contentView addSubview:subtitleLabel];
@ -421,7 +421,7 @@ NS_ASSUME_NONNULL_BEGIN
UILabel *rowLabel = strongSelf.disappearingMessagesDurationLabel;
[strongSelf updateDisappearingMessagesDurationLabel];
rowLabel.textColor = [UIColor blackColor];
rowLabel.font = [UIFont ows_footnoteFont];
rowLabel.font = [UIFont ows_dynamicTypeFootnoteFont];
rowLabel.lineBreakMode = NSLineBreakByTruncatingTail;
[topView addSubview:rowLabel];
[rowLabel autoVCenterInSuperview];

@ -118,7 +118,7 @@ class AttachmentPointerView: UIView {
statusLabel.numberOfLines = 2
statusLabel.textColor = self.textColor
statusLabel.font = UIFont.ows_footnote
statusLabel.font = .ows_dynamicTypeFootnote
statusLabel.autoPinWidthToSuperview()
statusLabel.autoPinEdge(.top, to: .bottom, of: progressView, withOffset: 4)

@ -24,8 +24,8 @@ import SignalServiceKit
self.contentView.addSubview(textContainer)
// Font config
nameLabel.font = UIFont.ows_dynamicTypeBody
subtitleLabel.font = UIFont.ows_footnote
nameLabel.font = .ows_dynamicTypeBody
subtitleLabel.font = .ows_dynamicTypeFootnote
subtitleLabel.textColor = UIColor.ows_darkGray
// Listen to notifications...

@ -40,7 +40,7 @@ class QuotedReplyPreview: UIView {
let bodyLabel: UILabel = UILabel()
bodyLabel.textColor = foregroundColor
bodyLabel.font = .ows_footnote
bodyLabel.font = .ows_dynamicTypeFootnote
bodyLabel.text = {
if let contentType = quotedReply.contentType {

@ -83,12 +83,12 @@ const CGFloat kContactTableViewCellAvatarTextMargin = 12;
_profileNameLabel = [UILabel new];
_profileNameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
_profileNameLabel.font = [UIFont ows_footnoteFont];
_profileNameLabel.font = [UIFont ows_dynamicTypeFootnoteFont];
_profileNameLabel.textColor = [UIColor grayColor];
[_nameContainerView addSubview:_profileNameLabel];
_subtitle = [UILabel new];
_subtitle.font = [UIFont ows_footnoteFont];
_subtitle.font = [UIFont ows_dynamicTypeFootnoteFont];
_subtitle.textColor = [UIColor ows_darkGrayColor];
[_nameContainerView addSubview:self.subtitle];

@ -18,8 +18,6 @@ NS_ASSUME_NONNULL_BEGIN
+ (UIFont *)ows_boldFontWithSize:(CGFloat)size;
+ (UIFont *)ows_dynamicTypeBodyFont:(CGFloat)size;
#pragma mark - Icon Fonts
+ (UIFont *)ows_fontAwesomeFont:(CGFloat)size;
@ -28,11 +26,20 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Dynamic Type
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeBodyFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle1Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle2Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeTitle3Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeHeadlineFont;
@property (class, readonly, nonatomic) UIFont *ows_infoMessageFont;
@property (class, readonly, nonatomic) UIFont *ows_footnoteFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeSubheadlineFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeBodyFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeFootnoteFont;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption1Font;
@property (class, readonly, nonatomic) UIFont *ows_dynamicTypeCaption2Font;
#pragma mark - Styles
- (UIFont *)ows_italic;
- (UIFont *)ows_medium;
@end

@ -33,11 +33,6 @@ NS_ASSUME_NONNULL_BEGIN
return [UIFont boldSystemFontOfSize:size];
}
+ (UIFont *)ows_dynamicTypeBodyFont:(CGFloat)size
{
return [UIFont ows_dynamicTypeBodyFont];
}
#pragma mark - Icon Fonts
+ (UIFont *)ows_fontAwesomeFont:(CGFloat)size
@ -57,29 +52,85 @@ NS_ASSUME_NONNULL_BEGIN
#pragma mark - Dynamic Type
+ (UIFont *)ows_dynamicTypeBodyFont
+ (UIFont *)ows_dynamicTypeTitle1Font
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle1];
}
+ (UIFont *)ows_dynamicTypeTitle2Font
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
}
+ (UIFont *)ows_infoMessageFont
+ (UIFont *)ows_dynamicTypeTitle3Font
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle3];
}
+ (UIFont *)ows_dynamicTypeHeadlineFont
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
}
+ (UIFont *)ows_dynamicTypeSubheadlineFont
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleSubheadline];
}
+ (UIFont *)ows_footnoteFont
+ (UIFont *)ows_dynamicTypeBodyFont
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
}
+ (UIFont *)ows_dynamicTypeFootnoteFont
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleFootnote];
}
+ (UIFont *)ows_dynamicTypeTitle2Font
+ (UIFont *)ows_dynamicTypeCaption1Font
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleTitle2];
return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption1];
}
+ (UIFont *)ows_dynamicTypeHeadlineFont
+ (UIFont *)ows_dynamicTypeCaption2Font
{
return [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
return [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
}
#pragma mark - Styles
- (UIFont *)ows_italic
{
return [self styleWithSymbolicTraits:UIFontDescriptorTraitItalic];
}
- (UIFont *)styleWithSymbolicTraits:(UIFontDescriptorSymbolicTraits)symbolicTraits
{
UIFontDescriptor *fontDescriptor = [self.fontDescriptor fontDescriptorWithSymbolicTraits:symbolicTraits];
UIFont *font = [UIFont fontWithDescriptor:fontDescriptor size:0];
OWSAssert(font);
return font ?: self;
}
- (UIFont *)ows_medium
{
// The recommended approach of deriving "medium" weight fonts for dynamic
// type fonts is:
//
// [UIFontDescriptor fontDescriptorByAddingAttributes:...]
//
// But this doesn't seem to work in practice on iOS 11 using UIFontWeightMedium.
UIFont *derivedFont = [UIFont systemFontOfSize:self.pointSize weight:UIFontWeightMedium];
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(11, 0)) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpartial-availability"
return [[UIFontMetrics defaultMetrics] scaledFontForFont:derivedFont];
#pragma clang diagnostic pop
} else {
return derivedFont;
}
}
@end

Loading…
Cancel
Save