Merge branch 'charlesmchen/quotedReplies8'

pull/1/head
Matthew Chen 7 years ago
commit dc0e5a6b9c

@ -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

@ -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

@ -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));
}

@ -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

@ -1101,7 +1101,7 @@ typedef enum : NSUInteger {
name = [self.contactsManager
attributedStringForConversationTitleWithPhoneIdentifier:self.thread.contactIdentifier
primaryFont:[self navigationBarTitleLabelFont]
secondaryFont:[UIFont ows_footnoteFont]];
secondaryFont:[UIFont ows_regularFontWithSize:11.f]];
}
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