|
|
@ -79,13 +79,11 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
|
|
|
|
// using iOS auto layout.
|
|
|
|
// using iOS auto layout.
|
|
|
|
_leftButtonWrapper = [UIView containerView];
|
|
|
|
_leftButtonWrapper = [UIView containerView];
|
|
|
|
[self.leftButtonWrapper
|
|
|
|
[self.leftButtonWrapper
|
|
|
|
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
|
|
|
|
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(leftButtonTapped:)]];
|
|
|
|
action:@selector(leadingButtonTapped:)]];
|
|
|
|
|
|
|
|
[self addSubview:self.leftButtonWrapper];
|
|
|
|
[self addSubview:self.leftButtonWrapper];
|
|
|
|
_rightButtonWrapper = [UIView containerView];
|
|
|
|
_rightButtonWrapper = [UIView containerView];
|
|
|
|
[self.rightButtonWrapper
|
|
|
|
[self.rightButtonWrapper
|
|
|
|
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self
|
|
|
|
addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(rightButtonTapped:)]];
|
|
|
|
action:@selector(trailingButtonTapped:)]];
|
|
|
|
|
|
|
|
[self addSubview:self.rightButtonWrapper];
|
|
|
|
[self addSubview:self.rightButtonWrapper];
|
|
|
|
|
|
|
|
|
|
|
|
_attachmentButton = [[UIButton alloc] init];
|
|
|
|
_attachmentButton = [[UIButton alloc] init];
|
|
|
@ -207,24 +205,24 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
|
|
|
|
const CGFloat textViewHeight = ceil(MAX(kMinTextViewHeight, MIN(kMaxTextViewHeight, textViewDesiredHeight)));
|
|
|
|
const CGFloat textViewHeight = ceil(MAX(kMinTextViewHeight, MIN(kMaxTextViewHeight, textViewDesiredHeight)));
|
|
|
|
const CGFloat kMinContentHeight = kMinTextViewHeight + textViewVInset * 2;
|
|
|
|
const CGFloat kMinContentHeight = kMinTextViewHeight + textViewVInset * 2;
|
|
|
|
|
|
|
|
|
|
|
|
UIButton *leadingButton = self.attachmentButton;
|
|
|
|
UIButton *leftButton = self.attachmentButton;
|
|
|
|
UIButton *trailingButton = (self.shouldShowVoiceMemoButton ? self.voiceMemoButton : self.sendButton);
|
|
|
|
UIButton *rightButton = (self.shouldShowVoiceMemoButton ? self.voiceMemoButton : self.sendButton);
|
|
|
|
UIButton *inactiveTrailingButton = (self.shouldShowVoiceMemoButton ? self.sendButton : self.voiceMemoButton);
|
|
|
|
UIButton *inactiveRightButton = (self.shouldShowVoiceMemoButton ? self.sendButton : self.voiceMemoButton);
|
|
|
|
leadingButton.enabled = YES;
|
|
|
|
leftButton.enabled = YES;
|
|
|
|
trailingButton.enabled = YES;
|
|
|
|
rightButton.enabled = YES;
|
|
|
|
inactiveTrailingButton.enabled = NO;
|
|
|
|
inactiveRightButton.enabled = NO;
|
|
|
|
leadingButton.hidden = NO;
|
|
|
|
leftButton.hidden = NO;
|
|
|
|
trailingButton.hidden = NO;
|
|
|
|
rightButton.hidden = NO;
|
|
|
|
inactiveTrailingButton.hidden = YES;
|
|
|
|
inactiveRightButton.hidden = YES;
|
|
|
|
|
|
|
|
|
|
|
|
[leadingButton setContentHuggingHigh];
|
|
|
|
[leftButton setContentHuggingHigh];
|
|
|
|
[trailingButton setContentHuggingHigh];
|
|
|
|
[rightButton setContentHuggingHigh];
|
|
|
|
[leadingButton setCompressionResistanceHigh];
|
|
|
|
[leftButton setCompressionResistanceHigh];
|
|
|
|
[trailingButton setCompressionResistanceHigh];
|
|
|
|
[rightButton setCompressionResistanceHigh];
|
|
|
|
[self.inputTextView setContentHuggingLow];
|
|
|
|
[self.inputTextView setContentHuggingLow];
|
|
|
|
|
|
|
|
|
|
|
|
OWSAssert(leadingButton.superview == self.leftButtonWrapper);
|
|
|
|
OWSAssert(leftButton.superview == self.leftButtonWrapper);
|
|
|
|
OWSAssert(trailingButton.superview == self.rightButtonWrapper);
|
|
|
|
OWSAssert(rightButton.superview == self.rightButtonWrapper);
|
|
|
|
|
|
|
|
|
|
|
|
// The leading and trailing buttons should be center-aligned with the
|
|
|
|
// The leading and trailing buttons should be center-aligned with the
|
|
|
|
// inputTextView when the inputTextView is at its minimum size.
|
|
|
|
// inputTextView when the inputTextView is at its minimum size.
|
|
|
@ -242,10 +240,10 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
|
|
|
|
[self.leftButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop],
|
|
|
|
[self.leftButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop],
|
|
|
|
[self.leftButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
[self.leftButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
|
|
|
|
|
|
|
|
[leadingButton autoSetDimension:ALDimensionHeight toSize:kMinContentHeight],
|
|
|
|
[leftButton autoSetDimension:ALDimensionHeight toSize:kMinContentHeight],
|
|
|
|
[leadingButton autoPinLeadingToSuperviewWithMargin:contentHInset],
|
|
|
|
[leftButton autoPinLeadingToSuperviewWithMargin:contentHInset],
|
|
|
|
[leadingButton autoPinTrailingToSuperviewWithMargin:contentHSpacing],
|
|
|
|
[leftButton autoPinTrailingToSuperviewWithMargin:contentHSpacing],
|
|
|
|
[leadingButton autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
[leftButton autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
|
|
|
|
|
|
|
|
[self.inputTextView autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.leftButtonWrapper],
|
|
|
|
[self.inputTextView autoPinEdge:ALEdgeLeft toEdge:ALEdgeRight ofView:self.leftButtonWrapper],
|
|
|
|
[self.inputTextView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:textViewVInset],
|
|
|
|
[self.inputTextView autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:textViewVInset],
|
|
|
@ -257,10 +255,10 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
|
|
|
|
[self.rightButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop],
|
|
|
|
[self.rightButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeTop],
|
|
|
|
[self.rightButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
[self.rightButtonWrapper autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
|
|
|
|
|
|
|
|
[trailingButton autoSetDimension:ALDimensionHeight toSize:kMinContentHeight],
|
|
|
|
[rightButton autoSetDimension:ALDimensionHeight toSize:kMinContentHeight],
|
|
|
|
[trailingButton autoPinLeadingToSuperviewWithMargin:contentHSpacing],
|
|
|
|
[rightButton autoPinLeadingToSuperviewWithMargin:contentHSpacing],
|
|
|
|
[trailingButton autoPinTrailingToSuperviewWithMargin:contentHInset],
|
|
|
|
[rightButton autoPinTrailingToSuperviewWithMargin:contentHInset],
|
|
|
|
[trailingButton autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
[rightButton autoPinEdgeToSuperviewEdge:ALEdgeBottom],
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
[self layoutIfNeeded];
|
|
|
|
[self layoutIfNeeded];
|
|
|
@ -544,14 +542,14 @@ static void *kConversationInputTextViewObservingContext = &kConversationInputTex
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Event Handlers
|
|
|
|
#pragma mark - Event Handlers
|
|
|
|
|
|
|
|
|
|
|
|
- (void)leadingButtonTapped:(UIGestureRecognizer *)sender
|
|
|
|
- (void)leftButtonTapped:(UIGestureRecognizer *)sender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (sender.state == UIGestureRecognizerStateRecognized) {
|
|
|
|
if (sender.state == UIGestureRecognizerStateRecognized) {
|
|
|
|
[self attachmentButtonPressed];
|
|
|
|
[self attachmentButtonPressed];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)trailingButtonTapped:(UIGestureRecognizer *)sender
|
|
|
|
- (void)rightButtonTapped:(UIGestureRecognizer *)sender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (sender.state == UIGestureRecognizerStateRecognized) {
|
|
|
|
if (sender.state == UIGestureRecognizerStateRecognized) {
|
|
|
|
if (!self.shouldShowVoiceMemoButton) {
|
|
|
|
if (!self.shouldShowVoiceMemoButton) {
|
|
|
|