Skip to content

Commit 807320e

Browse files
author
Henrique Valcanaia
committed
LIVE-225: Add left button image and text support
https://github.com/slackhq/SlackTextViewController/pull/654/files
1 parent ec03a3b commit 807320e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Source/SLKTextInputbar.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ - (void)slk_commonInit
105105

106106
[self slk_registerTo:self.layer forSelector:@selector(position)];
107107
[self slk_registerTo:self.leftButton.imageView forSelector:@selector(image)];
108+
[self slk_registerTo:self.leftButton.titleLabel forSelector:@selector(font)];
109+
[self slk_registerTo:self.leftButton.titleLabel forSelector:@selector(text)];
108110
[self slk_registerTo:self.rightButton.titleLabel forSelector:@selector(font)];
109111
}
110112

@@ -746,7 +748,7 @@ - (void)slk_updateConstraintConstants
746748
else {
747749
self.editorContentViewHC.constant = zero;
748750

749-
CGSize leftButtonSize = [self.leftButton imageForState:self.leftButton.state].size;
751+
CGSize leftButtonSize = self.leftButton.intrinsicContentSize;
750752

751753
if (leftButtonSize.width > 0) {
752754
self.leftButtonHC.constant = roundf(leftButtonSize.height);
@@ -802,6 +804,11 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
802804
[self slk_updateConstraintConstants];
803805
}
804806
}
807+
else if ([object isEqual:self.leftButton.titleLabel] &&
808+
([keyPath isEqualToString:NSStringFromSelector(@selector(font))]
809+
|| [keyPath isEqualToString:NSStringFromSelector(@selector(text))])) {
810+
[self slk_updateConstraintConstants];
811+
}
805812
else if ([object isEqual:self.rightButton.titleLabel] && [keyPath isEqualToString:NSStringFromSelector(@selector(font))]) {
806813

807814
[self slk_updateConstraintConstants];
@@ -839,6 +846,8 @@ - (void)dealloc
839846

840847
[self slk_unregisterFrom:self.layer forSelector:@selector(position)];
841848
[self slk_unregisterFrom:self.leftButton.imageView forSelector:@selector(image)];
849+
[self slk_unregisterFrom:self.leftButton.titleLabel forSelector:@selector(font)];
850+
[self slk_unregisterFrom:self.leftButton.titleLabel forSelector:@selector(text)];
842851
[self slk_unregisterFrom:self.rightButton.titleLabel forSelector:@selector(font)];
843852
}
844853

0 commit comments

Comments
 (0)