From 6626e2ecc39919382eac182687ad8174cbee50d6 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 26 Jun 2018 10:02:27 -0400 Subject: [PATCH] Introduce message cell footer view. --- .../Cells/OWSMessageBubbleView.m | 20 ++++----- .../Cells/OWSMessageFooterView.h | 2 + .../Cells/OWSMessageFooterView.m | 42 +++++++++++++++++-- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 089838cbe..c6f662907 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -383,15 +383,14 @@ NS_ASSUME_NONNULL_BEGIN } } - OWSMessageTextView *_Nullable bodyTextView = nil; - UIStackView *_Nullable textStackView = [UIStackView new]; + UIStackView *_Nullable textStackView = nil; // We render malformed messages as "empty text" messages, // so create a text view if there is no body media view. if (self.hasBodyText || !bodyMediaView) { + OWSMessageTextView *_Nullable bodyTextView = nil; bodyTextView = [self configureBodyTextView]; - } - if (bodyTextView) { + textStackView = [UIStackView new]; textStackView.axis = UILayoutConstraintAxisVertical; textStackView.alignment = UIStackViewAlignmentFill; @@ -406,8 +405,6 @@ NS_ASSUME_NONNULL_BEGIN [textStackView addArrangedSubview:bodyTextView]; [self.viewConstraints addObjectsFromArray:@[ - // [bodyTextView autoSetDimension:ALDimensionWidth toSize:bodyTextContentSize.width - // relation:NSLayoutRelationLessThanOrEqual], [bodyTextView autoSetDimension:ALDimensionHeight toSize:bodyTextContentSize.height], ]]; @@ -415,8 +412,6 @@ NS_ASSUME_NONNULL_BEGIN if (tapForMoreLabel) { [textStackView addArrangedSubview:tapForMoreLabel]; [self.viewConstraints addObjectsFromArray:@[ - // [tapForMoreLabel autoPinEdge:ALEdgeTop - // toEdge:ALEdgeBottom ofView:lastSubview], [tapForMoreLabel autoSetDimension:ALDimensionHeight toSize:self.tapForMoreHeight], ]]; } @@ -426,6 +421,7 @@ NS_ASSUME_NONNULL_BEGIN [footerView configureWithConversationViewItem:self.viewItem]; if (textStackView) { [textStackView addArrangedSubview:self.footerView]; + [self.footerView setHasShadows:NO viewItem:self.viewItem]; } else if (bodyMediaView) { [bodyMediaView addSubview:footerView]; @@ -435,7 +431,7 @@ NS_ASSUME_NONNULL_BEGIN [footerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal], [footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom], ]]; - // TODO: Drop shadow. + [self.footerView setHasShadows:YES viewItem:self.viewItem]; } else { // Display footer over media. OWSFail(@"%@ could not display footer.", self.logTag); @@ -1023,7 +1019,7 @@ NS_ASSUME_NONNULL_BEGIN // contact shares. if (self.hasFooter && self.hasBodyText) { CGSize footerSize = [self.footerView measureWithConversationViewItem:self.viewItem]; - cellSize.width = MAX(cellSize.width, footerSize.width); + cellSize.width = MAX(cellSize.width, footerSize.width + self.conversationStyle.textInsetHorizontal * 2); cellSize.height += self.textViewVSpacing + footerSize.height; } @@ -1110,6 +1106,10 @@ NS_ASSUME_NONNULL_BEGIN self.quotedMessageView = nil; [self.footerView removeFromSuperview]; + + for (UIView *subview in self.stackView.subviews) { + [subview removeFromSuperview]; + } } #pragma mark - Gestures diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h index e837d6ad8..a3d1dfcda 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN - (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem; +- (void)setHasShadows:(BOOL)hasShadows viewItem:(ConversationViewItem *)viewItem; + @end NS_ASSUME_NONNULL_END diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m index 215eae8d1..656b17a60 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageFooterView.m @@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN - (CGFloat)statusIndicatorSize { // TODO: Review constant. - return 20.f; + return 16.f; } - (CGFloat)hSpacing @@ -100,10 +100,9 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(viewItem); [self configureLabelsWithConversationViewItem:viewItem]; - ; // TODO: - self.statusIndicatorView.backgroundColor = [UIColor ows_materialBlueColor]; + self.statusIndicatorView.backgroundColor = [UIColor redColor]; } - (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem @@ -123,7 +122,6 @@ NS_ASSUME_NONNULL_BEGIN OWSAssert(viewItem); [self configureLabelsWithConversationViewItem:viewItem]; - ; CGSize result = CGSizeZero; result.height @@ -146,6 +144,42 @@ NS_ASSUME_NONNULL_BEGIN return statusMessage; } +#pragma mark - Shadows + +- (void)setHasShadows:(BOOL)hasShadows viewItem:(ConversationViewItem *)viewItem +{ + // TODO: Constants + for (UIView *subview in @[ + self.timestampLabel, + self.statusLabel, + self.statusIndicatorView, + ]) { + if (hasShadows) { + subview.layer.shadowColor = [UIColor blackColor].CGColor; + subview.layer.shadowOpacity = 0.35f; + subview.layer.shadowOffset = CGSizeZero; + subview.layer.shadowRadius = 0.5f; + } else { + subview.layer.shadowColor = nil; + subview.layer.shadowOpacity = 0.f; + subview.layer.shadowOffset = CGSizeZero; + subview.layer.shadowRadius = 0.f; + } + } + + UIColor *textColor; + if (hasShadows) { + textColor = [UIColor whiteColor]; + } else if (viewItem.interaction.interactionType == OWSInteractionType_IncomingMessage) { + // TODO: + textColor = [UIColor lightGrayColor]; + } else { + textColor = [UIColor whiteColor]; + } + self.timestampLabel.textColor = textColor; + self.statusLabel.textColor = textColor; +} + @end NS_ASSUME_NONNULL_END