Merge branch 'charlesmchen/quotedReplyMargins'

pull/1/head
Matthew Chen 7 years ago
commit 6ea3c13738

@ -47,7 +47,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
#pragma mark - #pragma mark -
@property (nonatomic, nullable) QuotedReplyPreview *quotedMessagePreview; @property (nonatomic, nullable) UIView *quotedMessagePreview;
#pragma mark - Voice Memo Recording UI #pragma mark - Voice Memo Recording UI
@ -92,6 +92,7 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
// to determine the height of the rendered inputAccessoryView. // to determine the height of the rendered inputAccessoryView.
CGFloat height = self.toolbarHeight + ConversationInputToolbarBorderViewHeight; CGFloat height = self.toolbarHeight + ConversationInputToolbarBorderViewHeight;
if (self.quotedMessagePreview) { if (self.quotedMessagePreview) {
height += self.quotedMessageTopMargin;
height += self.quotedMessagePreview.intrinsicContentSize.height; height += self.quotedMessagePreview.intrinsicContentSize.height;
} }
CGSize newSize = CGSizeMake(self.bounds.size.width, height); CGSize newSize = CGSizeMake(self.bounds.size.width, height);
@ -284,11 +285,23 @@ static const CGFloat ConversationInputToolbarBorderViewHeight = 0.5;
return; return;
} }
self.quotedMessagePreview = [[QuotedReplyPreview alloc] initWithQuotedReply:quotedReply conversationStyle:self.conversationStyle]; QuotedReplyPreview *quotedMessagePreview =
self.quotedMessagePreview.delegate = self; [[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 // TODO animate
[self.contentStackView insertArrangedSubview:self.quotedMessagePreview atIndex:0]; [self.contentStackView insertArrangedSubview:wrapper atIndex:0];
self.quotedMessagePreview = wrapper;
}
- (CGFloat)quotedMessageTopMargin
{
return 5.f;
} }
- (void)clearQuotedMessagePreview - (void)clearQuotedMessagePreview

@ -28,6 +28,7 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value);
- (NSArray<NSLayoutConstraint *> *)autoPinHeightToSuperview; - (NSArray<NSLayoutConstraint *> *)autoPinHeightToSuperview;
- (NSArray<NSLayoutConstraint *> *)autoPinToSuperviewEdges; - (NSArray<NSLayoutConstraint *> *)autoPinToSuperviewEdges;
- (NSArray<NSLayoutConstraint *> *)autoPinToSuperviewMargins;
- (NSLayoutConstraint *)autoHCenterInSuperview; - (NSLayoutConstraint *)autoHCenterInSuperview;
- (NSLayoutConstraint *)autoVCenterInSuperview; - (NSLayoutConstraint *)autoVCenterInSuperview;

@ -90,6 +90,17 @@ CGFloat ScaleFromIPhone5(CGFloat iPhone5Value)
return result; return result;
} }
- (NSArray<NSLayoutConstraint *> *)autoPinToSuperviewMargins
{
NSArray<NSLayoutConstraint *> *result = @[
[self autoPinTopToSuperviewMargin],
[self autoPinLeadingToSuperviewMargin],
[self autoPinTrailingToSuperviewMargin],
[self autoPinBottomToSuperviewMargin],
];
return result;
}
- (NSLayoutConstraint *)autoHCenterInSuperview - (NSLayoutConstraint *)autoHCenterInSuperview
{ {
return [self autoAlignAxis:ALAxisVertical toSameAxisOfView:self.superview]; return [self autoAlignAxis:ALAxisVertical toSameAxisOfView:self.superview];

Loading…
Cancel
Save