diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m index f81e766ba..161e5d906 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageCell.m @@ -389,7 +389,7 @@ NS_ASSUME_NONNULL_BEGIN lastSubview = quotedMessageView; bottomMargin = 0; - [self.bubbleView addPartnerView:quotedMessageView]; + [self.bubbleView addPartnerView:quotedMessageView.boundsStrokeView]; } UIView *_Nullable bodyMediaView = nil; @@ -473,7 +473,6 @@ NS_ASSUME_NONNULL_BEGIN OWSBubbleStrokeView *bubbleStrokeView = [OWSBubbleStrokeView new]; bubbleStrokeView.strokeThickness = 1.f; bubbleStrokeView.strokeColor = [UIColor colorWithWhite:0.f alpha:0.1f]; - bubbleStrokeView.bubbleView = self.bubbleView; [self.bubbleView addSubview:bubbleStrokeView]; [bubbleStrokeView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:bodyMediaView]; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.h b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.h index f65109e8c..d4f455157 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.h +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.h @@ -2,14 +2,15 @@ // Copyright (c) 2018 Open Whisper Systems. All rights reserved. // -#import "OWSBubbleView.h" - NS_ASSUME_NONNULL_BEGIN @class DisplayableText; +@class OWSBubbleStrokeView; @class TSQuotedMessage; -@interface OWSQuotedMessageView : UIView +@interface OWSQuotedMessageView : UIView + +@property (nonatomic, nullable, readonly) OWSBubbleStrokeView *boundsStrokeView; - (instancetype)init NS_UNAVAILABLE; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m index e8a956b16..8a69d2922 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSQuotedMessageView.m @@ -5,6 +5,7 @@ #import "OWSQuotedMessageView.h" #import "ConversationViewItem.h" #import "Environment.h" +#import "OWSBubbleStrokeView.h" #import "OWSMessageCell.h" #import "Signal-Swift.h" #import @@ -24,16 +25,12 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, readonly) UIFont *textMessageFont; -@property (nonatomic, readonly) UIColor *strokeColor; -@property (nonatomic, readonly) CGFloat strokeThickness; - -// TODO: Replace with a bubble stroke view. -@property (nonatomic) CAShapeLayer *shapeLayer; - -@property (nonatomic, weak) OWSBubbleView *bubbleView; +@property (nonatomic, nullable) OWSBubbleStrokeView *boundsStrokeView; @end +#pragma mark - + @implementation OWSQuotedMessageView + (OWSQuotedMessageView *)quotedMessageViewForConversation:(TSQuotedMessage *)quotedMessage @@ -73,11 +70,6 @@ NS_ASSUME_NONNULL_BEGIN _quotedMessage = quotedMessage; _displayableQuotedText = displayableQuotedText; _textMessageFont = OWSMessageCell.defaultTextMessageFont; - _strokeColor = OWSMessagesBubbleImageFactory.bubbleColorIncoming; - _strokeThickness = 1.f; - - self.shapeLayer = [CAShapeLayer new]; - [self.layer addSublayer:self.shapeLayer]; return self; } @@ -97,6 +89,14 @@ NS_ASSUME_NONNULL_BEGIN self.layoutMargins = UIEdgeInsetsZero; self.clipsToBounds = YES; + self.boundsStrokeView = [OWSBubbleStrokeView new]; + self.boundsStrokeView.strokeColor = OWSMessagesBubbleImageFactory.bubbleColorIncoming; + self.boundsStrokeView.strokeThickness = 1.f; + [self addSubview:self.boundsStrokeView]; + [self.boundsStrokeView autoPinToSuperviewEdges]; + [self.boundsStrokeView setContentHuggingLow]; + [self.boundsStrokeView setCompressionResistanceLow]; + UIView *_Nullable quotedAttachmentView = nil; // TODO: // if (self.hasQuotedAttachmentThumbnail) @@ -114,6 +114,11 @@ NS_ASSUME_NONNULL_BEGIN [quotedAttachmentView setCompressionResistanceHigh]; // TODO: Consider stroking the quoted thumbnail. + if (quotedAttachmentView) { + quotedAttachmentView.layer.borderColor = [UIColor colorWithWhite:0.f alpha:0.1f].CGColor; + quotedAttachmentView.layer.borderWidth = 1.f; + quotedAttachmentView.layer.cornerRadius = 2.f; + } } OWSContactsManager *contactsManager = Environment.current.contactsManager; @@ -366,101 +371,6 @@ NS_ASSUME_NONNULL_BEGIN return 8.f; } -#pragma mark - Stroke - -//- (instancetype)init -//{ -// self = [super init]; -// if (!self) { -// return self; -// } -// -// self.opaque = NO; -// self.backgroundColor = [UIColor clearColor]; -// -// -// [self updateLayers]; -// -// return self; -//} - -- (void)setStrokeColor:(UIColor *)strokeColor -{ - _strokeColor = strokeColor; - - [self updateLayers]; -} - -- (void)setStrokeThickness:(CGFloat)strokeThickness -{ - _strokeThickness = strokeThickness; - - [self updateLayers]; -} - -- (void)setFrame:(CGRect)frame -{ - BOOL didChange = !CGRectEqualToRect(self.frame, frame); - - [super setFrame:frame]; - - if (didChange) { - [self updateLayers]; - } -} - -- (void)setBounds:(CGRect)bounds -{ - BOOL didChange = !CGRectEqualToRect(self.bounds, bounds); - - [super setBounds:bounds]; - - if (didChange) { - [self updateLayers]; - } -} - -- (void)setCenter:(CGPoint)center -{ - [super setCenter:center]; - - [self updateLayers]; -} - -- (void)updateLayers -{ - if (!self.shapeLayer) { - return; - } - - // Don't fill the shape layer; we just want a stroke around the border. - self.shapeLayer.fillColor = [UIColor clearColor].CGColor; - - self.clipsToBounds = YES; - - if (!self.bubbleView) { - return; - } - - self.shapeLayer.strokeColor = self.strokeColor.CGColor; - self.shapeLayer.lineWidth = self.strokeThickness; - self.shapeLayer.zPosition = 100.f; - - UIBezierPath *bezierPath = [UIBezierPath new]; - - UIBezierPath *boundsBezierPath = [UIBezierPath bezierPathWithRect:self.bounds]; - [bezierPath appendPath:boundsBezierPath]; - - UIBezierPath *bubbleBezierPath = [self.bubbleView maskPath]; - // We need to convert between coordinate systems using layers, not views. - CGPoint bubbleOffset = [self.layer convertPoint:CGPointZero fromLayer:self.bubbleView.layer]; - CGAffineTransform transform = CGAffineTransformMakeTranslation(bubbleOffset.x, bubbleOffset.y); - [bubbleBezierPath applyTransform:transform]; - [bezierPath appendPath:bubbleBezierPath]; - - self.shapeLayer.path = bezierPath.CGPath; -} - @end NS_ASSUME_NONNULL_END