diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m index 04a2f1e0a5..7913b63b74 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSAudioMessageView.m @@ -223,7 +223,7 @@ NS_ASSUME_NONNULL_BEGIN UIView *labelsView = [UIView containerView]; [contentView addSubview:labelsView]; [labelsView autoPinLeadingToTrailingOfView:self.audioPlayPauseButton margin:kLabelHSpacing]; - [labelsView autoPinEdgeToSuperviewEdge:ALEdgeRight]; + [labelsView autoPinTrailingToSuperviewWithMargin:self.audioIconHMargin]; [labelsView autoVCenterInSuperview]; const CGFloat kLabelVSpacing = 2; diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m index 2c0d869108..8a0eb832de 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m @@ -4,6 +4,7 @@ #import "OWSGenericAttachmentView.h" #import "NSString+OWS.h" +#import "OWSBezierPathView.h" #import "UIColor+JSQMessages.h" #import "UIColor+OWS.h" #import "UIFont+OWS.h" @@ -116,25 +117,35 @@ NS_ASSUME_NONNULL_BEGIN [contentView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:self.vMargin]; [contentView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:self.vMargin]; + OWSBezierPathView *iconCircleView = [OWSBezierPathView new]; + UIColor *iconColor + = (self.isIncoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self foregroundColorWithOpacity:0.15f]); + iconCircleView.configureShapeLayerBlock = ^(CAShapeLayer *_Nonnull layer, CGRect bounds) { + layer.path = [UIBezierPath bezierPathWithOvalInRect:bounds].CGPath; + layer.fillColor = iconColor.CGColor; + }; + [contentView addSubview:iconCircleView]; + [iconCircleView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:self.iconHMargin]; + [iconCircleView autoVCenterInSuperview]; + [iconCircleView autoSetDimension:ALDimensionWidth toSize:self.iconSize]; + [iconCircleView autoSetDimension:ALDimensionHeight toSize:self.iconSize]; + UIImage *image = [UIImage imageNamed:@"generic-attachment-small"]; OWSAssert(image); UIImageView *imageView = [UIImageView new]; imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageView.tintColor = self.bubbleBackgroundColor; - imageView.backgroundColor - = (self.isIncoming ? [UIColor colorWithRGBHex:0x9e9e9e] : [self foregroundColorWithOpacity:0.15f]); - imageView.layer.cornerRadius = MIN(imageView.bounds.size.width, imageView.bounds.size.height) * 0.5f; [contentView addSubview:imageView]; - [imageView autoPinEdgeToSuperviewEdge:ALEdgeLeft withInset:self.iconHMargin]; - [imageView autoVCenterInSuperview]; - [imageView autoSetDimension:ALDimensionWidth toSize:self.iconSize]; - [imageView autoSetDimension:ALDimensionHeight toSize:self.iconSize]; + [imageView autoPinEdge:ALEdgeLeft toEdge:ALEdgeLeft ofView:iconCircleView]; + [imageView autoPinEdge:ALEdgeRight toEdge:ALEdgeRight ofView:iconCircleView]; + [imageView autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:iconCircleView]; + [imageView autoPinEdge:ALEdgeBottom toEdge:ALEdgeBottom ofView:iconCircleView]; const CGFloat kLabelHSpacing = self.iconHSpacing; UIView *labelsView = [UIView containerView]; [contentView addSubview:labelsView]; [labelsView autoPinLeadingToTrailingOfView:imageView margin:kLabelHSpacing]; - [labelsView autoPinEdgeToSuperviewEdge:ALEdgeRight]; + [labelsView autoPinTrailingToSuperviewWithMargin:self.iconHMargin]; [labelsView autoVCenterInSuperview]; NSString *filename = self.attachmentStream.sourceFilename; @@ -152,15 +163,15 @@ NS_ASSUME_NONNULL_BEGIN UILabel *fileTypeLabel = [UILabel new]; fileTypeLabel.text = fileExtension.uppercaseString; - fileTypeLabel.textColor = imageView.backgroundColor; + fileTypeLabel.textColor = iconColor; fileTypeLabel.lineBreakMode = NSLineBreakByTruncatingTail; fileTypeLabel.font = [UIFont ows_mediumFontWithSize:20.f]; fileTypeLabel.adjustsFontSizeToFitWidth = YES; fileTypeLabel.textAlignment = NSTextAlignmentCenter; // Center on icon. [imageView addSubview:fileTypeLabel]; - [imageView autoCenterInSuperview]; - [imageView autoSetDimension:ALDimensionWidth toSize:15.f]; + [fileTypeLabel autoCenterInSuperview]; + [fileTypeLabel autoSetDimension:ALDimensionWidth toSize:15.f]; const CGFloat kLabelVSpacing = 2; NSString *topText = [self.attachmentStream.sourceFilename ows_stripped];