Skip to content

Commit 0b0de95

Browse files
guangyaoguangyao
authored andcommitted
Add 点击收起键盘
1 parent 931610c commit 0b0de95

File tree

12 files changed

+47
-27
lines changed

12 files changed

+47
-27
lines changed

chatinput.ios.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export default class ChatInput extends Component {
6565
ChatInput.propTypes = {
6666
...View.propTypes,
6767
menuViewH:PropTypes.number,
68-
DefaultToolHeight:PropTypes.number,
68+
defaultToolHeight:PropTypes.number,
6969
onFeatureView:PropTypes.func,
7070
onShowKeyboard:PropTypes.func,
7171
onChangeBarHeight:PropTypes.func,

ios/RCTAuroraIMUI/DWCustomView/InputView/DWInputBarControl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ typedef enum{
4141
@property (strong, nonatomic) UIButton *showRecordeBtn;
4242
@property (strong, nonatomic) HPGrowingTextView *inputGrowView;
4343
@property (strong, nonatomic) DWRecordButton *recordBtn;
44-
@property (assign, nonatomic) CGFloat DefaultToolHeight;
44+
@property (assign, nonatomic) CGFloat defaultToolHeight;
4545
@property (assign, nonatomic) CGFloat inputViewHeight;
4646

4747
@property (assign, nonatomic) id<DWInputBarControlDelegate> delegate;

ios/RCTAuroraIMUI/DWCustomView/InputView/DWInputBarControl.m

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ - (void)clickKeyBoardChange:(NSNotification *)noti{
4949
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
5050
self.height = screenH - endFrame.origin.y+self.inputViewHeight;
5151
if(!self.onShowKeyboard) { return; }
52+
// [UIView animateWithDuration:0.5 animations:<#^(void)animations#>]
53+
5254
self.onShowKeyboard(@{@"inputHeight":@(self.height),@"showType":@(0)});
5355
[[NSNotificationCenter defaultCenter]postNotificationName:@"ChangeMessageListHeightNotification" object:@{@"listViewHeight":@(screenH - 60 - self.height)}];
5456

@@ -57,14 +59,14 @@ - (void)clickKeyBoardChange:(NSNotification *)noti{
5759
- (void)hidenFeatureView{
5860
__weak typeof(self)weakSelf = self;
5961
dispatch_sync(dispatch_get_main_queue(), ^{
60-
weakSelf.showMenuBtn.selected = NO;
61-
weakSelf.showExpressionBtn.selected = NO;
62+
[weakSelf.inputGrowView endEditing:YES];
6263
weakSelf.expressionView.hidden = YES;
6364
if (weakSelf.showMenuBtn.selected && (weakSelf.height > self.menuViewH )) {
6465
weakSelf.showMenuBtn.selected = NO;
6566
weakSelf.height = weakSelf.height - self.menuViewH;
6667
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
6768
}else if(weakSelf.showExpressionBtn.selected && (weakSelf.height > expressionViewH )){
69+
weakSelf.showExpressionBtn.selected = NO;
6870
weakSelf.height = weakSelf.height - expressionViewH;
6971
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
7072
}
@@ -112,14 +114,14 @@ - (instancetype)initWithFrame:(CGRect)frame{
112114
}
113115

114116

115-
- (void)setDefaultToolHeight:(CGFloat)DefaultToolHeight{
116-
if (DefaultToolHeight) {
117-
_DefaultToolHeight = DefaultToolHeight;
117+
- (void)setDefaultToolHeight:(CGFloat)defaultToolHeight{
118+
if (defaultToolHeight) {
119+
_defaultToolHeight = defaultToolHeight;
118120
}else{
119-
_DefaultToolHeight = DESIGN_SIZE_750(90);
121+
_defaultToolHeight = DESIGN_SIZE_750(90);
120122
}
121-
_toolH = _DefaultToolHeight;
122-
_inputViewHeight = _DefaultToolHeight;
123+
_toolH = _defaultToolHeight;
124+
_inputViewHeight = _defaultToolHeight;
123125
[self creatUI];
124126
}
125127
//发送录音message
@@ -204,8 +206,8 @@ - (void)setToolH:(CGFloat)toolH{
204206

205207
- (void)creatUI{
206208
line.frame = CGRectMake(0, 0, screenW, 1);
207-
CGFloat _margin = _DefaultToolHeight*0.1;
208-
CGFloat btnWH = _DefaultToolHeight - 3*_margin;
209+
CGFloat _margin = _defaultToolHeight*0.1;
210+
CGFloat btnWH = _defaultToolHeight - 3*_margin;
209211
_toolView.frame = CGRectMake(0, 0, screenW, _toolH);
210212

211213
CGFloat btnY = _toolH - 1.5*_margin - btnWH;

ios/RCTAuroraIMUI/DWCustomView/RNCustomInputView.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ @implementation RNCustomInputView
2323
RCT_EXPORT_MODULE()
2424

2525
RCT_EXPORT_VIEW_PROPERTY(menuViewH, CGFloat);
26-
RCT_EXPORT_VIEW_PROPERTY(DefaultToolHeight, CGFloat);
26+
RCT_EXPORT_VIEW_PROPERTY(defaultToolHeight, CGFloat);
2727
RCT_EXPORT_VIEW_PROPERTY(onFeatureView, RCTBubblingEventBlock)
2828
RCT_EXPORT_VIEW_PROPERTY(onShowKeyboard, RCTBubblingEventBlock)
2929
RCT_EXPORT_VIEW_PROPERTY(onChangeBarHeight, RCTBubblingEventBlock)
@@ -97,10 +97,10 @@ - (void)changeRecordView{
9797
inpuntBar.expressionView.hidden = YES;
9898
if (inpuntBar.showRecordeBtn.selected) {
9999
[inpuntBar.inputGrowView endEditing:YES];
100-
inpuntBar.height = inpuntBar.DefaultToolHeight;
100+
inpuntBar.height = inpuntBar.defaultToolHeight;
101101
inpuntBar.recordBtn.hidden = NO;
102102
inpuntBar.inputGrowView.hidden = YES;
103-
inpuntBar.toolH = inpuntBar.DefaultToolHeight;
103+
inpuntBar.toolH = inpuntBar.defaultToolHeight;
104104
}else{
105105
inpuntBar.recordBtn.hidden = YES;
106106
inpuntBar.inputGrowView.hidden = NO;

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Protocol/IMUIMessageMessageCollectionViewDelegate.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import UIKit
2727
@objc optional func messageCollectionView(didShowMenuStr: String, model: IMUIMessageModelProtocol)
2828
@objc optional func messageCollectionView(openMessageBubbleUrl: String)
2929
@objc optional func messageCollectionView(reloadMoreData:String)
30+
@objc optional func messageCollectionView(tapCellView:UICollectionViewCell)
3031

3132

3233
/**

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIBaseMessageCell.swift

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
2525

2626
weak var delegate: IMUIMessageMessageCollectionViewDelegate?
2727
var message: IMUIMessageModelProtocol?
28+
var cellGesture = UITapGestureRecognizer.init()
2829
var bubbleGesture = UITapGestureRecognizer.init()
2930
var longPress = UILongPressGestureRecognizer.init()
3031
override init(frame: CGRect) {
@@ -40,12 +41,14 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
4041
self.contentView.addSubview(self.isPlayedView)
4142
// self.bubbleGesture = UITapGestureRecognizer(target: self, action: #selector(self.tapBubbleView))
4243
// let longPress = UILongPressGestureRecognizer(target: self, action: #selector(self.longTapBubbleView(sender:)))
44+
self.cellGesture.addTarget(self, action: #selector(self.tapCellView))
4345
self.bubbleGesture.addTarget(self, action: #selector(self.tapBubbleView))
4446
self.longPress.addTarget(self, action: #selector(self.longTapBubbleView(sender:)))
4547
self.bubbleView.isUserInteractionEnabled = true
4648
self.bubbleView.addGestureRecognizer(self.bubbleGesture)
4749
self.bubbleView.addGestureRecognizer(self.longPress)
4850
self.bubbleGesture.numberOfTapsRequired = 1
51+
self.addGestureRecognizer(self.cellGesture)
4952

5053
let avatarGesture = UITapGestureRecognizer(target: self, action: #selector(self.tapHeaderImage))
5154
avatarGesture.numberOfTapsRequired = 1
@@ -145,6 +148,7 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
145148
self.isPlayedView.isHidden = true
146149

147150
let statusView = self.statusView as! IMUIMessageStatusViewProtocal
151+
self.statusView?.isHidden = false
148152
switch message.messageStatus {
149153
case .sending:
150154
statusView.layoutSendingStatus()
@@ -154,6 +158,7 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
154158
break
155159
case .success:
156160
statusView.layoutSuccessStatus()
161+
self.statusView?.isHidden = true
157162
if message.type == .voice{//录音
158163
self.durationLabel.isHidden = false
159164
let tmpDict = message.customDict
@@ -201,9 +206,17 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
201206
}
202207

203208
func tapBubbleView() {
204-
self.delegate?.messageCollectionView?(didTapMessageBubbleInCell: self, model: self.message!)
209+
if self.message?.type == .text {
210+
self.delegate?.messageCollectionView?(tapCellView: self)
211+
}else{
212+
self.delegate?.messageCollectionView?(didTapMessageBubbleInCell: self, model: self.message!)
213+
}
205214
}
206215

216+
func tapCellView(){//点击整个cell,隐藏键盘
217+
self.delegate?.messageCollectionView?(tapCellView: self)
218+
}
219+
207220
func longTapBubbleView(sender : UILongPressGestureRecognizer) {
208221
if sender.state == UIGestureRecognizerState.began{
209222
if self.message?.type == .notification || self.message?.type == .redpacketOpen {
@@ -244,7 +257,8 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
244257
}
245258

246259
func tapSatusView() {
247-
self.delegate?.messageCollectionView?(didTapStatusViewInCell: self, model: self.message!)
260+
self.delegate?.messageCollectionView?(didTapStatusViewInCell: self, model: self.message!)
261+
248262
}
249263

250264
func didDisAppearCell() {
@@ -255,16 +269,19 @@ open class IMUIBaseMessageCell: UICollectionViewCell, IMUIMessageCellProtocal,Me
255269
if strTouch == "begin" {
256270
self.bubbleView.removeGestureRecognizer(self.bubbleGesture)
257271
self.bubbleView.removeGestureRecognizer(self.longPress)
272+
self.removeGestureRecognizer(self.cellGesture)
258273
}else{
259274
self.bubbleView.addGestureRecognizer(bubbleGesture)
260275
self.bubbleView.addGestureRecognizer(longPress)
276+
self.addGestureRecognizer(self.cellGesture)
261277
}
262278
}
263279

264280
deinit {
265281
NotificationCenter.default.removeObserver(self)
266282
self.bubbleView.removeGestureRecognizer(self.bubbleGesture)
267283
self.bubbleView.removeGestureRecognizer(self.longPress)
284+
self.removeGestureRecognizer(self.cellGesture)
268285
}
269286

270287

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIMessageCollectionView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ open class IMUIMessageCollectionView: UIView {
109109
open func appendMessage(with message: IMUIMessageModel) {
110110
self.chatDataManager.appendMessage(with: message)
111111
self.messageCollectionView.reloadData()
112-
self.scrollToBottom(with: true)
112+
// self.scrollToBottom(with: true)
113113
}
114114

115115
open func fristAppendMessage(with message: IMUIMessageModel) {

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUITextMessageCell.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ open class IMUITextMessageCell: IMUIBaseMessageCell {
3939
fatalError("init(coder:) has not been implemented")
4040
}
4141

42-
override open func tapBubbleView() {
43-
44-
}
4542

4643
override open func layoutSubviews() {
4744
super.layoutSubviews()
@@ -83,6 +80,7 @@ open class IMUITextMessageCell: IMUIBaseMessageCell {
8380
}
8481

8582
func clickOpenLink(notification: Notification){
83+
print("clickOpenLink")
8684
let dict = notification.object as! NSDictionary
8785
let tmpLabel = dict.object(forKey: "label") as! M80AttributedLabel
8886
if tmpLabel == self.textMessageLable {

ios/RCTAuroraIMUI/RCTAuroraIMUIModule.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#define kInsertMessagesToTop @"kInsertMessagesToTop"
2121
#define kUpdateMessge @"kUpdateMessge"
2222
#define kScrollToBottom @"kScrollToBottom"
23-
#define kScrollToBottom @"kScrollToBottom"
2423
#define kHidenFeatureView @"kHidenFeatureView"
2524
#define kRecordChangeNotification @"RecordChangeNotification"
2625
#define kRecordLevelNotification @"RecordLevelNotification"

0 commit comments

Comments
 (0)