From 5ffff3d3b74553b88f471a9e39d1f21e694c57dd Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Wed, 11 Dec 2019 10:25:53 +1100 Subject: [PATCH] WIP --- .../Cells/OWSMessageBubbleView.m | 8 ++--- .../Cells/OWSMessageHeaderView.m | 6 ++-- .../Cells/OWSQuotedMessageView.m | 35 +++++++++---------- .../ConversationInputToolbar.m | 1 + .../ConversationScrollButton.m | 18 ++++------ .../ConversationViewController.m | 9 +++-- .../ConversationView/ConversationViewModel.m | 4 ++- .../translations/en.lproj/Localizable.strings | 3 +- SignalMessaging/utils/ConversationStyle.swift | 18 +++++++--- 9 files changed, 52 insertions(+), 50 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 11be8bce8..304fc035b 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -74,12 +74,12 @@ NS_ASSUME_NONNULL_BEGIN return self; } - [self commontInit]; + [self commonInit]; return self; } -- (void)commontInit +- (void)commonInit { // Ensure only called once. OWSAssertDebug(!self.bodyTextView); @@ -633,7 +633,7 @@ NS_ASSUME_NONNULL_BEGIN - (CGFloat)quotedReplyTopMargin { - return 6.f; + return 22.f; } - (nullable LinkPreviewSent *)linkPreviewState @@ -1153,7 +1153,7 @@ NS_ASSUME_NONNULL_BEGIN return [NSValue valueWithCGSize:CGSizeCeil(result)]; } -- (DisplayableText *)getDisplayableQuotedText +- (DisplayableText *_Nullable)getDisplayableQuotedText { if (!self.viewItem.hasQuotedText) { return nil; } NSString *rawText = self.viewItem.displayableQuotedText.fullText; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m index 98db100ea..07a987135 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageHeaderView.m @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN -const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 16; +const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 16; // Values.mediumSpacing @interface OWSMessageHeaderView () @@ -80,8 +80,8 @@ const CGFloat OWSMessageHeaderViewDateHeaderVMargin = 16; OWSAssertDebug(conversationStyle); OWSAssertDebug(viewItem.unreadIndicator || viewItem.shouldShowDate); - self.titleLabel.textColor = Theme.primaryColor; - self.subtitleLabel.textColor = Theme.primaryColor; + self.titleLabel.textColor = [LKColors.text colorWithAlphaComponent:0.8]; + self.subtitleLabel.textColor = [LKColors.text colorWithAlphaComponent:0.8]; [self configureLabelsWithViewItem:viewItem]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index a38ccda9c..65bb0f449 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN const CGFloat kRemotelySourcedContentGlyphLength = 16; const CGFloat kRemotelySourcedContentRowMargin = 4; -const CGFloat kRemotelySourcedContentRowSpacing = 3; +const CGFloat kRemotelySourcedContentRowSpacing = 4; @interface OWSQuotedMessageView () @@ -162,7 +162,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; self.userInteractionEnabled = YES; self.layoutMargins = UIEdgeInsetsZero; self.clipsToBounds = YES; - + CAShapeLayer *maskLayer = [CAShapeLayer new]; OWSDirectionalRectCorner sharpCorners = self.sharpCorners; @@ -176,7 +176,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; const CGFloat bubbleTop = 0.f; const CGFloat bubbleBottom = layerFrame.size.height; - const CGFloat sharpCornerRadius = self.isForPreview ? 4 : 2; + const CGFloat sharpCornerRadius = 2; const CGFloat wideCornerRadius = self.isForPreview ? 14 : 4; UIBezierPath *bezierPath = [OWSBubbleView roundedBezierRectWithBubbleTop:bubbleTop @@ -321,22 +321,21 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; if (self.isForPreview) { UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; [cancelButton setImage:[UIImage imageNamed:@"X"] forState:UIControlStateNormal]; + cancelButton.contentMode = UIViewContentModeScaleAspectFit; [cancelButton addTarget:self action:@selector(didTapCancel) forControlEvents:UIControlEventTouchUpInside]; - [cancelButton setContentHuggingHorizontalHigh]; - [cancelButton setCompressionResistanceHorizontalHigh]; + [cancelButton autoSetDimension:ALDimensionWidth toSize:14.f]; + [cancelButton autoSetDimension:ALDimensionHeight toSize:14.f]; UIStackView *cancelStack = [[UIStackView alloc] initWithArrangedSubviews:@[ cancelButton ]]; cancelStack.axis = UILayoutConstraintAxisHorizontal; cancelStack.alignment = UIStackViewAlignmentTop; cancelStack.layoutMarginsRelativeArrangement = YES; - CGFloat hMarginLeading = 0; - CGFloat hMarginTrailing = 6; - cancelStack.layoutMargins = UIEdgeInsetsMake(6, + CGFloat hMarginLeading = 8; + CGFloat hMarginTrailing = 8; + cancelStack.layoutMargins = UIEdgeInsetsMake(8, CurrentAppContext().isRTL ? hMarginTrailing : hMarginLeading, 0, CurrentAppContext().isRTL ? hMarginLeading : hMarginTrailing); - [cancelStack setContentHuggingHorizontalHigh]; - [cancelStack setCompressionResistanceHorizontalHigh]; UIStackView *cancelWrapper = [[UIStackView alloc] initWithArrangedSubviews:@[ contentView, @@ -361,7 +360,7 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; OWSAssertDebug(CGSizeEqualToSize( CGSizeMake(kRemotelySourcedContentGlyphLength, kRemotelySourcedContentGlyphLength), glyphImage.size)); UIImageView *glyphView = [[UIImageView alloc] initWithImage:glyphImage]; - glyphView.tintColor = UIColor.whiteColor; + glyphView.tintColor = LKColors.text; [glyphView autoSetDimensionsToSize:CGSizeMake(kRemotelySourcedContentGlyphLength, kRemotelySourcedContentGlyphLength)]; @@ -373,13 +372,13 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; sourceRow.spacing = kRemotelySourcedContentRowSpacing; sourceRow.layoutMarginsRelativeArrangement = YES; - const CGFloat leftMargin = 8; + const CGFloat leftMargin = 4; sourceRow.layoutMargins = UIEdgeInsetsMake(kRemotelySourcedContentRowMargin, leftMargin, kRemotelySourcedContentRowMargin, kRemotelySourcedContentRowMargin); - UIColor *backgroundColor = [UIColor.whiteColor colorWithAlphaComponent:0.4]; + UIColor *backgroundColor = [LKColors.text colorWithAlphaComponent:LKValues.unimportantElementOpacity]; [sourceRow addBackgroundViewWithBackgroundColor:backgroundColor]; return sourceRow; @@ -476,8 +475,8 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; { OWSAssertDebug(self.quoteContentSourceLabel); - self.quoteContentSourceLabel.font = UIFont.ows_dynamicTypeFootnoteFont; - self.quoteContentSourceLabel.textColor = Theme.primaryColor; + self.quoteContentSourceLabel.font = [UIFont systemFontOfSize:LKValues.smallFontSize]; + self.quoteContentSourceLabel.textColor = LKColors.text; self.quoteContentSourceLabel.text = NSLocalizedString(@"QUOTED_REPLY_CONTENT_FROM_REMOTE_SOURCE", @"Footer label that appears below quoted messages when the quoted content was not derived locally. When the " @"local user doesn't have a copy of the message being quoted, e.g. if it had since been deleted, we instead " @@ -541,11 +540,9 @@ const CGFloat kRemotelySourcedContentRowSpacing = 3; if ([localNumber isEqualToString:self.quotedMessage.authorId]) { if (self.isOutgoing) { - quotedAuthorText = NSLocalizedString( - @"QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF", @"message header label when quoting yourself"); + quotedAuthorText = NSLocalizedString(@"You", @""); } else { - quotedAuthorText = NSLocalizedString( - @"QUOTED_REPLY_AUTHOR_INDICATOR_YOU", @"message header label when someone else is quoting you"); + quotedAuthorText = NSLocalizedString(@"You", @""); } } else { OWSContactsManager *contactsManager = Environment.shared.contactsManager; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 73c93a039..bb144aa26 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -166,6 +166,7 @@ const CGFloat kMaxTextViewHeight = 120; self.userInteractionEnabled = YES; _quotedReplyWrapper = [UIView containerView]; + self.quotedReplyWrapper.backgroundColor = LKColors.composeViewTextFieldBackground; self.quotedReplyWrapper.hidden = YES; [self.quotedReplyWrapper setContentHuggingHorizontalLow]; [self.quotedReplyWrapper setCompressionResistanceHorizontalLow]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationScrollButton.m b/Signal/src/ViewControllers/ConversationView/ConversationScrollButton.m index 2cf21b99d..6ce8c4e4b 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationScrollButton.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationScrollButton.m @@ -7,6 +7,7 @@ #import "UIFont+OWS.h" #import "UIView+OWS.h" #import +#import "Session-Swift.h" NS_ASSUME_NONNULL_BEGIN @@ -57,8 +58,8 @@ NS_ASSUME_NONNULL_BEGIN self.circleView = circleView; circleView.userInteractionEnabled = NO; circleView.layer.cornerRadius = circleSize * 0.5f; - circleView.layer.borderColor = UIColor.whiteColor.CGColor; - circleView.layer.borderWidth = 1 / UIScreen.mainScreen.scale; + circleView.layer.borderColor = [LKColors.text colorWithAlphaComponent:LKValues.composeViewTextFieldBorderOpacity].CGColor; + circleView.layer.borderWidth = LKValues.composeViewTextFieldBorderThickness; [circleView autoSetDimension:ALDimensionWidth toSize:circleSize]; [circleView autoSetDimension:ALDimensionHeight toSize:circleSize]; @@ -79,22 +80,15 @@ NS_ASSUME_NONNULL_BEGIN - (void)updateColors { - UIColor *foregroundColor; - UIColor *backgroundColor; - if (self.hasUnreadMessages) { - foregroundColor = UIColor.whiteColor; - backgroundColor = UIColor.ows_materialBlueColor; - } else { - foregroundColor = UIColor.ows_materialBlueColor; - backgroundColor = Theme.scrollButtonBackgroundColor; - } + UIColor *foregroundColor = LKColors.text; + UIColor *backgroundColor = LKColors.composeViewBackground; const CGFloat circleSize = self.class.circleSize; self.circleView.backgroundColor = backgroundColor; self.iconLabel.attributedText = [[NSAttributedString alloc] initWithString:self.iconText attributes:@{ - NSFontAttributeName : [UIFont ows_fontAwesomeFont:circleSize * 0.8f], + NSFontAttributeName : [UIFont ows_fontAwesomeFont:circleSize * 0.75f], NSForegroundColorAttributeName : foregroundColor, NSBaselineOffsetAttributeName : @(-0.5f), }]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index dfa12b237..11052692a 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -685,11 +685,10 @@ typedef enum : NSUInteger { [self updateInputToolbar]; self.loadMoreHeader = [UILabel new]; - self.loadMoreHeader.text = NSLocalizedString(@"CONVERSATION_VIEW_LOADING_MORE_MESSAGES", - @"Indicates that the app is loading more messages in this conversation."); - self.loadMoreHeader.textColor = [UIColor ows_materialBlueColor]; + self.loadMoreHeader.text = NSLocalizedString(@"CONVERSATION_VIEW_LOADING_MORE_MESSAGES", @"Indicates that the app is loading more messages in this conversation."); + self.loadMoreHeader.textColor = [LKColors.text colorWithAlphaComponent:0.8]; self.loadMoreHeader.textAlignment = NSTextAlignmentCenter; - self.loadMoreHeader.font = [UIFont ows_mediumFontWithSize:16.f]; + self.loadMoreHeader.font = [UIFont boldSystemFontOfSize:LKValues.verySmallFontSize]; [self.collectionView addSubview:self.loadMoreHeader]; [self.loadMoreHeader autoPinWidthToWidthOfView:self.view]; [self.loadMoreHeader autoPinEdgeToSuperviewEdge:ALEdgeTop]; @@ -2574,7 +2573,7 @@ typedef enum : NSUInteger { - (void)createConversationScrollButtons { - self.scrollDownButton = [[ConversationScrollButton alloc] initWithIconText:@"\uf103"]; + self.scrollDownButton = [[ConversationScrollButton alloc] initWithIconText:@"\uf107"]; [self.scrollDownButton addTarget:self action:@selector(scrollDownButtonTapped) forControlEvents:UIControlEventTouchUpInside]; diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m index 505877a06..b0674590d 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewModel.m @@ -1540,7 +1540,9 @@ static const int kYapDatabaseRangeMaxLength = 25000; // the next message has the same sender avatar and // no "date break" separates us. shouldShowSenderAvatar = YES; - if (previousViewItem && previousViewItem.interaction.interactionType == interactionType) { + if (viewItem.isRSSFeed) { + shouldShowSenderAvatar = NO; + } else if (previousViewItem && previousViewItem.interaction.interactionType == interactionType) { shouldShowSenderAvatar = (![NSObject isNullableObject:previousIncomingSenderId equalTo:incomingSenderId]); } } diff --git a/Signal/translations/en.lproj/Localizable.strings b/Signal/translations/en.lproj/Localizable.strings index 8f10ff6e3..5d93dfd33 100644 --- a/Signal/translations/en.lproj/Localizable.strings +++ b/Signal/translations/en.lproj/Localizable.strings @@ -1770,7 +1770,7 @@ "QUOTED_REPLY_AUTHOR_INDICATOR_YOURSELF" = "Replying to Yourself"; /* Footer label that appears below quoted messages when the quoted content was not derived locally. When the local user doesn't have a copy of the message being quoted, e.g. if it had since been deleted, we instead show the content specified by the sender. */ -"QUOTED_REPLY_CONTENT_FROM_REMOTE_SOURCE" = "Original message not found."; +"QUOTED_REPLY_CONTENT_FROM_REMOTE_SOURCE" = "Original message not found"; /* Toast alert text shown when tapping on a quoted message which we cannot scroll to because the local copy of the message was since deleted. */ "QUOTED_REPLY_ORIGINAL_MESSAGE_DELETED" = "Original message no longer available."; @@ -2739,3 +2739,4 @@ "Restore your account using your seed" = "Restore your account using your seed"; "Enter your seed" = "Enter your seed"; "Message" = "Message"; +"You" = "You"; diff --git a/SignalMessaging/utils/ConversationStyle.swift b/SignalMessaging/utils/ConversationStyle.swift index 5e95bce71..fc712b02f 100644 --- a/SignalMessaging/utils/ConversationStyle.swift +++ b/SignalMessaging/utils/ConversationStyle.swift @@ -91,8 +91,13 @@ public class ConversationStyle: NSObject { @objc public func updateProperties() { if thread.isGroupThread() { - gutterLeading = 16 + 35 + 24 // Values.mediumSpacing + Values.smallProfilePictureSize + Values.largeSpacing - gutterTrailing = 16 + if let thread = thread as? TSGroupThread, thread.isRSSFeed { + gutterLeading = 16 + gutterTrailing = 16 + } else { + gutterLeading = 16 + 35 + 24 // Values.mediumSpacing + Values.smallProfilePictureSize + Values.largeSpacing + gutterTrailing = 16 + } } else { gutterLeading = 16 gutterTrailing = 16 @@ -103,7 +108,11 @@ public class ConversationStyle: NSObject { headerGutterTrailing = 16 errorGutterTrailing = 16 - maxMessageWidth = floor(contentWidth - 32) + if let thread = thread as? TSGroupThread, thread.isRSSFeed { + maxMessageWidth = floor(contentWidth) + } else { + maxMessageWidth = floor(contentWidth - 32) + } let messageTextFont = UIFont.systemFont(ofSize: 13) // Values.smallFontSize @@ -232,8 +241,7 @@ public class ConversationStyle: NSObject { @objc public func quotingSelfHighlightColor() -> UIColor { - // TODO: - return UIColor.init(rgbHex: 0xFF0000) + return UIColor.init(rgbHex: 0xB5B5B5) } @objc