Improve contact share message bubble layout with large dynamic type sizes.

pull/1/head
Matthew Chen 7 years ago
parent b4ef8afbf0
commit ff3524fb00

@ -117,12 +117,15 @@ NS_ASSUME_NONNULL_BEGIN
+ (CGFloat)contentHeight + (CGFloat)contentHeight
{ {
return self.iconSize + self.iconVMargin * 2; CGFloat labelsHeight = (self.nameFont.lineHeight + self.labelsVSpacing + self.subtitleFont.lineHeight);
CGFloat contentHeight = MAX(self.iconSize, labelsHeight);
contentHeight += self.iconVMargin * 2;
return contentHeight;
} }
+ (CGFloat)buttonHeight + (CGFloat)buttonHeight
{ {
return 44.f; return MAX(44.f, self.buttonFont.lineHeight + self.buttonVMargin * 2);
} }
+ (CGFloat)iconSize + (CGFloat)iconSize
@ -145,6 +148,31 @@ NS_ASSUME_NONNULL_BEGIN
return self.isIncoming ? [UIColor jsq_messageBubbleLightGrayColor] : [UIColor ows_materialBlueColor]; return self.isIncoming ? [UIColor jsq_messageBubbleLightGrayColor] : [UIColor ows_materialBlueColor];
} }
+ (UIFont *)nameFont
{
return [UIFont ows_dynamicTypeBodyFont];
}
+ (UIFont *)subtitleFont
{
return [UIFont ows_dynamicTypeCaption1Font];
}
+ (CGFloat)labelsVSpacing
{
return 2;
}
+ (UIFont *)buttonFont
{
return [UIFont ows_dynamicTypeBodyFont];
}
+ (CGFloat)buttonVMargin
{
return 5;
}
- (void)createContents - (void)createContents
{ {
self.backgroundColor = [UIColor colorWithRGBHex:0xefeff4]; self.backgroundColor = [UIColor colorWithRGBHex:0xefeff4];
@ -172,11 +200,11 @@ NS_ASSUME_NONNULL_BEGIN
topLabel.text = self.contactShare.displayName; topLabel.text = self.contactShare.displayName;
topLabel.textColor = [UIColor blackColor]; topLabel.textColor = [UIColor blackColor];
topLabel.lineBreakMode = NSLineBreakByTruncatingTail; topLabel.lineBreakMode = NSLineBreakByTruncatingTail;
topLabel.font = [UIFont ows_dynamicTypeBodyFont]; topLabel.font = OWSContactShareView.nameFont;
UIStackView *labelsView = [UIStackView new]; UIStackView *labelsView = [UIStackView new];
labelsView.axis = UILayoutConstraintAxisVertical; labelsView.axis = UILayoutConstraintAxisVertical;
labelsView.spacing = 2; labelsView.spacing = OWSContactShareView.labelsVSpacing;
[labelsView addArrangedSubview:topLabel]; [labelsView addArrangedSubview:topLabel];
NSString *_Nullable firstPhoneNumber = NSString *_Nullable firstPhoneNumber =
@ -186,7 +214,7 @@ NS_ASSUME_NONNULL_BEGIN
bottomLabel.text = [PhoneNumber bestEffortLocalizedPhoneNumberWithE164:firstPhoneNumber]; bottomLabel.text = [PhoneNumber bestEffortLocalizedPhoneNumberWithE164:firstPhoneNumber];
bottomLabel.textColor = [UIColor ows_darkGrayColor]; bottomLabel.textColor = [UIColor ows_darkGrayColor];
bottomLabel.lineBreakMode = NSLineBreakByTruncatingTail; bottomLabel.lineBreakMode = NSLineBreakByTruncatingTail;
bottomLabel.font = [UIFont ows_dynamicTypeCaption1Font]; bottomLabel.font = OWSContactShareView.subtitleFont;
[labelsView addArrangedSubview:bottomLabel]; [labelsView addArrangedSubview:bottomLabel];
} }
@ -230,7 +258,7 @@ NS_ASSUME_NONNULL_BEGIN
} else { } else {
OWSFail(@"%@ unexpected button state.", self.logTag); OWSFail(@"%@ unexpected button state.", self.logTag);
} }
label.font = [UIFont ows_dynamicTypeBodyFont]; label.font = OWSContactShareView.buttonFont;
label.textColor = UIColor.ows_materialBlueColor; label.textColor = UIColor.ows_materialBlueColor;
label.textAlignment = NSTextAlignmentCenter; label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor whiteColor]; label.backgroundColor = [UIColor whiteColor];

Loading…
Cancel
Save