Skip to content

Commit 83eb507

Browse files
authored
Add barState and InputBarDelegate to SLKTextInputbar (#2)
1 parent d45e19d commit 83eb507

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Source/SLKTextInputbar.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,24 @@ typedef NS_ENUM(NSUInteger, SLKCounterPosition) {
2323
SLKCounterPositionBottom
2424
};
2525

26+
typedef NS_ENUM(NSUInteger, SLKInputBarState) {
27+
SLKInputBarStateNormal,
28+
SLKInputBarStateHighlight,
29+
SLKInputBarStateDisabled
30+
};
31+
32+
@protocol SLKInputBarViewDelegate <NSObject>
33+
- (void)barStateDidChange:(SLKInputBarState)state;
34+
@end
35+
2636
NS_ASSUME_NONNULL_BEGIN
2737

2838
/** @name A custom tool bar encapsulating messaging controls. */
2939
@interface SLKTextInputbar : UIToolbar
3040

41+
@property (nonatomic, assign) SLKInputBarState barState;
42+
@property (nonatomic, weak) id<SLKInputBarViewDelegate> barDelegate;
43+
3144
/** The centered text input view.
3245
The maximum number of lines is configured by default, to best fit each devices dimensions.
3346
For iPhone 4 (<=480pts): 4 lines

Source/SLKTextInputbar.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,26 @@ - (void)slk_commonInit
102102
[self slk_registerTo:self.layer forSelector:@selector(position)];
103103
[self slk_registerTo:self.leftButton.imageView forSelector:@selector(image)];
104104
[self slk_registerTo:self.rightButton.titleLabel forSelector:@selector(font)];
105+
106+
self.barState = SLKInputBarStateNormal;
107+
}
108+
109+
#pragma mark - SLKInputBarViewDelegate
110+
111+
- (void)setBarDelegate:(id<SLKInputBarViewDelegate>)barDelegate
112+
{
113+
_barDelegate = barDelegate;
114+
self.barState = SLKInputBarStateNormal;
105115
}
106116

117+
- (void)setBarState:(SLKInputBarState)barState
118+
{
119+
if ([self.barDelegate respondsToSelector:@selector(barStateDidChange:)]) {
120+
[self.barDelegate barStateDidChange:barState];
121+
}
122+
123+
_barState = barState;
124+
}
107125

108126
#pragma mark - UIView Overrides
109127

0 commit comments

Comments
 (0)