Introduce message cell footer view.

pull/1/head
Matthew Chen 7 years ago
parent f363a196f3
commit 6626e2ecc3

@ -383,15 +383,14 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
OWSMessageTextView *_Nullable bodyTextView = nil; UIStackView *_Nullable textStackView = nil;
UIStackView *_Nullable textStackView = [UIStackView new];
// We render malformed messages as "empty text" messages, // We render malformed messages as "empty text" messages,
// so create a text view if there is no body media view. // so create a text view if there is no body media view.
if (self.hasBodyText || !bodyMediaView) { if (self.hasBodyText || !bodyMediaView) {
OWSMessageTextView *_Nullable bodyTextView = nil;
bodyTextView = [self configureBodyTextView]; bodyTextView = [self configureBodyTextView];
}
if (bodyTextView) {
textStackView = [UIStackView new]; textStackView = [UIStackView new];
textStackView.axis = UILayoutConstraintAxisVertical; textStackView.axis = UILayoutConstraintAxisVertical;
textStackView.alignment = UIStackViewAlignmentFill; textStackView.alignment = UIStackViewAlignmentFill;
@ -406,8 +405,6 @@ NS_ASSUME_NONNULL_BEGIN
[textStackView addArrangedSubview:bodyTextView]; [textStackView addArrangedSubview:bodyTextView];
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
// [bodyTextView autoSetDimension:ALDimensionWidth toSize:bodyTextContentSize.width
// relation:NSLayoutRelationLessThanOrEqual],
[bodyTextView autoSetDimension:ALDimensionHeight toSize:bodyTextContentSize.height], [bodyTextView autoSetDimension:ALDimensionHeight toSize:bodyTextContentSize.height],
]]; ]];
@ -415,8 +412,6 @@ NS_ASSUME_NONNULL_BEGIN
if (tapForMoreLabel) { if (tapForMoreLabel) {
[textStackView addArrangedSubview:tapForMoreLabel]; [textStackView addArrangedSubview:tapForMoreLabel];
[self.viewConstraints addObjectsFromArray:@[ [self.viewConstraints addObjectsFromArray:@[
// [tapForMoreLabel autoPinEdge:ALEdgeTop
// toEdge:ALEdgeBottom ofView:lastSubview],
[tapForMoreLabel autoSetDimension:ALDimensionHeight toSize:self.tapForMoreHeight], [tapForMoreLabel autoSetDimension:ALDimensionHeight toSize:self.tapForMoreHeight],
]]; ]];
} }
@ -426,6 +421,7 @@ NS_ASSUME_NONNULL_BEGIN
[footerView configureWithConversationViewItem:self.viewItem]; [footerView configureWithConversationViewItem:self.viewItem];
if (textStackView) { if (textStackView) {
[textStackView addArrangedSubview:self.footerView]; [textStackView addArrangedSubview:self.footerView];
[self.footerView setHasShadows:NO viewItem:self.viewItem];
} else if (bodyMediaView) { } else if (bodyMediaView) {
[bodyMediaView addSubview:footerView]; [bodyMediaView addSubview:footerView];
@ -435,7 +431,7 @@ NS_ASSUME_NONNULL_BEGIN
[footerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal], [footerView autoPinTrailingToSuperviewMarginWithInset:self.conversationStyle.textInsetHorizontal],
[footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom], [footerView autoPinBottomToSuperviewMarginWithInset:self.conversationStyle.textInsetBottom],
]]; ]];
// TODO: Drop shadow. [self.footerView setHasShadows:YES viewItem:self.viewItem];
} else { } else {
// Display footer over media. // Display footer over media.
OWSFail(@"%@ could not display footer.", self.logTag); OWSFail(@"%@ could not display footer.", self.logTag);
@ -1023,7 +1019,7 @@ NS_ASSUME_NONNULL_BEGIN
// contact shares. // contact shares.
if (self.hasFooter && self.hasBodyText) { if (self.hasFooter && self.hasBodyText) {
CGSize footerSize = [self.footerView measureWithConversationViewItem:self.viewItem]; 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; cellSize.height += self.textViewVSpacing + footerSize.height;
} }
@ -1110,6 +1106,10 @@ NS_ASSUME_NONNULL_BEGIN
self.quotedMessageView = nil; self.quotedMessageView = nil;
[self.footerView removeFromSuperview]; [self.footerView removeFromSuperview];
for (UIView *subview in self.stackView.subviews) {
[subview removeFromSuperview];
}
} }
#pragma mark - Gestures #pragma mark - Gestures

@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN
- (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem; - (CGSize)measureWithConversationViewItem:(ConversationViewItem *)viewItem;
- (void)setHasShadows:(BOOL)hasShadows viewItem:(ConversationViewItem *)viewItem;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN
- (CGFloat)statusIndicatorSize - (CGFloat)statusIndicatorSize
{ {
// TODO: Review constant. // TODO: Review constant.
return 20.f; return 16.f;
} }
- (CGFloat)hSpacing - (CGFloat)hSpacing
@ -100,10 +100,9 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(viewItem); OWSAssert(viewItem);
[self configureLabelsWithConversationViewItem:viewItem]; [self configureLabelsWithConversationViewItem:viewItem];
;
// TODO: // TODO:
self.statusIndicatorView.backgroundColor = [UIColor ows_materialBlueColor]; self.statusIndicatorView.backgroundColor = [UIColor redColor];
} }
- (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem - (void)configureLabelsWithConversationViewItem:(ConversationViewItem *)viewItem
@ -123,7 +122,6 @@ NS_ASSUME_NONNULL_BEGIN
OWSAssert(viewItem); OWSAssert(viewItem);
[self configureLabelsWithConversationViewItem:viewItem]; [self configureLabelsWithConversationViewItem:viewItem];
;
CGSize result = CGSizeZero; CGSize result = CGSizeZero;
result.height result.height
@ -146,6 +144,42 @@ NS_ASSUME_NONNULL_BEGIN
return statusMessage; 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 @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

Loading…
Cancel
Save