mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Merge branch 'mkirk/share-audio'
This commit is contained in:
commit
481427bf90
2 changed files with 37 additions and 20 deletions
|
@ -121,22 +121,23 @@ public class AttachmentApprovalViewController: OWSViewController {
|
|||
containerView.autoMatch(.width, to: .width, of: self.view)
|
||||
|
||||
containerView.addSubview(mediaMessageView)
|
||||
mediaMessageView.autoCenterInSuperview()
|
||||
mediaMessageView.setCompressionResistanceHigh()
|
||||
mediaMessageView.autoPinEdgesToSuperviewEdges()
|
||||
|
||||
// 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))
|
||||
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))
|
||||
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
|
||||
|
@ -235,7 +236,12 @@ public class AttachmentApprovalViewController: OWSViewController {
|
|||
extension AttachmentApprovalViewController: UIScrollViewDelegate {
|
||||
|
||||
public func viewForZooming(in scrollView: UIScrollView) -> UIView? {
|
||||
return mediaMessageView
|
||||
if attachment.isImage || attachment.isVideo {
|
||||
return mediaMessageView
|
||||
} else {
|
||||
// don't zoom for audio or generic attachments.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func updateMinZoomScaleForSize(_ size: CGSize) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue