From c1f35a0ea6bbbb90a647cb577c902b76f0141334 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 24 Oct 2017 09:41:03 -0400 Subject: [PATCH] Respond to CR. // FREEBIE --- .../ConversationView/ConversationInputToolbar.m | 3 ++- Signal/src/ViewControllers/MediaMessageView.swift | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index bde8022fc3..a0a675f4d0 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -4,6 +4,7 @@ #import "ConversationInputToolbar.h" #import "ConversationInputTextView.h" +#import "OWSMath.h" #import "Signal-Swift.h" #import "UIColor+OWS.h" #import "UIFont+OWS.h" @@ -222,7 +223,7 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex const CGFloat kMaxTextViewHeight = 100.f; const CGFloat textViewDesiredHeight = (self.inputTextView.contentSize.height + self.inputTextView.contentInset.top + self.inputTextView.contentInset.bottom); - const CGFloat textViewHeight = ceil(MAX(kMinTextViewHeight, MIN(kMaxTextViewHeight, textViewDesiredHeight))); + const CGFloat textViewHeight = ceil(Clamp(textViewDesiredHeight, kMinTextViewHeight, kMaxTextViewHeight)); const CGFloat kMinContentHeight = kMinTextViewHeight + textViewVInset * 2; if (self.attachmentToApprove) { diff --git a/Signal/src/ViewControllers/MediaMessageView.swift b/Signal/src/ViewControllers/MediaMessageView.swift index 6ca66713ba..2449d6b008 100644 --- a/Signal/src/ViewControllers/MediaMessageView.swift +++ b/Signal/src/ViewControllers/MediaMessageView.swift @@ -173,6 +173,11 @@ class MediaMessageView: UIView, OWSAudioAttachmentPlayerDelegate { private func addSubviewWithScaleAspectFitLayout(view: UIView, aspectRatio: CGFloat) { self.addSubview(view) + // This emulates the behavior of contentMode = .scaleAspectFit using + // iOS auto layout constraints. + // + // This allows ConversationInputToolbar to place the "cancel" button + // in the upper-right hand corner of the preview content. view.autoCenterInSuperview() view.autoPin(toAspectRatio:aspectRatio) view.autoMatch(.width, to: .width, of: self, withMultiplier: 1.0, relation: .lessThanOrEqual)