You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

649 lines
27 KiB

5 years ago
  1. //
  2. // SlackTextViewController
  3. // https://github.com/slackhq/SlackTextViewController
  4. //
  5. // Copyright 2014-2016 Slack Technologies, Inc.
  6. // Licence: MIT-Licence
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import "SLKTextInputbar.h"
  11. #import "SLKTextView.h"
  12. #import "SLKTypingIndicatorView.h"
  13. #import "SLKTypingIndicatorProtocol.h"
  14. #import "SLKTextView+SLKAdditions.h"
  15. #import "UIScrollView+SLKAdditions.h"
  16. #import "UIView+SLKAdditions.h"
  17. #import "SLKUIConstants.h"
  18. NS_ASSUME_NONNULL_BEGIN
  19. /**
  20. UIKeyboard notification replacement, posting reliably only when showing/hiding the keyboard (not when resizing keyboard, or with inputAccessoryView reloads, etc).
  21. Only triggered when using SLKTextViewController's text view.
  22. */
  23. UIKIT_EXTERN NSString *const SLKKeyboardWillShowNotification;
  24. UIKIT_EXTERN NSString *const SLKKeyboardDidShowNotification;
  25. UIKIT_EXTERN NSString *const SLKKeyboardWillHideNotification;
  26. UIKIT_EXTERN NSString *const SLKKeyboardDidHideNotification;
  27. /**
  28. This feature doesn't work on iOS 9 due to no legit alternatives to detect the keyboard view.
  29. Open Radar: http://openradar.appspot.com/radar?id=5021485877952512
  30. */
  31. UIKIT_EXTERN NSString *const SLKTextInputbarDidMoveNotification;
  32. typedef NS_ENUM(NSUInteger, SLKKeyboardStatus) {
  33. SLKKeyboardStatusDidHide,
  34. SLKKeyboardStatusWillShow,
  35. SLKKeyboardStatusDidShow,
  36. SLKKeyboardStatusWillHide
  37. };
  38. /** @name A drop-in UIViewController subclass with a growing text input view and other useful messaging features. */
  39. NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController <SLKTextViewDelegate, UITableViewDelegate, UITableViewDataSource,
  40. UICollectionViewDelegate, UICollectionViewDataSource,
  41. UIGestureRecognizerDelegate, UIAlertViewDelegate>
  42. /** The main table view managed by the controller object. Created by default initializing with -init or initWithNibName:bundle: */
  43. @property (nonatomic, readonly) UITableView *_Nullable tableView;
  44. /** The main collection view managed by the controller object. Not nil if the controller is initialised with -initWithCollectionViewLayout: */
  45. @property (nonatomic, readonly) UICollectionView *_Nullable collectionView;
  46. /** The main scroll view managed by the controller object. Not nil if the controller is initialised with -initWithScrollView: */
  47. @property (nonatomic, readonly) UIScrollView *_Nullable scrollView;
  48. /** The bottom toolbar containing a text view and buttons. */
  49. @property (nonatomic, readonly) SLKTextInputbar *textInputbar;
  50. /** The default typing indicator used to display user names horizontally. */
  51. @property (nonatomic, readonly) SLKTypingIndicatorView *_Nullable typingIndicatorView;
  52. /**
  53. The custom typing indicator view. Default is kind of SLKTypingIndicatorView.
  54. To customize the typing indicator view, you will need to call -registerClassForTypingIndicatorView: nside of any initialization method.
  55. To interact with it directly, you will need to cast the return value of -typingIndicatorProxyView to the appropriate type.
  56. */
  57. @property (nonatomic, readonly) UIView <SLKTypingIndicatorProtocol> *typingIndicatorProxyView;
  58. /** A single tap gesture used to dismiss the keyboard. SLKTextViewController is its delegate. */
  59. @property (nonatomic, readonly) UIGestureRecognizer *singleTapGesture;
  60. /** A vertical pan gesture used for bringing the keyboard from the bottom. SLKTextViewController is its delegate. */
  61. @property (nonatomic, readonly) UIPanGestureRecognizer *verticalPanGesture;
  62. /** YES if animations should have bouncy effects. Default is YES. */
  63. @property (nonatomic, assign) BOOL bounces;
  64. /** YES if text view's content can be cleaned with a shake gesture. Default is NO. */
  65. @property (nonatomic, assign) BOOL shakeToClearEnabled;
  66. /**
  67. YES if keyboard can be dismissed gradually with a vertical panning gesture. Default is YES.
  68. This feature doesn't work on iOS 9 due to no legit alternatives to detect the keyboard view.
  69. Open Radar: http://openradar.appspot.com/radar?id=5021485877952512
  70. */
  71. @property (nonatomic, assign, getter = isKeyboardPanningEnabled) BOOL keyboardPanningEnabled;
  72. /** YES if an external keyboard has been detected (this value updates only when the text view becomes first responder). */
  73. @property (nonatomic, readonly, getter=isExternalKeyboardDetected) BOOL externalKeyboardDetected;
  74. /** YES if the keyboard has been detected as undocked or split (iPad Only). */
  75. @property (nonatomic, readonly, getter=isKeyboardUndocked) BOOL keyboardUndocked;
  76. /** YES if after right button press, the text view is cleared out. Default is YES. */
  77. @property (nonatomic, assign) BOOL shouldClearTextAtRightButtonPress;
  78. /** YES if the scrollView should scroll to bottom when the keyboard is shown. Default is NO.*/
  79. @property (nonatomic, assign) BOOL shouldScrollToBottomAfterKeyboardShows;
  80. /**
  81. YES if the main table view is inverted. Default is YES.
  82. This allows the table view to start from the bottom like any typical messaging interface.
  83. If inverted, you must assign the same transform property to your cells to match the orientation (ie: cell.transform = tableView.transform;)
  84. Inverting the table view will enable some great features such as content offset corrections automatically when resizing the text input and/or showing autocompletion.
  85. */
  86. @property (nonatomic, assign, getter = isInverted) BOOL inverted;
  87. /** YES if the view controller is presented inside of a popover controller. If YES, the keyboard won't move the text input bar and tapping on the tableView/collectionView will not cause the keyboard to be dismissed. This property is compatible only with iPad. */
  88. @property (nonatomic, assign, getter = isPresentedInPopover) BOOL presentedInPopover;
  89. /** The current keyboard status (will/did hide, will/did show) */
  90. @property (nonatomic, readonly) SLKKeyboardStatus keyboardStatus;
  91. /** Convenience accessors (accessed through the text input bar) */
  92. @property (nonatomic, readonly) SLKTextView *textView;
  93. @property (nonatomic, readonly) UIButton *leftButton;
  94. @property (nonatomic, readonly) UIButton *rightButton;
  95. @property (nonatomic, weak) UIView *menuAccesoryView;
  96. @property (nonatomic, assign) SLKInputBarState barState;
  97. #pragma mark - Initialization
  98. ///------------------------------------------------
  99. /// @name Initialization
  100. ///------------------------------------------------
  101. /**
  102. Initializes a text view controller to manage a table view of a given style.
  103. If you use the standard -init method, a table view with plain style will be created.
  104. @param style A constant that specifies the style of main table view that the controller object is to manage (UITableViewStylePlain or UITableViewStyleGrouped).
  105. @return An initialized SLKTextViewController object or nil if the object could not be created.
  106. */
  107. - (instancetype __nullable)initWithTableViewStyle:(UITableViewStyle)style;
  108. /**
  109. Initializes a collection view controller and configures the collection view with the provided layout.
  110. If you use the standard -init method, a table view with plain style will be created.
  111. @param layout The layout object to associate with the collection view. The layout controls how the collection view presents its cells and supplementary views.
  112. @return An initialized SLKTextViewController object or nil if the object could not be created.
  113. */
  114. - (instancetype __nullable)initWithCollectionViewLayout:(UICollectionViewLayout *)layout;
  115. /**
  116. Initializes a text view controller to manage an arbitraty scroll view. The caller is responsible for configuration of the scroll view, including wiring the delegate.
  117. @param scrollView UISCrollView to be used as the main content area.
  118. @return An initialized SLKTextViewController object or nil if the object could not be created.
  119. */
  120. - (instancetype __nullable)initWithScrollView:(UIScrollView *)scrollView;
  121. /**
  122. Initializes either a table or collection view controller.
  123. You must override either +tableViewStyleForCoder: or +collectionViewLayoutForCoder: to define witch view to be layed out.
  124. @param decoder An unarchiver object.
  125. @return An initialized SLKTextViewController object or nil if the object could not be created.
  126. */
  127. - (instancetype __nullable)initWithCoder:(NSCoder *)decoder;
  128. /**
  129. Returns the tableView style to be configured when using Interface Builder. Default is UITableViewStylePlain.
  130. You must override this method if you want to configure a tableView.
  131. @param decoder An unarchiver object.
  132. @return The tableView style to be used in the new instantiated tableView.
  133. */
  134. + (UITableViewStyle)tableViewStyleForCoder:(NSCoder *)decoder;
  135. /**
  136. Returns the tableView style to be configured when using Interface Builder. Default is nil.
  137. You must override this method if you want to configure a collectionView.
  138. @param decoder An unarchiver object.
  139. @return The collectionView style to be used in the new instantiated collectionView.
  140. */
  141. + (UICollectionViewLayout *)collectionViewLayoutForCoder:(NSCoder *)decoder;
  142. #pragma mark - Menu Accessory View
  143. - (void)presentMenuAccessoryView:(BOOL)animated;
  144. - (void)dismissMenuAccessoryView:(BOOL)animated;
  145. #pragma mark - Keyboard Handling
  146. ///------------------------------------------------
  147. /// @name Keyboard Handling
  148. ///------------------------------------------------
  149. /**
  150. Presents the keyboard, if not already, animated.
  151. You can override this method to perform additional tasks associated with presenting the keyboard.
  152. You SHOULD call super to inherit some conditionals.
  153. @param animated YES if the keyboard should show using an animation.
  154. */
  155. - (void)presentKeyboard:(BOOL)animated;
  156. /**
  157. Dimisses the keyboard, if not already, animated.
  158. You can override this method to perform additional tasks associated with dismissing the keyboard.
  159. You SHOULD call super to inherit some conditionals.
  160. @param animated YES if the keyboard should be dismissed using an animation.
  161. */
  162. - (void)dismissKeyboard:(BOOL)animated;
  163. /**
  164. Verifies if the text input bar should still move up/down even if it is NOT first responder. Default is NO.
  165. You can override this method to perform additional tasks associated with presenting the view.
  166. You don't need call super since this method doesn't do anything.
  167. @param responder The current first responder object.
  168. @return YES so the text input bar still move up/down.
  169. */
  170. - (BOOL)forceTextInputbarAdjustmentForResponder:(UIResponder *_Nullable)responder;
  171. /**
  172. Verifies if the text input bar should still move up/down when the text view is first responder.
  173. This is very useful when presenting the view controller in a custom modal presentation, when there keyboard events are being handled externally to reframe the presented view.
  174. You SHOULD call super to inherit some conditionals.
  175. @return YES so the text input bar still move up/down.
  176. */
  177. - (BOOL)ignoreTextInputbarAdjustment NS_REQUIRES_SUPER;
  178. /**
  179. Notifies the view controller that the keyboard changed status.
  180. You can override this method to perform additional tasks associated with presenting the view.
  181. You don't need call super since this method doesn't do anything.
  182. @param status The new keyboard status.
  183. */
  184. - (void)didChangeKeyboardStatus:(SLKKeyboardStatus)status;
  185. #pragma mark - Interaction Notifications
  186. ///------------------------------------------------
  187. /// @name Interaction Notifications
  188. ///------------------------------------------------
  189. /**
  190. Notifies the view controller that the text will update.
  191. You can override this method to perform additional tasks associated with text changes.
  192. You MUST call super at some point in your implementation.
  193. */
  194. - (void)textWillUpdate NS_REQUIRES_SUPER;
  195. /**
  196. Notifies the view controller that the text did update.
  197. You can override this method to perform additional tasks associated with text changes.
  198. You MUST call super at some point in your implementation.
  199. @param animated If YES, the text input bar will be resized using an animation.
  200. */
  201. - (void)textDidUpdate:(BOOL)animated NS_REQUIRES_SUPER;
  202. /**
  203. Notifies the view controller that the text selection did change.
  204. Use this method a replacement of UITextViewDelegate's -textViewDidChangeSelection: which is not reliable enough when using third-party keyboards (they don't forward events properly sometimes).
  205. You can override this method to perform additional tasks associated with text changes.
  206. You MUST call super at some point in your implementation.
  207. */
  208. - (void)textSelectionDidChange NS_REQUIRES_SUPER;
  209. /**
  210. Notifies the view controller when the left button's action has been triggered, manually.
  211. You can override this method to perform additional tasks associated with the left button.
  212. You don't need call super since this method doesn't do anything.
  213. @param sender The object calling this method.
  214. */
  215. - (void)didPressLeftButton:(id _Nullable)sender;
  216. /**
  217. Notifies the view controller when the right button's action has been triggered, manually or by using the keyboard return key.
  218. You can override this method to perform additional tasks associated with the right button.
  219. You MUST call super at some point in your implementation.
  220. @param sender The object calling this method.
  221. */
  222. - (void)didPressRightButton:(id _Nullable)sender NS_REQUIRES_SUPER;
  223. /**
  224. Verifies if the right button can be pressed. If NO, the button is disabled.
  225. You can override this method to perform additional tasks. You SHOULD call super to inherit some conditionals.
  226. @return YES if the right button can be pressed.
  227. */
  228. - (BOOL)canPressRightButton;
  229. /**
  230. Notifies the view controller when the user has pasted a supported media content (images and/or videos).
  231. You can override this method to perform additional tasks associated with image/video pasting. You don't need to call super since this method doesn't do anything.
  232. Only supported pastable medias configured in SLKTextView will be forwarded (take a look at SLKPastableMediaType).
  233. @para userInfo The payload containing the media data, content and media types.
  234. */
  235. - (void)didPasteMediaContent:(NSDictionary *)userInfo;
  236. /**
  237. Verifies that the typing indicator view should be shown.
  238. You can override this method to perform additional tasks.
  239. You SHOULD call super to inherit some conditionals.
  240. @return YES if the typing indicator view should be presented.
  241. */
  242. - (BOOL)canShowTypingIndicator;
  243. /**
  244. Notifies the view controller when the user has shaked the device for undoing text typing.
  245. You can override this method to perform additional tasks associated with the shake gesture.
  246. Calling super will prompt a system alert view with undo option. This will not be called if 'undoShakingEnabled' is set to NO and/or if the text view's content is empty.
  247. */
  248. - (void)willRequestUndo;
  249. /**
  250. Notifies the view controller when the user has pressed the Return key () with an external keyboard.
  251. You can override this method to perform additional tasks.
  252. You MUST call super at some point in your implementation.
  253. @param keyCommand The UIKeyCommand object being recognized.
  254. */
  255. - (void)didPressReturnKey:(UIKeyCommand * _Nullable)keyCommand NS_REQUIRES_SUPER;
  256. /**
  257. Notifies the view controller when the user has pressed the Escape key (Esc) with an external keyboard.
  258. You can override this method to perform additional tasks.
  259. You MUST call super at some point in your implementation.
  260. @param keyCommand The UIKeyCommand object being recognized.
  261. */
  262. - (void)didPressEscapeKey:(UIKeyCommand * _Nullable)keyCommand NS_REQUIRES_SUPER;
  263. /**
  264. Notifies the view controller when the user has pressed the arrow key with an external keyboard.
  265. You can override this method to perform additional tasks.
  266. You MUST call super at some point in your implementation.
  267. @param keyCommand The UIKeyCommand object being recognized.
  268. */
  269. - (void)didPressArrowKey:(UIKeyCommand * _Nullable)keyCommand NS_REQUIRES_SUPER;
  270. #pragma mark - Text Input Bar Adjustment
  271. ///------------------------------------------------
  272. /// @name Text Input Bar Adjustment
  273. ///------------------------------------------------
  274. /** YES if the text inputbar is hidden. Default is NO. */
  275. @property (nonatomic, getter=isTextInputbarHidden) BOOL textInputbarHidden;
  276. /**
  277. Changes the visibility of the text input bar.
  278. Calling this method with the animated parameter set to NO is equivalent to setting the value of the toolbarHidden property directly.
  279. @param hidden Specify YES to hide the toolbar or NO to show it.
  280. @param animated Specify YES if you want the toolbar to be animated on or off the screen.
  281. */
  282. - (void)setTextInputbarHidden:(BOOL)hidden animated:(BOOL)animated;
  283. #pragma mark - Text Edition
  284. ///------------------------------------------------
  285. /// @name Text Edition
  286. ///------------------------------------------------
  287. /** YES if the text editing mode is active. */
  288. @property (nonatomic, readonly, getter = isEditing) BOOL editing;
  289. /**
  290. Re-uses the text layout for edition, displaying an accessory view on top of the text input bar with options (cancel & save).
  291. You can override this method to perform additional tasks
  292. You MUST call super at some point in your implementation.
  293. @param text The string text to edit.
  294. */
  295. - (void)editText:(NSString *)text NS_REQUIRES_SUPER;
  296. /**
  297. Re-uses the text layout for edition, displaying an accessory view on top of the text input bar with options (cancel & save).
  298. You can override this method to perform additional tasks
  299. You MUST call super at some point in your implementation.
  300. @param attributedText The attributed text to edit.
  301. */
  302. - (void)editAttributedText:(NSAttributedString *)attributedText NS_REQUIRES_SUPER;
  303. /**
  304. Notifies the view controller when the editing bar's right button's action has been triggered, manually or by using the external keyboard's Return key.
  305. You can override this method to perform additional tasks associated with accepting changes.
  306. You MUST call super at some point in your implementation.
  307. @param sender The object calling this method.
  308. */
  309. - (void)didCommitTextEditing:(id)sender NS_REQUIRES_SUPER;
  310. /**
  311. Notifies the view controller when the editing bar's right button's action has been triggered, manually or by using the external keyboard's Esc key.
  312. You can override this method to perform additional tasks associated with accepting changes.
  313. You MUST call super at some point in your implementation.
  314. @param sender The object calling this method.
  315. */
  316. - (void)didCancelTextEditing:(id)sender NS_REQUIRES_SUPER;
  317. #pragma mark - Text Auto-Completion
  318. ///------------------------------------------------
  319. /// @name Text Auto-Completion
  320. ///------------------------------------------------
  321. /** The table view used to display autocompletion results. */
  322. @property (nonatomic, readonly) UITableView *autoCompletionView;
  323. @property (nonatomic, strong) UIColor *autoCompletionHairColor;
  324. /** YES if the autocompletion mode is active. */
  325. @property (nonatomic, readonly, getter = isAutoCompleting) BOOL autoCompleting;
  326. /** The recently found prefix symbol used as prefix for autocompletion mode. */
  327. @property (nonatomic, copy) NSString *_Nullable foundPrefix;
  328. /** The range of the found prefix in the text view content. */
  329. @property (nonatomic) NSRange foundPrefixRange;
  330. /** The recently found word at the text view's caret position. */
  331. @property (nonatomic, copy) NSString *_Nullable foundWord;
  332. /** An array containing all the registered prefix strings for autocompletion. */
  333. @property (nonatomic, readonly, copy) NSSet <NSString *> *_Nullable registeredPrefixes;
  334. @property (nonatomic, assign) BOOL alwaysEnableRightButton;
  335. /**
  336. Registers any string prefix for autocompletion detection, like for user mentions or hashtags autocompletion.
  337. The prefix must be valid string (i.e: '@', '#', '\', and so on).
  338. Prefixes can be of any length.
  339. @param prefixes An array of prefix strings.
  340. */
  341. - (void)registerPrefixesForAutoCompletion:(NSArray <NSString *> *_Nullable)prefixes;
  342. /**
  343. Verifies that controller is allowed to process the textView's text for auto-completion.
  344. You can override this method to disable momentarily the auto-completion feature, or to let it visible for longer time.
  345. You SHOULD call super to inherit some conditionals.
  346. @return YES if the controller is allowed to process the text for auto-completion.
  347. */
  348. - (BOOL)shouldProcessTextForAutoCompletion;
  349. - (BOOL)shouldProcessTextForAutoCompletion:(NSString *)text DEPRECATED_MSG_ATTRIBUTE("Use -shouldProcessTextForAutoCompletion instead.");
  350. /**
  351. During text autocompletion, by default, auto-correction and spell checking are disabled.
  352. Doing so, refreshes the text input to get rid of the Quick Type bar.
  353. You can override this method to avoid disabling in some cases.
  354. @return YES if the controller should not hide the quick type bar.
  355. */
  356. - (BOOL)shouldDisableTypingSuggestionForAutoCompletion;
  357. /**
  358. Notifies the view controller either the autocompletion prefix or word have changed.
  359. Use this method to modify your data source or fetch data asynchronously from an HTTP resource.
  360. Once your data source is ready, make sure to call -showAutoCompletionView: to display the view accordingly.
  361. You don't need call super since this method doesn't do anything.
  362. You SHOULD call super to inherit some conditionals.
  363. @param prefix The detected prefix.
  364. @param word The derected word.
  365. */
  366. - (void)didChangeAutoCompletionPrefix:(NSString *)prefix andWord:(NSString *)word;
  367. /**
  368. Use this method to programatically show/hide the autocompletion view.
  369. Right before the view is shown, -reloadData is called. So avoid calling it manually.
  370. @param show YES if the autocompletion view should be shown.
  371. */
  372. - (void)showAutoCompletionView:(BOOL)show;
  373. /**
  374. Use this method to programatically show the autocompletion view, with provided prefix and word to search.
  375. Right before the view is shown, -reloadData is called. So avoid calling it manually.
  376. @param prefix A prefix that is used to trigger autocompletion
  377. @param word A word to search for autocompletion
  378. @param prefixRange The range in which prefix spans.
  379. */
  380. - (void)showAutoCompletionViewWithPrefix:(NSString *)prefix andWord:(NSString *)word prefixRange:(NSRange)prefixRange;
  381. /**
  382. Returns a custom height for the autocompletion view. Default is 0.0.
  383. You can override this method to return a custom height.
  384. @return The autocompletion view's height.
  385. */
  386. - (CGFloat)heightForAutoCompletionView;
  387. /**
  388. Returns the maximum height for the autocompletion view. Default is 140 pts.
  389. You can override this method to return a custom max height.
  390. @return The autocompletion view's max height.
  391. */
  392. - (CGFloat)maximumHeightForAutoCompletionView;
  393. /**
  394. Cancels and hides the autocompletion view, animated.
  395. */
  396. - (void)cancelAutoCompletion;
  397. /**
  398. Accepts the autocompletion, replacing the detected word with a new string, keeping the prefix.
  399. This method is a convinience of -acceptAutoCompletionWithString:keepPrefix:
  400. @param string The string to be used for replacing autocompletion placeholders.
  401. */
  402. - (void)acceptAutoCompletionWithString:(NSString *_Nullable)string;
  403. /**
  404. Accepts the autocompletion, replacing the detected word with a new string, and optionally replacing the prefix too.
  405. @param string The string to be used for replacing autocompletion placeholders.
  406. @param keepPrefix YES if the prefix shouldn't be overidden.
  407. */
  408. - (void)acceptAutoCompletionWithString:(NSString *_Nullable)string keepPrefix:(BOOL)keepPrefix;
  409. #pragma mark - Text Caching
  410. ///------------------------------------------------
  411. /// @name Text Caching
  412. ///------------------------------------------------
  413. /**
  414. Returns the key to be associated with a given text to be cached. Default is nil.
  415. To enable text caching, you must override this method to return valid key.
  416. The text view will be populated automatically when the view controller is configured.
  417. You don't need to call super since this method doesn't do anything.
  418. @return The string key for which to enable text caching.
  419. */
  420. - (nullable NSString *)keyForTextCaching;
  421. /**
  422. Removes the current view controller's cached text.
  423. To enable this, you must return a valid key string in -keyForTextCaching.
  424. */
  425. - (void)clearCachedText;
  426. /**
  427. Removes all the cached text from disk.
  428. */
  429. + (void)clearAllCachedText;
  430. /**
  431. Caches text to disk.
  432. */
  433. - (void)cacheTextView;
  434. #pragma mark - Customization
  435. ///------------------------------------------------
  436. /// @name Customization
  437. ///------------------------------------------------
  438. /**
  439. Registers a class for customizing the behavior and appearance of the text view.
  440. You need to call this method inside of any initialization method.
  441. @param aClass A SLKTextView subclass.
  442. */
  443. - (void)registerClassForTextView:(Class _Nullable)aClass;
  444. /**
  445. Registers a class for customizing the behavior and appearance of the typing indicator view.
  446. You need to call this method inside of any initialization method.
  447. Make sure to conform to SLKTypingIndicatorProtocol and implement the required methods.
  448. @param aClass A UIView subclass conforming to the SLKTypingIndicatorProtocol.
  449. */
  450. - (void)registerClassForTypingIndicatorView:(Class _Nullable)aClass;
  451. #pragma mark - Layout Customization
  452. ///------------------------------------------------
  453. /// @name Layout Customization
  454. ///------------------------------------------------
  455. @property (nonatomic, assign) CGFloat textInputBarLRC;
  456. @property (nonatomic, assign) CGFloat textInputBarBC;
  457. /**
  458. Configure bottom margin.
  459. @param margin The margin to configure
  460. */
  461. - (void)adjustBottomMargin:(CGFloat)margin;
  462. #pragma mark - Delegate Methods Requiring Super
  463. ///------------------------------------------------
  464. /// @name Delegate Methods Requiring Super
  465. ///------------------------------------------------
  466. /** UITextViewDelegate */
  467. - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text NS_REQUIRES_SUPER;
  468. /** SLKTextViewDelegate */
  469. - (BOOL)textView:(SLKTextView *)textView shouldInsertSuffixForFormattingWithSymbol:(NSString *)symbol prefixRange:(NSRange)prefixRange NS_REQUIRES_SUPER;
  470. /** UIScrollViewDelegate */
  471. - (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView NS_REQUIRES_SUPER;
  472. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate NS_REQUIRES_SUPER;
  473. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView NS_REQUIRES_SUPER;
  474. - (void)scrollViewDidScroll:(UIScrollView *)scrollView NS_REQUIRES_SUPER;
  475. /** UIGestureRecognizerDelegate */
  476. - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer NS_REQUIRES_SUPER;
  477. /** UIAlertViewDelegate */
  478. #ifndef __IPHONE_8_0
  479. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex NS_REQUIRES_SUPER;
  480. #endif
  481. #pragma mark - Life Cycle Methods Requiring Super
  482. ///------------------------------------------------
  483. /// @name Life Cycle Methods Requiring Super
  484. ///------------------------------------------------
  485. /**
  486. Configures view hierarchy and layout constraints. If you override these methods, make sure to call super.
  487. */
  488. - (void)loadView NS_REQUIRES_SUPER;
  489. - (void)viewDidLoad NS_REQUIRES_SUPER;
  490. - (void)viewWillAppear:(BOOL)animated NS_REQUIRES_SUPER;
  491. - (void)viewDidAppear:(BOOL)animated NS_REQUIRES_SUPER;
  492. - (void)viewWillDisappear:(BOOL)animated NS_REQUIRES_SUPER;
  493. - (void)viewDidDisappear:(BOOL)animated NS_REQUIRES_SUPER;
  494. - (void)viewWillLayoutSubviews NS_REQUIRES_SUPER;
  495. - (void)viewDidLayoutSubviews NS_REQUIRES_SUPER;
  496. @end
  497. NS_ASSUME_NONNULL_END