You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A drop-in (and non-hacky) replacement of UITableViewController & UICollectionViewController, with growing text view and many other useful chat features. SCKChatViewController has beeen designed as a template view controller to be subclassed, overriding forward methods for performing additional logic.
6
+
A drop-in UIViewController subclass with a growing text input view and other useful messaging features. Meant to be a replacement for UITableViewController & UICollectionViewController.
7
7
8
-
This library is part of Slack's iOS UI foundations, specially designed and coded to best fit its needs, while still being flexible enough to be reused by others wanting to build great chat clients for iOS.
8
+
This library is used in Slack's iOS app. It was built to fit our needs, but is flexible enough to be reused by others wanting to build great messaging apps for iOS.
9
9
10
10
## Features
11
11
12
12
### Core
13
-
- UITableView/UICollectionView support
14
-
- Works completly with Auto-Layout, being flexible enough to any iOS8 Size Classes
15
-
- Totally customizable by exposing left and right buttons, text view and tool bar.
16
-
- Auto-expanding text view, with lines limit support
17
-
- Auto-completion mode by registering any prefix key (@,#,/, and so on)
18
-
- Tap gesture for dissmissing text input
19
-
- Useful text appending APIs
20
-
- External keyboard support for basic commands.
21
-
- Auto-orientation support
13
+
- iOS 7 and iOS 8
14
+
- iPhone 6 compatible
15
+
- iPad compatible
16
+
- Support for UITableView and UICollectionView
17
+
- Built with Auto Layout
18
+
- Customizable: provides left and right button, and toolbar outlets
19
+
- Growing text view, with line count limit support
20
+
- Autocomplete mode by registering any prefix key (`@`, `#`, `/`)
21
+
- Tap gesture for dismissing the keyboard
22
+
- Text append APIs
23
+
- External keyboard support for basic commands
24
+
- Rotation support
22
25
- Localization support
23
-
- iPhone and iPad support
24
-
- iOS 7 and 8 compatible
25
26
26
27
### Optional
27
-
-Edition mode
28
-
-Typing indicator display (as user name list)
29
-
-Panning gesture for gradually dissmissing the text input and keyboard
30
-
- Shake gesture for undoing typed text
28
+
-Edit mode
29
+
-"User is typing..." indicator display
30
+
-Pan gesture for sliding down the keyboard
31
+
- Shake gesture for undo
31
32
- Image pasting support
32
-
- Left accesorry button
33
-
- Inverted mode for displaying cells from bottom (using CATransform)
34
-
- bouncing effect in animations
33
+
- Inverted mode for displaying cells upside-down (using CATransform) -- a necessary hack for some messaging apps (including ours)
34
+
- Bouncy animations
35
35
36
36
## Installation
37
37
38
-
Available in [Cocoa Pods](http://cocoapods.org/?q=SlackChatKit)
38
+
Available in [Cocoa Pods](http://cocoapods.org/?q=SlackTextViewController)
39
39
```
40
-
pod 'SlackChatKit'
40
+
pod 'SlackTextViewController'
41
41
```
42
42
43
43
##How to use
44
44
45
45
###Subclassing
46
-
`SCKChatViewController` is meant to be suclassed, like you would normally do with UITableViewController or UICollectionViewController. This pattern is by far the more convinient way of extending a ViewController behaviours, managing all the magic behind the scene while you still being able to intervene with custom behaviours, overriding forwarding methods, and deciding either to call super and perform additional logic, or not to call super and override default logic.
46
+
`SCKChatViewController` is meant to be suclassed, like you would normally do with UITableViewController or UICollectionViewController. This pattern is a convenient way of extending UIViewController. SlackTextViewController manages a lot behind the scenes while still providing the ability to add custom behaviours. You may override methods, and decide to call super and perform additional logic, or not to call super and override default logic.
47
47
48
48
Start by creating a new instance sublass of `SCKChatViewController`.
49
49
@@ -63,11 +63,11 @@ Protocols like `UITableViewDelegate` and `UITableViewDataSource` are already set
63
63
Calling `[super init]` will call by default `[super initWithStyle:UITableViewStylePlain]`.
The text view expands automatically when a new line is requiered, until it reaches its `maxNumberOfLines`value. You may change this property's value in the textView.
70
+
The text view expands automatically when a new line is required, until it reaches its `maxNumberOfLines`value. You may change this property's value in the textView.
71
71
72
72
By default, the number of lines is set to best fit each device dimensions:
73
73
- iPhone 4 (<=480pts): 4 lines
@@ -76,25 +76,24 @@ By default, the number of lines is set to best fit each device dimensions:
76
76
77
77
On iPhone devices, in landscape orientation, the maximum number of lines is changed to 2 to best fit the limited height.
78
78
79
-
###Auto-Completion
79
+
###Autocompletion
80
80
81
-
At Slack we use auto-completion mechanism for many things such as completing user names, channel titles, emoji aliases and more. It is a great tool for users to quickly type repeated thing.
81
+
We use autocompletion for many things: names, channels, emoji, and more.
Enabling auto-completion for your application is really easy.
86
-
Just follow these simple steps:
85
+
To set up autocompletion in your app, follow these simple steps:
87
86
88
87
#### 1. Registration
89
-
You must first register all the prefixes you'd like to support for auto-completion detection:
88
+
You must first register all the prefixes you'd like to support for autocompletion detection:
90
89
````
91
90
[self registerPrefixesForAutoCompletion:@[@"#"]];
92
91
````
93
92
94
93
#### 2. Processing
95
94
Every time a new character is inserted in the text view, the nearest word to the caret will be processed and verified if it contains any of the registered prefixes.
96
95
97
-
Once the prefix has been detected, `-canShowAutoCompletion` will be called. This is the perfect place to populate your data source, and return a BOOL if the auto-completion view should actually be shown. So you must override it in your subclass, to be able to perform additional tasks. Default returns NO.
96
+
Once the prefix has been detected, `-canShowAutoCompletion` will be called. This is the perfect place to populate your data source, and return a BOOL if the autocompletion view should actually be shown. So you must override it in your subclass, to be able to perform additional tasks. Default returns NO.
98
97
99
98
````
100
99
- (BOOL)canShowAutoCompletion
@@ -119,13 +118,13 @@ Once the prefix has been detected, `-canShowAutoCompletion` will be called. This
119
118
}
120
119
````
121
120
122
-
The auto-completion view is a UITableView instance, so you will need to use `UITableViewDataSource` to populate its cells. You also have total freedom for customising the UITableViewCells displayed here.
121
+
The auto-completion view is a UITableView instance, so you will need to use `UITableViewDataSource` to populate its cells. You also have total freedom for customizing the UITableViewCells displayed here.
123
122
124
123
You don't need to call `-reloadData`, since it will be called automatically if you return `YES` in `-canShowAutoCompletion`.
125
124
126
125
#### 3. Layout
127
126
128
-
The maximum height of the auto-completion view is set to 140 pts, but you may change the minimum height depending of the amount of cells you are going to display in this tableview.
127
+
The maximum height of the autocompletion view is set to 140 pts, but you may change the minimum height depending of the amount of cells you are going to display in this tableview.
129
128
130
129
````
131
130
- (CGFloat)heightForAutoCompletionView
@@ -151,20 +150,18 @@ If the user selects any cells presented in the auto-completion view, calling `-t
151
150
}
152
151
````
153
152
154
-
The auto-completion view will automatically be dismissed, and the picked string will be inserted in the view right after the prefix string.
153
+
The autocompletion view will automatically be dismissed, and the chosen string will be inserted in the view right after the prefix string.
155
154
156
-
You can always can `-cancelAutoCompletion` for exiting the auto-completion mode.
155
+
You can always call `-cancelAutoCompletion` to exit the autocompletion mode.
157
156
158
157
159
-
Auto-completion has been designed to work with local data for now. It hasn't been tested with data being fetched from a remote server.
To enable edit mode, you simply need to call `[self editText:@"hello"];`, and the text input will automatically adjust to the edit mode, removing both left and right buttons, extending the view a bit higher with "Accept" and "Cancel" buttons. Both of this buttons are accessible under `SCKChatToolbar` for customisation.
164
163
165
-
To enable the edit mode, you simply need to call `[self editText:@"hello"];`, and the text input will automatically adjust to the edition mode, removing both left and right buttons, extending the view a bit higher with a "cancel" and "accept" buttons. Both of this buttons are accessible under `SCKChatToolbar` for customisation.
166
-
167
-
To capture the events of cancelling or accepting, you must override the following methods.
164
+
To capture the "Accept" or "Cancel" events, you must override the following methods.
168
165
169
166
````
170
167
- (void)didCommitTextEditing:(id)sender
@@ -184,39 +181,39 @@ To capture the events of cancelling or accepting, you must override the followin
184
181
}
185
182
````
186
183
187
-
Notice there that you must call `super` at some point, so the text input exits the edition mode, re-adjusting the layout and clearing the text view.
184
+
Notice that you must call `super` at some point, so the text input exits the edit mode, re-adjusting the layout and clearing the text view.
188
185
Use the `editing` property to know if the editing mode is on.
Additionaly, you can enable a simple typing indicator to be displayed right above the text input. It shows the name of the users that are typing, and if more than 2, it will display "Several are typing" message.
192
+
Optionally, you can enable a simple typing indicator, which will be displayed right above the text input. It shows the name of the people that are typing, and if more than 2, it will display "Several are typing" message.
196
193
197
-
To enable the typing indicator, just call `[self.typeIndicatorView insertUsername:@"John"];` and the view will automatically be animated on top of the text input. After a default interval of 6 seconds, if the same name hasn't been assigned once more, the view will be dismissed animately.
194
+
To enable the typing indicator, just call `[self.typeIndicatorView insertUsername:@"John"];` and the view will automatically be animated on top of the text input. After a default interval of 6 seconds, if the same name hasn't been assigned once more, the view will be dismissed with animation.
198
195
199
-
You can remove user names from the list by calling `[self.typeIndicatorView removeUsername:@"John"];`
196
+
You can remove names from the list by calling `[self.typeIndicatorView removeUsername:@"John"];`
200
197
201
-
You can also dismiss it completly by calling `[self.typeIndicatorView dismissIndicator];`
198
+
You can also dismiss it by calling `[self.typeIndicatorView dismissIndicator];`
202
199
203
200
###Panning Gesture
204
201
205
-
As part of the UI patterns for text composing in iOS, dismissing the keyboard with a panning gesture is a very practical feature. It is enabled by default with the `keyboardPanningEnabled` property. You can always disabled it if you'd like.
202
+
Dismissing the keyboard with a panning gesture is enabled by default with the `keyboardPanningEnabled` property. You can always disable it if you'd like.
Another UI pattern in text composing is the shake gesture for clearing a text view's content. This is also enabled by default with the `undoShakingEnabled` property.
208
+
A shake gesture to clear text is enabled by default with the `undoShakingEnabled` property.
212
209
213
210
You can optionally override `-willRequestUndo`, to implement your UI to ask the users if he would like to clean the text view's text. If there is not text entered, the method will not be called.
214
211
215
212
If you don't override `-willRequestUndo` and `undoShakingEnabled` is set to `YES`, a system UIAlertView will prompt.
216
213
217
214
###Inverted Mode
218
215
219
-
Some chat UI layouts may requiere that the message show from bottom to top. To enable this, you must use the `inverted` flag property. This will actually invert the UITableView/UICollectionView, so you will need to do a transform adjustment in your UITableViewDataSource method `-tableView:cellForRowAtIndexPath:` for the cells to show correctly.
216
+
Some UITableView layouts may require that new messages enter from bottom to top. To enable this, you must use the `inverted` flag property. This will actually invert the UITableView or UICollectionView, so you will need to do a transform adjustment in your UITableViewDataSource method `-tableView:cellForRowAtIndexPath:` for the cells to show correctly.
0 commit comments