Tweak contact shares.

pull/1/head
Matthew Chen 7 years ago
parent dc79d302c6
commit 3c4d14034b

@ -29,6 +29,8 @@ const CGFloat kOWSMessageCellCornerRadius = 16;
return self; return self;
} }
self.layoutMargins = UIEdgeInsetsZero;
self.shapeLayer = [CAShapeLayer new]; self.shapeLayer = [CAShapeLayer new];
[self.layer addSublayer:self.shapeLayer]; [self.layer addSublayer:self.shapeLayer];

@ -27,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) OWSBubbleShapeView *mediaClipView; @property (nonatomic) OWSBubbleShapeView *mediaClipView;
@property (nonatomic) OWSBubbleShapeView *bubbleStrokeView;
@property (nonatomic) UIStackView *stackView; @property (nonatomic) UIStackView *stackView;
@property (nonatomic) UILabel *senderNameLabel; @property (nonatomic) UILabel *senderNameLabel;
@ -81,6 +83,7 @@ NS_ASSUME_NONNULL_BEGIN
self.mediaShadowView = [OWSBubbleShapeView bubbleShadowView]; self.mediaShadowView = [OWSBubbleShapeView bubbleShadowView];
self.mediaClipView = [OWSBubbleShapeView bubbleClipView]; self.mediaClipView = [OWSBubbleShapeView bubbleClipView];
self.bubbleStrokeView = [OWSBubbleShapeView bubbleDrawView];
self.stackView = [UIStackView new]; self.stackView = [UIStackView new];
self.stackView.axis = UILayoutConstraintAxisVertical; self.stackView.axis = UILayoutConstraintAxisVertical;
@ -333,44 +336,57 @@ NS_ASSUME_NONNULL_BEGIN
bodyMediaView.layer.opacity = 0.75f; bodyMediaView.layer.opacity = 0.75f;
} }
if (self.hasBodyMediaWithThumbnail) { if (self.hasFullWidthMediaView) {
// Flush any pending "text" subviews. // Flush any pending "text" subviews.
OWSAssert(!topTextStackView); OWSAssert(!topTextStackView);
topTextStackView = [self insertAnyTextViewsIntoStackView:textViews]; topTextStackView = [self insertAnyTextViewsIntoStackView:textViews];
[textViews removeAllObjects]; [textViews removeAllObjects];
// The "body media" view casts a shadow "downward" onto adjacent views, if (self.hasBodyMediaWithThumbnail) {
// so we use a "proxy" view to take its place within the v-stack
// view and then insert the body media view above its proxy so that // The "body media" view casts a shadow "downward" onto adjacent views,
// it floats above the other content of the bubble view. // so we use a "proxy" view to take its place within the v-stack
// view and then insert the body media view above its proxy so that
// it floats above the other content of the bubble view.
UIView *bodyProxyView = [UIView new]; UIView *bodyProxyView = [UIView new];
[self.stackView addArrangedSubview:bodyProxyView]; [self.stackView addArrangedSubview:bodyProxyView];
[self addSubview:self.mediaShadowView]; [self addSubview:self.mediaShadowView];
[self.mediaShadowView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:bodyProxyView]; [self.mediaShadowView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:bodyProxyView];
[self.mediaShadowView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:bodyProxyView]; [self.mediaShadowView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:bodyProxyView];
[self.mediaShadowView autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:bodyProxyView]; [self.mediaShadowView autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:bodyProxyView];
[self.mediaShadowView autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:bodyProxyView]; [self.mediaShadowView autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:bodyProxyView];
[self.mediaShadowView addSubview:self.mediaClipView]; [self.mediaShadowView addSubview:self.mediaClipView];
[self.mediaClipView autoPinToSuperviewEdges]; [self.mediaClipView autoPinToSuperviewEdges];
[self.mediaClipView addSubview:bodyMediaView]; [self.mediaClipView addSubview:bodyMediaView];
[bodyMediaView autoPinToSuperviewEdges]; [bodyMediaView autoPinToSuperviewEdges];
[self.bubbleView addPartnerView:self.mediaClipView]; [self.bubbleView addPartnerView:self.mediaClipView];
[self.bubbleView addPartnerView:self.mediaShadowView]; [self.bubbleView addPartnerView:self.mediaShadowView];
// TODO: Constants
// TODO: What's the difference between an inner and outer shadow?
self.mediaShadowView.fillColor = self.bubbleColor;
self.mediaShadowView.layer.shadowColor = [UIColor blackColor].CGColor;
self.mediaShadowView.layer.shadowOpacity = 0.12f;
self.mediaShadowView.layer.shadowOffset = CGSizeMake(0.f, 0.f);
self.mediaShadowView.layer.shadowRadius = 0.5f;
} else {
OWSAssert(self.cellType == OWSMessageCellType_ContactShare);
// TODO: Constants [self.stackView addArrangedSubview:bodyMediaView];
// TODO: What's the difference between an inner and outer shadow?
self.mediaShadowView.fillColor = self.bubbleColor; // TODO: Constants.
self.mediaShadowView.layer.shadowColor = [UIColor blackColor].CGColor; self.bubbleStrokeView.strokeColor = [UIColor lightGrayColor];
self.mediaShadowView.layer.shadowOpacity = 0.12f; self.bubbleStrokeView.strokeThickness = 1.f;
self.mediaShadowView.layer.shadowOffset = CGSizeMake(0.f, 0.f); [self.bubbleView addSubview:self.bubbleStrokeView];
self.mediaShadowView.layer.shadowRadius = 0.5f; [self.bubbleStrokeView autoPinToSuperviewEdges];
[self.bubbleView addPartnerView:self.bubbleStrokeView];
}
} else { } else {
// [self.stackView addArrangedSubview:bodyMediaView];
[textViews addObject:bodyMediaView]; [textViews addObject:bodyMediaView];
} }
} }
@ -432,7 +448,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)updateBubbleColor - (void)updateBubbleColor
{ {
BOOL hasOnlyBodyMediaView = ([self hasBodyMediaWithThumbnail] && self.stackView.subviews.count == 1); BOOL hasOnlyBodyMediaView = ([self hasFullWidthMediaView] && self.stackView.subviews.count == 1);
if (!hasOnlyBodyMediaView) { if (!hasOnlyBodyMediaView) {
self.bubbleView.bubbleColor = self.bubbleColor; self.bubbleView.bubbleColor = self.bubbleColor;
} else { } else {
@ -469,11 +485,25 @@ NS_ASSUME_NONNULL_BEGIN
} }
} }
- (BOOL)hasFullWidthMediaView
{
return (self.hasBodyMediaWithThumbnail || self.cellType == OWSMessageCellType_ContactShare);
}
// Returns YES if there is a footer displayed _at the bottom_
// of the message bubble (as opposed to overlaid on a body media
// thumbnail).
- (BOOL)canFooterOverlayMedia - (BOOL)canFooterOverlayMedia
{ {
return self.hasBodyMediaWithThumbnail; return self.hasBodyMediaWithThumbnail;
} }
- (BOOL)hasBottomFooter
{
BOOL shouldFooterOverlayMedia = (self.canFooterOverlayMedia && !self.hasBodyText);
return !self.viewItem.shouldHideFooter && !shouldFooterOverlayMedia;
}
- (nullable UIView *)insertAnyTextViewsIntoStackView:(NSArray<UIView *> *)textViews - (nullable UIView *)insertAnyTextViewsIntoStackView:(NSArray<UIView *> *)textViews
{ {
if (textViews.count < 1) { if (textViews.count < 1) {
@ -1080,7 +1110,7 @@ NS_ASSUME_NONNULL_BEGIN
NSValue *_Nullable bodyMediaSize = [self bodyMediaSize]; NSValue *_Nullable bodyMediaSize = [self bodyMediaSize];
if (bodyMediaSize) { if (bodyMediaSize) {
if (self.hasBodyMediaWithThumbnail) { if (self.hasFullWidthMediaView) {
cellSize.width = MAX(cellSize.width, bodyMediaSize.CGSizeValue.width); cellSize.width = MAX(cellSize.width, bodyMediaSize.CGSizeValue.width);
cellSize.height += bodyMediaSize.CGSizeValue.height; cellSize.height += bodyMediaSize.CGSizeValue.height;
} else { } else {
@ -1104,8 +1134,7 @@ NS_ASSUME_NONNULL_BEGIN
[textViewSizes addObject:bodyTextSize]; [textViewSizes addObject:bodyTextSize];
} }
BOOL shouldFooterOverlayMedia = (self.canFooterOverlayMedia && !self.hasBodyText); if (self.hasBottomFooter) {
if (!self.viewItem.shouldHideFooter && !shouldFooterOverlayMedia) {
CGSize footerSize = [self.footerView measureWithConversationViewItem:self.viewItem]; CGSize footerSize = [self.footerView measureWithConversationViewItem:self.viewItem];
[textViewSizes addObject:[NSValue valueWithCGSize:footerSize]]; [textViewSizes addObject:[NSValue valueWithCGSize:footerSize]];
} }

Loading…
Cancel
Save