From 284cc8c265f5bdf66d15f57b5a69a547c228d1e2 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 16 Apr 2018 15:47:10 -0400 Subject: [PATCH] Apply attachment type assets. --- .../Cells/OWSGenericAttachmentView.m | 47 ++++--------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m index 32171fd94..934178ac3 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSGenericAttachmentView.m @@ -73,7 +73,7 @@ NS_ASSUME_NONNULL_BEGIN + (CGFloat)iconSize { - return 40.f; + return 44.f; } - (CGFloat)iconSize @@ -118,62 +118,31 @@ NS_ASSUME_NONNULL_BEGIN [contentView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:self.vMargin]; [contentView autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:self.vMargin]; - OWSBezierPathView *iconCircleView = [OWSBezierPathView new]; - UIColor *iconColor + UIView *iconCircleView = [UIView containerView]; + iconCircleView.backgroundColor = (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; - }; + iconCircleView.layer.cornerRadius = self.iconSize * 0.5f; [contentView addSubview:iconCircleView]; [iconCircleView autoPinLeadingToSuperviewMarginWithInset:self.iconHMargin]; [iconCircleView autoVCenterInSuperview]; [iconCircleView autoSetDimension:ALDimensionWidth toSize:self.iconSize]; [iconCircleView autoSetDimension:ALDimensionHeight toSize:self.iconSize]; - UIImage *image = [UIImage imageNamed:@"generic-attachment-small"]; + UIImage *image = [UIImage imageNamed:@"attachment_file"]; OWSAssert(image); UIImageView *imageView = [UIImageView new]; imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; imageView.tintColor = self.bubbleBackgroundColor; - [contentView addSubview:imageView]; - [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]; + [iconCircleView addSubview:imageView]; + [imageView autoCenterInSuperview]; const CGFloat kLabelHSpacing = self.iconHSpacing; UIView *labelsView = [UIView containerView]; [contentView addSubview:labelsView]; - [labelsView autoPinLeadingToTrailingEdgeOfView:imageView offset:kLabelHSpacing]; + [labelsView autoPinLeadingToTrailingEdgeOfView:iconCircleView offset:kLabelHSpacing]; [labelsView autoPinTrailingToSuperviewMarginWithInset:self.iconHMargin]; [labelsView autoVCenterInSuperview]; - NSString *filename = self.attachmentStream.sourceFilename; - if (!filename) { - filename = [[self.attachmentStream filePath] lastPathComponent]; - } - NSString *fileExtension = filename.pathExtension; - if (fileExtension.length < 1) { - [MIMETypeUtil fileExtensionForMIMEType:self.attachmentStream.contentType]; - } - if (fileExtension.length < 1) { - fileExtension = NSLocalizedString(@"GENERIC_ATTACHMENT_DEFAULT_TYPE", - @"A default label for attachment whose file extension cannot be determined."); - } - - UILabel *fileTypeLabel = [UILabel new]; - fileTypeLabel.text = fileExtension.uppercaseString; - 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]; - [fileTypeLabel autoCenterInSuperview]; - [fileTypeLabel autoSetDimension:ALDimensionWidth toSize:15.f]; - const CGFloat kLabelVSpacing = 2; NSString *topText = [self.attachmentStream.sourceFilename ows_stripped]; if (topText.length < 1) {