This repository was archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathSLKTextInputbar.h
More file actions
160 lines (114 loc) · 5.63 KB
/
SLKTextInputbar.h
File metadata and controls
160 lines (114 loc) · 5.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
//
// SlackTextViewController
// https://github.com/slackhq/SlackTextViewController
//
// Copyright 2014-2016 Slack Technologies, Inc.
// Licence: MIT-Licence
//
#import <UIKit/UIKit.h>
@class SLKTextView;
@class SLKInputAccessoryView;
typedef NS_ENUM(NSUInteger, SLKCounterStyle) {
SLKCounterStyleNone,
SLKCounterStyleSplit,
SLKCounterStyleCountdown,
SLKCounterStyleCountdownReversed
};
typedef NS_ENUM(NSUInteger, SLKCounterPosition) {
SLKCounterPositionTop,
SLKCounterPositionBottom
};
NS_ASSUME_NONNULL_BEGIN
/** @name A custom tool bar encapsulating messaging controls. */
@interface SLKTextInputbar : UIToolbar
/** The centered text input view.
The maximum number of lines is configured by default, to best fit each devices dimensions.
For iPhone 4 (<=480pts): 4 lines
For iPhone 5 & 6 (>=568pts): 6 lines
For iPad (>=768pts): 8 lines
*/
@property (nonatomic, readonly, strong) SLKTextView *textView;
/** Optional view to host outlets under the text view, adjusting its height based on its subviews. Non-visible by default. Subviews' layout should be configured using auto-layout as well. */
@property (nonatomic, readonly, strong) UIView *contentView;
/** The custom input accessory view, used as empty achor view to detect the keyboard frame. */
@property (nonatomic, readonly, strong) SLKInputAccessoryView *inputAccessoryView;
/** The left action button action. */
@property (nonatomic, strong) UIButton *leftButton;
/** The right action button action. */
@property (nonatomic, strong) UIButton *rightButton;
/** YES if the right button should be hidden animatedly in case the text view has no text in it. Default is YES. */
@property (nonatomic, readwrite) BOOL leftButtonIsHidden;
/** YES if the right button should be hidden animatedly in case the text view has no text in it. Default is YES. */
@property (nonatomic, readwrite) BOOL autoHideRightButton;
/** YES if animations should have bouncy effects. Default is YES. */
@property (nonatomic, assign) BOOL bounces;
/** The inner padding to use when laying out content in the view. Default is {5, 8, 5, 8}. */
@property (nonatomic, assign) UIEdgeInsets contentInset;
/** The minimum height based on the intrinsic content size's. */
@property (nonatomic, readonly) CGFloat minimumInputbarHeight;
/** The most appropriate height calculated based on the amount of lines of text and other factors. */
@property (nonatomic, readonly) CGFloat appropriateHeight;
#pragma mark - Initialization
///------------------------------------------------
/// @name Initialization
///------------------------------------------------
/**
Initializes a text input bar with a class to be used for the text view
@param textViewClass The class to be used when creating the text view. May be nil. If provided, the class must be a subclass of SLKTextView
@return An initialized SLKTextInputbar object or nil if the object could not be created.
*/
- (instancetype)initWithTextViewClass:(Class)textViewClass;
#pragma mark - Text Editing
///------------------------------------------------
/// @name Text Editing
///------------------------------------------------
/** The view displayed on top if the text input bar, containing the button outlets, when editing is enabled. */
@property (nonatomic, strong) UIView *editorContentView;
/** The title label displayed in the middle of the accessoryView. */
@property (nonatomic, strong) UILabel *editorTitle;
/** The 'cancel' button displayed left in the accessoryView. */
@property (nonatomic, strong) UIButton *editorLeftButton;
/** The 'accept' button displayed right in the accessoryView. */
@property (nonatomic, strong) UIButton *editorRightButton;
/** The accessory view's maximum height. Default is 38 pts. */
@property (nonatomic, assign) CGFloat editorContentViewHeight;
/** A Boolean value indicating whether the control is in edit mode. */
@property (nonatomic, getter = isEditing) BOOL editing;
/**
Verifies if the text can be edited.
@param text The text to be edited.
@return YES if the text is editable.
*/
- (BOOL)canEditText:(NSString *)text;
/**
Begins editing the text, by updating the 'editing' flag and the view constraints.
*/
- (void)beginTextEditing;
/**
End editing the text, by updating the 'editing' flag and the view constraints.
*/
- (void)endTextEdition;
/**
Set hidden state for left button.
*/
- (void)setLeftButtonHidden:(BOOL)isHidden;
#pragma mark - Text Counting
///------------------------------------------------
/// @name Text Counting
///------------------------------------------------
/** The label used to display the character counts. */
@property (nonatomic, readonly) UILabel *charCountLabel;
/** The maximum character count allowed. If larger than 0, a character count label will be displayed on top of the right button. Default is 0, which means limitless.*/
@property (nonatomic, readwrite) NSUInteger maxCharCount;
/** The character counter formatting. Ignored if maxCharCount is 0. Default is None. */
@property (nonatomic, assign) SLKCounterStyle counterStyle;
/** The character counter layout style. Ignored if maxCharCount is 0. Default is SLKCounterPositionTop. */
@property (nonatomic, assign) SLKCounterPosition counterPosition;
/** YES if the maxmimum character count has been exceeded. */
@property (nonatomic, readonly) BOOL limitExceeded;
/** The normal color used for character counter label. Default is lightGrayColor. */
@property (nonatomic, strong, readwrite) UIColor *charCountLabelNormalColor;
/** The color used for character counter label when it has exceeded the limit. Default is redColor. */
@property (nonatomic, strong, readwrite) UIColor *charCountLabelWarningColor;
@end
NS_ASSUME_NONNULL_END