Merge branch 'charlesmchen/moreTweaks'

pull/1/head
Matthew Chen 7 years ago
commit 92515bdd1d

@ -161,12 +161,12 @@ NS_ASSUME_NONNULL_BEGIN
+ (UIFont *)topLabelFont + (UIFont *)topLabelFont
{ {
return [UIFont ows_dynamicTypeCaption1Font]; return [UIFont ows_dynamicTypeBodyFont];
} }
+ (UIFont *)bottomLabelFont + (UIFont *)bottomLabelFont
{ {
return [UIFont ows_dynamicTypeCaption2Font]; return [UIFont ows_dynamicTypeCaption1Font];
} }
+ (CGFloat)labelVSpacing + (CGFloat)labelVSpacing

@ -372,15 +372,15 @@ NS_ASSUME_NONNULL_BEGIN
// TODO: Consider only using a single shadow for perf. // TODO: Consider only using a single shadow for perf.
shadowView1.fillColor = self.bubbleColor; shadowView1.fillColor = self.bubbleColor;
shadowView1.layer.shadowColor = [UIColor blackColor].CGColor; shadowView1.layer.shadowColor = [UIColor blackColor].CGColor;
shadowView1.layer.shadowOpacity = 0.2f; shadowView1.layer.shadowOpacity = 0.08f;
shadowView1.layer.shadowOffset = CGSizeMake(0.f, 4.f); shadowView1.layer.shadowOffset = CGSizeMake(0.f, 4.f);
shadowView1.layer.shadowRadius = 20.f; shadowView1.layer.shadowRadius = 12.f;
shadowView2.fillColor = self.bubbleColor; shadowView2.fillColor = self.bubbleColor;
shadowView2.layer.shadowColor = [UIColor blackColor].CGColor; shadowView2.layer.shadowColor = [UIColor blackColor].CGColor;
shadowView2.layer.shadowOpacity = 0.08f; shadowView2.layer.shadowOpacity = 0.12f;
shadowView2.layer.shadowOffset = CGSizeZero; shadowView2.layer.shadowOffset = CGSizeZero;
shadowView2.layer.shadowRadius = 4.f; shadowView2.layer.shadowRadius = 1.f;
} else { } else {
OWSAssert(self.cellType == OWSMessageCellType_ContactShare); OWSAssert(self.cellType == OWSMessageCellType_ContactShare);
@ -431,7 +431,7 @@ NS_ASSUME_NONNULL_BEGIN
} else if (shouldFooterOverlayMedia) { } else if (shouldFooterOverlayMedia) {
OWSAssert(bodyMediaView); OWSAssert(bodyMediaView);
CGFloat maxGradientHeight = 48.f; CGFloat maxGradientHeight = 40.f;
CAGradientLayer *gradientLayer = [CAGradientLayer new]; CAGradientLayer *gradientLayer = [CAGradientLayer new];
gradientLayer.colors = @[ gradientLayer.colors = @[
(id)[UIColor colorWithWhite:0.f alpha:0.f].CGColor, (id)[UIColor colorWithWhite:0.f alpha:0.f].CGColor,
@ -1038,10 +1038,7 @@ NS_ASSUME_NONNULL_BEGIN
UIView *wrapper = [UIView new]; UIView *wrapper = [UIView new];
[wrapper addSubview:downloadView]; [wrapper addSubview:downloadView];
[downloadView autoPinWidthToSuperview]; [downloadView autoPinEdgesToSuperviewEdges];
[downloadView autoVCenterInSuperview];
[downloadView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual];
[downloadView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual];
self.loadCellContentBlock = ^{ self.loadCellContentBlock = ^{
// Do nothing. // Do nothing.
@ -1200,7 +1197,7 @@ NS_ASSUME_NONNULL_BEGIN
break; break;
} }
case OWSMessageCellType_DownloadingAttachment: case OWSMessageCellType_DownloadingAttachment:
result = CGSizeMake(200, [AttachmentPointerView measureHeight]); result = CGSizeMake(MIN(200, maxMessageWidth), [AttachmentPointerView measureHeight]);
break; break;
case OWSMessageCellType_ContactShare: case OWSMessageCellType_ContactShare:
OWSAssert(self.viewItem.contactShare); OWSAssert(self.viewItem.contactShare);
@ -1209,6 +1206,9 @@ NS_ASSUME_NONNULL_BEGIN
break; break;
} }
OWSAssert(result.width <= maxMessageWidth);
result.width = MIN(result.width, maxMessageWidth);
return [NSValue valueWithCGSize:CGSizeCeil(result)]; return [NSValue valueWithCGSize:CGSizeCeil(result)];
} }

@ -210,16 +210,12 @@ NS_ASSUME_NONNULL_BEGIN
} }
if ([self updateAvatarView]) { if ([self updateAvatarView]) {
CGFloat avatarBottomMargin = round(self.conversationStyle.lastTextLineAxis - self.avatarSize * 0.5f);
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
// V-align the "group sender" avatar with the // V-align the "group sender" avatar with the
// last line of the text (if any, or where it // last line of the text (if any, or where it
// would be). // would be).
[self.messageBubbleView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:8], [self.messageBubbleView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:8],
[self.messageBubbleView autoPinEdge:ALEdgeBottom [self.messageBubbleView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.avatarView],
toEdge:ALEdgeBottom
ofView:self.avatarView
withOffset:avatarBottomMargin],
]]; ]];
} }
} }

@ -252,7 +252,7 @@ typedef void (^SystemMessageActionBlock)(void);
break; break;
} }
} else if ([interaction isKindOfClass:[TSCall class]]) { } else if ([interaction isKindOfClass:[TSCall class]]) {
return nil; result = [UIImage imageNamed:@"system_message_call"];
} else { } else {
OWSFail(@"Unknown interaction type: %@", [interaction class]); OWSFail(@"Unknown interaction type: %@", [interaction class]);
return nil; return nil;

@ -254,7 +254,7 @@ NS_ASSUME_NONNULL_BEGIN
[NSLayoutConstraint autoSetPriority:UILayoutPriorityDefaultHigh [NSLayoutConstraint autoSetPriority:UILayoutPriorityDefaultHigh
forConstraints:^{ forConstraints:^{
// This is a bit arbitrary, but it should scale with the size of dynamic text // This is a bit arbitrary, but it should scale with the size of dynamic text
CGFloat minMargin = CeilEven(unreadBadgeHeight * .5); CGFloat minMargin = CeilEven(unreadBadgeHeight * .5f);
// Spec check. Should be 12pts (6pt on each side) when using default font size. // Spec check. Should be 12pts (6pt on each side) when using default font size.
OWSAssert(UIFont.ows_dynamicTypeBodyFont.pointSize != 17 || minMargin == 12); OWSAssert(UIFont.ows_dynamicTypeBodyFont.pointSize != 17 || minMargin == 12);
@ -273,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN
}]; }];
} else { } else {
UIImage *_Nullable statusIndicatorImage = nil; UIImage *_Nullable statusIndicatorImage = nil;
UIColor *messageStatusViewTintColor = textColor; UIColor *messageStatusViewTintColor = [UIColor ows_light35Color];
BOOL shouldAnimateStatusIcon = NO; BOOL shouldAnimateStatusIcon = NO;
if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) { if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) {
TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox; TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox;

@ -81,21 +81,26 @@ class AttachmentPointerView: UIStackView {
} }
private static var vSpacing: CGFloat = 5 private static var vSpacing: CGFloat = 5
private static var nameFont = UIFont.ows_dynamicTypeBody private class func nameFont() -> UIFont { return UIFont.ows_dynamicTypeBody }
private static var statusFont = UIFont.ows_dynamicTypeCaption1 private class func statusFont() -> UIFont { return UIFont.ows_dynamicTypeCaption1 }
private static var progressWidth: CGFloat = 80
private static var progressHeight: CGFloat = 6
func createSubviews() { func createSubviews() {
progressView.autoSetDimension(.width, toSize: AttachmentPointerView.progressWidth)
progressView.autoSetDimension(.height, toSize: AttachmentPointerView.progressHeight)
// truncate middle to be sure we include file extension // truncate middle to be sure we include file extension
nameLabel.lineBreakMode = .byTruncatingMiddle nameLabel.lineBreakMode = .byTruncatingMiddle
nameLabel.textAlignment = .center nameLabel.textAlignment = .center
nameLabel.textColor = self.textColor nameLabel.textColor = self.textColor
nameLabel.font = AttachmentPointerView.nameFont nameLabel.font = AttachmentPointerView.nameFont()
statusLabel.textAlignment = .center statusLabel.textAlignment = .center
statusLabel.adjustsFontSizeToFitWidth = true statusLabel.adjustsFontSizeToFitWidth = true
statusLabel.numberOfLines = 2 statusLabel.numberOfLines = 2
statusLabel.textColor = self.textColor statusLabel.textColor = self.textColor
statusLabel.font = AttachmentPointerView.statusFont statusLabel.font = AttachmentPointerView.statusFont()
self.axis = .vertical self.axis = .vertical
self.spacing = AttachmentPointerView.vSpacing self.spacing = AttachmentPointerView.vSpacing
@ -115,7 +120,7 @@ class AttachmentPointerView: UIStackView {
case .downloading: case .downloading:
return NSLocalizedString("ATTACHMENT_DOWNLOADING_STATUS_IN_PROGRESS", comment: "Status label when an attachment is currently downloading") return NSLocalizedString("ATTACHMENT_DOWNLOADING_STATUS_IN_PROGRESS", comment: "Status label when an attachment is currently downloading")
case .failed: case .failed:
return self.attachmentPointer.mostRecentFailureLocalizedText ?? NSLocalizedString("ATTACHMENT_DOWNLOADING_STATUS_FAILED", comment: "Status label when an attachment download has failed.") return NSLocalizedString("ATTACHMENT_DOWNLOADING_STATUS_FAILED", comment: "Status label when an attachment download has failed.")
} }
}() }()
@ -134,9 +139,9 @@ class AttachmentPointerView: UIStackView {
@objc @objc
public class func measureHeight() -> CGFloat { public class func measureHeight() -> CGFloat {
return ceil(nameFont.lineHeight + return ceil(nameFont().lineHeight +
statusFont.lineHeight + statusFont().lineHeight +
OWSProgressView.defaultSize().height + progressHeight +
vSpacing * 2) vSpacing * 2)
} }
} }

@ -81,10 +81,10 @@ public class ConversationStyle: NSObject {
public func updateProperties() { public func updateProperties() {
if thread.isGroupThread() { if thread.isGroupThread() {
gutterLeading = 52 gutterLeading = 52
gutterTrailing = 20 gutterTrailing = 16
} else { } else {
gutterLeading = 16 gutterLeading = 16
gutterTrailing = 20 gutterTrailing = 16
} }
fullWidthGutterLeading = 16 fullWidthGutterLeading = 16
fullWidthGutterTrailing = 16 fullWidthGutterTrailing = 16
@ -94,7 +94,7 @@ public class ConversationStyle: NSObject {
fullWidthContentWidth = viewWidth - (fullWidthGutterLeading + fullWidthGutterTrailing) fullWidthContentWidth = viewWidth - (fullWidthGutterLeading + fullWidthGutterTrailing)
maxMessageWidth = floor(contentWidth - 48) maxMessageWidth = floor(contentWidth - 32)
let messageTextFont = UIFont.ows_dynamicTypeBody let messageTextFont = UIFont.ows_dynamicTypeBody

Loading…
Cancel
Save