Fixup approval view for audio and generic attachments

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 26c76e6a0c
commit 73b215229f

@ -121,11 +121,11 @@ public class AttachmentApprovalViewController: OWSViewController {
containerView.autoMatch(.width, to: .width, of: self.view) containerView.autoMatch(.width, to: .width, of: self.view)
containerView.addSubview(mediaMessageView) containerView.addSubview(mediaMessageView)
mediaMessageView.autoCenterInSuperview() mediaMessageView.autoPinEdgesToSuperviewEdges()
mediaMessageView.setCompressionResistanceHigh()
if attachment.isImage || attachment.isVideo {
// Add top and bottom gradients to ensure toolbar controls are legible // Add top and bottom gradients to ensure toolbar controls are legible
// when placed over media with a clashing color // when placed over image/video preview which may be a clashing color.
let topGradient = GradientView(from: backgroundColor, to: UIColor.clear) let topGradient = GradientView(from: backgroundColor, to: UIColor.clear)
self.view.addSubview(topGradient) self.view.addSubview(topGradient)
topGradient.autoPinWidthToSuperview() topGradient.autoPinWidthToSuperview()
@ -137,6 +137,7 @@ public class AttachmentApprovalViewController: OWSViewController {
bottomGradient.autoPinWidthToSuperview() bottomGradient.autoPinWidthToSuperview()
bottomGradient.autoPinEdge(toSuperviewEdge: .bottom) bottomGradient.autoPinEdge(toSuperviewEdge: .bottom)
bottomGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(100)) bottomGradient.autoSetDimension(.height, toSize: ScaleFromIPhone5(100))
}
// Hide the play button embedded in the MediaView and replace it with our own. // 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 // This allows us to zoom in on the media view without zooming in on the button

@ -292,8 +292,10 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
private func createHeroViewSize() -> CGFloat { private func createHeroViewSize() -> CGFloat {
switch mode { switch mode {
case .large, .attachmentApproval: case .large:
return ScaleFromIPhone5To7Plus(175, 225) return ScaleFromIPhone5To7Plus(175, 225)
case .attachmentApproval:
return ScaleFromIPhone5(100)
case .small: case .small:
return ScaleFromIPhone5To7Plus(80, 80) 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? { private func formattedFileExtension() -> String? {
guard let fileExtension = attachment.fileExtension else { guard let fileExtension = attachment.fileExtension else {
return nil return nil
@ -357,7 +368,7 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let label = UILabel() let label = UILabel()
label.text = filename label.text = filename
label.textColor = UIColor.ows_materialBlue() label.textColor = controlTintColor
label.font = labelFont() label.font = labelFont()
label.textAlignment = .center label.textAlignment = .center
label.lineBreakMode = .byTruncatingMiddle 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'}}."), comment: "Format string for file size label in call interstitial view. Embeds: {{file size as 'N mb' or 'N kb'}}."),
OWSFormat.formatFileSize(UInt(fileSize))) OWSFormat.formatFileSize(UInt(fileSize)))
label.textColor = UIColor.ows_materialBlue() label.textColor = controlTintColor
label.font = labelFont() label.font = labelFont()
label.textAlignment = .center label.textAlignment = .center
@ -412,14 +423,14 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let image = UIImage(named: "audio_play_black_large")?.withRenderingMode(.alwaysTemplate) let image = UIImage(named: "audio_play_black_large")?.withRenderingMode(.alwaysTemplate)
assert(image != nil) assert(image != nil)
audioPlayButton?.setImage(image, for: .normal) audioPlayButton?.setImage(image, for: .normal)
audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() audioPlayButton?.imageView?.tintColor = controlTintColor
} }
private func setAudioIconToPause() { private func setAudioIconToPause() {
let image = UIImage(named: "audio_pause_black_large")?.withRenderingMode(.alwaysTemplate) let image = UIImage(named: "audio_pause_black_large")?.withRenderingMode(.alwaysTemplate)
assert(image != nil) assert(image != nil)
audioPlayButton?.setImage(image, for: .normal) audioPlayButton?.setImage(image, for: .normal)
audioPlayButton?.imageView?.tintColor = UIColor.ows_materialBlue() audioPlayButton?.imageView?.tintColor = controlTintColor
} }
// MARK: - Full Screen Image // MARK: - Full Screen Image

Loading…
Cancel
Save