|
|
@@ -30,6 +30,10 @@
|
|
|
@property(nonatomic, assign) BOOL isFocusOn;
|
|
|
@property(nonatomic, strong) NSTimer *sendTypingStatusTimer;
|
|
|
@property(nonatomic, assign) BOOL allowSendTypingStatusByChangeWord;
|
|
|
+
|
|
|
+@property(nonatomic, strong) UIButton *sendButton;
|
|
|
+@property(nonatomic, strong) UIView *bgView;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation TUIInputBar
|
|
|
@@ -59,12 +63,19 @@
|
|
|
_lineView = [[UIView alloc] init];
|
|
|
_lineView.backgroundColor = TIMCommonDynamicColor(@"separator_color", @"#FFFFFF");
|
|
|
[self addSubview:_lineView];
|
|
|
+
|
|
|
+ _bgView = [[UIView alloc] init];
|
|
|
+ _bgView.backgroundColor = TUIChatDynamicColor(@"chat_input_bg_color", @"#FFFFFF");
|
|
|
+ _bgView.layer.cornerRadius = 12.0f;
|
|
|
+ _bgView.layer.masksToBounds = YES;
|
|
|
+ [self addSubview:_bgView];
|
|
|
|
|
|
_micButton = [[UIButton alloc] init];
|
|
|
[_micButton addTarget:self action:@selector(onMicButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
[_micButton setImage:TUIChatBundleThemeImage(@"chat_ToolViewInputVoice_img", @"ToolViewInputVoice") forState:UIControlStateNormal];
|
|
|
[_micButton setImage:TUIChatBundleThemeImage(@"chat_ToolViewInputVoiceHL_img", @"ToolViewInputVoiceHL") forState:UIControlStateHighlighted];
|
|
|
[self addSubview:_micButton];
|
|
|
+ _micButton.hidden = YES;
|
|
|
|
|
|
_faceButton = [[UIButton alloc] init];
|
|
|
[_faceButton addTarget:self action:@selector(onFaceEmojiButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
@@ -84,6 +95,12 @@
|
|
|
[_moreButton setImage:TUIChatBundleThemeImage(@"chat_TypeSelectorBtn_Black_img", @"TypeSelectorBtn_Black_2") forState:UIControlStateNormal];
|
|
|
[_moreButton setImage:TUIChatBundleThemeImage(@"chat_TypeSelectorBtnHL_Black_img", @"TypeSelectorBtnHL_Black_2") forState:UIControlStateHighlighted];
|
|
|
[self addSubview:_moreButton];
|
|
|
+
|
|
|
+ _sendButton = [[UIButton alloc] init];
|
|
|
+ [_sendButton addTarget:self action:@selector(onSendButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
+ [_sendButton setImage:TUIChatBundleThemeImage(@"chat_icon_new_send_btn_img", @"icon_new_send_btn") forState:UIControlStateNormal];
|
|
|
+ [_sendButton setImage:TUIChatBundleThemeImage(@"chat_icon_new_send_btn_img", @"icon_new_send_btn") forState:UIControlStateHighlighted];
|
|
|
+ [self addSubview:_sendButton];
|
|
|
|
|
|
_recordButton = [[UIButton alloc] init];
|
|
|
[_recordButton.titleLabel setFont:[UIFont systemFontOfSize:15.0f]];
|
|
|
@@ -100,7 +117,8 @@
|
|
|
_inputTextView = [[TUIResponderTextView alloc] init];
|
|
|
_inputTextView.delegate = self;
|
|
|
[_inputTextView setFont:kTUIInputNoramlFont];
|
|
|
- _inputTextView.backgroundColor = TUIChatDynamicColor(@"chat_input_bg_color", @"#FFFFFF");
|
|
|
+// _inputTextView.backgroundColor = TUIChatDynamicColor(@"chat_input_bg_color", @"#FFFFFF");
|
|
|
+ _inputTextView.backgroundColor = [UIColor clearColor];
|
|
|
_inputTextView.textColor = TUIChatDynamicColor(@"chat_input_text_color", @"#000000");
|
|
|
_inputTextView.textAlignment = isRTL()?NSTextAlignmentRight: NSTextAlignmentLeft;
|
|
|
[_inputTextView setReturnKeyType:UIReturnKeySend];
|
|
|
@@ -123,9 +141,13 @@
|
|
|
|
|
|
if (_inputTextView) {
|
|
|
[_inputTextView.layer setMasksToBounds:YES];
|
|
|
- [_inputTextView.layer setCornerRadius:4.0f];
|
|
|
- [_inputTextView.layer setBorderWidth:0.5f];
|
|
|
- [_inputTextView.layer setBorderColor:TIMCommonDynamicColor(@"separator_color", @"#DBDBDB").CGColor];
|
|
|
+// [_inputTextView.layer setCornerRadius:4.0f];
|
|
|
+ [_inputTextView.layer setCornerRadius:12.0f];
|
|
|
+// [_inputTextView.layer setBorderWidth:0.5f];
|
|
|
+// [_inputTextView.layer setBorderColor:TIMCommonDynamicColor(@"separator_color", @"#DBDBDB").CGColor];
|
|
|
+
|
|
|
+ [_bgView.layer setBorderWidth:0.5f];
|
|
|
+ [_bgView.layer setBorderColor:TIMCommonDynamicColor(@"separator_color", @"#DBDBDB").CGColor];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -148,23 +170,48 @@
|
|
|
[_keyboardButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.edges.mas_equalTo(_micButton);
|
|
|
}];
|
|
|
-
|
|
|
- [_moreButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+
|
|
|
+ [_sendButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.trailing.mas_equalTo(self.mas_trailing).mas_offset(0);
|
|
|
make.size.mas_equalTo(buttonSize);
|
|
|
make.centerY.mas_equalTo(self);
|
|
|
}];
|
|
|
+
|
|
|
+// [_moreButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.trailing.mas_equalTo(self.mas_trailing).mas_offset(0);
|
|
|
+// make.size.mas_equalTo(buttonSize);
|
|
|
+// make.centerY.mas_equalTo(self);
|
|
|
+// }];
|
|
|
+// [_faceButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+// make.trailing.mas_equalTo(_moreButton.mas_leading).mas_offset(- TTextView_Margin);
|
|
|
+// make.size.mas_equalTo(buttonSize);
|
|
|
+// make.centerY.mas_equalTo(self);
|
|
|
+// }];
|
|
|
+
|
|
|
+ [_moreButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.leading.mas_equalTo(self.mas_leading);
|
|
|
+ make.centerY.mas_equalTo(self);
|
|
|
+ make.size.mas_equalTo(buttonSize);
|
|
|
+ }];
|
|
|
[_faceButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
- make.trailing.mas_equalTo(_moreButton.mas_leading).mas_offset(- TTextView_Margin);
|
|
|
+ make.trailing.mas_equalTo(_sendButton.mas_leading).mas_offset(- TTextView_Margin * 2.0);
|
|
|
make.size.mas_equalTo(buttonSize);
|
|
|
make.centerY.mas_equalTo(self);
|
|
|
}];
|
|
|
+
|
|
|
[_recordButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.leading.mas_equalTo(_micButton.mas_trailing).mas_offset(10);
|
|
|
make.trailing.mas_equalTo(_faceButton.mas_leading).mas_offset(-10);;
|
|
|
make.height.mas_equalTo(TTextView_TextView_Height_Min);
|
|
|
make.centerY.mas_equalTo(self);
|
|
|
}];
|
|
|
+
|
|
|
+ [_bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.leading.mas_equalTo(_moreButton.mas_trailing).mas_offset(10);
|
|
|
+ make.trailing.mas_equalTo(_sendButton.mas_leading).mas_offset(-TTextView_Margin);
|
|
|
+ make.height.mas_equalTo(TTextView_TextView_Height_Min);
|
|
|
+ make.centerY.mas_equalTo(self);
|
|
|
+ }];
|
|
|
|
|
|
[_inputTextView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
if (self.isFromReplyPage) {
|
|
|
@@ -172,9 +219,10 @@
|
|
|
}
|
|
|
else {
|
|
|
// make.leading.mas_equalTo(_micButton.mas_trailing).mas_offset(10);
|
|
|
- make.leading.mas_equalTo(self.mas_leading);
|
|
|
+// make.leading.mas_equalTo(self.mas_leading);
|
|
|
+ make.leading.mas_equalTo(_moreButton.mas_trailing).mas_offset(10);
|
|
|
}
|
|
|
- make.trailing.mas_equalTo(_faceButton.mas_leading).mas_offset(-10);;
|
|
|
+ make.trailing.mas_equalTo(_faceButton.mas_leading).mas_offset(-10);
|
|
|
make.height.mas_equalTo(TTextView_TextView_Height_Min);
|
|
|
make.centerY.mas_equalTo(self);
|
|
|
}];
|
|
|
@@ -201,6 +249,10 @@
|
|
|
CGRect voiceFrame = _micButton.frame;
|
|
|
voiceFrame.origin.y = originY;
|
|
|
_micButton.frame = voiceFrame;
|
|
|
+
|
|
|
+ CGRect sendFrame = _sendButton.frame;
|
|
|
+ sendFrame.origin.y = originY;
|
|
|
+ _sendButton.frame = sendFrame;
|
|
|
|
|
|
[_keyboardButton mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
make.edges.mas_equalTo(_faceButton);
|
|
|
@@ -230,7 +282,8 @@
|
|
|
}
|
|
|
|
|
|
- (void)onKeyboardButtonClicked:(UIButton *)sender {
|
|
|
- _micButton.hidden = NO;
|
|
|
+// _micButton.hidden = NO;
|
|
|
+ _micButton.hidden = YES;
|
|
|
_keyboardButton.hidden = YES;
|
|
|
_recordButton.hidden = YES;
|
|
|
_inputTextView.hidden = NO;
|
|
|
@@ -242,7 +295,8 @@
|
|
|
}
|
|
|
|
|
|
- (void)onFaceEmojiButtonClicked:(UIButton *)sender {
|
|
|
- _micButton.hidden = NO;
|
|
|
+// _micButton.hidden = NO;
|
|
|
+ _micButton.hidden = YES;
|
|
|
_faceButton.hidden = YES;
|
|
|
_keyboardButton.hidden = NO;
|
|
|
_recordButton.hidden = YES;
|
|
|
@@ -261,6 +315,23 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)onSendButtonClicked:(UIButton *)sender {
|
|
|
+ //自定义发送按钮 触发
|
|
|
+ if (_delegate && [_delegate respondsToSelector:@selector(inputBar:didSendText:)]) {
|
|
|
+ NSString *sp = [[self.inputTextView.textStorage tui_getPlainString] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
|
+ if (sp.length == 0) {
|
|
|
+ UIAlertController *ac = [UIAlertController alertControllerWithTitle:TIMCommonLocalizableString(TUIKitInputBlankMessageTitle)
|
|
|
+ message:nil
|
|
|
+ preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ [ac tuitheme_addAction:[UIAlertAction actionWithTitle:TIMCommonLocalizableString(Confirm) style:UIAlertActionStyleDefault handler:nil]];
|
|
|
+ [self.mm_viewController presentViewController:ac animated:YES completion:nil];
|
|
|
+ } else {
|
|
|
+ [_delegate inputBar:self didSendText:[self.inputTextView.textStorage tui_getPlainString]];
|
|
|
+ [self clearInput];
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
- (void)onRecordButtonTouchDown:(UIButton *)sender {
|
|
|
[self.recorder record];
|
|
|
}
|
|
|
@@ -344,7 +415,8 @@
|
|
|
#pragma mark-- UITextViewDelegate
|
|
|
- (void)textViewDidBeginEditing:(UITextView *)textView {
|
|
|
self.keyboardButton.hidden = YES;
|
|
|
- self.micButton.hidden = NO;
|
|
|
+// self.micButton.hidden = NO;
|
|
|
+ self.micButton.hidden = YES;
|
|
|
self.faceButton.hidden = NO;
|
|
|
|
|
|
self.isFocusOn = YES;
|
|
|
@@ -407,11 +479,19 @@
|
|
|
animations:^{
|
|
|
[ws.inputTextView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
// make.leading.mas_equalTo(ws.micButton.mas_trailing).mas_offset(10);
|
|
|
- make.leading.mas_equalTo(ws.mas_leading);
|
|
|
+// make.leading.mas_equalTo(ws.mas_leading);
|
|
|
+ make.leading.mas_equalTo(ws.moreButton.mas_trailing).mas_offset(10);
|
|
|
make.trailing.mas_equalTo(ws.faceButton.mas_leading).mas_offset(-10);
|
|
|
make.height.mas_equalTo(newHeight);
|
|
|
make.centerY.mas_equalTo(self);
|
|
|
}];
|
|
|
+
|
|
|
+ [ws.bgView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
|
|
+ make.leading.mas_equalTo(ws.moreButton.mas_trailing).mas_offset(10);
|
|
|
+ make.trailing.mas_equalTo(ws.sendButton.mas_leading).mas_offset(-TTextView_Margin);
|
|
|
+ make.height.mas_equalTo(newHeight);
|
|
|
+ make.centerY.mas_equalTo(self);
|
|
|
+ }];
|
|
|
[ws layoutButton:newHeight + 2 * TTextView_Margin];
|
|
|
}];
|
|
|
}
|