From 828707649918ecc8186f1ff641bda898d5ba2d23 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Thu, 12 Jul 2018 15:02:25 -0400 Subject: [PATCH] More design tweaks. --- .../Cells/OWSGenericAttachmentView.m | 4 ++-- .../Cells/OWSMessageBubbleView.m | 20 +++++++++--------- .../ConversationView/Cells/OWSMessageCell.m | 6 +----- .../Cells/OWSSystemMessageCell.m | 2 +- .../ViewControllers/HomeView/HomeViewCell.m | 4 ++-- Signal/src/views/AttachmentPointerView.swift | 21 ++++++++++++------- SignalMessaging/utils/ConversationStyle.swift | 6 +++--- 7 files changed, 32 insertions(+), 31 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m index a43991249..9c7c62a7d 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m @@ -161,12 +161,12 @@ NS_ASSUME_NONNULL_BEGIN + (UIFont *)topLabelFont { - return [UIFont ows_dynamicTypeCaption1Font]; + return [UIFont ows_dynamicTypeBodyFont]; } + (UIFont *)bottomLabelFont { - return [UIFont ows_dynamicTypeCaption2Font]; + return [UIFont ows_dynamicTypeCaption1Font]; } + (CGFloat)labelVSpacing diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 3e1a6209c..17fa9c618 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -372,15 +372,15 @@ NS_ASSUME_NONNULL_BEGIN // TODO: Consider only using a single shadow for perf. shadowView1.fillColor = self.bubbleColor; 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.shadowRadius = 20.f; + shadowView1.layer.shadowRadius = 12.f; shadowView2.fillColor = self.bubbleColor; shadowView2.layer.shadowColor = [UIColor blackColor].CGColor; - shadowView2.layer.shadowOpacity = 0.08f; + shadowView2.layer.shadowOpacity = 0.12f; shadowView2.layer.shadowOffset = CGSizeZero; - shadowView2.layer.shadowRadius = 4.f; + shadowView2.layer.shadowRadius = 1.f; } else { OWSAssert(self.cellType == OWSMessageCellType_ContactShare); @@ -431,7 +431,7 @@ NS_ASSUME_NONNULL_BEGIN } else if (shouldFooterOverlayMedia) { OWSAssert(bodyMediaView); - CGFloat maxGradientHeight = 48.f; + CGFloat maxGradientHeight = 40.f; CAGradientLayer *gradientLayer = [CAGradientLayer new]; gradientLayer.colors = @[ (id)[UIColor colorWithWhite:0.f alpha:0.f].CGColor, @@ -1038,10 +1038,7 @@ NS_ASSUME_NONNULL_BEGIN UIView *wrapper = [UIView new]; [wrapper addSubview:downloadView]; - [downloadView autoPinWidthToSuperview]; - [downloadView autoVCenterInSuperview]; - [downloadView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; - [downloadView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; + [downloadView autoPinEdgesToSuperviewEdges]; self.loadCellContentBlock = ^{ // Do nothing. @@ -1200,7 +1197,7 @@ NS_ASSUME_NONNULL_BEGIN break; } case OWSMessageCellType_DownloadingAttachment: - result = CGSizeMake(200, [AttachmentPointerView measureHeight]); + result = CGSizeMake(MIN(200, maxMessageWidth), [AttachmentPointerView measureHeight]); break; case OWSMessageCellType_ContactShare: OWSAssert(self.viewItem.contactShare); @@ -1209,6 +1206,9 @@ NS_ASSUME_NONNULL_BEGIN break; } + OWSAssert(result.width <= maxMessageWidth); + result.width = MIN(result.width, maxMessageWidth); + return [NSValue valueWithCGSize:CGSizeCeil(result)]; } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index 72de49af2..4e716f286 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -210,16 +210,12 @@ NS_ASSUME_NONNULL_BEGIN } if ([self updateAvatarView]) { - CGFloat avatarBottomMargin = round(self.conversationStyle.lastTextLineAxis - self.avatarSize * 0.5f); [self.viewConstraints addObjectsFromArray:@[ // V-align the "group sender" avatar with the // last line of the text (if any, or where it // would be). [self.messageBubbleView autoPinLeadingToTrailingEdgeOfView:self.avatarView offset:8], - [self.messageBubbleView autoPinEdge:ALEdgeBottom - toEdge:ALEdgeBottom - ofView:self.avatarView - withOffset:avatarBottomMargin], + [self.messageBubbleView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:self.avatarView], ]]; } } diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m index ad78d4155..b26aa48cc 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSSystemMessageCell.m @@ -252,7 +252,7 @@ typedef void (^SystemMessageActionBlock)(void); break; } } else if ([interaction isKindOfClass:[TSCall class]]) { - return nil; + result = [UIImage imageNamed:@"system_message_call"]; } else { OWSFail(@"Unknown interaction type: %@", [interaction class]); return nil; diff --git a/Signal/src/ViewControllers/HomeView/HomeViewCell.m b/Signal/src/ViewControllers/HomeView/HomeViewCell.m index 965c5df9e..40f3f4545 100644 --- a/Signal/src/ViewControllers/HomeView/HomeViewCell.m +++ b/Signal/src/ViewControllers/HomeView/HomeViewCell.m @@ -254,7 +254,7 @@ NS_ASSUME_NONNULL_BEGIN [NSLayoutConstraint autoSetPriority:UILayoutPriorityDefaultHigh forConstraints:^{ // 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. OWSAssert(UIFont.ows_dynamicTypeBodyFont.pointSize != 17 || minMargin == 12); @@ -273,7 +273,7 @@ NS_ASSUME_NONNULL_BEGIN }]; } else { UIImage *_Nullable statusIndicatorImage = nil; - UIColor *messageStatusViewTintColor = textColor; + UIColor *messageStatusViewTintColor = [UIColor ows_light35Color]; BOOL shouldAnimateStatusIcon = NO; if ([self.thread.lastMessageForInbox isKindOfClass:[TSOutgoingMessage class]]) { TSOutgoingMessage *outgoingMessage = (TSOutgoingMessage *)self.thread.lastMessageForInbox; diff --git a/Signal/src/views/AttachmentPointerView.swift b/Signal/src/views/AttachmentPointerView.swift index 5178049db..b707e70b0 100644 --- a/Signal/src/views/AttachmentPointerView.swift +++ b/Signal/src/views/AttachmentPointerView.swift @@ -81,21 +81,26 @@ class AttachmentPointerView: UIStackView { } private static var vSpacing: CGFloat = 5 - private static var nameFont = UIFont.ows_dynamicTypeBody - private static var statusFont = UIFont.ows_dynamicTypeCaption1 + private class func nameFont() -> UIFont { return UIFont.ows_dynamicTypeBody } + private class func statusFont() -> UIFont { return UIFont.ows_dynamicTypeCaption1 } + private static var progressWidth: CGFloat = 80 + private static var progressHeight: CGFloat = 6 func createSubviews() { + progressView.autoSetDimension(.width, toSize: AttachmentPointerView.progressWidth) + progressView.autoSetDimension(.height, toSize: AttachmentPointerView.progressHeight) + // truncate middle to be sure we include file extension nameLabel.lineBreakMode = .byTruncatingMiddle nameLabel.textAlignment = .center nameLabel.textColor = self.textColor - nameLabel.font = AttachmentPointerView.nameFont + nameLabel.font = AttachmentPointerView.nameFont() statusLabel.textAlignment = .center statusLabel.adjustsFontSizeToFitWidth = true statusLabel.numberOfLines = 2 statusLabel.textColor = self.textColor - statusLabel.font = AttachmentPointerView.statusFont + statusLabel.font = AttachmentPointerView.statusFont() self.axis = .vertical self.spacing = AttachmentPointerView.vSpacing @@ -115,7 +120,7 @@ class AttachmentPointerView: UIStackView { case .downloading: return NSLocalizedString("ATTACHMENT_DOWNLOADING_STATUS_IN_PROGRESS", comment: "Status label when an attachment is currently downloading") 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 public class func measureHeight() -> CGFloat { - return ceil(nameFont.lineHeight + - statusFont.lineHeight + - OWSProgressView.defaultSize().height + + return ceil(nameFont().lineHeight + + statusFont().lineHeight + + progressHeight + vSpacing * 2) } } diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index a91841a30..e13b6e8cb 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -81,10 +81,10 @@ public class ConversationStyle: NSObject { public func updateProperties() { if thread.isGroupThread() { gutterLeading = 52 - gutterTrailing = 20 + gutterTrailing = 16 } else { gutterLeading = 16 - gutterTrailing = 20 + gutterTrailing = 16 } fullWidthGutterLeading = 16 fullWidthGutterTrailing = 16 @@ -94,7 +94,7 @@ public class ConversationStyle: NSObject { fullWidthContentWidth = viewWidth - (fullWidthGutterLeading + fullWidthGutterTrailing) - maxMessageWidth = floor(contentWidth - 48) + maxMessageWidth = floor(contentWidth - 32) let messageTextFont = UIFont.ows_dynamicTypeBody