diff --git a/SignalMessaging/attachments/AttachmentApprovalViewController.swift b/SignalMessaging/attachments/AttachmentApprovalViewController.swift index b564f1b50..dcdf58e0b 100644 --- a/SignalMessaging/attachments/AttachmentApprovalViewController.swift +++ b/SignalMessaging/attachments/AttachmentApprovalViewController.swift @@ -121,22 +121,23 @@ public class AttachmentApprovalViewController: OWSViewController { containerView.autoMatch(.width, to: .width, of: self.view) containerView.addSubview(mediaMessageView) - mediaMessageView.autoCenterInSuperview() - mediaMessageView.setCompressionResistanceHigh() - - // Add top and bottom gradients to ensure toolbar controls are legible - // when placed over media with a clashing color - let topGradient = GradientView(from: backgroundColor, to: UIColor.clear) - self.view.addSubview(topGradient) - topGradient.autoPinWidthToSuperview() - topGradient.autoPinEdge(toSuperviewEdge: .top) - topGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(60)) - - let bottomGradient = GradientView(from: UIColor.clear, to: backgroundColor) - self.view.addSubview(bottomGradient) - bottomGradient.autoPinWidthToSuperview() - bottomGradient.autoPinEdge(toSuperviewEdge: .bottom) - bottomGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(100)) + mediaMessageView.autoPinEdgesToSuperviewEdges() + + if attachment.isImage || attachment.isVideo { + // Add top and bottom gradients to ensure toolbar controls are legible + // when placed over image/video preview which may be a clashing color. + let topGradient = GradientView(from: backgroundColor, to: UIColor.clear) + self.view.addSubview(topGradient) + topGradient.autoPinWidthToSuperview() + topGradient.autoPinEdge(toSuperviewEdge: .top) + topGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(60)) + + let bottomGradient = GradientView(from: UIColor.clear, to: backgroundColor) + self.view.addSubview(bottomGradient) + bottomGradient.autoPinWidthToSuperview() + bottomGradient.autoPinEdge(toSuperviewEdge: .bottom) + bottomGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(100)) + } // Hide the play button embedded in the MediaView and replace it with our own. // This allows us to zoom in on the media view without zooming in on the button diff --git a/SignalMessaging/attachments/MediaMessageView.swift b/SignalMessaging/attachments/MediaMessageView.swift index 5360f329c..1f5504929 100644 --- a/SignalMessaging/attachments/MediaMessageView.swift +++ b/SignalMessaging/attachments/MediaMessageView.swift @@ -292,8 +292,10 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { private func createHeroViewSize() -> CGFloat { switch mode { - case .large, .attachmentApproval: + case .large: return ScaleFromIPhone5To7Plus(175, 225) + case .attachmentApproval: + return ScaleFromIPhone5(100) case .small: return ScaleFromIPhone5To7Plus(80, 80) } @@ -327,6 +329,15 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { } } + private var controlTintColor: UIColor { + switch mode { + case .small, .large: + return UIColor.ows_materialBlue() + case .attachmentApproval: + return UIColor.white + } + } + private func formattedFileExtension() -> String? { guard let fileExtension = attachment.fileExtension else { return nil @@ -357,7 +368,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { let label = UILabel() label.text = filename - label.textColor = UIColor.ows_materialBlue() + label.textColor = controlTintColor label.font = labelFont() label.textAlignment = .center label.lineBreakMode = .byTruncatingMiddle @@ -371,7 +382,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."), OWSFormat.formatFileSize(UInt(fileSize))) - label.textColor = UIColor.ows_materialBlue() + label.textColor = controlTintColor label.font = labelFont() label.textAlignment = .center @@ -412,14 +423,14 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { let image = UIImage(named: "audio_play_black_large")?.withRenderingMode(.alwaysTemplate) assert(image != nil) audioPlayButton?.setImage(image, for: .normal) - audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() + audioPlayButton?.imageView?.tintColor = controlTintColor } private func setAudioIconToPause() { let image = UIImage(named: "audio_pause_black_large")?.withRenderingMode(.alwaysTemplate) assert(image != nil) audioPlayButton?.setImage(image, for: .normal) - audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() + audioPlayButton?.imageView?.tintColor = controlTintColor } // MARK: - Full Screen Image