JCHATToolBar.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. //
  2. // JCHATToolBar.h
  3. // JPush IM
  4. //
  5. // Created by Apple on 14/12/26.
  6. // Copyright (c) 2014年 Apple. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "JChatConstants.h"
  10. #import "JCHATRecordAnimationView.h"
  11. #import "JCHATMessageTextView.h"
  12. @protocol SendMessageDelegate <NSObject>
  13. @optional
  14. /**
  15. * 发送文本
  16. *
  17. * @param text 文本
  18. */
  19. /**
  20. * 输入框刚好开始编辑
  21. *
  22. * @param messageInputTextView 输入框对象
  23. */
  24. - (void)inputTextViewDidBeginEditing:(JCHATMessageTextView *)messageInputTextView;
  25. - (void)inputTextViewDidEndEditing:(JCHATMessageTextView *)messageInputTextView;
  26. - (void)inputTextViewDidChange:(JCHATMessageTextView *)messageInputTextView;
  27. /**
  28. * 输入框将要开始编辑
  29. *
  30. * @param messageInputTextView 输入框对象
  31. */
  32. - (void)inputTextViewWillBeginEditing:(JCHATMessageTextView *)messageInputTextView;
  33. - (void)sendText :(NSString *)text;
  34. - (void)noPressmoreBtnClick :(UIButton *)btn;
  35. - (void)pressMoreBtnClick :(UIButton *)btn;
  36. -(void)pressFaceBtnClick:(UIButton *)btn; //表情弹出
  37. -(void)noPressFaceBtnClick:(UIButton *)btn; //表情落下
  38. - (void)startRecordVoice;
  39. - (void)playVoice :(NSString *)voicePath time:(NSString * )time;
  40. - (void)pressVoiceBtnToHideKeyBoard;
  41. - (void)switchToTextInputMode;
  42. /**
  43. * 按下录音按钮开始录音
  44. */
  45. - (void)didStartRecordingVoiceAction;
  46. /**
  47. * 手指向上滑动取消录音
  48. */
  49. - (void)didCancelRecordingVoiceAction;
  50. /**
  51. * 松开手指完成录音
  52. */
  53. - (void)didFinishRecordingVoiceAction;
  54. /**
  55. * 当手指离开按钮的范围内时,主要为了通知外部的HUD
  56. */
  57. - (void)didDragOutsideAction;
  58. /**
  59. * 当手指再次进入按钮的范围内时,主要也是为了通知外部的HUD
  60. */
  61. - (void)didDragInsideAction;
  62. @end
  63. @interface JCHATToolBar : UIView<UITextViewDelegate>
  64. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *voideWidth;
  65. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *addBtnWidth;
  66. /**
  67. * 表情button
  68. */
  69. @property (weak, nonatomic) IBOutlet UIButton *faceBtn;
  70. @property (weak, nonatomic) IBOutlet UIButton *voiceButton;
  71. //@property (weak, nonatomic) IBOutlet UIButton *faceButton;
  72. /**
  73. * 更多功能button
  74. */
  75. @property (weak, nonatomic) IBOutlet UIButton *addButton;
  76. /**
  77. * 语音button
  78. */
  79. /**
  80. * 文本输入view
  81. */
  82. @property (weak, nonatomic) IBOutlet JCHATMessageTextView *textView;
  83. /**
  84. * Height of textView
  85. */
  86. @property (weak, nonatomic) IBOutlet NSLayoutConstraint *textViewHeight;
  87. /**
  88. * 开始录音button
  89. */
  90. @property (strong, nonatomic) UIButton *startRecordButton;
  91. /**
  92. * 录音button 的高度
  93. */
  94. //@property (strong, nonatomic) UIButton *startRecordButton;
  95. /**
  96. * 是否正在录音
  97. */
  98. @property (nonatomic) BOOL isRecording;
  99. @property (assign, nonatomic) id<SendMessageDelegate> delegate;
  100. @property (strong, nonatomic) JCHATRecordAnimationView *recordAnimationView;
  101. @property (nonatomic) BOOL isPlaying;
  102. /**
  103. * 当录音按钮被按下所触发的事件,这时候是开始录音
  104. */
  105. - (void)holdDownButtonTouchDown;
  106. /**
  107. * 当手指在录音按钮范围之外离开屏幕所触发的事件,这时候是取消录音
  108. */
  109. - (void)holdDownButtonTouchUpOutside;
  110. /**
  111. * 当手指在录音按钮范围之内离开屏幕所触发的事件,这时候是完成录音
  112. */
  113. - (void)holdDownButtonTouchUpInside;
  114. /**
  115. * 当手指滑动到录音按钮的范围之外所触发的事件
  116. */
  117. - (void)holdDownDragOutside;
  118. /**
  119. * 当手指滑动到录音按钮的范围之内所触发的时间
  120. */
  121. - (void)holdDownDragInside;
  122. /**
  123. * 切换为文本输入模式,并且当前处于输入状态
  124. */
  125. - (void)switchToTextInputMode;
  126. /**
  127. * 转换toolbar 为文本输入样式
  128. */
  129. - (void)switchToolbarToTextMode;
  130. /**
  131. * 动态改变高度
  132. *
  133. * @param changeInHeight 目标变化的高度
  134. */
  135. - (void)adjustTextViewHeightBy:(CGFloat)changeInHeight;
  136. /**
  137. * 获取输入框内容字体行高
  138. *
  139. * @return 返回行高
  140. */
  141. + (CGFloat)textViewLineHeight;
  142. /**
  143. * 获取最大行数
  144. *
  145. * @return 返回最大行数
  146. */
  147. + (CGFloat)maxLines;
  148. /**
  149. * 获取根据最大行数和每行高度计算出来的最大显示高度
  150. *
  151. * @return 返回最大显示高度
  152. */
  153. + (CGFloat)maxHeight;
  154. @end
  155. @interface JCHATToolBarContainer : UIView
  156. @property (strong, nonatomic) JCHATToolBar *toolbar;
  157. @end