Tweak message cells.

pull/1/head
Matthew Chen 6 years ago
parent 560d5b530a
commit 87380894ba

@ -23,7 +23,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic) OWSBubbleView *bubbleView; @property (nonatomic) OWSBubbleView *bubbleView;
@property (nonatomic) OWSBubbleShapeView *mediaShadowView; // TODO: We may only end up using a single shadow.
@property (nonatomic) OWSBubbleShapeView *mediaShadowView1;
@property (nonatomic) OWSBubbleShapeView *mediaShadowView2;
@property (nonatomic) OWSBubbleShapeView *mediaClipView; @property (nonatomic) OWSBubbleShapeView *mediaClipView;
@ -81,7 +84,8 @@ NS_ASSUME_NONNULL_BEGIN
[self addSubview:self.bubbleView]; [self addSubview:self.bubbleView];
[self.bubbleView autoPinEdgesToSuperviewEdges]; [self.bubbleView autoPinEdgesToSuperviewEdges];
self.mediaShadowView = [OWSBubbleShapeView bubbleShadowView]; self.mediaShadowView1 = [OWSBubbleShapeView bubbleShadowView];
self.mediaShadowView2 = [OWSBubbleShapeView bubbleShadowView];
self.mediaClipView = [OWSBubbleShapeView bubbleClipView]; self.mediaClipView = [OWSBubbleShapeView bubbleClipView];
self.bubbleStrokeView = [OWSBubbleShapeView bubbleDrawView]; self.bubbleStrokeView = [OWSBubbleShapeView bubbleDrawView];
@ -348,28 +352,33 @@ NS_ASSUME_NONNULL_BEGIN
UIView *bodyProxyView = [UIView new]; UIView *bodyProxyView = [UIView new];
[self.stackView addArrangedSubview:bodyProxyView]; [self.stackView addArrangedSubview:bodyProxyView];
[self addSubview:self.mediaShadowView]; [self addSubview:self.mediaShadowView1];
[self.mediaShadowView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:bodyProxyView]; [self addSubview:self.mediaShadowView2];
[self.mediaShadowView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:bodyProxyView]; [self addSubview:self.mediaClipView];
[self.mediaShadowView autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:bodyProxyView];
[self.mediaShadowView autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:bodyProxyView];
[self.mediaShadowView addSubview:self.mediaClipView]; [self.viewConstraints addObjectsFromArray:[self.mediaShadowView1 autoPinToEdgesOfView:bodyProxyView]];
[self.mediaClipView autoPinToSuperviewEdges]; [self.viewConstraints addObjectsFromArray:[self.mediaShadowView2 autoPinToEdgesOfView:bodyProxyView]];
[self.viewConstraints addObjectsFromArray:[self.mediaClipView autoPinToEdgesOfView:bodyProxyView]];
[self.mediaClipView addSubview:bodyMediaView]; [self.mediaClipView addSubview:bodyMediaView];
[bodyMediaView autoPinToSuperviewEdges]; [self.viewConstraints addObjectsFromArray:[bodyMediaView autoPinToSuperviewEdges]];
[self.bubbleView addPartnerView:self.mediaShadowView1];
[self.bubbleView addPartnerView:self.mediaShadowView2];
[self.bubbleView addPartnerView:self.mediaClipView]; [self.bubbleView addPartnerView:self.mediaClipView];
[self.bubbleView addPartnerView:self.mediaShadowView];
// TODO: Consider only using a single shadow for perf.
// TODO: Constants self.mediaShadowView1.fillColor = self.bubbleColor;
// TODO: What's the difference between an inner and outer shadow? self.mediaShadowView1.layer.shadowColor = [UIColor blackColor].CGColor;
self.mediaShadowView.fillColor = self.bubbleColor; self.mediaShadowView1.layer.shadowOpacity = 0.2f;
self.mediaShadowView.layer.shadowColor = [UIColor blackColor].CGColor; self.mediaShadowView1.layer.shadowOffset = CGSizeMake(0.f, 4.f);
self.mediaShadowView.layer.shadowOpacity = 0.12f; self.mediaShadowView1.layer.shadowRadius = 20.f;
self.mediaShadowView.layer.shadowOffset = CGSizeMake(0.f, 0.f);
self.mediaShadowView.layer.shadowRadius = 0.5f; self.mediaShadowView2.fillColor = self.bubbleColor;
self.mediaShadowView2.layer.shadowColor = [UIColor blackColor].CGColor;
self.mediaShadowView2.layer.shadowOpacity = 0.08f;
self.mediaShadowView2.layer.shadowOffset = CGSizeZero;
self.mediaShadowView2.layer.shadowRadius = 4.f;
} else { } else {
OWSAssert(self.cellType == OWSMessageCellType_ContactShare); OWSAssert(self.cellType == OWSMessageCellType_ContactShare);
@ -379,7 +388,7 @@ NS_ASSUME_NONNULL_BEGIN
self.bubbleStrokeView.strokeColor = [UIColor lightGrayColor]; self.bubbleStrokeView.strokeColor = [UIColor lightGrayColor];
self.bubbleStrokeView.strokeThickness = 1.f; self.bubbleStrokeView.strokeThickness = 1.f;
[self.bubbleView addSubview:self.bubbleStrokeView]; [self.bubbleView addSubview:self.bubbleStrokeView];
[self.bubbleStrokeView autoPinToSuperviewEdges]; [self.viewConstraints addObjectsFromArray:[self.bubbleStrokeView autoPinToSuperviewEdges]];
[self.bubbleView addPartnerView:self.bubbleStrokeView]; [self.bubbleView addPartnerView:self.bubbleStrokeView];
} }
} else { } else {
@ -1235,7 +1244,8 @@ NS_ASSUME_NONNULL_BEGIN
[self.quotedMessageView removeFromSuperview]; [self.quotedMessageView removeFromSuperview];
self.quotedMessageView = nil; self.quotedMessageView = nil;
[self.mediaShadowView removeFromSuperview]; [self.mediaShadowView1 removeFromSuperview];
[self.mediaShadowView2 removeFromSuperview];
[self.mediaClipView removeFromSuperview]; [self.mediaClipView removeFromSuperview];
[self.footerView removeFromSuperview]; [self.footerView removeFromSuperview];

@ -106,6 +106,8 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
// When using a UIView as a "div" to structure layout, we don't want it to have margins. // When using a UIView as a "div" to structure layout, we don't want it to have margins.
- (void)setHLayoutMargins:(CGFloat)value; - (void)setHLayoutMargins:(CGFloat)value;
- (NSArray<NSLayoutConstraint *> *)autoPinToEdgesOfView:(UIView *)view;
#pragma mark - Containers #pragma mark - Containers
+ (UIView *)containerView; + (UIView *)containerView;

@ -402,6 +402,18 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
self.layoutMargins = layoutMargins; self.layoutMargins = layoutMargins;
} }
- (NSArray<NSLayoutConstraint *> *)autoPinToEdgesOfView:(UIView *)view
{
OWSAssert(view);
return @[
[self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:view],
[self autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:view],
[self autoPinEdge:ALEdgeLeading toEdge:ALEdgeLeading ofView:view],
[self autoPinEdge:ALEdgeTrailing toEdge:ALEdgeTrailing ofView:view],
];
}
#pragma mark - Containers #pragma mark - Containers
+ (UIView *)containerView + (UIView *)containerView

Loading…
Cancel
Save