Skip to content

Commit 6bb2d03

Browse files
guangyaoguangyao
authored andcommitted
fix animation
1 parent 0b0de95 commit 6bb2d03

File tree

4 files changed

+43
-25
lines changed

4 files changed

+43
-25
lines changed

ios/RCTAuroraIMUI/DWCustomView/InputView/DWInputBarControl.m

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,39 @@ - (void)addNotification{
4545
#pragma mark -- 监听键盘
4646
- (void)clickKeyBoardChange:(NSNotification *)noti{
4747
NSDictionary *userInfo = noti.userInfo;
48-
NSLog(@"clickKeyBoardChange:%@",userInfo);
48+
// NSLog(@"clickKeyBoardChange:%@",userInfo);
4949
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
50-
self.height = screenH - endFrame.origin.y+self.inputViewHeight;
51-
if(!self.onShowKeyboard) { return; }
52-
// [UIView animateWithDuration:0.5 animations:<#^(void)animations#>]
50+
// self.height = screenH - endFrame.origin.y+self.inputViewHeight;
51+
NSLog(@"----height:%f",self.height);
52+
CGFloat tmpH = screenH - endFrame.origin.y+self.inputViewHeight;
53+
CGFloat keyboardY = screenH - 20;
54+
if (!(self.showExpressionBtn.selected || self.showMenuBtn.selected) || (keyboardY > endFrame.origin.y)) {
55+
if(!self.onShowKeyboard) { return; }
56+
self.onShowKeyboard(@{@"inputHeight":@(tmpH),@"showType":@(0)});
57+
}
58+
// [[NSNotificationCenter defaultCenter]postNotificationName:@"ChangeMessageListHeightNotification" object:@{@"listViewHeight":@(screenH - 60 - tmpH)}];
5359

54-
self.onShowKeyboard(@{@"inputHeight":@(self.height),@"showType":@(0)});
55-
[[NSNotificationCenter defaultCenter]postNotificationName:@"ChangeMessageListHeightNotification" object:@{@"listViewHeight":@(screenH - 60 - self.height)}];
5660

5761
}
5862

5963
- (void)hidenFeatureView{
6064
__weak typeof(self)weakSelf = self;
6165
dispatch_sync(dispatch_get_main_queue(), ^{
6266
[weakSelf.inputGrowView endEditing:YES];
63-
weakSelf.expressionView.hidden = YES;
64-
if (weakSelf.showMenuBtn.selected && (weakSelf.height > self.menuViewH )) {
65-
weakSelf.showMenuBtn.selected = NO;
66-
weakSelf.height = weakSelf.height - self.menuViewH;
67-
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
68-
}else if(weakSelf.showExpressionBtn.selected && (weakSelf.height > expressionViewH )){
69-
weakSelf.showExpressionBtn.selected = NO;
70-
weakSelf.height = weakSelf.height - expressionViewH;
71-
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
72-
}
67+
[UIView animateWithDuration:1.0 animations:^{
68+
if (weakSelf.showMenuBtn.selected && (weakSelf.height > self.menuViewH )) {
69+
weakSelf.showMenuBtn.selected = NO;
70+
weakSelf.height = weakSelf.height - self.menuViewH;
71+
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
72+
}else if(weakSelf.showExpressionBtn.selected && (weakSelf.height > expressionViewH )){
73+
weakSelf.showExpressionBtn.selected = NO;
74+
weakSelf.height = weakSelf.height - expressionViewH;
75+
weakSelf.onFeatureView(@{@"inputHeight":@(weakSelf.height),@"showType":@(0)});
76+
}
77+
} completion:^(BOOL finished) {
78+
weakSelf.expressionView.hidden = YES;
79+
}];
80+
7381
});
7482

7583
}

ios/RCTAuroraIMUI/DWCustomView/RNCustomInputView.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,14 @@ - (void)changeMenuView{
5858
}else{
5959
inpuntBar.height = inpuntBar.inputViewHeight;
6060
[inpuntBar.inputGrowView becomeFirstResponder];
61-
showType = 0;
6261
}
6362
if(!inpuntBar.onFeatureView) { return; }
6463
inpuntBar.onFeatureView(@{@"inputHeight":@(inpuntBar.height),@"showType":@(showType)});
6564
}
6665
//显示ExpressionView
6766
- (void)changExpressionView{
6867
int showType = 0;
69-
[inpuntBar.inputGrowView endEditing:YES];
68+
// [inpuntBar.inputGrowView endEditing:YES];
7069
if (inpuntBar.showRecordeBtn.selected) {
7170
inpuntBar.showRecordeBtn.selected = NO;
7271
inpuntBar.recordBtn.hidden = YES;
@@ -80,6 +79,7 @@ - (void)changExpressionView{
8079
inpuntBar.expressionView.hidden = NO;
8180
CGFloat inputH = inpuntBar.inputViewHeight + expressionViewH;
8281
inpuntBar.height = inputH;
82+
showType = 2;
8383

8484
}else{
8585
inpuntBar.expressionView.hidden = YES;

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUIMessageCollectionView.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ open class IMUIMessageCollectionView: UIView {
5858
self.setupMessageCollectionView()
5959
}
6060

61+
6162
override open func layoutSubviews() {
6263
super.layoutSubviews()
63-
IMUIMessageCellLayout.cellWidth = self.imui_width
64+
// IMUIMessageCellLayout.cellWidth = self.imui_width
65+
IMUIMessageCellLayout.cellWidth = UIScreen.main.bounds.size.width
6466
}
6567

6668
func setupMessageCollectionView() {
@@ -112,10 +114,12 @@ open class IMUIMessageCollectionView: UIView {
112114
// self.scrollToBottom(with: true)
113115
}
114116

117+
115118
open func fristAppendMessage(with message: IMUIMessageModel) {
116119
self.chatDataManager.appendMessage(with: message)
117120
self.messageCollectionView.reloadData()
118-
self.scrollToBottom(with: false)
121+
scrollToBottom(with: false)
122+
119123
}
120124

121125
open func deleteMessage(with messageId: String) {
@@ -168,6 +172,7 @@ extension IMUIMessageCollectionView: UICollectionViewDelegate, UICollectionViewD
168172
func collectionView(_ collectionView: UICollectionView,
169173
layout collectionViewLayout: UICollectionViewLayout,
170174
sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
175+
// return CGSize(width: messageCollectionView.imui_width, height: chatDataManager[indexPath.item].layout.cellHeight)
171176
return CGSize(width: messageCollectionView.imui_width, height: chatDataManager[indexPath.item].layout.cellHeight)
172177
}
173178

ios/RCTAuroraIMUI/RCTMessageListView.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#import <RCTAuroraIMUI/RCTAuroraIMUI-Swift.h>
1212
#import "RCTAuroraIMUIModule.h"
1313
#import "RNRecordTipsView.h"
14-
14+
#import "UIView+Extend.h"
1515

1616
#define screenW [UIScreen mainScreen].bounds.size.width
1717
#define screenH [UIScreen mainScreen].bounds.size.height
@@ -276,10 +276,15 @@ - (void)clickRecordLongTimeNotification:(NSNotification *)notification{
276276

277277
- (void)clickChangeHeight:(NSNotification *)noti{
278278
NSDictionary *dict = noti.object;
279-
CGFloat height = [[dict objectForKey:@"listViewHeight"] floatValue];
280-
CGRect rect = self.frame;
281-
rect.size.height = height;
282-
self.frame = rect;
279+
CGFloat height = [[dict objectForKey:@"listViewHeight"] floatValue] ;
280+
CGFloat tmpH = height - self.height;
281+
[UIView animateWithDuration:3 animations:^{
282+
self.height += tmpH;
283+
} completion:^(BOOL finished) {
284+
self.height = height;
285+
}];
286+
287+
283288
}
284289

285290
- (void)clickLongTouchShowMenu:(NSNotification *)noti{

0 commit comments

Comments
 (0)