From bc527273f26103dfe44544d26e541353aa17c45a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 2 Jul 2018 15:58:28 -0400 Subject: [PATCH 1/2] Fix quoted reply margin. --- .../ConversationView/ConversationInputToolbar.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index 7a7fc7824..ab5bf1ad7 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -92,6 +92,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; // to determine the height of the rendered inputAccessoryView. CGFloat height = self.toolbarHeight + ConversationInputToolbarBorderViewHeight; if (self.quotedMessagePreview) { + height += self.quotedMessageTopMargin; height += self.quotedMessagePreview.intrinsicContentSize.height; } CGSize newSize = CGSizeMake(self.bounds.size.width, height); @@ -127,6 +128,8 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; _composeContainer = [UIView containerView]; _contentStackView = [[UIStackView alloc] initWithArrangedSubviews:@[ _composeContainer ]]; _contentStackView.axis = UILayoutConstraintAxisVertical; + _contentStackView.layoutMargins = UIEdgeInsetsZero; + _contentStackView.layoutMarginsRelativeArrangement = YES; [self addSubview:_contentStackView]; [_contentStackView autoPinEdgesToSuperviewEdges]; @@ -289,6 +292,12 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; // TODO animate [self.contentStackView insertArrangedSubview:self.quotedMessagePreview atIndex:0]; + self.contentStackView.layoutMargins = UIEdgeInsetsMake(self.quotedMessageTopMargin, 0, 0, 0); +} + +- (CGFloat)quotedMessageTopMargin +{ + return 5.f; } - (void)clearQuotedMessagePreview @@ -299,6 +308,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; [self.quotedMessagePreview removeFromSuperview]; self.quotedMessagePreview = nil; } + self.contentStackView.layoutMargins = UIEdgeInsetsZero; } - (void)beginEditingTextMessage From 05b1b37eab80847b8be5b86a80ea90fa26edd902 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Mon, 2 Jul 2018 16:35:30 -0400 Subject: [PATCH 2/2] Respond to CR. --- .../ConversationInputToolbar.m | 19 +++++++++++-------- SignalMessaging/categories/UIView+OWS.h | 1 + SignalMessaging/categories/UIView+OWS.m | 11 +++++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m index ab5bf1ad7..9c6ece9cf 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationInputToolbar.m @@ -47,7 +47,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; #pragma mark - -@property (nonatomic, nullable) QuotedReplyPreview *quotedMessagePreview; +@property (nonatomic, nullable) UIView *quotedMessagePreview; #pragma mark - Voice Memo Recording UI @@ -128,8 +128,6 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; _composeContainer = [UIView containerView]; _contentStackView = [[UIStackView alloc] initWithArrangedSubviews:@[ _composeContainer ]]; _contentStackView.axis = UILayoutConstraintAxisVertical; - _contentStackView.layoutMargins = UIEdgeInsetsZero; - _contentStackView.layoutMarginsRelativeArrangement = YES; [self addSubview:_contentStackView]; [_contentStackView autoPinEdgesToSuperviewEdges]; @@ -287,12 +285,18 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; return; } - self.quotedMessagePreview = [[QuotedReplyPreview alloc] initWithQuotedReply:quotedReply conversationStyle:self.conversationStyle]; - self.quotedMessagePreview.delegate = self; + QuotedReplyPreview *quotedMessagePreview = + [[QuotedReplyPreview alloc] initWithQuotedReply:quotedReply conversationStyle:self.conversationStyle]; + quotedMessagePreview.delegate = self; + + UIView *wrapper = [UIView containerView]; + wrapper.layoutMargins = UIEdgeInsetsMake(self.quotedMessageTopMargin, 0, 0, 0); + [wrapper addSubview:quotedMessagePreview]; + [quotedMessagePreview autoPinToSuperviewMargins]; // TODO animate - [self.contentStackView insertArrangedSubview:self.quotedMessagePreview atIndex:0]; - self.contentStackView.layoutMargins = UIEdgeInsetsMake(self.quotedMessageTopMargin, 0, 0, 0); + [self.contentStackView insertArrangedSubview:wrapper atIndex:0]; + self.quotedMessagePreview = wrapper; } - (CGFloat)quotedMessageTopMargin @@ -308,7 +312,6 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5; [self.quotedMessagePreview removeFromSuperview]; self.quotedMessagePreview = nil; } - self.contentStackView.layoutMargins = UIEdgeInsetsZero; } - (void)beginEditingTextMessage diff --git a/SignalMessaging/categories/UIView+OWS.h b/SignalMessaging/categories/UIView+OWS.h index e6998635d..cd9a9b79f 100644 --- a/SignalMessaging/categories/UIView+OWS.h +++ b/SignalMessaging/categories/UIView+OWS.h @@ -28,6 +28,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value); - (NSArray *)autoPinHeightToSuperview; - (NSArray *)autoPinToSuperviewEdges; +- (NSArray *)autoPinToSuperviewMargins; - (NSLayoutConstraint *)autoHCenterInSuperview; - (NSLayoutConstraint *)autoVCenterInSuperview; diff --git a/SignalMessaging/categories/UIView+OWS.m b/SignalMessaging/categories/UIView+OWS.m index df4323ce6..5fa542ce9 100644 --- a/SignalMessaging/categories/UIView+OWS.m +++ b/SignalMessaging/categories/UIView+OWS.m @@ -90,6 +90,17 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value) return result; } +- (NSArray *)autoPinToSuperviewMargins +{ + NSArray *result = @[ + [self autoPinTopToSuperviewMargin], + [self autoPinLeadingToSuperviewMargin], + [self autoPinTrailingToSuperviewMargin], + [self autoPinBottomToSuperviewMargin], + ]; + return result; +} + - (NSLayoutConstraint *)autoHCenterInSuperview { return [self autoAlignAxis:ALAxisVertical toSameAxisOfView:self.superview];