make sure mediaview isn't too tall in detail view

// FREEBIE
This commit is contained in:
sdkjfhsdkjhfsdlkjhfsdf 2017-12-19 17:59:34 -06:00
parent 411de65b40
commit 2c20cb9e7b
2 changed files with 17 additions and 1 deletions

View file

@ -300,7 +300,7 @@ class MessageDetailViewController: OWSViewController, UIScrollViewDelegate {
}
if let mediaMessageView = mediaMessageView {
mediaMessageView.autoPinToSquareAspectRatio()
mediaMessageView.autoMatch(.height, to: .width, of: mediaMessageView, withOffset:0, relation: .lessThanOrEqual)
}
}

View file

@ -172,8 +172,16 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let stackView = wrapViewsInVerticalStack(subviews: subviews)
self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32)
// We want to center the stackView in it's superview while ensuring
// it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview()
NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultLow) {
stackView.autoPinHeightToSuperview()
}
stackView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
stackView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual)
}
private func createAnimatedPreview() {
@ -286,8 +294,16 @@ public class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate {
let stackView = wrapViewsInVerticalStack(subviews: subviews)
self.addSubview(stackView)
fileNameLabel?.autoPinWidthToSuperview(withMargin: 32)
// We want to center the stackView in it's superview while ensuring
// it's superview is big enough to contain it.
stackView.autoPinWidthToSuperview()
stackView.autoVCenterInSuperview()
NSLayoutConstraint.autoSetPriority(UILayoutPriorityDefaultLow) {
stackView.autoPinHeightToSuperview()
}
stackView.autoPinEdge(toSuperviewEdge: .top, withInset: 0, relation: .greaterThanOrEqual)
stackView.autoPinEdge(toSuperviewEdge: .bottom, withInset: 0, relation: .greaterThanOrEqual)
}
private func createHeroViewSize() -> CGFloat {