TUIInputBar_Minimalist.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // Created by Tencent on 2023/06/09.
  2. // Copyright © 2023 Tencent. All rights reserved.
  3. /**
  4. * This file declares the TUIInputBarDelegate protocol and the TUIInputBar class.
  5. * TUI input bar, a UI component used to detect and obtain user input.
  6. * TUIInputBar, the UI component at the bottom of the chat message. Includes text input box, emoji button, voice button, and "+" button ("More" button)
  7. * TUIInputBarDelegate provides callbacks for various situations of the input bar, including the callback for the emoticon of clicking the input bar, the
  8. * "more" view, and the voice button. And callbacks to send message, send voice, change input height.
  9. */
  10. #import <TIMCommon/TIMCommonModel.h>
  11. #import <TUICore/TUIThemeManager.h>
  12. #import <UIKit/UIKit.h>
  13. #import "TUIResponderTextView_Minimalist.h"
  14. #define kTUIInputNoramlFont [UIFont systemFontOfSize:16.0]
  15. #define kTUIInputNormalTextColor TUIChatDynamicColor(@"chat_input_text_color", @"#000000")
  16. typedef NS_ENUM(NSInteger, TUIRecordStatus) {
  17. TUIRecordStatus_Init,
  18. TUIRecordStatus_Record,
  19. TUIRecordStatus_Delete,
  20. TUIRecordStatus_Cancel,
  21. };
  22. @class TUIInputBar_Minimalist;
  23. /////////////////////////////////////////////////////////////////////////////////
  24. //
  25. // TUIInputBarDelegate
  26. //
  27. /////////////////////////////////////////////////////////////////////////////////
  28. @protocol TUIInputBarDelegate_Minimalist <NSObject>
  29. /**
  30. * Callback after clicking the emoji button - "smiley" button.
  31. * You can use this callback to achieve: After clicking the emoticon button, the corresponding emoticon view is displayed.
  32. */
  33. - (void)inputBarDidTouchFace:(TUIInputBar_Minimalist *)textView;
  34. /**
  35. * Callback after more button - "+" is clicked.
  36. * You can use this callback to achieve: corresponding user's click operation to display more corresponding views.
  37. */
  38. - (void)inputBarDidTouchMore:(TUIInputBar_Minimalist *)textView;
  39. /**
  40. * You can use this callback to achieve: jump to the camera interface, take a photo or select a local photo
  41. */
  42. - (void)inputBarDidTouchCamera:(TUIInputBar_Minimalist *)textView;
  43. /**
  44. * Callback when input bar height changes
  45. * This callback is fired when the InputBar height changes when you click the voice button, emoji button, "+" button, or call out/retract the keyboard
  46. * You can use this callback to achieve: UI layout adjustment when InputBar height changes through this callback function.
  47. * In the default implementation of TUIKit, this callback function further calls the didChangeHeight delegate in TUIInputController to adjust the height of the
  48. * UI layout after processing the appearance of the expression view and more views.
  49. */
  50. - (void)inputBar:(TUIInputBar_Minimalist *)textView didChangeInputHeight:(CGFloat)offset;
  51. /**
  52. * Callback when sending a text message.
  53. * This callback is fired when you send a text message through the InputBar (click the send button from the keyboard).
  54. * You can use this callback to get the content of the InputBar and send the message.
  55. * In the default implementation of TUIKit, this callback further calls the didSendMessage delegate in TUIInputController for further logical processing of
  56. * message sending after processing the appearance of the expression view and more views.
  57. */
  58. - (void)inputBar:(TUIInputBar_Minimalist *)textView didSendText:(NSString *)text;
  59. /**
  60. * Callback when sending voice
  61. * This callback is triggered when you long press and release the voice button.
  62. * You can use this callback to process the recorded voice information and send the voice message.
  63. * In the default implementation of TUIKit, this callback function further calls the didSendMessage delegate in TUIInputController for further logical
  64. * processing of message sending after processing the appearance of the expression view and more views.
  65. */
  66. - (void)inputBar:(TUIInputBar_Minimalist *)textView didSendVoice:(NSString *)path;
  67. /**
  68. * Callback after entering text containing the @ character
  69. */
  70. - (void)inputBarDidInputAt:(TUIInputBar_Minimalist *)textView;
  71. /**
  72. * Callback after removing text containing @ characters (e.g. removing @xxx)
  73. */
  74. - (void)inputBar:(TUIInputBar_Minimalist *)textView didDeleteAt:(NSString *)text;
  75. /**
  76. * Callback after keyboard button click
  77. * After clicking the emoticon button, the "smiley face" icon at the corresponding position will become the "keyboard" icon, which is the keyboard button at
  78. * this time. You can use this callback to: hide the currently displayed emoticon view or more views, and open the keyboard.
  79. */
  80. - (void)inputBarDidTouchKeyboard:(TUIInputBar_Minimalist *)textView;
  81. /**
  82. * Callback after clicking delete button on keyboard
  83. */
  84. - (void)inputBarDidDeleteBackward:(TUIInputBar_Minimalist *)textView;
  85. - (void)inputTextViewShouldBeginTyping:(UITextView *)textView;
  86. - (void)inputTextViewShouldEndTyping:(UITextView *)textView;
  87. @end
  88. /////////////////////////////////////////////////////////////////////////////////
  89. //
  90. // TUIInputBar
  91. //
  92. /////////////////////////////////////////////////////////////////////////////////
  93. @interface TUIInputBar_Minimalist : UIView
  94. /**
  95. * Separtor
  96. */
  97. @property(nonatomic, strong) UIView *lineView;
  98. /**
  99. * Voice button
  100. * Switch to voice input state after clicking
  101. */
  102. @property(nonatomic, strong) UIButton *micButton;
  103. /**
  104. * Camera button
  105. * Switch to camera after clicking
  106. */
  107. @property(nonatomic, strong) UIButton *cameraButton;
  108. /**
  109. * Keyboard button
  110. * Switch to keyboard input state after clicking
  111. */
  112. @property(nonatomic, strong) UIButton *keyboardButton;
  113. /**
  114. * Input view
  115. */
  116. @property(nonatomic, strong) TUIResponderTextView_Minimalist *inputTextView;
  117. /**
  118. * Emoticon button
  119. * Switch to emoji input state after clicking
  120. */
  121. @property(nonatomic, strong) UIButton *faceButton;
  122. /**
  123. * More button
  124. * A button that, when clicked, opens up more menu options
  125. */
  126. @property(nonatomic, strong) UIButton *moreButton;
  127. /**
  128. * Record View
  129. */
  130. @property(nonatomic, strong) UIView *recordView;
  131. @property(nonatomic, strong) UIImageView *recordDeleteView;
  132. @property(nonatomic, strong) UIView *recordBackgroudView;
  133. @property(nonatomic, strong) UIView *recordTipsView;
  134. @property(nonatomic, strong) UILabel *recordTipsLabel;
  135. @property(nonatomic, strong) UILabel *recordTimeLabel;
  136. @property(nonatomic, strong) NSMutableArray *recordAnimateViews;
  137. @property(nonatomic, strong) UIImageView *recordAnimateCoverView;
  138. @property(nonatomic, assign) CGRect recordAnimateCoverViewFrame;
  139. @property(nonatomic, weak) id<TUIInputBarDelegate_Minimalist> delegate;
  140. @property(nonatomic, copy) void (^inputBarTextChanged)(UITextView * textview);
  141. /**
  142. *
  143. * Add emoticon text
  144. * Used to input emoticon text in the current text input box
  145. *
  146. * @param emoji The string representation of the emoticon to be entered.
  147. */
  148. - (void)addEmoji:(TUIFaceCellData *)emoji;
  149. - (void)backDelete;
  150. - (void)clearInput;
  151. - (NSString *)getInput;
  152. - (void)updateTextViewFrame;
  153. - (void)changeToKeyboard;
  154. - (void)addDraftToInputBar:(NSAttributedString *)draft;
  155. - (void)addWordsToInputBar:(NSAttributedString *)words;
  156. @end