Skip to content

Commit af39106

Browse files
guangyaoguangyao
authored andcommitted
Fix 第一次加载页面慢的问题
1 parent ec624e3 commit af39106

File tree

8 files changed

+42
-22
lines changed

8 files changed

+42
-22
lines changed

ios/RCTAuroraIMUI/DWCustomView/DWEmoticonView/NIMInputEmoticonContainerView.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#import "UIImage+NIM.h"
1818
//#import "NIMKitUIConfig.h"
1919

20+
#define sreenW [UIScreen mainScreen].bounds.size.width
21+
2022
NSInteger NIMCustomPageControlHeight = 36;
2123
NSInteger NIMCustomPageViewHeight = 159;
2224

@@ -34,6 +36,7 @@ - (instancetype)initWithFrame:(CGRect)frame
3436
if (self = [super initWithFrame:frame]) {
3537
[self loadConfig];
3638
}
39+
3740
return self;
3841
}
3942

@@ -55,7 +58,7 @@ - (void)loadUIComponents
5558
_emoticonPageView.pageViewDelegate = self;
5659
[self addSubview:_emoticonPageView];
5760

58-
_emotPageController = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, self.width, NIMCustomPageControlHeight)];
61+
_emotPageController = [[UIPageControl alloc] initWithFrame:CGRectMake(0, 0, sreenW, NIMCustomPageControlHeight)];
5962
// _emotPageController.autoresizingMask = UIViewAutoresizingFlexibleWidth;
6063
_emotPageController.pageIndicatorTintColor = [UIColor lightGrayColor];
6164
_emotPageController.currentPageIndicatorTintColor = [UIColor grayColor];
@@ -204,7 +207,7 @@ - (NIMInputEmoticonCatalog*)loadDefaultCatalog
204207
{
205208
NIMInputEmoticonCatalog *emoticonCatalog = [[NIMInputEmoticonManager sharedManager] emoticonCatalog:NIMKit_EmojiCatalog];
206209
if (emoticonCatalog) {
207-
NIMInputEmoticonLayout *layout = [[NIMInputEmoticonLayout alloc] initEmojiLayout:self.width];
210+
NIMInputEmoticonLayout *layout = [[NIMInputEmoticonLayout alloc] initEmojiLayout:sreenW];
208211
emoticonCatalog.layout = layout;
209212
emoticonCatalog.pagesCount = [self numberOfPagesWithEmoticon:emoticonCatalog];
210213
}
@@ -215,7 +218,7 @@ - (NIMInputEmoticonCatalog*)loadDefaultCatalog
215218
- (NSArray *)loadChartlet{
216219
NSArray *chatlets = [[NIMInputEmoticonManager sharedManager] loadChartletEmoticonCatalog];
217220
for (NIMInputEmoticonCatalog *item in chatlets) {
218-
NIMInputEmoticonLayout *layout = [[NIMInputEmoticonLayout alloc] initCharletLayout:self.width];
221+
NIMInputEmoticonLayout *layout = [[NIMInputEmoticonLayout alloc] initCharletLayout:sreenW];
219222
item.layout = layout;
220223
item.pagesCount = [self numberOfPagesWithEmoticon:item];
221224
}
@@ -323,7 +326,7 @@ - (NSArray *)allEmoticons{
323326
- (NIMInputEmoticonTabView *)tabView
324327
{
325328
if (!_tabView) {
326-
_tabView = [[NIMInputEmoticonTabView alloc] initWithFrame:CGRectMake(0, 0, self.width, 0)];
329+
_tabView = [[NIMInputEmoticonTabView alloc] initWithFrame:CGRectMake(0, 0, sreenW, 0)];
327330
// _tabView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
328331
_tabView.delegate = self;
329332
[_tabView.sendButton addTarget:self action:@selector(didPressSend:) forControlEvents:UIControlEventTouchUpInside];

ios/RCTAuroraIMUI/DWCustomView/DWEmoticonView/NIMPageView.m

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ @interface NIMPageView ()
1212
{
1313
NSInteger _currentPage;
1414
NSInteger _currentPageForRotation;
15+
BOOL _isLoaded;
1516
}
1617

1718
@property (nonatomic,strong) NSMutableArray *pages;
@@ -33,9 +34,20 @@ - (id)initWithFrame:(CGRect)frame
3334
{
3435
[self setupControls];
3536
}
37+
_isLoaded = NO;
38+
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(clickLoadPages) name:@"LoadPagesNotification" object:nil];
3639
return self;
3740
}
3841

42+
- (void)clickLoadPages{
43+
if (!_isLoaded) {
44+
_isLoaded = YES;
45+
dispatch_async(dispatch_get_main_queue(), ^{
46+
[self reloadData];
47+
});
48+
}
49+
}
50+
3951
- (id)initWithCoder:(NSCoder *)aDecoder
4052
{
4153
if (self = [super initWithCoder:aDecoder])
@@ -56,6 +68,7 @@ - (void)setFrame:(CGRect)frame{
5668
- (void)dealloc
5769
{
5870
_scrollView.delegate = nil;
71+
[[NSNotificationCenter defaultCenter]removeObserver:self];
5972
}
6073

6174
- (void)layoutSubviews
@@ -106,7 +119,7 @@ - (void)scrollToPage: (NSInteger)page
106119
if (_currentPage != page || page == 0)
107120
{
108121
_currentPage = page;
109-
[self reloadData];
122+
// [self reloadData];
110123
}
111124

112125
}
@@ -196,7 +209,6 @@ - (void)loadPagesForCurrentPage:(NSInteger)currentPage
196209
}
197210
}
198211

199-
200212
- (void)calculatePageNumbers
201213
{
202214
NSInteger numberOfPages = 0;

ios/RCTAuroraIMUI/DWCustomView/InputView/DWInputBarControl.m

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ @interface DWInputBarControl ()<HPGrowingTextViewDelegate,DWRecordDelegate,NIMIn
1818
}
1919
@property (nonatomic, strong) NIMInputAtCache *atCache;
2020
@property (copy, nonatomic) NSString *strRecordPath;
21-
2221
@end
2322

2423
@implementation DWInputBarControl
@@ -45,14 +44,12 @@ - (void)addNotification{
4544
#pragma mark -- 监听键盘
4645
- (void)clickKeyBoardChange:(NSNotification *)noti{
4746
NSDictionary *userInfo = noti.userInfo;
48-
NSLog(@"clickKeyBoardChange:%@",userInfo);
47+
// NSLog(@"clickKeyBoardChange:%@",userInfo);
4948
CGRect endFrame = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
5049
// self.height = screenH - endFrame.origin.y+self.inputViewHeight;
51-
NSLog(@"----height:%f ----y:%f",self.height,endFrame.origin.y);
5250
CGFloat tmpH = screenH - endFrame.origin.y+self.inputViewHeight;
5351
CGFloat keyboardY = screenH - 20;
5452
if (!(self.showExpressionBtn.selected || self.showMenuBtn.selected) || (keyboardY > endFrame.origin.y)) {
55-
NSLog(@"进来了~~~~~");
5653
if(!self.onShowKeyboard) { return; }
5754
self.onShowKeyboard(@{@"inputHeight":@(tmpH),@"showType":@(0)});
5855
}
@@ -190,7 +187,6 @@ - (void)addSubContentView{
190187
[_toolView addSubview:_showMenuBtn];
191188

192189
_expressionView = [[NIMInputEmoticonContainerView alloc]initWithFrame:CGRectMake(0, 0, screenW, expressionViewH)];
193-
// _expressionView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
194190
_expressionView.delegate = self;
195191
[self addSubview:_expressionView];
196192
_expressionView.hidden = YES;

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Layout/IMUIMessageCellLayout.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ open class IMUIMessageCellLayout: NSObject, IMUIMessageCellLayoutProtocal {
1818

1919
public static var avatarSize: CGSize = CGSize(width: 40, height: 40)
2020

21-
public static var avatarOffsetToCell: UIOffset = UIOffset(horizontal: 5, vertical: 10)
21+
public static var avatarOffsetToCell: UIOffset = UIOffset(horizontal: 0, vertical: 10)
2222

2323
public static var timeLabelFrame: CGRect = CGRect.zero
2424

2525
public static var nameLabelSize: CGSize = CGSize(width: 200, height: 18)
2626

27-
public static var nameLabelOffsetToAvatar: UIOffset = UIOffset(horizontal: 8 , vertical: 0)
27+
public static var nameLabelOffsetToAvatar: UIOffset = UIOffset(horizontal: 4 , vertical: 0)
2828

29-
public static var bubbleOffsetToAvatar: UIOffset = UIOffset(horizontal: 8 , vertical: 0)
29+
public static var bubbleOffsetToAvatar: UIOffset = UIOffset(horizontal: 4 , vertical: 0)
3030

3131
public static var cellWidth: CGFloat = 0
3232

ios/RCTAuroraIMUI/IMUIMessageCollectionView/Views/IMUITextMessageCell.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ open class IMUITextMessageCell: IMUIBaseMessageCell {
1414
open static var inComingTextColor = UIColor.white
1515
open static let screenW = UIScreen.main.bounds.size.width
1616

17-
open static var outGoingTextFont = UIFont.systemFont(ofSize: (screenW * 14 / 375))
18-
open static var inComingTextFont = UIFont.systemFont(ofSize: (screenW * 14 / 375))
17+
open static var outGoingTextFont = UIFont.systemFont(ofSize: (screenW * 15 / 375))
18+
open static var inComingTextFont = UIFont.systemFont(ofSize: (screenW * 15 / 375))
1919

2020
// var textMessageLable = IMUITextView()
2121
var textMessageLable = M80AttributedLabel()

ios/RCTAuroraIMUI/RCTAuroraIMUIModule.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,24 @@
1515
#import "React/RCTBridgeModule.h"
1616
#endif
1717

18+
//message Notification
1819
#define kAppendMessages @"kAppendMessage"
1920
#define kFristAppendMessage @"kFristAppendMessage"
2021
#define kInsertMessagesToTop @"kInsertMessagesToTop"
2122
#define kUpdateMessge @"kUpdateMessge"
2223
#define kScrollToBottom @"kScrollToBottom"
2324
#define kHidenFeatureView @"kHidenFeatureView"
24-
#define kRecordChangeNotification @"RecordChangeNotification"
25-
#define kRecordLevelNotification @"RecordLevelNotification"
26-
#define kRecordLongNotification @"RecordLongNotification"
27-
#define kGetAtPersonNotification @"GetAtPersonNotification"
2825
#define kDeleteMessage @"kDeleteMessage"
2926
#define kCleanAllMessages @"kCleanAllMessages"
3027
#define kClickLongTouchShowMenu @"kClickLongTouchShowMenuNotification"
3128
#define kStopPlayVoice @"kStopPlayVoice"
29+
#define kRecordLongNotification @"RecordLongNotification"
30+
#define kRecordLevelNotification @"RecordLevelNotification"
31+
32+
//inputControll Notification
33+
#define LoadPagesNotification @"LoadPagesNotification" //加载表情
34+
#define RecordChangeNotification @"RecordChangeNotification"
35+
#define GetAtPersonNotification @"GetAtPersonNotification"
3236

3337
@interface RCTAuroraIMUIModule : NSObject <RCTBridgeModule>
3438

ios/RCTAuroraIMUI/RCTAuroraIMUIModule.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@ - (id)init {
7373
}
7474

7575
RCT_EXPORT_METHOD(clickGetAtPerson:(NSDictionary *)person) {
76-
[[NSNotificationCenter defaultCenter] postNotificationName:kGetAtPersonNotification object:person];
76+
[[NSNotificationCenter defaultCenter] postNotificationName:GetAtPersonNotification object:person];
7777
}
7878

79+
RCT_EXPORT_METHOD(clickLoadEmotionPages) {
80+
[[NSNotificationCenter defaultCenter] postNotificationName:LoadPagesNotification object:nil];
81+
}
82+
83+
7984
RCT_EXPORT_METHOD(tapVoiceBubbleView:(NSString *)messageID) {
8085
[[NSNotificationCenter defaultCenter] postNotificationName:@"tapVoiceBubbleViewNotification" object:messageID];
8186
}

ios/RCTAuroraIMUI/RCTMessageListView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ - (id)initWithCoder:(NSCoder *)aDecoder {
7979
name:kScrollToBottom object:nil];
8080
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickLongTouchShowMenu:) name:kClickLongTouchShowMenu object:nil];
8181

82-
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickRecordNotification:) name:kRecordChangeNotification object:nil];
82+
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickRecordNotification:) name:RecordChangeNotification object:nil];
8383
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickRecordLevelNotification:) name:kRecordLevelNotification object:nil];
8484
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickRecordLongTimeNotification:) name:kRecordLongNotification object:nil];
8585
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(clickChangeHeight:) name:@"ChangeMessageListHeightNotification" object:nil];

0 commit comments

Comments
 (0)