vertically align input toolbar items

pull/1/head
Michael Kirk 7 years ago
parent 1a00690b17
commit 17f0400bb5

@ -126,10 +126,8 @@ const CGFloat kMaxTextViewHeight = 98;
UIImage *attachmentImage = [UIImage imageNamed:@"btnAttachments--blue"]; UIImage *attachmentImage = [UIImage imageNamed:@"btnAttachments--blue"];
[self.attachmentButton setImage:[attachmentImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] [self.attachmentButton setImage:[attachmentImage imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal]; forState:UIControlStateNormal];
self.attachmentButton.contentEdgeInsets = UIEdgeInsetsMake(0, 3, 0, 3);
self.attachmentButton.tintColor = UIColor.ows_navbarIconColor; self.attachmentButton.tintColor = UIColor.ows_navbarIconColor;
[self.attachmentButton setCompressionResistanceHigh]; [self.attachmentButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)];
[self.attachmentButton setContentHuggingHigh];
_sendButton = [UIButton buttonWithType:UIButtonTypeCustom]; _sendButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.sendButton [self.sendButton
@ -138,8 +136,8 @@ const CGFloat kMaxTextViewHeight = 98;
[self.sendButton setTitleColor:UIColor.ows_signalBlueColor forState:UIControlStateNormal]; [self.sendButton setTitleColor:UIColor.ows_signalBlueColor forState:UIControlStateNormal];
self.sendButton.titleLabel.textAlignment = NSTextAlignmentCenter; self.sendButton.titleLabel.textAlignment = NSTextAlignmentCenter;
self.sendButton.titleLabel.font = [UIFont ows_mediumFontWithSize:17.f]; self.sendButton.titleLabel.font = [UIFont ows_mediumFontWithSize:17.f];
[self.sendButton setCompressionResistanceHigh]; self.sendButton.contentEdgeInsets = UIEdgeInsetsMake(0, 4, 0, 4);
[self.sendButton setContentHuggingHigh]; [self.sendButton autoSetDimension:ALDimensionHeight toSize:kMinTextViewHeight];
[self.sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside]; [self.sendButton addTarget:self action:@selector(sendButtonPressed) forControlEvents:UIControlEventTouchUpInside];
UIImage *voiceMemoIcon = [UIImage imageNamed:@"voice-memo-button"]; UIImage *voiceMemoIcon = [UIImage imageNamed:@"voice-memo-button"];
@ -148,8 +146,7 @@ const CGFloat kMaxTextViewHeight = 98;
[self.voiceMemoButton setImage:[voiceMemoIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate] [self.voiceMemoButton setImage:[voiceMemoIcon imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]
forState:UIControlStateNormal]; forState:UIControlStateNormal];
self.voiceMemoButton.imageView.tintColor = UIColor.ows_navbarIconColor; self.voiceMemoButton.imageView.tintColor = UIColor.ows_navbarIconColor;
[self.voiceMemoButton setCompressionResistanceHigh]; [self.voiceMemoButton autoSetDimensionsToSize:CGSizeMake(40, kMinTextViewHeight)];
[self.voiceMemoButton setContentHuggingHigh];
// We want to be permissive about the voice message gesture, so we hang // We want to be permissive about the voice message gesture, so we hang
// the long press GR on the button's wrapper, not the button itself. // the long press GR on the button's wrapper, not the button itself.
@ -157,22 +154,23 @@ const CGFloat kMaxTextViewHeight = 98;
[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
longPressGestureRecognizer.minimumPressDuration = 0; longPressGestureRecognizer.minimumPressDuration = 0;
longPressGestureRecognizer.delegate = self; longPressGestureRecognizer.delegate = self;
[self.voiceMemoButton addGestureRecognizer:longPressGestureRecognizer];
self.userInteractionEnabled = YES; self.userInteractionEnabled = YES;
_composeRow = [[UIStackView alloc] _composeRow = [[UIStackView alloc]
initWithArrangedSubviews:@[ self.attachmentButton, self.inputTextView, self.voiceMemoButton, self.sendButton ]]; initWithArrangedSubviews:@[ self.attachmentButton, self.inputTextView, self.voiceMemoButton, self.sendButton ]];
_composeRow.axis = UILayoutConstraintAxisHorizontal; self.composeRow.axis = UILayoutConstraintAxisHorizontal;
_composeRow.layoutMarginsRelativeArrangement = YES; self.composeRow.layoutMarginsRelativeArrangement = YES;
_composeRow.layoutMargins = UIEdgeInsetsMake(6, 8, 6, 8); self.composeRow.layoutMargins = UIEdgeInsetsMake(6, 6, 6, 6);
_composeRow.alignment = UIStackViewAlignmentBottom; self.composeRow.alignment = UIStackViewAlignmentBottom;
_composeRow.spacing = 8; self.composeRow.spacing = 8;
_contentRows = [[UIStackView alloc] initWithArrangedSubviews:@[ _composeRow ]]; _contentRows = [[UIStackView alloc] initWithArrangedSubviews:@[ self.composeRow ]];
_contentRows.axis = UILayoutConstraintAxisVertical; self.contentRows.axis = UILayoutConstraintAxisVertical;
[self addSubview:_contentRows]; [self addSubview:self.contentRows];
[_contentRows autoPinEdgesToSuperviewEdges]; [self.contentRows autoPinEdgesToSuperviewEdges];
[self ensureShouldShowVoiceMemoButtonAnimated:NO]; [self ensureShouldShowVoiceMemoButtonAnimated:NO];
} }

Loading…
Cancel
Save