From 80549b57aa6ac390372b6cbae20255ecbf0a07dd Mon Sep 17 00:00:00 2001 From: eggmanQQQ <3671373519@qq.com> Date: Fri, 11 Oct 2024 16:41:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9F=BA=E6=9C=AC=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=86=85=E6=B6=88=E6=81=AF=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Features/Boom/BoomInfoViewController.m | 47 +++--- .../Features/Boom/RoomBoomBannerAnimation.m | 10 +- .../YMRoom/Features/Boom/RoomBoomEntryView.m | 26 ++-- .../Features/Boom/RoomBoomExplosionView.h | 8 - .../Features/Boom/RoomBoomExplosionView.m | 42 +---- .../YMRoom/Features/Boom/RoomBoomManager.h | 4 + .../YMRoom/Features/Boom/RoomBoomManager.m | 15 +- .../MsRoomMessageMainView.m | 129 +++++++++++++--- .../Tool/XPRoomMessageParser.m | 3 + .../XPRoomMessageContainerView.h | 2 + .../XPRoomMessageContainerView.m | 143 +++++++++++++++--- .../YMRoom/View/XPRoomViewController.m | 12 +- YuMi/ar.lproj/Localizable.strings | 4 + YuMi/en.lproj/Localizable.strings | 4 + YuMi/zh-Hans.lproj/Localizable.strings | 4 + YuMi/zh-Hant.lproj/Localizable.strings | 4 + 16 files changed, 311 insertions(+), 146 deletions(-) diff --git a/YuMi/Modules/YMRoom/Features/Boom/BoomInfoViewController.m b/YuMi/Modules/YMRoom/Features/Boom/BoomInfoViewController.m index aa45d0c2..a96d5bfd 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/BoomInfoViewController.m +++ b/YuMi/Modules/YMRoom/Features/Boom/BoomInfoViewController.m @@ -65,10 +65,6 @@ - (void)setLevel:(NSInteger)level { _level = level; - -// NSString *iconPicName = [NSString stringWithFormat:@"room_boom_rocket_box_%ld", (long)level]; -// self.icon.image = kImage(iconPicName); - self.levelLabel.text = [NSString stringWithFormat:@"LV.%ld", (long)level]; } @@ -226,37 +222,38 @@ make.height.mas_equalTo(kGetScaleWidth(188)); }]; - UIButton *bottomButton = [self bottomButton]; - [self.view addSubview:bottomButton]; - [bottomButton mas_makeConstraints:^(MASConstraintMaker *make) { - make.centerX.mas_equalTo(self.view); - make.bottom.mas_equalTo(self.view).offset(-11 - kSafeAreaBottomHeight); - make.width.mas_equalTo(kGetScaleWidth(340)); - make.height.mas_equalTo(kGetScaleWidth(44)); - }]; - _vapView = [[VAPView alloc] init]; - _vapView.contentMode = UIViewContentModeScaleAspectFit; + _vapView.contentMode = UIViewContentModeScaleAspectFill; [self.view addSubview:_vapView]; [_vapView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.view); - make.top.mas_equalTo(self.view).offset(kGetScaleWidth(170)); + make.top.mas_equalTo(self.view).offset(kGetScaleWidth(170) - kSafeAreaBottomHeight); make.width.mas_equalTo(kGetScaleWidth(211)); make.height.mas_equalTo(kGetScaleWidth(489)); }]; [self.view addSubview:self.giftsView]; [self.giftsView mas_makeConstraints:^(MASConstraintMaker *make) { - make.bottom.mas_equalTo(bottomButton.mas_top).offset(-10); - make.centerX.mas_equalTo(self.view); - make.leading.mas_equalTo(10); - make.trailing.mas_equalTo(-10); - make.height.equalTo(self.giftsView.mas_width).multipliedBy(230.0/355.0); + make.bottom.leading.trailing.mas_equalTo(self.view); + make.height.mas_equalTo(kGetScaleWidth(230+65) + kSafeAreaBottomHeight); }]; + + UIButton *bottomButton = [self bottomButton]; + [self.giftsView addSubview:bottomButton]; + [bottomButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.mas_equalTo(self.giftsView); + make.bottom.mas_equalTo(self.view).offset(kGetScaleWidth(-11)); + make.width.mas_equalTo(kGetScaleWidth(340)); + make.height.mas_equalTo(kGetScaleWidth(44)); + }]; + UIImageView *jackpotBackgroundImageView = [self jackpotBackgroundImageView]; [self.giftsView addSubview:jackpotBackgroundImageView]; [jackpotBackgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self.giftsView); + make.bottom.mas_equalTo(self.giftsView).offset(kGetScaleWidth(-65)); + make.centerX.mas_equalTo(self.giftsView); + make.width.mas_equalTo(kGetScaleWidth(355)); + make.height.mas_equalTo(kGetScaleWidth(230)); }]; UIButton *helpButton = [self helpButton]; @@ -366,7 +363,8 @@ [progressBG addSubview:self.progressBar]; [self.progressBar mas_makeConstraints:^(MASConstraintMaker *make) { - make.centerX.mas_equalTo(progressBG); +// make.centerX.mas_equalTo(progressBG); + make.leading.mas_equalTo(progressBG).offset(kGetScaleWidth(21.5)); make.bottom.mas_equalTo(progressBG).offset(kGetScaleWidth(-35)); make.width.mas_equalTo(kGetScaleWidth(18)); make.height.mas_equalTo(kGetScaleWidth(180)).multipliedBy(1); @@ -376,7 +374,8 @@ [self.view addSubview:progressNumberBG]; [progressNumberBG mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(progressBG).offset(kGetScaleWidth(-13)); - make.centerX.mas_equalTo(progressBG); +// make.centerX.mas_equalTo(progressBG); + make.leading.mas_equalTo(progressBG).offset(11); make.width.height.mas_equalTo(kGetScaleWidth(43)); }]; @@ -742,7 +741,7 @@ - (UIImageView *)jackpotBackgroundImageView { UIImageView *bg = [[UIImageView alloc] initWithImage:kImage(@"room_boom_progress_jackpot_bg")]; - bg.contentMode = UIViewContentModeScaleToFill; + bg.contentMode = UIViewContentModeScaleAspectFill; return bg; } diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomBannerAnimation.m b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomBannerAnimation.m index dde6ec90..4fa772f1 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomBannerAnimation.m +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomBannerAnimation.m @@ -114,7 +114,7 @@ - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { - self.backgroundColor = [UIColor yellowColor]; + self.backgroundColor = [UIColor clearColor]; UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:kImage(@"boom_banner_bg")]; backgroundImageView.contentMode = UIViewContentModeScaleAspectFit; @@ -170,7 +170,6 @@ make.right.mas_equalTo(goButton.mas_left); make.height.mas_offset(17); }]; - } return self; } @@ -197,8 +196,6 @@ - (NetImageView *)rocket { if (!_rocket) { _rocket = [[NetImageView alloc] init]; - - _rocket.backgroundColor = [UIColor purpleColor]; } return _rocket; } @@ -208,10 +205,7 @@ _titleLabel = [UILabel labelInitWithText:@"" font:kFontMedium(12) textColor:[UIColor whiteColor]]; - // 设置文本阴影颜色 - _titleLabel.shadowColor = [UIColor redColor]; - - // 设置阴影的偏移量,(width, height),正值表示向右下偏移,负值表示向左上偏移 + _titleLabel.shadowColor = [UIColor grayColor]; _titleLabel.shadowOffset = CGSizeMake(2, 2); } return _titleLabel; diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomEntryView.m b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomEntryView.m index d2467759..ab94e6c3 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomEntryView.m +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomEntryView.m @@ -25,18 +25,18 @@ dispatch_async(dispatch_get_main_queue(), ^{ @kStrongify(self); self.icon.imageUrl = boomModel.pic; -// CGFloat progress = boomModel.speed * 1.0 / 100.0; -// if (progress == 0) { -// self.progress.hidden = YES; -// } else { -// self.progress.hidden = NO; -// [UIView animateWithDuration:0.3 animations:^{ -// [self.progress mas_updateConstraints:^(MASConstraintMaker *make) { -// make.width.mas_equalTo(kGetScaleWidth(32) * progress); -// }]; -// [self layoutIfNeeded]; -// }]; -// } + CGFloat progress = boomModel.speed * 1.0 / 100.0; + if (progress == 0) { + self.progress.hidden = YES; + } else { + self.progress.hidden = NO; + [UIView animateWithDuration:0.3 animations:^{ + [self.progress mas_updateConstraints:^(MASConstraintMaker *make) { + make.width.mas_equalTo(kGetScaleWidth(32) * progress); + }]; + [self layoutIfNeeded]; + }]; + } }); } @@ -60,7 +60,7 @@ [self.progress mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.progressBG); make.leading.mas_equalTo(self.icon).offset(4.5); - make.width.mas_equalTo(kGetScaleWidth(32)); + make.width.mas_equalTo(0); make.height.mas_equalTo(5); }]; } diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.h b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.h index 365892f2..d3a23451 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.h +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.h @@ -17,14 +17,6 @@ NS_ASSUME_NONNULL_BEGIN with:(NSArray *)vapSources complete:(void(^)(void))complete; -//+ (void)display:(UIView *)superView -// with:(AttachmentModel *)attachment -// complete:(void(^)(void))complete; -// -//+ (void)displayWhenEnter:(UIView *)superView -// with:(BoomInfoModel *)model -// complete:(void(^)(void))complete; - - (void)saveCurrenRoomUID:(NSInteger)room; @end diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.m b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.m index f8c64469..123929bf 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.m +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomExplosionView.m @@ -48,42 +48,16 @@ } - (void)saveCurrenRoomUID:(NSInteger)room { - + } -//+ (void)display:(UIView *)superView -// with:(AttachmentModel *)attachment -// complete:(void(^)(void))complete { -// -// if (!attachment) { -// return; -// } -// -// Boom632Model *m = [Boom632Model modelWithJSON:attachment.data]; -// -// RoomBoomExplosionView *explosionView = [[RoomBoomExplosionView alloc] initWithFrame:CGRectMake(0, 0, superView.bounds.size.width, superView.bounds.size.height)]; -// explosionView.userInteractionEnabled = NO; -// explosionView.completeDisplay = complete; -// [superView addSubview:explosionView]; -// explosionView.model = m; -//} -// -//+ (void)displayWhenEnter:(UIView *)superView -// with:(BoomInfoModel *)model -// complete:(void(^)(void))complete { -// if (!model) { -// return; -// } -// -// RoomBoomExplosionView *explosionView = [[RoomBoomExplosionView alloc] initWithFrame:CGRectMake(0, 0, superView.bounds.size.width, superView.bounds.size.height)]; -// explosionView.userInteractionEnabled = NO; -// explosionView.completeDisplay = complete; -// [superView addSubview:explosionView]; -// explosionView.boomInfo = model; -//} - - (void)dealloc { + if (self.seq != 2) { + // 没有播放完就被移除,通知 manager + [[RoomBoomManager sharedManager] explosionEnd]; + } + [self.vapView stopHWDMP4]; [self.vapView removeFromSuperview]; self.vapView = nil; @@ -172,10 +146,6 @@ @kStrongify(self); [[RoomBoomManager sharedManager] explosionEnd]; [self removeFromSuperview]; -// if (self.completeDisplay) { -// self.completeDisplay(); -// -// } }); } } diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.h b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.h index fffc4b6f..65542eb1 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.h +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.h @@ -19,6 +19,8 @@ typedef void(^BoomEventBlock)(id sth); - (NSArray *)loadBoomDetails; +- (void)leaveRoom; + - (void)updateBoomDetailArray:(NSArray *)array; - (void)updateBoomDetail:(BoomDetailModel *)boomDetail; - (void)cleanBoomDetail; @@ -40,6 +42,8 @@ typedef void(^BoomEventBlock)(id sth); - (void)receiveNIMResponse:(AttachmentModel *)attachment; + + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m index 23a347da..be00d49b 100644 --- a/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m +++ b/YuMi/Modules/YMRoom/Features/Boom/RoomBoomManager.m @@ -64,6 +64,10 @@ return self.boomDetailArray; } +- (void)leaveRoom { + self.boomEventsQueue = @[].mutableCopy; +} + - (void)updateBoomDetailArray:(NSArray *)array { self.boomDetailArray = array.mutableCopy; } @@ -129,7 +133,7 @@ url_2 = m.endVapUrl; } else if ([obj isKindOfClass:[RoomBoomSignVo class]]) { url_1 = [(RoomBoomSignVo *)obj countDownVapUrl]; - url_1 = [(RoomBoomSignVo *)obj endVapUrl]; + url_2 = [(RoomBoomSignVo *)obj endVapUrl]; } if (url_1.length > 0 && url_2.length > 0) { @@ -176,7 +180,6 @@ - (void)removeEventListenerForTarget:(id)target { @synchronized (self.progressUpdateListeners) { NSString *key = NSStringFromClass([target class]); - for (NSDictionary *dic in self.progressUpdateListeners) { if ([[dic allKeys] containsObject:key]) { [self.progressUpdateListeners removeObject:dic]; @@ -187,7 +190,6 @@ @synchronized (self.ExplosionListeners) { NSString *key = NSStringFromClass([target class]); - for (NSDictionary *dic in self.ExplosionListeners) { if ([[dic allKeys] containsObject:key]) { [self.ExplosionListeners removeObject:dic]; @@ -198,7 +200,6 @@ @synchronized (self.bannerListeners) { NSString *key = NSStringFromClass([target class]); - for (NSDictionary *dic in self.bannerListeners) { if ([[dic allKeys] containsObject:key]) { [self.bannerListeners removeObject:dic]; @@ -209,7 +210,6 @@ @synchronized (self.boomGiftsListeners) { NSString *key = NSStringFromClass([target class]); - for (NSDictionary *dic in self.boomGiftsListeners) { if ([[dic allKeys] containsObject:key]) { [self.boomGiftsListeners removeObject:dic]; @@ -220,7 +220,6 @@ @synchronized (self.enterRoomExplosionListeners) { NSString *key = NSStringFromClass([target class]); - for (NSDictionary *dic in self.enterRoomExplosionListeners) { if ([[dic allKeys] containsObject:key]) { [self.enterRoomExplosionListeners removeObject:dic]; @@ -236,7 +235,6 @@ } - (void)receiveNIMResponse:(AttachmentModel *)attachment { - // TODO: 增加隊列處理 switch (attachment.second) { case Custom_Message_Room_Boom_EXP: { NSLog(@" 火箭 -------- 631 : %@", attachment.data); @@ -247,8 +245,6 @@ case Custom_Message_Room_Boom_LevelUp: { NSLog(@" 火箭 -------- 632 : %@", attachment.data); [self.boomEventsQueue addObject:attachment]; -// [self handleExplosionUpdate:attachment]; -// [self handleBannerUpdate:attachment]; [self.bannerEventsQueue addObject:attachment]; [self checkAndStartBoomEvent]; @@ -258,7 +254,6 @@ case Custom_Message_Room_Boom_Award: NSLog(@" 火箭 -------- 633 : %@", attachment.data); [self.giftEventsQueue addObject:attachment]; -// [self handleBoomGiftUpdate:attachment]; break; default: break; diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m index ac7d6813..67fdfeca 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m @@ -14,12 +14,18 @@ #import "RoomInfoModel.h" @interface MsRoomMessageMainView() -@property(nonatomic,strong) XPRoomMessageContainerView *roomView; +@property(nonatomic,strong) XPRoomMessageContainerView *messageListView; ///房间的代理 @property (nonatomic,weak) id hostDelegate; ///是否是大的 只有在小游戏的时候有用 @property (nonatomic,assign) BOOL isLarge; + +@property (nonatomic, strong) UIButton *buttonRoom; +@property (nonatomic, strong) UIButton *buttonChat; +@property (nonatomic, strong) UIButton *buttonGift; +@property (nonatomic, strong) UIImageView *selectedMark; + @end @implementation MsRoomMessageMainView @@ -28,24 +34,71 @@ self = [super init]; if (self) { self.hostDelegate = delegate; - -// TODO: 处理连击飘屏 - [self installUI]; [self installConstraints]; } return self; } -(void)installUI{ - [self addSubview:self.roomView]; + [self addSubview:self.buttonRoom]; + [self addSubview:self.buttonChat]; + [self addSubview:self.buttonGift]; + [self addSubview:self.selectedMark]; + [self addSubview:self.messageListView]; } -(void)installConstraints{ - [self.roomView mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.mas_equalTo(self); + [self.buttonRoom mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.top.mas_equalTo(self); + make.width.mas_equalTo(100); + make.height.mas_equalTo(40); + }]; + + [self.buttonChat mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self); + make.leading.mas_equalTo(self.buttonRoom.mas_trailing).offset(8); + make.width.mas_equalTo(100); + make.height.mas_equalTo(40); + }]; + + [self.buttonGift mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self); + make.leading.mas_equalTo(self.buttonChat.mas_trailing).offset(8); + make.width.mas_equalTo(100); + make.height.mas_equalTo(40); + }]; + + [self.selectedMark mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self).offset(40); + make.centerX.mas_equalTo(self.buttonRoom); + make.size.mas_equalTo(CGSizeMake(10, 3)); + }]; + + [self.messageListView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self.buttonRoom.mas_bottom).offset(16); + make.leading.bottom.trailing.mas_equalTo(self); }]; } - (void)showUserCard:(NSInteger)uid{ - [self.roomView showUserCard:uid]; + [self.messageListView showUserCard:uid]; +} + +- (void)didTapButton:(UIButton *)sender { + [self.messageListView changeType:sender.tag - 100]; + + [UIView animateWithDuration:0.2 animations:^{ + [self.selectedMark mas_remakeConstraints:^(MASConstraintMaker *make) { + make.top.mas_equalTo(self).offset(40); + if (sender.tag == 101) { + make.centerX.mas_equalTo(self.buttonRoom); + } else if (sender.tag == 102) { + make.centerX.mas_equalTo(self.buttonChat); + } else { + make.centerX.mas_equalTo(self.buttonGift); + } + make.size.mas_equalTo(CGSizeMake(10, 3)); + }]; + [self layoutIfNeeded]; + }]; } #pragma mark - RoomGuestDelegate @@ -53,7 +106,7 @@ UserInfoModel *infoModel = self.hostDelegate.getUserInfo; NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]]; if(![message.session.sessionId isEqualToString:publicChatRoomId]){ - [self.roomView handleNIMCustomMessage:message]; + [self.messageListView handleNIMCustomMessage:message]; return; } } @@ -62,7 +115,7 @@ UserInfoModel *infoModel = self.hostDelegate.getUserInfo; NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]]; if(![message.session.sessionId isEqualToString:publicChatRoomId]){ - [self.roomView handleNIMNotificationMessage:message]; + [self.messageListView handleNIMNotificationMessage:message]; return; } } @@ -71,7 +124,7 @@ UserInfoModel *infoModel = self.hostDelegate.getUserInfo; NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]]; if(![message.session.sessionId isEqualToString:publicChatRoomId]){ - [self.roomView handleNIMTextMessage:message]; + [self.messageListView handleNIMTextMessage:message]; return; } } @@ -81,15 +134,15 @@ - (void)onRoomMiniEntered { - [self.roomView onRoomMiniEntered]; + [self.messageListView onRoomMiniEntered]; } - (void)onRoomEntered { - [self.roomView onRoomEntered]; + [self.messageListView onRoomEntered]; } - (void)onRoomUpdate { - [self.roomView onRoomUpdate]; + [self.messageListView onRoomUpdate]; } #pragma mark - XPRoomMessageContainerViewDelegate - (void)xPRoomMessageContainerViewlDidTapEmpty:(XPRoomMessageContainerView *)view{ @@ -107,12 +160,50 @@ return 0; } -- (XPRoomMessageContainerView *)roomView{ - if(!_roomView){ - _roomView = [[XPRoomMessageContainerView alloc] initWithDelegate:self.hostDelegate]; - _roomView.delegate = self; +- (XPRoomMessageContainerView *)messageListView{ + if(!_messageListView){ + _messageListView = [[XPRoomMessageContainerView alloc] initWithDelegate:self.hostDelegate]; + _messageListView.delegate = self; } - return _roomView; + return _messageListView; +} + +- (UIButton *)buttonRoom { + if (!_buttonRoom) { + _buttonRoom = [UIButton buttonWithType:UIButtonTypeCustom]; + _buttonRoom.tag = 101; + [_buttonRoom setTitle:YMLocalizedString(@"RoomMessageTitle_0") forState:UIControlStateNormal]; + [_buttonRoom addTarget:self action:@selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside]; + } + return _buttonRoom; +} + +- (UIButton *)buttonChat { + if (!_buttonChat) { + _buttonChat = [UIButton buttonWithType:UIButtonTypeCustom]; + _buttonChat.tag = 102; + [_buttonChat setTitle:YMLocalizedString(@"RoomMessageTitle_1") forState:UIControlStateNormal]; + [_buttonChat addTarget:self action:@selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside]; + } + return _buttonChat; +} + +- (UIButton *)buttonGift { + if (!_buttonGift) { + _buttonGift = [UIButton buttonWithType:UIButtonTypeCustom]; + _buttonGift.tag = 103; + [_buttonGift setTitle:YMLocalizedString(@"RoomMessageTitle_2") forState:UIControlStateNormal]; + [_buttonGift addTarget:self action:@selector(didTapButton:) forControlEvents:UIControlEventTouchUpInside]; + } + return _buttonGift; +} + +- (UIImageView *)selectedMark { + if (!_selectedMark) { + _selectedMark = [[UIImageView alloc] init]; + _selectedMark.backgroundColor = [UIColor systemGreenColor]; + } + return _selectedMark; } @end diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m index 7cfc52ec..79bc2a98 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m @@ -316,6 +316,7 @@ NSAttributedString * attribute = [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont]; messageInfo.content = attribute; } + messageInfo.first = message.messageType; return messageInfo; } @@ -385,6 +386,7 @@ [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser6") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; messageInfo.content = attribute; + messageInfo.first = 10; return messageInfo; } break; @@ -393,6 +395,7 @@ if (self.hostDelegate.getRoomInfo.datingState == RoomDatingStateChangeType_Open) { [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser8") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; messageInfo.content = attribute; + messageInfo.first = 10; return messageInfo; } } diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h index 05f98d44..506bc202 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h @@ -25,6 +25,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)showUserCard:(NSInteger)uid; - (instancetype)initWithDelegate:(id)delegate; +- (void)changeType:(NSInteger)type; + @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m index 728481db..9d18d65e 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m @@ -39,7 +39,6 @@ ///View #import "XPRoomMessageTableViewCell.h" #import "XPRoomMessageHeaderView.h" -#import "View/XPRoomMessageHeaderView.h" #import "PIRoomMessagePhotoAlbumCell.h" #import "PIRoomMessageUnlockPhotoAlbumView.h" #import "PIRoomPhotoAlbumItemModel.h" @@ -65,6 +64,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; @property (nonatomic,assign) BOOL isMiniEnter; ///数据源 @property (nonatomic,strong) NSMutableArray *datasource; +@property (nonatomic,strong) NSMutableArray *datasource_chat; +@property (nonatomic,strong) NSMutableArray *datasource_gift; ///临时存放消息的数组 @property (nonatomic,strong) NSMutableArray *incomingMessages; ///有多少人at我 @@ -76,6 +77,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; @property(nonatomic,strong) PIRoomPhotoAlbumItemModel *lookUpModel; @property(nonatomic,assign) BOOL isLoadHistoryMessage; + +@property (nonatomic, assign) NSInteger displayType; @end @@ -88,6 +91,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; - (instancetype)initWithDelegate:(id)delegate { self = [super init]; if (self) { + self.displayType = 1; self.isLoadHistoryMessage = YES; self.hostDelegate = delegate; [self initSubViews]; @@ -95,6 +99,36 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; } return self; } + +- (void)changeType:(NSInteger)type { + self.displayType = type; + [self updateAllDataSource]; + [self.messageTableView reloadData]; + + if (self.displayType == 1) { + self.messageTableView.tableHeaderView = self.headerView; + } else { + self.messageTableView.tableHeaderView = nil; + } +} + +- (void)updateAllDataSource { + self.datasource_chat = @[].mutableCopy; + self.datasource_gift = @[].mutableCopy; + + for (XPMessageInfoModel *model in self.datasource) { + switch (model.first) { + case NIMMessageTypeText: + [self.datasource_chat addObject:model]; + break; + case CustomMessageType_Gift: + case CustomMessageType_AllMicroSend: + [self.datasource_gift addObject:model]; + break; + } + } +} + - (UIView *)listView { return self; } @@ -153,6 +187,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set]; [self.datasource removeObjectsInArray:needRemoveMsgArray]; + [self updateAllDataSource]; NSMutableIndexSet *indexSet = [NSMutableIndexSet indexSet]; for (int i = 0; i 0){ - NSIndexPath *ip = [NSIndexPath indexPathForRow:self.datasource.count-1 inSection:0]; //取最后一行数据 + NSArray *source = @[]; + switch (self.displayType) { + case 1: + source = self.datasource; + break; + case 2: + source = self.datasource_chat; + break; + case 3: + source = self.datasource_gift; + break; + + default: + source = self.datasource; + break; + } + if(source.count > 0){ + NSIndexPath *ip = [NSIndexPath indexPathForRow:source.count-1 inSection:0]; //取最后一行数据 [self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //滚动到最后一行 self.atCount = 0; self.atTipBtn.hidden = YES; @@ -583,6 +639,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; NSDateComponents *compons = [PLTimeUtil compareTwoDate:date secondDate:[NSDate date]]; if (ABS(compons.year) > 0 || ABS(compons.month) > 0 || ABS(compons.day) > 0) { NIMMessage * message = [[NIMMessage alloc] init]; + NIMTipObject *tipObject = [[NIMTipObject alloc] init]; + message.messageObject = tipObject; NSString * content = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageContainerView3"), roomInfo.introduction]; message.text = content; message.localExt = @{@"isRoomTopic": @(NO)}; @@ -608,6 +666,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; } NIMMessage * message = [[NIMMessage alloc] init]; + NIMTipObject *tipObject = [[NIMTipObject alloc] init]; + message.messageObject = tipObject; message.text = YMLocalizedString(@"XPRoomMessageContainerView5"); message.localExt = @{@"isRoomTopic": @(YES)}; [message setValue:@(NIMMessageTypeTip) forKey:@"messageType"]; @@ -626,6 +686,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; AttachmentModel *attachment = (AttachmentModel *)obj.attachment; if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) { [self.datasource removeAllObjects]; + [self updateAllDataSource]; [self.incomingMessages removeAllObjects]; [self.locationArray removeAllObjects]; self.atCount = 0; @@ -637,6 +698,7 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; return; } else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) { [self.datasource removeAllObjects]; + [self updateAllDataSource]; [self.incomingMessages removeAllObjects]; [self.locationArray removeAllObjects]; self.atCount = 0; @@ -783,6 +845,8 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; } [self createUserEnterRoomAddRoomTopicMessage]; + [self updateAllDataSource]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.messageTableView reloadData]; [self scrollToBottom:YES]; @@ -810,6 +874,9 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; [self roomInfoNoGiftAnimationMessage:message]; } [self createUserEnterRoomAddRoomTopicMessage]; + + [self updateAllDataSource]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [self.messageTableView reloadData]; [self scrollToBottom:YES]; @@ -889,6 +956,9 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; for (NIMMessage *item in temArray) { [self.datasource addObject:[self.messageParser parseMessageAttribute:item]]; } + + [self updateAllDataSource]; + [self.messageTableView reloadData]; //执行插入动画并滚动 [self scrollToBottom:YES]; @@ -959,31 +1029,52 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; #pragma mark - UITableViewDelegate And UITableViewDataSource - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return self.datasource.count; + switch (self.displayType) { + case 1: + return self.datasource.count; + break; + case 2: + return self.datasource_chat.count; + break; + case 3: + return self.datasource_gift.count; + break; + + default: + return self.datasource.count; + break; + } } -//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { -// XPMessageInfoModel* messageInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; -// -// if(messageInfo.first == CustomMessageType_Room_Album){ -// return 186; -// } -// -// return messageInfo.rowHeight; -//} - - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - XPMessageInfoModel* attr = [self.datasource xpSafeObjectAtIndex:indexPath.row]; - if(attr.first == CustomMessageType_Room_Album){ + NSArray *source = @[]; + switch (self.displayType) { + case 1: + source = self.datasource; + break; + case 2: + source = self.datasource_chat; + break; + case 3: + source = self.datasource_gift; + break; + + default: + source = self.datasource; + break; + } + + XPMessageInfoModel *model = [source xpSafeObjectAtIndex:indexPath.row]; + if(model.first == CustomMessageType_Room_Album){ PIRoomMessagePhotoAlbumCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])]; cell.delegate = self; - cell.messageInfo = attr; + cell.messageInfo = model; cell.roomType = self.hostDelegate.getRoomInfo.type; return cell; } else { XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])]; cell.delegate = self; - cell.messageInfo = attr; + cell.messageInfo = model; cell.roomType = self.hostDelegate.getRoomInfo.type; return cell; } @@ -1156,6 +1247,20 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; return _datasource; } +- (NSMutableArray *)datasource_chat { + if (!_datasource_chat) { + _datasource_chat = [NSMutableArray array]; + } + return _datasource_chat; +} + +- (NSMutableArray *)datasource_gift { + if (!_datasource_gift) { + _datasource_gift = [NSMutableArray array]; + } + return _datasource_gift; +} + - (NSMutableArray *)incomingMessages { if (!_incomingMessages) { _incomingMessages = [NSMutableArray array]; diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index 05c7ab4a..20619487 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -286,6 +286,8 @@ XPCandyTreeInsufficientBalanceViewDelegate> timer = nil; } + [[RoomBoomManager sharedManager] leaveRoom]; + [[CountDownHelper shareHelper] stopCountDown]; [CountDownHelper shareHelper].delegate = nil; [[NIMSDK sharedSDK].chatroomManager removeDelegate:self]; @@ -1928,14 +1930,6 @@ XPCandyTreeInsufficientBalanceViewDelegate> [[NSNotificationCenter defaultCenter]postNotificationName:kFreeGiftCountdownNotification object:nil userInfo:@{@"updateGiftInfo":attachment.data ?: @""}]; } } -// else if (attachment.first == CustomMessageType_RoomBoom) { -// if (attachment.second == 631) { -// [[RoomBoomManager sharedManager] receiveNIMResponse:attachment]; -// } else if (attachment.second == 633) { -// [[RoomBoomManager sharedManager] receiveNIMResponse:attachment]; -// } -// } - [self.messageContainerView handleNIMCustomMessage:message]; } } else if(message.messageType == NIMMessageTypeText) { @@ -2345,7 +2339,7 @@ XPCandyTreeInsufficientBalanceViewDelegate> } - (void)getRoomBoomExplosionSuccess:(BoomInfoModel *)model { -// [[RoomBoomManager sharedManager] updateBoomDetailArray:models]; + [[RoomBoomManager sharedManager] receiveEnterRoomBoom:model]; } #pragma mark - 首次退出非自己的房间,处理是否需要弹新用户充值优惠 diff --git a/YuMi/ar.lproj/Localizable.strings b/YuMi/ar.lproj/Localizable.strings index f71e99b3..04d2547c 100644 --- a/YuMi/ar.lproj/Localizable.strings +++ b/YuMi/ar.lproj/Localizable.strings @@ -3938,3 +3938,7 @@ ineHeadView12" = "الحمل"; "RoomBoom_4" = ",前去圍觀"; "RoomBoom_5" = "房間暱稱:"; "RoomBoom_6" = "Reset time: 0:00 (GMT+3) daily"; + +"RoomMessageTitle_0" = "房間"; +"RoomMessageTitle_1" = "聊天"; +"RoomMessageTitle_2" = "禮物"; diff --git a/YuMi/en.lproj/Localizable.strings b/YuMi/en.lproj/Localizable.strings index 0e4ac942..3e47773d 100644 --- a/YuMi/en.lproj/Localizable.strings +++ b/YuMi/en.lproj/Localizable.strings @@ -3734,3 +3734,7 @@ "RoomBoom_4" = ",前去圍觀"; "RoomBoom_5" = "房間暱稱:"; "RoomBoom_6" = "Reset time: 0:00 (GMT+3) daily"; + +"RoomMessageTitle_0" = "房間"; +"RoomMessageTitle_1" = "聊天"; +"RoomMessageTitle_2" = "禮物"; diff --git a/YuMi/zh-Hans.lproj/Localizable.strings b/YuMi/zh-Hans.lproj/Localizable.strings index ad35a600..888cf80a 100644 --- a/YuMi/zh-Hans.lproj/Localizable.strings +++ b/YuMi/zh-Hans.lproj/Localizable.strings @@ -3398,3 +3398,7 @@ "RoomBoom_4" = ",前去圍觀"; "RoomBoom_5" = "房間暱稱:"; "RoomBoom_6" = "Reset time: 0:00 (GMT+3) daily"; + +"RoomMessageTitle_0" = "房間"; +"RoomMessageTitle_1" = "聊天"; +"RoomMessageTitle_2" = "禮物"; diff --git a/YuMi/zh-Hant.lproj/Localizable.strings b/YuMi/zh-Hant.lproj/Localizable.strings index c9381ca2..9e7b50c5 100644 --- a/YuMi/zh-Hant.lproj/Localizable.strings +++ b/YuMi/zh-Hant.lproj/Localizable.strings @@ -3390,3 +3390,7 @@ "RoomBoom_4" = ",前去圍觀"; "RoomBoom_5" = "房間暱稱:"; "RoomBoom_6" = "Reset time: 0:00 (GMT+3) daily"; + +"RoomMessageTitle_0" = "房間"; +"RoomMessageTitle_1" = "聊天"; +"RoomMessageTitle_2" = "禮物";