diff --git a/YuMi.xcodeproj/project.pbxproj b/YuMi.xcodeproj/project.pbxproj index c9bec060..791a0e64 100644 --- a/YuMi.xcodeproj/project.pbxproj +++ b/YuMi.xcodeproj/project.pbxproj @@ -228,6 +228,9 @@ 2357148C2BECEE33004C81D6 /* MSSessionPublicChatHalTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357148B2BECEE33004C81D6 /* MSSessionPublicChatHalTextCell.m */; }; 2357148F2BEDC94D004C81D6 /* MSSessionPublicChatHalImageCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357148E2BEDC94D004C81D6 /* MSSessionPublicChatHalImageCell.m */; }; 235714922BEDC9B1004C81D6 /* MSSessionPublicChatHalImageModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714912BEDC9B1004C81D6 /* MSSessionPublicChatHalImageModel.m */; }; + 235714952BEDF517004C81D6 /* MsRoomMessagChatHallView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714942BEDF517004C81D6 /* MsRoomMessagChatHallView.m */; }; + 235714982BEDF54E004C81D6 /* MsRoomMessageMainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235714972BEDF54E004C81D6 /* MsRoomMessageMainView.m */; }; + 2357149B2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2357149A2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m */; }; 235A451A2B04A352009753F5 /* PIRoomActivityWebView.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */; }; 235A451D2B04A452009753F5 /* PIRoomActivityWebCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A451C2B04A452009753F5 /* PIRoomActivityWebCell.m */; }; 235A45232B04BEB6009753F5 /* PIBaseModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 235A45222B04BEB6009753F5 /* PIBaseModel.m */; }; @@ -1973,6 +1976,12 @@ 2357148E2BEDC94D004C81D6 /* MSSessionPublicChatHalImageCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionPublicChatHalImageCell.m; sourceTree = ""; }; 235714902BEDC9B1004C81D6 /* MSSessionPublicChatHalImageModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSSessionPublicChatHalImageModel.h; sourceTree = ""; }; 235714912BEDC9B1004C81D6 /* MSSessionPublicChatHalImageModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSSessionPublicChatHalImageModel.m; sourceTree = ""; }; + 235714932BEDF517004C81D6 /* MsRoomMessagChatHallView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MsRoomMessagChatHallView.h; sourceTree = ""; }; + 235714942BEDF517004C81D6 /* MsRoomMessagChatHallView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessagChatHallView.m; sourceTree = ""; }; + 235714962BEDF54E004C81D6 /* MsRoomMessageMainView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MsRoomMessageMainView.h; sourceTree = ""; }; + 235714972BEDF54E004C81D6 /* MsRoomMessageMainView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessageMainView.m; sourceTree = ""; }; + 235714992BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MsRoomMessagChatHallCell.h; sourceTree = ""; }; + 2357149A2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MsRoomMessagChatHallCell.m; sourceTree = ""; }; 235A45182B04A352009753F5 /* PIRoomActivityWebView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebView.h; sourceTree = ""; }; 235A45192B04A352009753F5 /* PIRoomActivityWebView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PIRoomActivityWebView.m; sourceTree = ""; }; 235A451B2B04A452009753F5 /* PIRoomActivityWebCell.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PIRoomActivityWebCell.h; sourceTree = ""; }; @@ -8157,6 +8166,8 @@ E84B0E412727EE0A008818C6 /* XPRoomMessageHeaderView.m */, E84B0E3D2727EDF6008818C6 /* XPRoomMessageTableViewCell.h */, E84B0E3E2727EDF6008818C6 /* XPRoomMessageTableViewCell.m */, + 235714992BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.h */, + 2357149A2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m */, ); path = View; sourceTree = ""; @@ -9971,8 +9982,12 @@ E84B0E47272801F6008818C6 /* Tool */, E84B0E432727EF2C008818C6 /* Model */, E84B0E3C2727EDD4008818C6 /* View */, + 235714962BEDF54E004C81D6 /* MsRoomMessageMainView.h */, + 235714972BEDF54E004C81D6 /* MsRoomMessageMainView.m */, E8AEAEF127141C7C0017FCE0 /* XPRoomMessageContainerView.h */, E8AEAEF227141C7C0017FCE0 /* XPRoomMessageContainerView.m */, + 235714932BEDF517004C81D6 /* MsRoomMessagChatHallView.h */, + 235714942BEDF517004C81D6 /* MsRoomMessagChatHallView.m */, ); path = MessageContainerView; sourceTree = ""; @@ -11216,6 +11231,7 @@ E8751E6E28A64F990056EF44 /* XPSailingEmptyTableViewCell.m in Sources */, E87E625A2A3F560B002F68C9 /* XPHomeRecommendViewController.m in Sources */, E8950189282CFFB1007E459A /* XPMonentsLayoutConfig.m in Sources */, + 2357149B2BEE2AD1004C81D6 /* MsRoomMessagChatHallCell.m in Sources */, E81061032987CFCE00B772F0 /* MessageSkillCardModel.m in Sources */, 9BD9A18727A120FD004186FE /* XPMineVisitorUnReadModel.m in Sources */, E85E7BAD2A4EC99300B6D00A /* XPMineGiveDiamondDetailsCell.m in Sources */, @@ -11829,6 +11845,7 @@ E8098CAE282E07C00090B9F0 /* XPMonentsEmptyTableViewCell.m in Sources */, 237700D72BC7D51400D661F1 /* UIButton+MSRTL.m in Sources */, E85E7B4F2A4EB0D300B6D00A /* XPMineExchangeAuthorityVC.m in Sources */, + 235714952BEDF517004C81D6 /* MsRoomMessagChatHallView.m in Sources */, 23FE47DB2BB4171C00F09D23 /* PINobleCenterListView.m in Sources */, E84A2E932A527EC800D6AF8A /* XPIncomeRecordPresent.m in Sources */, 236B2E432AA07D06003967A8 /* NSString+RW.m in Sources */, @@ -11843,6 +11860,7 @@ E8778AF82988F4E200CF139B /* XPSessionSayHelloHeaderView.m in Sources */, E84150C527747E0900A7F548 /* FirstRechargeRewardModel.m in Sources */, E8B9843328ABA2FF0022D026 /* MonentsPicResInfo.m in Sources */, + 235714982BEDF54E004C81D6 /* MsRoomMessageMainView.m in Sources */, 9BE9F10227FEE5C200667200 /* XPAnchorFansTaskDetailModel.m in Sources */, E8E0DAE6285C280E00566A2F /* XPSessionFindNewAlertView.m in Sources */, E85E7B1A2A4EB0D200B6D00A /* XPMineGoldIncomeRecordVC.m in Sources */, diff --git a/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@2x.png b/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@2x.png index bb68ff99..f73bb0b4 100644 Binary files a/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@2x.png and b/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@3x.png b/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@3x.png index 9155aad6..93594504 100644 Binary files a/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@3x.png and b/YuMi/Assets.xcassets/chat/ms_public_chat_hall_head_enter_bg.imageset/ms_public_chat_hall_head_enter_bg@3x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/Contents.json b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/Contents.json new file mode 100644 index 00000000..ec64b85b --- /dev/null +++ b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ms_room_message_send_headline_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ms_room_message_send_headline_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@2x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@2x.png new file mode 100644 index 00000000..4112fc59 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@3x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@3x.png new file mode 100644 index 00000000..ae27a42e Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon.imageset/ms_room_message_send_headline_icon@3x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/Contents.json b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/Contents.json new file mode 100644 index 00000000..af36f27b --- /dev/null +++ b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ms_room_message_send_headline_icon_ar@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ms_room_message_send_headline_icon_ar@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@2x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@2x.png new file mode 100644 index 00000000..6b016ba4 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@3x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@3x.png new file mode 100644 index 00000000..d3ffbb86 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_ar.imageset/ms_room_message_send_headline_icon_ar@3x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/Contents.json b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/Contents.json new file mode 100644 index 00000000..08cf46e1 --- /dev/null +++ b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "ms_room_message_send_headline_icon_en@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "ms_room_message_send_headline_icon_en@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@2x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@2x.png new file mode 100644 index 00000000..f2de4d04 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@2x.png differ diff --git a/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@3x.png b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@3x.png new file mode 100644 index 00000000..f3df0721 Binary files /dev/null and b/YuMi/Assets.xcassets/chat/ms_room_message_send_headline_icon_en.imageset/ms_room_message_send_headline_icon_en@3x.png differ diff --git a/YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m b/YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m index a802b33c..29274a65 100644 --- a/YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m +++ b/YuMi/CustomUI/MSRTL/YYLabel+MSRTL.m @@ -30,6 +30,7 @@ BOOL isRTLString(NSString *string) { } -(void)msrtl_setAttributedText:(NSAttributedString *)attributedText{ + if(attributedText == nil)return; NSMutableAttributedString * attributedString = [[NSMutableAttributedString alloc]init]; if(self.textAlignment == NSTextAlignmentCenter){ if (isMSRTL()) { @@ -46,6 +47,7 @@ BOOL isRTLString(NSString *string) { [attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSRTL]]; // [attributedString appendAttributedString:[NSMutableAttributedString createBlankAttributeToMSLTR]]; } + [attributedString appendAttributedString:attributedText]; [self msrtl_setAttributedText:attributedString]; if(isMSRTL()){ diff --git a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentHeadLinesText.m b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentHeadLinesText.m index f7160f54..78506259 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/MessageContentHeadLinesText.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/MessageContentHeadLinesText.m @@ -166,7 +166,7 @@ [self.rightAvatar loadImageWithUrl:extModel.avatar completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) { self.rightAvatar.image = image; }]; - self.rightMessageText.text = self.message.text; + self.rightMessageText.attributedText = textModel.textAttribute; self.rightBubbleImageView.image = nil; self.rightBgImage.image = [self resizableImage:kImage(@"ms_message_headlines_text_right")]; @@ -223,7 +223,7 @@ self.leftBubbleImageView.image = [self resizableImage:image1]; }]; self.leftNameView.attributedText = textModel.nameAtt; - self.messageText.text = self.message.text; + self.messageText.attributedText = textModel.textAttribute; } - (UIImage*)resizableImage:(UIImage *)image { //图片拉伸区域 diff --git a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.h b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.h index d1ab4019..8badf16a 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.h +++ b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.h @@ -10,7 +10,8 @@ NS_ASSUME_NONNULL_BEGIN @interface MessageHeadlinesTextModel : MessageBaseModel - +///富文本 +@property (nonatomic,strong) NSAttributedString *textAttribute; @property(nonatomic,strong) NSMutableAttributedString *nameAtt; @property(nonatomic,assign) BOOL isSelf ; @property(nonatomic,strong) XPMessageRemoteExtModel *extModel; diff --git a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.m b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.m index 9ec4ba6c..57be58fb 100644 --- a/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.m +++ b/YuMi/Modules/YMMessage/View/Session/Content/SesssionModel/MessageHeadlinesTextModel.m @@ -30,13 +30,34 @@ if (!messageText) { messageText = YMLocalizedString(@"MessageTextModel0"); } + + + + + + CGFloat width = [UILabel getWidthWithText:messageText height:kGetScaleWidth(36) font:kFontMedium(14)]; width = width > kGetScaleWidth(200) ? kGetScaleWidth(200) : width; self.width = width >= kGetScaleWidth(220) ? kGetScaleWidth(220) : (width + kGetScaleWidth(25)); - CGFloat height = [UILabel getLabelHeightWithText:messageText width:width font:kFontMedium(14)] + kGetScaleWidth(25); - self.imageHeight = height; - self.height = (self.isSelf ? kGetScaleWidth(35) : kGetScaleWidth(65)) + height; + + + CGSize dstRect = CGSizeMake(width, MAXFLOAT); + QEmotionHelper *faceManager = [QEmotionHelper sharedEmotionHelper]; + NSMutableAttributedString * attribute = [faceManager attributedStringByText:messageText font:kFontMedium(14)]; + if(extModel.iosBubbleUrl.length > 0){ + [attribute addAttributes:@{NSForegroundColorAttributeName: UIColorFromRGB(0x333333)} range:[attribute.string rangeOfString:attribute.string]]; + }else{ + [attribute addAttributes:@{NSForegroundColorAttributeName:self.isSelf ? UIColorFromRGB(0x333333) : [UIColor whiteColor]} range:[attribute.string rangeOfString:attribute.string]]; + } + + self.textAttribute = attribute; + YYTextContainer *container = [YYTextContainer containerWithSize:dstRect]; + container.maximumNumberOfRows = 0; + YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:attribute]; + CGFloat rowHeight = layout.textBoundingSize.height + kGetScaleWidth(25); + self.imageHeight = rowHeight; + self.height = (self.isSelf ? kGetScaleWidth(35) : kGetScaleWidth(65)) + rowHeight; self.isHiddenAvatar = YES; } diff --git a/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m b/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m index 06ae01a4..b6159db6 100644 --- a/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m +++ b/YuMi/Modules/YMMessage/View/Session/MSSessionPublicChatHallVC.m @@ -52,6 +52,7 @@ #import "XPIncomeRecordModel.h" #import "XPCandyTreeInsufficientBalanceView.h" #import "XPIAPRechargeViewController.h" +#import "Api+Mine.h" @interface MSSessionPublicChatHallVC () @property (nonatomic, strong) NIMSession * session; @property (nonatomic, strong) NSMutableArray * messages; @@ -81,7 +82,7 @@ - (void)dealloc { [[NIMSDK sharedSDK].chatManager removeDelegate:self]; [[NSNotificationCenter defaultCenter] removeObserver:self]; - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(setHeadViewData) object:nil]; + [self.presenter exitNIMRoom:self.publicChatMessageRoomId]; } @@ -156,14 +157,14 @@ model = [[MessageHeadlinesModel alloc] initWithMessage:message]; MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data]; self.headView.topModel = topModel; - [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(setHeadViewData) object:nil]; + [self setTime:topModel]; } return model; } -(void)setTime:(MSSessionPublicChatHallTopModel *)topModel{ - NSInteger time = topModel.endTime/1000 - topModel.startTime/1000; - [self performSelector:@selector(setHeadViewData) withObject:nil afterDelay:time]; +// NSInteger time = topModel.endTime/1000 - topModel.startTime/1000; +// [self performSelector:@selector(setHeadViewData) withObject:nil afterDelay:time]; } -(void)setHeadViewData{ diff --git a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.h b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.h index 52028289..1860d137 100644 --- a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.h +++ b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @end @interface MSSessionReleaseHeadlinesPayView : UIView +@property(nonatomic,copy) NSString *releaseCoins; @property(nonatomic,copy) NSString *coins; @property(nonatomic,weak) iddelegate; @end diff --git a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.m b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.m index b5a1cf7b..a3f8880b 100644 --- a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.m +++ b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesPayView.m @@ -77,6 +77,10 @@ [self.delegate payReleaseHeadlines]; } } +-(void)setReleaseCoins:(NSString *)releaseCoins{ + _releaseCoins = releaseCoins; + _numView.text = _releaseCoins; +} - (void)setCoins:(NSString *)coins{ _coins = coins; UIImage *iconImage = kImage(@"exchange_gold_icon"); diff --git a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.h b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.h index 3c07dbdc..ef40d9fe 100644 --- a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.h +++ b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.h @@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property(nonatomic,copy) NSString *golds; @property(nonatomic,copy) NSString *myCoins; @property(nonatomic,weak) iddelegate; +-(void)loadDataForRoom; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.m b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.m index 2ff2a42f..4d284569 100644 --- a/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.m +++ b/YuMi/Modules/YMMessage/View/Session/View/MSSessionReleaseHeadlinesView.m @@ -4,7 +4,9 @@ // // Created by duoban on 2024/5/9. // - +#import "Api+Mine.h" +#import "XPIncomeRecordModel.h" +#import "Api+Message.h" #import "MSSessionReleaseHeadlinesView.h" #import "MSSessionReleaseHeadlinesPayView.h" @interface MSSessionReleaseHeadlinesView() @@ -13,6 +15,7 @@ @property(nonatomic,strong) UIView *bgTextView; @property(nonatomic,strong) UIButton *releaseBtn; @property(nonatomic,strong) UIButton *backBtn; +@property(nonatomic,assign) BOOL isRoom; @end @implementation MSSessionReleaseHeadlinesView @@ -60,6 +63,21 @@ make.top.equalTo(self.bgTextView.mas_bottom).mas_offset(kGetScaleWidth(26)); }]; } +-(void)loadDataForRoom{ + self.isRoom = YES; + [self getCoinsData]; +} +-(void)getCoinsData{ + [Api requestRecordIncome:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + XPIncomeRecordModel *model = [XPIncomeRecordModel modelWithDictionary:data.data]; + self.myCoins = @(model.diamonds).stringValue; + } + }]; + [Api getPublicChatHallTopTextPayMoney:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + self.golds = [NSString stringWithFormat:@"%@",data.data]; + }]; +} -(void)releaseBtnAction{ if(self.textView.text.length == 0){ [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"MSSessionReleaseHeadlinesView0")]; @@ -67,6 +85,7 @@ } [self.textView resignFirstResponder]; MSSessionReleaseHeadlinesPayView *payView = [[MSSessionReleaseHeadlinesPayView alloc]initWithFrame:CGRectZero]; + payView.releaseCoins = self.golds; payView.coins = self.myCoins; payView.delegate = self; [self addSubview:payView]; @@ -77,6 +96,25 @@ } -(void)payReleaseHeadlines{ + if(self.isRoom){ + if (self.myCoins.integerValue < self.golds.integerValue){ + if(self.delegate && [self.delegate respondsToSelector:@selector(releaseHeadlinesWithText:)]){ + [self.delegate releaseHeadlinesWithText:self.textView.text]; + } + [TTPopup dismiss]; + return; + } + + [Api sendPublicChatHallTopText:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + [TTPopup dismiss]; + [XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPSessionFindNewGreetListView0")]; + return; + } + [XNDJTDDLoadingTool showErrorWithMessage:msg]; + } content:self.textView.text]; + return; + } if(self.delegate && [self.delegate respondsToSelector:@selector(releaseHeadlinesWithText:)]){ [self.delegate releaseHeadlinesWithText:self.textView.text]; } diff --git a/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m b/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m index 534d0d51..de30cf74 100644 --- a/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m +++ b/YuMi/Modules/YMMessage/View/Session/XPSessionMainViewController.m @@ -92,18 +92,18 @@ }]; [self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(kStatusBarHeight); - make.height.mas_equalTo(kGetScaleWidth(99)); + make.height.mas_equalTo(kGetScaleWidth(112)); make.leading.trailing.equalTo(self.view); }]; [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { - make.top.mas_equalTo(kGetScaleWidth(13)); + make.top.mas_equalTo(kGetScaleWidth(25.5)); make.centerX.equalTo(self.bgImageView); }]; [self.scrollingView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(0); - make.top.mas_equalTo(kGetScaleWidth(35)); + make.top.mas_equalTo(kGetScaleWidth(48)); make.trailing.mas_equalTo(-kGetScaleWidth(0)); - make.bottom.mas_equalTo(kGetScaleWidth(10)); + make.bottom.mas_equalTo(kGetScaleWidth(8)); }]; [self.pagingView mas_makeConstraints:^(MASConstraintMaker *make) { diff --git a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h index 2c4d5103..c21fce67 100644 --- a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h +++ b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @class UserInfoModel; @interface XPRoomPresenter : BaseMvpPresenter +@property(nonatomic,strong) UserInfoModel *infoModel; + - (void)initEnterRoom:(NSString *)roomUid user:(NSString *)uid; diff --git a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m index fa945f41..5ac1afd3 100644 --- a/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m +++ b/YuMi/Modules/YMRoom/Presenter/XPRoomPresenter.m @@ -6,6 +6,7 @@ // #import "XPRoomPresenter.h" +#import "ClientConfig.h" ///API #import "Api+Room.h" #import "Api+Gift.h" @@ -45,6 +46,7 @@ [Api getUserInfo:[self createHttpCompletion:^(BaseModel * _Nonnull data) { UserInfoModel * infoModel = [UserInfoModel modelWithJSON:data.data]; + self.infoModel = infoModel; [user sendNext:infoModel]; [user sendCompleted]; } fail:^(NSInteger code, NSString * _Nullable msg) { @@ -110,10 +112,22 @@ [[self getView] enterRoomSuccess:chatroom]; } }]; + NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[userInfo.partitionId]]; + NIMChatroomEnterRequest *publicChatRoomRequest = [[NIMChatroomEnterRequest alloc] init]; + publicChatRoomRequest.roomId = publicChatRoomId; + + NSMutableDictionary *publicChatRoomExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:publicChatRoomId]; + request.roomExt = [publicChatRoomExt toJSONString]; + + [[NIMSDK sharedSDK].chatroomManager enterChatroom:publicChatRoomRequest completion:^(NSError * _Nullable error, NIMChatroom * _Nullable chatroom, NIMChatroomMember * _Nullable me) { + NSLog(@"111"); + }]; } - (void)exitNIMRoom:(NSString *)roomId { [[NIMSDK sharedSDK].chatroomManager exitChatroom:roomId completion:nil]; + NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[self.infoModel.partitionId]]; + [[NIMSDK sharedSDK].chatroomManager exitChatroom:publicChatRoomId completion:nil]; } /// 开启用户自己的房间 diff --git a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m index fc8084a1..011737bb 100644 --- a/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m +++ b/YuMi/Modules/YMRoom/View/AnimationView/XPRoomAnimationView.m @@ -919,6 +919,16 @@ #pragma mark - 进房动画 XXX来了 - (void)userEnterRoom:(NIMChatroomNotificationContent *)content ext:(XPMessageRemoteExtModel *)extModel { + if(extModel.enterRoomEffects.length > 0){ + NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomAnimationView0"), content.source.nick]; + if (self.enterEffectQueue.count ==0) { + [self playUserEnterRoomAnimation:title experLevelSeq:extModel.experLevelSeq effectPath:extModel.enterRoomEffects]; + } + NSDictionary * dic= @{@"title":title, @"experLevelSeq":[NSString stringWithFormat:@"%ld", extModel.experLevelSeq], @"effectPath" : extModel.enterRoomEffects.length ? extModel.enterRoomEffects : @""}; + [self.enterEffectQueue addObject:dic]; + return; + } + if (extModel.experLevelSeq < 30) return; NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomAnimationView0"), content.source.nick]; if (self.enterEffectQueue.count ==0) { diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.h b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.h index 551e7863..4838422b 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.h +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.h @@ -9,6 +9,10 @@ #import "RoomHostDelegate.h" NS_ASSUME_NONNULL_BEGIN + + + + @interface XPRoomSendTextView : UIView - (instancetype)initWithDelegate:(id)delegate; diff --git a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.m b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.m index 0e1a0de9..5a002752 100644 --- a/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.m +++ b/YuMi/Modules/YMRoom/View/MenuContainerView/XPRoomSendTextView.m @@ -19,16 +19,19 @@ #import "XPMessageRemoteExtModel.h" #import "UserInfoModel.h" #import "RoomInfoModel.h" +#import "ClientConfig.h" //公屏限制最大字数 #define MAX_STARWORDS_LENGTH 300 @interface XPRoomSendTextView () -/// -@property (nonatomic,strong) UIStackView *stackView; + ///输入框 @property (nonatomic, strong) MSBaseTextField *editTextFiled; +@property (nonatomic, strong) UIView *bgEditTextFiled; ///发送按钮 @property (nonatomic, strong) UIButton *sendButton; +///上头像 +@property(nonatomic,strong) UIButton *headlineBtn; ///文本输入的内容 @property (nonatomic,copy) NSString *inputMessage; ///代理 @@ -47,7 +50,7 @@ } - (instancetype)initWithDelegate:(id)delegate { - self = [super initWithFrame:CGRectMake(0, KScreenHeight - 40, KScreenWidth, 40)]; + self = [super initWithFrame:CGRectMake(0, KScreenHeight - 60, KScreenWidth, 60)]; if (self) { self.delegate = delegate; [self addNotification]; @@ -78,27 +81,36 @@ extModel.iosBubbleUrl = userInfo.iosBubbleUrl; extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel; + if([self.delegate getPublicScreenType]==1){ + extModel.avatar = userInfo.avatar; + extModel.nick = userInfo.nick; + NSString * headwearUrl= userInfo.headwearEffect.length > 0 ? userInfo.headwearEffect : userInfo.headwearPic; + extModel.headwearUrl = headwearUrl; + } + NIMMessage * message = [[NIMMessage alloc] init]; message.text = self.inputMessage; NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[AccountInfoStorage instance].getUid]; - //查找消息中是否有@人 - NSMutableArray *nickArray = [NSMutableArray array]; - NSMutableArray *uidArray = [NSMutableArray array]; - for (int i = 0; i +#import "RoomHostDelegate.h" +#import "RoomGuestDelegate.h" +#import +NS_ASSUME_NONNULL_BEGIN + +@interface MsRoomMessagChatHallView : UIView +- (instancetype)initWithDelegate:(id)delegate; +- (void)handleNIMImageMessage:(NIMMessage *)message; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m new file mode 100644 index 00000000..2f1b1904 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessagChatHallView.m @@ -0,0 +1,637 @@ +// +// MsRoomMessagChatHallView.m +// YuMi +// +// Created by duoban on 2024/5/10. +// + +#import "MsRoomMessagChatHallView.h" +///Third +#import +#import + +///Tool +#import "DJDKMIMOMColor.h" +#import "YUMIMacroUitls.h" +#import "XPRoomMessageConstant.h" +#import "XPRoomMessageParser.h" +#import "AccountInfoStorage.h" +#import "XPRoomMiniManager.h" +#import "PLTimeUtil.h" +#import "ClientConfig.h" +#import +#import "ThemeColor+Room.h" +#import "NSArray+Safe.h" +#import "Api+Room.h" +#import "Api+Message.h" +#import "XPMessageRemoteExtModel.h" +///Model +#import "RoomInfoModel.h" +#import "AttachmentModel.h" +#import "RoomFaceSendInfoModel.h" +#import "XPMessageRemoteExtModel.h" +#import "RoomPKChooseUserModel.h" +#import "CandyTreeResultModel.h" +#import "RoomSailingPrizeModel.h" +#import "UserInfoModel.h" +#import "XPMessageInfoModel.h" +#import "GiftReceiveInfoModel.h" +#import "XPGiftStorage.h" +///View +#import "XPRoomMessageTableViewCell.h" +#import "XPRoomMessageHeaderView.h" +#import "View/XPRoomMessageHeaderView.h" +#import "PIRoomMessagePhotoAlbumCell.h" +#import "PIRoomMessageUnlockPhotoAlbumView.h" +#import "PIRoomPhotoAlbumItemModel.h" +#import "SDPhotoBrowser.h" +#import "XPSkillCardPlayerManager.h" +#import "MsRoomMessagChatHallCell.h" +#import "MSSessionPublicChatHallTopModel.h" +@interface MsRoomMessagChatHallView () +///房间的代理 +@property (nonatomic,weak) id hostDelegate; + +///列表 +@property (nonatomic,strong) UITableView *messageTableView; +///头部 +@property (nonatomic,strong) UIView *headerView; +@property(nonatomic,strong) UILabel *titleView; +///messageView 持有这个工具类 进行数据的分发操作 TODO: 有需要在改 +@property (nonatomic,strong) XPRoomMessageParser *messageParser; + +///是否是最小化进房的 +@property (nonatomic,assign) BOOL isMiniEnter; +///数据源 +@property (nonatomic,strong) NSMutableArray *datasource; + +@property(nonatomic,strong) PIRoomPhotoAlbumItemModel *lookUpModel; + +///是否是大的 只有在小游戏的时候有用 +@property (nonatomic,assign) BOOL isLarge; +@property(nonatomic,assign) BOOL isLoadHistoryMessage; +@end +@implementation MsRoomMessagChatHallView + +- (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self]; +} + +- (instancetype)initWithDelegate:(id)delegate { + self = [super init]; + if (self) { + self.isLoadHistoryMessage = YES; + self.hostDelegate = delegate; + [self initSubViews]; + [self initSubViewConstraints]; + } + return self; +} +#pragma mark - JXCategoryListContentViewDelegate +- (UIView *)listView { + return self; +} +- (void)showUserCard:(NSInteger)uid{ + [self.messageParser showUserCard:uid]; +} +#pragma mark - Response + + + + + + +#pragma mark - Private Method +- (void)initSubViews { + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil]; + [self addSubview:self.headerView]; + [self.headerView addSubview:self.titleView]; + [self addSubview:self.messageTableView]; + + [Api getPublicChatHallTopText:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + if(code == 200){ + MSSessionPublicChatHallTopModel *model = [MSSessionPublicChatHallTopModel modelWithDictionary:data.data]; + if(model != nil){ + self.titleView.text = model.content; + [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.top.trailing.mas_equalTo(self); + make.height.mas_greaterThanOrEqualTo(0); + + }]; + }else{ + [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.top.trailing.mas_equalTo(self); + make.height.mas_equalTo(0); + + }]; + } + + } + }]; +} + +- (void)initSubViewConstraints { + [self.headerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.top.trailing.mas_equalTo(self); + make.height.mas_greaterThanOrEqualTo(0); + + }]; + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.trailing.top.bottom.equalTo(self.headerView).inset(10); + }]; + [self.messageTableView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.bottom.trailing.mas_equalTo(self); + make.top.equalTo(self.headerView.mas_bottom).mas_offset(10); + }]; + + +} + + + + + +#pragma mark - 添加数据并且做自动滚动 + + +///执行插入动画并滚动 +- (void)scrollToBottom:(BOOL)animated { + if(self.datasource.count > 0){ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + NSIndexPath *ip = [NSIndexPath indexPathForRow:self.datasource.count-1 inSection:0]; //取最后一行数据 + [self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //滚动到最后一行 + }); + + + } + +} + +///自定义消息 是否可以加到 公屏 需要自己维护 +- (BOOL)isCanDisplayMessage:(NIMMessage *)message { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel *attachment = (AttachmentModel *)obj.attachment; + return [[[self supportMessageDic] objectForKey:@(attachment.first)] containsObject:@(attachment.second)]; + } + return NO; +} + +- (NSDictionary *)supportMessageDic { + if (![ClientConfig shareConfig].canOpen) { + return @{}; + } + return @{ + @(CustomMessageType_Chat_Hall_Headlinesn): + [NSSet setWithObjects: + @(Custom_Message_Sub_Chat_Hall_Headlinesn), + nil] + }; +} +-(void)addRoomMessage:(NIMMessage *)msg{ + if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;} + [self.datasource addObject:[self.messageParser parseMessageAttribute:msg]]; + [self.messageTableView reloadData]; + [self scrollToBottom:YES]; +} +- (void)addCustomMessage:(NSNotification *)notification { + self.isMiniEnter = NO; + if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;} + NIMMessage * message = notification.object; + [self addRoomMessage:message]; +} + + + +#pragma mark - RoomGuestDelegate +- (void)handleNIMCustomAttachment:(AttachmentModel *)attachment{ + +} +- (void)handleNIMCustomMessage:(NIMMessage *)message { + self.isMiniEnter = NO; + if ([self isCanDisplayMessage:message]) { + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + AttachmentModel *attachment = (AttachmentModel *)obj.attachment; + if(attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){ + MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data]; + if(topModel == nil){ + self.titleView.text = topModel.content; + [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.top.trailing.mas_equalTo(self); + make.height.mas_equalTo(0); + + }]; + }else{ + self.titleView.text = topModel.content; + [self.headerView mas_remakeConstraints:^(MASConstraintMaker *make) { + make.leading.mas_equalTo(self).offset(15); + make.top.trailing.mas_equalTo(self); + make.height.mas_greaterThanOrEqualTo(0); + + }]; + } + + + } + [self addRoomMessage:message]; + } +} +- (void)handleNIMImageMessage:(NIMMessage *)message { + self.isMiniEnter = NO; + if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;} + PIRoomPhotoAlbumItemModel*model = [PIRoomPhotoAlbumItemModel new]; + model.type = @"1"; + model.status = 1; + NIMImageObject * imageObject = (NIMImageObject*)message.messageObject; + model.photoUrl = imageObject.url; + XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; + messageInfo.albumModel = model; + messageInfo.first = CustomMessageType_Room_Album; + XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; + messageInfo.charmUrl = extModel.charmUrl; + messageInfo.experUrl = extModel.experUrl; + messageInfo.bubbleImageUrl = extModel.iosBubbleUrl; + messageInfo.nameText = extModel.nick; + [self.datasource addObject:messageInfo]; + [self.messageTableView reloadData]; + [self scrollToBottom:YES]; +} +- (void)handleNIMNotificationMessage:(NIMMessage *)message { + self.isMiniEnter = NO; + NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; + NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + if (content.eventType == NIMChatroomEventTypeEnter) { + + if (roomInfo.isCloseScreen) { + self.isLoadHistoryMessage = NO; + AttachmentModel *attachement = [[AttachmentModel alloc]init]; + attachement.first = CustomMessageType_Update_RoomInfo; + attachement.second = Custom_Message_Sub_Update_RoomInfo_MessageState; + attachement.data = @{@"roomInfo":self.hostDelegate.getRoomInfo.model2dictionary}; + NIMMessage *message = [[NIMMessage alloc]init]; + NIMCustomObject *object = [[NIMCustomObject alloc] init]; + object.attachment = attachement; + message.messageObject = object; + [self addRoomMessage:message]; + return; + } else { + NIMChatroomNotificationMember *member = content.targets[0]; + if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) { + ///自己进房成功后拉取历史消息 + if(self.datasource.count > 0) + { + self.isLoadHistoryMessage = NO; + return; + } + [self handleFetchHistoryMessage:message]; + } else { + self.isLoadHistoryMessage = NO; + } + } + } +} + +- (void)handleFetchHistoryMessage:(NIMMessage *)message { + UserInfoModel *infoModel = self.hostDelegate.getUserInfo; + NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]]; + + NSString *roomId = publicChatRoomId; + NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init]; + option.limit = 100; + option.startTime = 0; + option.order = NIMMessageSearchOrderAsc; + option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)]; + [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { + if(error != nil){ + self.isLoadHistoryMessage = NO; + } + + //如果拉取的数量等于请求的数量,说明这个时间点以后的消息数量大于等于需要拉取的数量,直接拉取最新的50条 + if (messages.count == 100) { + NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init]; + option.limit = 100; + option.order = NIMMessageSearchOrderDesc; + option.messageTypes = @[@(NIMMessageTypeText),@(NIMMessageTypeImage)]; + [[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray * _Nullable messages) { + if(error != nil){ + self.isLoadHistoryMessage = NO; + } + dispatch_async(dispatch_get_main_queue(), ^{///回到主线程 + if (self.datasource.count > kRoomMessageMaxLength) { + NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; + NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set]; + [self.datasource removeObjectsInArray:needRemoveMsgArray]; + } + // 执行插入 + for (NIMMessage *item in messages.reverseObjectEnumerator) { + [self dealWithHistoryDataWithMessage:item]; + + } + [self.messageTableView reloadData]; + //执行插入动画并滚动 + [self scrollToBottom:YES]; + self.isLoadHistoryMessage = NO; + + + }); + }]; + return; + } + dispatch_async(dispatch_get_main_queue(), ^{///回到主线程 + if (self.datasource.count > kRoomMessageMaxLength) { + NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)]; + NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set]; + [self.datasource removeObjectsInArray:needRemoveMsgArray]; + } + // 执行插入 + for (NIMMessage *item in messages) { + [self dealWithHistoryDataWithMessage:item]; + } + + [self.messageTableView reloadData]; + //执行插入动画并滚动 + [self scrollToBottom:YES]; + self.isLoadHistoryMessage = NO; + + + }); + + + }]; +} +-(void)dealWithHistoryDataWithMessage:(NIMMessage *)item{ + BOOL isHaveSave = NO; + if(item.messageType == NIMMessageTypeText){ + isHaveSave = YES; + }else if(item.messageType == NIMMessageTypeImage){ + isHaveSave = YES; + }else if(item.messageType == NIMMessageTypeCustom){ + NIMCustomObject *obj = (NIMCustomObject *)item.messageObject; + if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) { + AttachmentModel *attachment = (AttachmentModel *)obj.attachment; + if (attachment.first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn) { + isHaveSave = YES; + } + + } + } + if(isHaveSave == NO)return; + if (item.messageType == NIMMessageTypeImage){ + PIRoomPhotoAlbumItemModel*model = [PIRoomPhotoAlbumItemModel new]; + model.type = @"1"; + model.status = 1; + NIMImageObject * imageObject = (NIMImageObject*)item.messageObject; + model.photoUrl = imageObject.url; + XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; + messageInfo.albumModel = model; + messageInfo.first = CustomMessageType_Room_Album; + XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithJSON:item.remoteExt[item.from]]; + messageInfo.charmUrl = extModel.charmUrl; + messageInfo.experUrl = extModel.experUrl; + messageInfo.bubbleImageUrl = extModel.iosBubbleUrl; + messageInfo.nameText = extModel.nick; + [self.datasource addObject:messageInfo]; + return; + } + [self.datasource addObject:[self.messageParser parseMessageAttribute:item]]; +} +- (void)handleNIMTextMessage:(NIMMessage *)message { + self.isMiniEnter = NO; + if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;} + [self addRoomMessage:message]; +} + + + +- (void)onRoomMiniEntered { + self.isMiniEnter = YES; + self.isLoadHistoryMessage = NO; + +} + +- (void)onRoomEntered { + self.headerView.backgroundColor = UIColorRGBAlpha(0x593722, 0.4); +} + +- (void)onRoomUpdate { + ///改变公屏的背景样式 + if (self.hostDelegate.getRoomInfo.hadChangeRoomType) { + self.headerView.backgroundColor = UIColorRGBAlpha(0x593722, 0.4); + [self.messageTableView reloadData]; + } +} + + + + +#pragma mark - UITableViewDelegate And UITableViewDataSource +- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { + return self.datasource.count; +} + +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { + XPMessageInfoModel* messageInfo = [self.datasource safeObjectAtIndex1:indexPath.row]; + + if(messageInfo.first == CustomMessageType_Room_Album){ + return 186; + }else if(messageInfo.first == CustomMessageType_Chat_Hall_Headlinesn){ + return 40; + } + + return messageInfo.rowHeight; +} + +- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { + XPMessageInfoModel* attr = [self.datasource safeObjectAtIndex1:indexPath.row]; + if(attr.first == CustomMessageType_Room_Album){ + PIRoomMessagePhotoAlbumCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])]; + cell.delegate = self; + cell.messageInfo = attr; + cell.roomType = self.hostDelegate.getRoomInfo.type; + return cell; + }else if (attr.first == CustomMessageType_Chat_Hall_Headlinesn){ + MsRoomMessagChatHallCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([MsRoomMessagChatHallCell class]) forIndexPath:indexPath]; + cell.model = attr; + return cell; + } + XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])]; + cell.delegate = self; + cell.messageInfo = attr; + cell.roomType = self.hostDelegate.getRoomInfo.type; + return cell; + + +} + + +#pragma mark - XPRoomMessageTableViewCellDelegate +- (void)xPRoomMessageTableViewCellDidTapEmpty:(XPRoomMessageTableViewCell *)view { + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { + self.isLarge = !self.isLarge; + CGFloat height = self.isLarge ? 200 : 80; + [self mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(height); + }]; + } +} +#pragma mark - PIRoomMessagePhotoAlbumCell +- (void)pIRoomMessagePhotoAlbumCellDelegateDidTapEmpty:(PIRoomMessagePhotoAlbumCell *)view{ + if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) { + self.isLarge = !self.isLarge; + CGFloat height = self.isLarge ? 200 : 80; + [self mas_updateConstraints:^(MASConstraintMaker *make) { + make.height.mas_equalTo(height); + }]; + } +} +-(void)unlockAlbumHandleWithInfo:(PIRoomPhotoAlbumItemModel *_Nonnull)info{ + PIRoomMessageUnlockPhotoAlbumView *albumView = [[PIRoomMessageUnlockPhotoAlbumView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + albumView.albumModel = info; + albumView.delegate = self; + [TTPopup popupView:albumView style:TTPopupStyleAlert]; +} +-(void)pIRoomMessagePhotoAlbumCell:(PIRoomMessagePhotoAlbumCell *_Nonnull)cell lookUpAlbumPhotoWithAlbumModel:(PIRoomPhotoAlbumItemModel *_Nonnull)albumModel;{ + SDPhotoBrowser *browser = [[SDPhotoBrowser alloc]init]; + browser.sourceImagesContainerView = cell; + browser.delegate = self; + browser.imageCount = 1; + browser.currentImageIndex = 0; + browser.isMe = NO; + self.lookUpModel = albumModel; + [browser show]; +} +- (void)pIRoomMessagePhotoAlbumCell:(PIRoomMessagePhotoAlbumCell *)cell lookUpUserCardModel:(PIRoomPhotoAlbumItemModel *)albumModel{ + [self.messageParser showUserCard:albumModel.uid.integerValue]; +} +#pragma mark - PIRoomMessageUnlockPhotoAlbumViewDelegate +- (void)unlockRoomAlbumImageWithAlbumModel:(PIRoomPhotoAlbumItemModel *)albumModel{ + [XNDJTDDLoadingTool showLoading]; + [Api unlockRoomAlbumPhoto:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { + + [XNDJTDDLoadingTool hideHUD]; + if(code == 200){ + NSMutableDictionary *getData = [NSMutableDictionary dictionary]; + [getData addEntriesFromDictionary:data.data]; + AttachmentModel *attachment = [[AttachmentModel alloc] init]; + attachment.first = CustomMessageType_Gift; + attachment.second = Custom_Message_Sub_Gift_Send; + NSDictionary *targetUsers = ((NSArray *)[getData objectForKey:@"targetUsers"]).firstObject; + [getData setObject:[targetUsers valueForKeyPath:@"uid"] forKey:@"targetUid"]; + [getData setObject:[targetUsers valueForKeyPath:@"nick"] forKey:@"targetNick"]; + [getData setObject:[targetUsers valueForKeyPath:@"avatar"] forKey:@"targetAvatar"]; + [getData setObject:@(YES) forKey:@"isRoomAlbum"]; + attachment.data = getData; + [self sendCustomMessage:attachment]; + if(albumModel.ID != nil){ + if(![[XPSkillCardPlayerManager shareInstance].photoIdList containsObject:albumModel.ID]){ + if([XPSkillCardPlayerManager shareInstance].photoIdList == nil){ + [XPSkillCardPlayerManager shareInstance].photoIdList = [NSMutableArray arrayWithArray:@[albumModel.ID]]; + }else{ + [[XPSkillCardPlayerManager shareInstance].photoIdList addObject:albumModel.ID]; + } + } + [[NSNotificationCenter defaultCenter]postNotificationName:@"kGetgetUnlockRoomAlbumPhotoListNot" object:nil]; + } + return; + } + [XNDJTDDLoadingTool showErrorWithMessage:msg]; + } id:albumModel.ID roomUid:@(self.hostDelegate.getRoomInfo.uid).stringValue]; +} +- (void)sendCustomMessage:(AttachmentModel *)attachment { + + NSString *sessionID = [NSString stringWithFormat:@"%ld", [self.hostDelegate getRoomInfo].roomId]; + NIMMessage *message = [[NIMMessage alloc]init]; + NIMCustomObject *object = [[NIMCustomObject alloc] init]; + object.attachment = attachment; + message.messageObject = object; + + UserInfoModel *userInfo = [self.hostDelegate getUserInfo]; + XPMessageRemoteExtModel *extModel = [[XPMessageRemoteExtModel alloc] init]; + extModel.androidBubbleUrl = userInfo.androidBubbleUrl; + extModel.iosBubbleUrl = userInfo.iosBubbleUrl; + extModel.fromSayHelloChannel = userInfo.fromSayHelloChannel; + NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:extModel.model2dictionary forKey:[NSString stringWithFormat:@"%ld", userInfo.uid]]; + message.remoteExt = remoteExt; + NIMSessionType sessionType = NIMSessionTypeChatroom; + //构造会话 + NIMSession *session = [NIMSession session:sessionID type:sessionType]; + [[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil]; +} + +#pragma mark - SDPhotoBrowserDelegate +- (NSURL *)photoBrowser:(SDPhotoBrowser *)browser highQualityImageURLForIndex:(NSInteger)index{ + if(self.lookUpModel != nil){ + return [[NSURL alloc]initWithString:self.lookUpModel.photoUrl]; + } + return nil; +} +- (UIImage *)photoBrowser:(SDPhotoBrowser *)browser placeholderImageForIndex:(NSInteger)index { + return [UIImageConstant defalutBannerPlaceholder]; +} +#pragma mark - Getters And Setters +- (UITableView *)messageTableView { + if (!_messageTableView) { + _messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain]; + _messageTableView.delegate = self; + _messageTableView.dataSource = self; + _messageTableView.tableFooterView = [UIView new]; + _messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone; + _messageTableView.backgroundColor = [UIColor clearColor]; + _messageTableView.showsVerticalScrollIndicator = NO; + _messageTableView.tag = 666; + if (@available(iOS 11.0, *)) { + _messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; + } + [_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])]; + [_messageTableView registerClass:[PIRoomMessagePhotoAlbumCell class] forCellReuseIdentifier:NSStringFromClass([PIRoomMessagePhotoAlbumCell class])]; + [_messageTableView registerClass:[MsRoomMessagChatHallCell class] forCellReuseIdentifier:NSStringFromClass([MsRoomMessagChatHallCell class])]; + + + } + return _messageTableView; +} + +- (UIView *)headerView { + if (!_headerView) { + _headerView = [[UIView alloc] init]; + _headerView.layer.cornerRadius = 7; + _headerView.layer.masksToBounds = YES; + } + return _headerView; +} + + + +- (NSMutableArray *)datasource { + if (!_datasource) { + _datasource = [NSMutableArray array]; + } + return _datasource; +} + + + + +- (XPRoomMessageParser *)messageParser { + if (!_messageParser) { + _messageParser = [[XPRoomMessageParser alloc] init]; + _messageParser.hostDelegate = self.hostDelegate; + } + return _messageParser; +} +- (UILabel *)titleView{ + if(!_titleView){ + _titleView = [UILabel labelInitWithText:@"" font:[UIFont systemFontOfSize:12 weight:UIFontWeightMedium] textColor:UIColorFromRGB(0xFDF4D5)]; + _titleView.textAlignment = NSTextAlignmentCenter; + _titleView.numberOfLines = 0; + } + return _titleView; +} + +@end diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.h b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.h new file mode 100644 index 00000000..f1419ceb --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.h @@ -0,0 +1,21 @@ +// +// MsRoomMessageMainView.h +// YuMi +// +// Created by duoban on 2024/5/10. +// + +#import +#import "RoomHostDelegate.h" +#import "RoomGuestDelegate.h" +NS_ASSUME_NONNULL_BEGIN + +@interface MsRoomMessageMainView : UIView +- (void)showUserCard:(NSInteger)uid; +- (instancetype)initWithDelegate:(id)delegate; +- (void)handleNIMImageMessage:(NIMMessage *)message; +///0房间,1.聊天大厅 +@property(nonatomic,assign) NSInteger type; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m new file mode 100644 index 00000000..e1076497 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/MsRoomMessageMainView.m @@ -0,0 +1,190 @@ +// +// MsRoomMessageMainView.m +// YuMi +// +// Created by duoban on 2024/5/10. +// +#import +#import +#import +#import "MsRoomMessageMainView.h" +#import "XPRoomMessageContainerView.h" +#import "MsRoomMessagChatHallView.h" +#import "ClientConfig.h" +#import "UserInfoModel.h" +#import +@interface MsRoomMessageMainView() +///分页标题 +@property (nonatomic, strong) NSArray *titles; +///分页控件 +@property (nonatomic, strong) JXCategoryTitleView *titleView; +///分页lineView +@property (nonatomic, strong) JXCategoryListContainerView *pi_containerView; +@property(nonatomic,strong) XPRoomMessageContainerView *roomView; +@property(nonatomic,strong) MsRoomMessagChatHallView *chatHallView; +///房间的代理 +@property (nonatomic,weak) id hostDelegate; +@end + +@implementation MsRoomMessageMainView + + +- (instancetype)initWithDelegate:(id)delegate { + self = [super init]; + if (self) { + self.hostDelegate = delegate; + [self installUI]; + [self installConstraints]; + } + return self; +} +-(void)installUI{ + [self addSubview:self.titleView]; + [self addSubview:self.pi_containerView]; +} +-(void)installConstraints{ + [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.leading.mas_equalTo(kGetScaleWidth(0)); + make.width.mas_equalTo(150); + make.height.mas_equalTo(kGetScaleWidth(30)); + + }]; + + [self.pi_containerView mas_makeConstraints:^(MASConstraintMaker *make) { + make.leading.trailing.bottom.mas_equalTo(self); + make.top.mas_equalTo(self.titleView.mas_bottom).offset(8); + }]; +} +- (void)showUserCard:(NSInteger)uid{ + [self.roomView showUserCard:uid]; +} +#pragma mark - JXCategoryViewDelegate +- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView { + return self.titles.count; +} + +- (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index { + if (index == 0) { + return self.roomView; + } else { + return self.chatHallView; + } +} + +#pragma mark - RoomGuestDelegate +- (void)handleNIMCustomMessage:(NIMMessage *)message { + 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]; + return; + } + + + [self.chatHallView handleNIMCustomMessage:message]; +} + +- (void)handleNIMNotificationMessage:(NIMMessage *)message { + 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]; + return; + } + + [self.chatHallView handleNIMNotificationMessage:message]; +} + + + +- (void)handleNIMTextMessage:(NIMMessage *)message { + 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]; + return; + } + + [self.chatHallView handleNIMTextMessage:message]; +} + +- (void)handleNIMImageMessage:(NIMMessage *)message { + [self.chatHallView handleNIMImageMessage:message]; +} + + +- (void)onRoomMiniEntered { + [self.roomView onRoomMiniEntered]; + [self.chatHallView onRoomMiniEntered]; +} + +- (void)onRoomEntered { + [self.roomView onRoomEntered]; + [self.chatHallView onRoomEntered]; +} + +- (void)onRoomUpdate { + [self.roomView onRoomUpdate]; + [self.chatHallView onRoomUpdate]; +} + +#pragma mark - 懒加载 +- (NSInteger)type{ + return self.titleView.selectedIndex; +} +- (JXCategoryTitleView *)titleView { + if (!_titleView) { + _titleView = [[JXCategoryTitleView alloc] init]; + _titleView.delegate = self; + _titleView.titles = self.titles; + _titleView.backgroundColor = [UIColor clearColor]; + _titleView.titleColor = UIColorFromRGB(0x4D415E); + _titleView.titleSelectedColor = UIColorFromRGB(0xFFFFFF); + _titleView.titleFont = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; + _titleView.titleSelectedFont = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; + _titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter; + _titleView.contentScrollViewClickTransitionAnimationEnabled = NO; + _titleView.defaultSelectedIndex = 0; + _titleView.cellSpacing = 20; + _titleView.cellWidthIncrement = 5; + _titleView.cellWidth = 40; + _titleView.listContainer = self.pi_containerView; + + JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init]; + lineView.indicatorImageViewSize = CGSizeMake(8, 1.5); + lineView.verticalMargin = 0; + lineView.indicatorImageView.image = [UIImage imageWithColor:UIColorFromRGB(0x10ECD6) size:CGSizeMake(8, 1.5)]; + lineView.indicatorImageView.layer.masksToBounds = YES; + lineView.indicatorImageView.layer.cornerRadius = 1.5/2; + _titleView.indicators = @[lineView]; + } + return _titleView; +} + +- (NSArray *)titles{ + if(!_titles){ + _titles = @[YMLocalizedString(@"XPMineMainGuildListVC1"),YMLocalizedString(@"MSSessionPublicChatHallVC0")]; + } + return _titles; +} +- (JXCategoryListContainerView *)pi_containerView { + if (!_pi_containerView) { + _pi_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; + _pi_containerView.defaultSelectedIndex = 0; + _pi_containerView.scrollView.tag = 1009; + } + return _pi_containerView; +} +- (XPRoomMessageContainerView *)roomView{ + if(!_roomView){ + _roomView = [[XPRoomMessageContainerView alloc] initWithDelegate:self.hostDelegate]; + } + return _roomView; +} +- (MsRoomMessagChatHallView *)chatHallView{ + if(!_chatHallView){ + _chatHallView = [[MsRoomMessagChatHallView alloc]initWithDelegate:self.hostDelegate]; + } + return _chatHallView; +} +@end diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m index d6bbc588..40c3dbd1 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m @@ -53,13 +53,14 @@ #import "XCCurrentVCStackManager.h" #import "XPTreasureFairyViewController.h" #import "PIGeneralPublicScreenModel.h" +#import "MSSessionPublicChatHallTopModel.h" @implementation XPRoomMessageParser - (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message { NIMMessageType messageType = message.messageType; - XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; + XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init]; if([message.messageObject isKindOfClass:[NIMCustomObject class]] ){ NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; @@ -70,7 +71,7 @@ } } } - + switch (messageType) { case NIMMessageTypeText: @@ -91,7 +92,7 @@ return model != nil ? model : [XPMessageInfoModel new]; break; } - case NIMMessageTypeCustom: + case NIMMessageTypeCustom: { XPMessageInfoModel *model = [self makeCustomAttribute:message messageInfo:messageInfo]; return model != nil ? model : [XPMessageInfoModel new]; @@ -109,119 +110,125 @@ /// 用户公屏聊天 - (XPMessageInfoModel *)makeCustomAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel*)messageInfo{ - NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; - AttachmentModel *attachment = (AttachmentModel *)obj.attachment; - XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; - messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; - int first = attachment.first; - if (first == CustomMessageType_Gift) {///单人送 - return [self createSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; - } else if(first == CustomMessageType_AllMicroSend) {///全麦送 多人送 - return [self createBatchMicroSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; - } else if(first == CustomMessageType_Room_Tip) {///分享/收藏房间 - return [self createShareOrAttentionRoomAttribute:attachment sendInfo:model uid:message.from messageInfo:messageInfo]; - } else if(first == CustomMessageType_Kick_User || first == CustomMessageType_Queue) { - XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; - } else if(first == CustomMessageType_Look_Love) {//糖果树 - return [self createCandyTreeHighLevelAttribute:attachment messageInfo:messageInfo]; - } else if(first == CustomMessageType_Arrange_Mic) { - return [self createArrangeMicAttribute:attachment messageInfo:messageInfo]; - }else if(first == CustomMessageType_Update_RoomInfo) { - return [self createRoomInfoUpdateAttribute:attachment messageInfo:messageInfo]; - } else if(first == CustomMessageType_Collection_Room) { - return [self createCollectRoomAttribute:attachment messageInfo:messageInfo]; - } else if(first == CustomMessageType_RoomPlay_Dating) { - return [self createRoomDatingAttribute:attachment messageInfo:messageInfo]; - } else if (first == CustomMessageType_Noble_VIP) {//VIP + NIMCustomObject *obj = (NIMCustomObject *)message.messageObject; + AttachmentModel *attachment = (AttachmentModel *)obj.attachment; + XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; + int first = attachment.first; + if (first == CustomMessageType_Gift) {///单人送 + return [self createSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; + } else if(first == CustomMessageType_AllMicroSend) {///全麦送 多人送 + return [self createBatchMicroSendGiftAttribute:attachment sendInfo:model messageInfo:messageInfo]; + } else if(first == CustomMessageType_Room_Tip) {///分享/收藏房间 + return [self createShareOrAttentionRoomAttribute:attachment sendInfo:model uid:message.from messageInfo:messageInfo]; + } else if(first == CustomMessageType_Kick_User || first == CustomMessageType_Queue) { + XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; + return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; + } else if(first == CustomMessageType_Look_Love) {//糖果树 + return [self createCandyTreeHighLevelAttribute:attachment messageInfo:messageInfo]; + } else if(first == CustomMessageType_Arrange_Mic) { + return [self createArrangeMicAttribute:attachment messageInfo:messageInfo]; + }else if(first == CustomMessageType_Update_RoomInfo) { + return [self createRoomInfoUpdateAttribute:attachment messageInfo:messageInfo]; + } else if(first == CustomMessageType_Collection_Room) { + return [self createCollectRoomAttribute:attachment messageInfo:messageInfo]; + } else if(first == CustomMessageType_RoomPlay_Dating) { + return [self createRoomDatingAttribute:attachment messageInfo:messageInfo]; + } else if (first == CustomMessageType_Noble_VIP) {//VIP return [self createNobleLevelAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Face) {//VIP - return [self createRoomFaceAttribute:attachment messageInfo:messageInfo]; + return [self createRoomFaceAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Tarot) {//塔罗 return [self createTarotAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Anchor_FansTeam) {//粉丝团 return [self createAnchorFansTeamAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Hall_Super_Admin) {///超管踢人出房间 - XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; - return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; - } else if (first == CustomMessageType_Room_PK) {///房内PK - return [self createRoomPKAttribute:attachment messageInfo:messageInfo]; - } else if (first == CustomMessageType_LuckyBag) {///幸运礼物 - return [self createRoomLuckyBigPrizeAttribute:attachment messageInfo:messageInfo]; + XPKickUserModel * kickModel = [XPKickUserModel modelWithJSON:attachment.data]; + return [self createKickUserAttribute:attachment info:kickModel messageInfo:messageInfo]; + } else if (first == CustomMessageType_Room_PK) {///房内PK + return [self createRoomPKAttribute:attachment messageInfo:messageInfo]; + } else if (first == CustomMessageType_LuckyBag) {///幸运礼物 + return [self createRoomLuckyBigPrizeAttribute:attachment messageInfo:messageInfo]; } else if(first == CustomMessageType_Gift_Compound) {///礼物合成 return [self createRoomGiftCompoundAttribute:attachment messageInfo:messageInfo]; - } else if(first == CustomMessageType_Room_Sailing) {///航海 - return [self createRoomSailingAttribute:attachment messageInfo:messageInfo]; + } else if(first == CustomMessageType_Room_Sailing) {///航海 + return [self createRoomSailingAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_RedPacket && attachment.second == Custom_Message_Sub_OpenRedPacketSuccess) { return [self createRedPacketAttribute:attachment messageInfo:messageInfo]; } else if (first == CustomMessageType_Treasure_Fairy) { - return [self createTreasureFairyAttribute:attachment messageInfo:messageInfo]; - }else if (first == CustomMessageType_Room_Album) { - NSDictionary *userInfo = attachment.data[@"user"]; - NSDictionary *userLevel = attachment.data[@"userLevel"]; - if(userLevel != nil){ - NSString *charmUrl = userLevel[@"charmUrl"]; - NSString *experUrl = userLevel[@"experUrl"]; - messageInfo.charmUrl = charmUrl; - messageInfo.experUrl = experUrl; - } - PIRoomPhotoAlbumItemModel *albumModel = [PIRoomPhotoAlbumItemModel modelWithDictionary:attachment.data[@"roomPhoto"]]; - NSString * uid = [AccountInfoStorage instance].getUid; - NSString * nick = @""; - if(userInfo != nil){ + return [self createTreasureFairyAttribute:attachment messageInfo:messageInfo]; + }else if (first == CustomMessageType_Room_Album) { + NSDictionary *userInfo = attachment.data[@"user"]; + NSDictionary *userLevel = attachment.data[@"userLevel"]; + if(userLevel != nil){ + NSString *charmUrl = userLevel[@"charmUrl"]; + NSString *experUrl = userLevel[@"experUrl"]; + messageInfo.charmUrl = charmUrl; + messageInfo.experUrl = experUrl; + } + PIRoomPhotoAlbumItemModel *albumModel = [PIRoomPhotoAlbumItemModel modelWithDictionary:attachment.data[@"roomPhoto"]]; + NSString * uid = [AccountInfoStorage instance].getUid; + NSString * nick = @""; + if(userInfo != nil){ nick = [NSString stringWithFormat:@"%@:", userInfo[@"nick"]]; - } - if ([message.from isEqualToString:uid]) { - nick = YMLocalizedString(@"XPRoomMessageParser0"); - } - messageInfo.first = CustomMessageType_Room_Album; - messageInfo.nameText = nick; - messageInfo.albumModel = albumModel; - return messageInfo; - }else if(first == CustomMessageType_Guardian_Planet){ - return [self createGuardianPlanetAttribute:attachment messageInfo:messageInfo]; - }else if(first == CustomMessageType_General_Public_Screen){ - return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo]; - }else if(first == CustomMessageType_Super_Gift){ - return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo]; - } + } + if ([message.from isEqualToString:uid]) { + nick = YMLocalizedString(@"XPRoomMessageParser0"); + } + messageInfo.first = CustomMessageType_Room_Album; + messageInfo.nameText = nick; + messageInfo.albumModel = albumModel; + return messageInfo; + }else if(first == CustomMessageType_Guardian_Planet){ + return [self createGuardianPlanetAttribute:attachment messageInfo:messageInfo]; + }else if(first == CustomMessageType_General_Public_Screen){ + return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo]; + }else if(first == CustomMessageType_Super_Gift){ + return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo]; + }else if(first == CustomMessageType_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){ + return [self createChatHallnAttribute:attachment messageInfo:messageInfo]; + } - return nil; + return nil; } /// @param message 消息的实体 - (XPMessageInfoModel*)makeChatAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ NSString * uid = [AccountInfoStorage instance].getUid; XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]]; - messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; - NSString * nick = [NSString stringWithFormat:@"%@:", ((NIMMessageChatroomExtension *)message.messageExt).roomNickname]; + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; + NSString *getNick = ((NIMMessageChatroomExtension *)message.messageExt).roomNickname; + if(getNick == nil && model.nick != nil){ + getNick = model.nick; + } + NSString * nick = [NSString stringWithFormat:@"%@:", getNick]; if ([message.from isEqualToString:uid]) { nick = YMLocalizedString(@"XPRoomMessageParser0"); } - + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - - if ([ClientConfig shareConfig].canOpen) { - ///官方新用户 - [attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]]; - if ([self isCurrentRoomSuperAdmin:message.from]) { - [attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]]; - } - - if (model.vipIcon) {//VIPicon - [attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon size:CGSizeMake(20, 20)]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } - if (model.experUrl) { - [attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } + + if ([ClientConfig shareConfig].canOpen) { + ///官方新用户 + [attribute appendAttributedString:[self createOfficalAndNewuserAttribute:model.defUser newUser:model.newUser fromSayHelloChannel:model.fromSayHelloChannel]]; + if ([self isCurrentRoomSuperAdmin:message.from]) { + [attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]]; + } + + if (model.vipIcon) {//VIPicon + [attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon size:CGSizeMake(20, 20)]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } + if (model.experUrl) { + [attribute appendAttributedString:[self createUrlImageAttribute:model.experUrl]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } if(model.isCustomWord == YES){ if (model.inRoomNameplatePic.length > 0){ [attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]]; [attribute appendAttributedString:[self createSapceAttribute:2]]; } - + }else{ if (model.inRoomNameplatePic.length > 0 && model.inRoomNameplateWord.length > 0) { //铭牌有图片加文字 [attribute appendAttributedString:[self createNameplateAttibute:model.inRoomNameplateWord image:model.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]]; @@ -231,10 +238,10 @@ [attribute appendAttributedString:[self createSapceAttribute:2]]; } } - - } - - [attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; + + } + + [attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; [attribute appendAttributedString:[self createSapceAttribute:2]]; id nickNameNifo = message.remoteExt[@"atNames"]; @@ -242,8 +249,8 @@ if (message.text) { msgStr = [[NSMutableAttributedString alloc] initWithString:message.text]; [msgStr addAttribute:NSForegroundColorAttributeName - value:[DJDKMIMOMColor messageTextColor] - range:NSMakeRange(0, msgStr.length)]; + value:[DJDKMIMOMColor messageTextColor] + range:NSMakeRange(0, msgStr.length)]; if ([nickNameNifo isKindOfClass:[NSArray class]]) { for (NSString *nick in nickNameNifo) { NSRange range = [message.text rangeOfString:nick]; @@ -255,7 +262,7 @@ [attribute appendAttributedString:msgStr]; } [self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname]; - messageInfo.content = attribute; + messageInfo.content = attribute; messageInfo.vipIcon = model.vipIcon; return messageInfo; } @@ -263,62 +270,62 @@ /// 房间tips消息 /// @param message 消息的实体 - (XPMessageInfoModel*)makeTipsAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ - messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; - if ([message.localExt.allKeys containsObject:@"isRoomTopic"]) { - NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - [attribute appendAttributedString: [self createTextAttribute:message.text color:[UIColor whiteColor] font:kRoomMessageDefalutFont]]; - if ([[message.localExt objectForKey:@"isRoomTopic"] boolValue] == YES) { - [attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { - RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; - TTPopupService * config = [[TTPopupService alloc] init]; - XPRoomTopicAlertView * alertView = [[XPRoomTopicAlertView alloc] init]; - alertView.title = roomInfo.roomDesc; - alertView.message = roomInfo.introduction; - config.contentView = alertView; - [TTPopup popupWithConfig:config]; - }]; - } - messageInfo.content = attribute; - } else { - NSAttributedString * attribute = [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont]; - messageInfo.content = attribute; - } - return messageInfo; + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; + if ([message.localExt.allKeys containsObject:@"isRoomTopic"]) { + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; + [attribute appendAttributedString: [self createTextAttribute:message.text color:[UIColor whiteColor] font:kRoomMessageDefalutFont]]; + if ([[message.localExt objectForKey:@"isRoomTopic"] boolValue] == YES) { + [attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { + RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo; + TTPopupService * config = [[TTPopupService alloc] init]; + XPRoomTopicAlertView * alertView = [[XPRoomTopicAlertView alloc] init]; + alertView.title = roomInfo.roomDesc; + alertView.message = roomInfo.introduction; + config.contentView = alertView; + [TTPopup popupWithConfig:config]; + }]; + } + messageInfo.content = attribute; + } else { + NSAttributedString * attribute = [self createTextAttribute:message.text color:UIColorFromRGB(0xFE5D7F) font:kRoomMessageDefalutFont]; + messageInfo.content = attribute; + } + return messageInfo; } /// 房间通知类消息 /// @param message 消息的实体 - (XPMessageInfoModel*)makeNotificationAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{ - messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; + messageInfo.bubbleImageUrl = [self parseMessageBubble:message]; NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; NIMChatroomNotificationMember *member = content.targets[0]; - NIMMessageChatroomExtension * messageExt = (NIMMessageChatroomExtension *)message.messageExt; + NIMMessageChatroomExtension * messageExt = (NIMMessageChatroomExtension *)message.messageExt; switch (content.eventType) { case NIMChatroomEventTypeEnter:///进入房间 { NSString* nick = member.nick.length > 0 ? member.nick : @""; NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from]; - XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithDictionary:dic]; - if ([ClientConfig shareConfig].canOpen) { - ///官方新用户 - [attribute appendAttributedString:[self createOfficalAndNewuserAttribute:extModel.defUser newUser:extModel.newUser fromSayHelloChannel:extModel.fromSayHelloChannel]]; - - if ([self isCurrentRoomSuperAdmin:message.from]) { - [attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } - - if (extModel.vipIcon.length > 0) {//VIPicon + NSDictionary * dic = [(NSDictionary *)messageExt.roomExt.toJSONObject objectForKey:message.from]; + XPMessageRemoteExtModel * extModel = [XPMessageRemoteExtModel modelWithDictionary:dic]; + if ([ClientConfig shareConfig].canOpen) { + ///官方新用户 + [attribute appendAttributedString:[self createOfficalAndNewuserAttribute:extModel.defUser newUser:extModel.newUser fromSayHelloChannel:extModel.fromSayHelloChannel]]; + + if ([self isCurrentRoomSuperAdmin:message.from]) { + [attribute appendAttributedString:[self createLanguageImageAttribute:@"common_super_admin"]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } + + if (extModel.vipIcon.length > 0) {//VIPicon messageInfo.vipIcon = extModel.vipIcon; - [attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon size:CGSizeMake(20, 20)]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } - if (extModel.experUrl.length > 0) {//等级 - [attribute appendAttributedString:[self createUrlImageAttribute:extModel.experUrl]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } + [attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon size:CGSizeMake(20, 20)]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } + if (extModel.experUrl.length > 0) {//等级 + [attribute appendAttributedString:[self createUrlImageAttribute:extModel.experUrl]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } if(extModel.isCustomWord == YES){ if (extModel.inRoomNameplatePic.length > 0) { [attribute appendAttributedString:[self createUrlImageAttribute:extModel.inRoomNameplatePic]]; @@ -330,49 +337,49 @@ [attribute appendAttributedString:[self createSapceAttribute:2]]; } } - - [attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]]; - if (extModel.carName.length > 0) { - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser1") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - [attribute appendAttributedString:[self createTextAttribute:extModel.carName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]]; - [attribute appendAttributedString:[self createSapceAttribute:2]]; - } - - if (extModel.fromType > 0) { - if (extModel.fromType == UserEnterRoomFromType_Home_Recommend) { - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser2") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - } else if(extModel.fromType == UserEnterRoomFromType_Follow_User || extModel.fromType == UserEnterRoomFromType_New_User_Greet) { - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser3") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - [attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]]; - } else if(extModel.fromType == UserEnterRoomFromType_Follow_Game_Detail) { - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser4") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - [attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]]; - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser5") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - } - } - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser6") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - } else { - [attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]]; - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser7") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; - } - - messageInfo.content = attribute; + + [attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]]; + if (extModel.carName.length > 0) { + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser1") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + [attribute appendAttributedString:[self createTextAttribute:extModel.carName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]]; + [attribute appendAttributedString:[self createSapceAttribute:2]]; + } + + if (extModel.fromType > 0) { + if (extModel.fromType == UserEnterRoomFromType_Home_Recommend) { + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser2") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + } else if(extModel.fromType == UserEnterRoomFromType_Follow_User || extModel.fromType == UserEnterRoomFromType_New_User_Greet) { + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser3") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + [attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]]; + } else if(extModel.fromType == UserEnterRoomFromType_Follow_Game_Detail) { + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser4") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + [attribute appendAttributedString:[self createNickAtrribute:extModel.fromNick uid:extModel.fromUid.integerValue]]; + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser5") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + } + } + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser6") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + } else { + [attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]]; + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser7") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]]; + } + + messageInfo.content = attribute; return messageInfo; } - break; - case NIMChatroomEventTypeInfoUpdated:{ - NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; - if (self.hostDelegate.getRoomInfo.datingState == RoomDatingStateChangeType_Open) { - [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser8") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; - messageInfo.content = attribute; - return messageInfo; - } - } - break; + break; + case NIMChatroomEventTypeInfoUpdated:{ + NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init]; + if (self.hostDelegate.getRoomInfo.datingState == RoomDatingStateChangeType_Open) { + [attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser8") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]]; + messageInfo.content = attribute; + return messageInfo; + } + } + break; default: return nil; } - return nil; + return nil; } #pragma mark - 夺宝精灵 - (XPMessageInfoModel *)createTreasureFairyAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ @@ -439,11 +446,11 @@ @kWeakify(self); [nickAttriibute yy_setTextHighlightRange:NSMakeRange(0, nickAttriibute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { @kStrongify(self); - + XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate]; fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid]; - fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen; - [self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil]; + fairyVC.modalPresentationStyle = UIModalPresentationOverFullScreen; + [self.hostDelegate.getCurrentNav presentViewController:fairyVC animated:YES completion:nil]; }]; [attribute appendAttributedString:nickAttriibute]; } @@ -467,7 +474,22 @@ // // return attribute; //} - +- (XPMessageInfoModel *)createChatHallnAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ + MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data]; + + + + messageInfo.first = CustomMessageType_Chat_Hall_Headlinesn; + if (topModel.nick != nil){ + NSString *text = [NSString stringWithFormat:YMLocalizedString(@"MSSessionContextHeadlinesView0"),topModel.nick]; + NSMutableAttributedString *textAtt = [[NSMutableAttributedString alloc]initWithString:text attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:UIColorFromRGB(0xffffff)}]; + [textAtt addAttributes:@{NSForegroundColorAttributeName:UIColorFromRGB(0xFE6859)} range:[text rangeOfString:topModel.nick]]; + messageInfo.content = textAtt; + } + + return messageInfo; + +} - (XPMessageInfoModel *)createGeneralPublicScreenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{ PIGeneralPublicScreenModel *screenModel = [PIGeneralPublicScreenModel modelWithDictionary:attachment.data]; diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.h b/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.h new file mode 100644 index 00000000..148f2b35 --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.h @@ -0,0 +1,16 @@ +// +// MsRoomMessagChatHallCell.h +// YuMi +// +// Created by duoban on 2024/5/10. +// + +#import +#import "XPMessageInfoModel.h" +NS_ASSUME_NONNULL_BEGIN + +@interface MsRoomMessagChatHallCell : UITableViewCell +@property(nonatomic,strong) XPMessageInfoModel *model; +@end + +NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.m b/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.m new file mode 100644 index 00000000..b46b712d --- /dev/null +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/View/MsRoomMessagChatHallCell.m @@ -0,0 +1,58 @@ +// +// MsRoomMessagChatHallCell.m +// YuMi +// +// Created by duoban on 2024/5/10. +// + +#import "MsRoomMessagChatHallCell.h" +@interface MsRoomMessagChatHallCell() +@property(nonatomic,strong) UILabel *textView; +@end +@implementation MsRoomMessagChatHallCell +-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ + self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; + if(self){ + [self installUI]; + [self installConstraints]; + } + return self; +} + +-(void)installUI{ + self.backgroundColor = [UIColor clearColor]; + self.contentView.backgroundColor = [UIColor clearColor]; + self.selectionStyle = UITableViewCellSelectionStyleNone; + [self.contentView addSubview:self.textView]; +} +-(void)installConstraints{ + [self.textView mas_makeConstraints:^(MASConstraintMaker *make) { + make.top.bottom.equalTo(self.contentView); + make.leading.trailing.equalTo(self.contentView).inset(kGetScaleWidth(10)); + }]; +} +- (void)setModel:(XPMessageInfoModel *)model{ + _model = model; + _textView.attributedText = _model.content; +} +#pragma mark - 懒加载 +- (UILabel *)textView{ + if(!_textView){ + _textView = [UILabel new]; + _textView.textAlignment = NSTextAlignmentCenter; + _textView.numberOfLines = 2; + } + return _textView; +} +- (void)awakeFromNib { + [super awakeFromNib]; + // Initialization code +} + +- (void)setSelected:(BOOL)selected animated:(BOOL)animated { + [super setSelected:selected animated:animated]; + + // Configure the view for the selected state +} + +@end diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.h b/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.h index a7dd666b..68dd7e35 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.h +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.h @@ -12,6 +12,8 @@ NS_ASSUME_NONNULL_BEGIN @interface XPRoomMessageHeaderView : UIView ///头部的背景颜色 @property (nonatomic,strong) UIColor *bubbleColor; +@property (nonatomic,strong) UIColor *titleColor; +@property(nonatomic,copy) NSString *title; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.m index 388328ae..b08087a4 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/View/XPRoomMessageHeaderView.m @@ -36,7 +36,14 @@ [self addSubview:self.bubbleView]; [self addSubview:self.titleLabel]; } - +- (void)setTitle:(NSString *)title{ + _title = title; + _titleLabel.text = title; +} +-(void)setTitleColor:(UIColor *)titleColor{ + _titleColor = titleColor; + _titleLabel.textColor = _titleColor; +} - (void)initSubViewConstraints { /// 设置绿色消息 NSString *title = YMLocalizedString(@"XPRoomMessageHeaderView0"); diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h index e7d34bc6..8cb4f487 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.h @@ -8,9 +8,10 @@ #import #import "RoomHostDelegate.h" #import "RoomGuestDelegate.h" +#import NS_ASSUME_NONNULL_BEGIN -@interface XPRoomMessageContainerView : UIView +@interface XPRoomMessageContainerView : UIView - (void)showUserCard:(NSInteger)uid; - (instancetype)initWithDelegate:(id)delegate; diff --git a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m index a79a9939..48e74c1c 100644 --- a/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m +++ b/YuMi/Modules/YMRoom/View/MessageContainerView/XPRoomMessageContainerView.m @@ -96,6 +96,9 @@ NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey"; } return self; } +- (UIView *)listView { + return self; +} - (void)showUserCard:(NSInteger)uid{ [self.messageParser showUserCard:uid]; } diff --git a/YuMi/Modules/YMRoom/View/RoomHostDelegate.h b/YuMi/Modules/YMRoom/View/RoomHostDelegate.h index 3aef24d4..d5d01366 100644 --- a/YuMi/Modules/YMRoom/View/RoomHostDelegate.h +++ b/YuMi/Modules/YMRoom/View/RoomHostDelegate.h @@ -41,6 +41,7 @@ NS_ASSUME_NONNULL_BEGIN ///屏蔽 -(void)requesstShieldingAction; -(NSMutableArray *)getPlayList;; +-(NSInteger)getPublicScreenType; @end NS_ASSUME_NONNULL_END diff --git a/YuMi/Modules/YMRoom/View/XPRoomMiniManager.m b/YuMi/Modules/YMRoom/View/XPRoomMiniManager.m index cbd7bef4..04d53b17 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomMiniManager.m +++ b/YuMi/Modules/YMRoom/View/XPRoomMiniManager.m @@ -75,6 +75,7 @@ - (NSArray *)getLocalCurrentRoomMessage { return [self.messageArray copy]; } + - (void)resetLocalMessage { [self.messageArray removeAllObjects]; } diff --git a/YuMi/Modules/YMRoom/View/XPRoomViewController.m b/YuMi/Modules/YMRoom/View/XPRoomViewController.m index a4935d57..218a217a 100644 --- a/YuMi/Modules/YMRoom/View/XPRoomViewController.m +++ b/YuMi/Modules/YMRoom/View/XPRoomViewController.m @@ -45,7 +45,7 @@ #import "XPRoomBackContainerView.h" #import "XPRoomMenuContainerView.h" #import "XPRoomQuickMessageContainView.h" -#import "XPRoomMessageContainerView.h" +#import "MsRoomMessageMainView.h" #import "RoomHeaderView.h" #import "SocialStageView.h" #import "DatingStageView.h" @@ -76,8 +76,9 @@ #import "XPRoomLittleGameContainerView.h" #import "XPUserCardViewController.h" #import "PIRoomEnterRedPacketView.h" - - +#import "MSSessionReleaseHeadlinesView.h" +#import "XPIAPRechargeViewController.h" +#import "XPCandyTreeInsufficientBalanceView.h" UIKIT_EXTERN NSString * const kShieldingNotification; UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey; UIKIT_EXTERN NSString * const kRoomMiniNotificationKey; @@ -87,7 +88,7 @@ UIKIT_EXTERN NSString * const kFreeGiftCountdownNotification; NSString * const kHadShowAnchorRoomTipKey = @"kHadShowAnchorRoomTipKey";//是否展示过个播房上划用户引导 NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出过非自己房间 -@interface XPRoomViewController () +@interface XPRoomViewController () ///背景 @property (nonatomic,strong) XPRoomBackContainerView *backContainerView; @@ -98,7 +99,7 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 ///坑位信息 @property (nonatomic,strong) StageView *stageView; ///公屏 -@property (nonatomic,strong) XPRoomMessageContainerView *messageContainerView; +@property (nonatomic,strong) MsRoomMessageMainView *messageContainerView; ///快捷发言 @property (nonatomic, strong) XPRoomQuickMessageContainView *quickMessageContainerView; ///底部操作栏 @@ -155,6 +156,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 @property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView; ///是否正在显示红包弹窗,防止显示多个弹窗 @property(nonatomic,assign) BOOL isShowRedPacket; +@property(nonatomic,copy) NSString *releaseCoins; +@property(nonatomic,copy) NSString *myCoins; @end @implementation XPRoomViewController @@ -312,6 +315,28 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showRoomFirstChargeWindowFormNot:) name:kShowFirstRechargeView object:nil]; [XPSkillCardPlayerManager shareInstance].isInRoom = YES; [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(openRedPacketNotification:) name:@"kOpenRedPacketNotification" object:nil]; + [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showSendheadlineView) name:@"kShowSendheadlineView" object:nil]; + +} + +-(void)showSendheadlineView{ + MSSessionReleaseHeadlinesView *releaseView = [[MSSessionReleaseHeadlinesView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + [releaseView loadDataForRoom]; + releaseView.delegate = self; + [TTPopup popupView:releaseView style:TTPopupStyleAlert]; +} +#pragma makr- MSSessionReleaseHeadlinesViewDelegate +-(void)releaseHeadlinesWithText:(NSString *)text{ + XPCandyTreeInsufficientBalanceView *balanceView = [[XPCandyTreeInsufficientBalanceView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)]; + balanceView.delegate = self; + [self.view addSubview:balanceView]; + +} +#pragma mark- XPCandyTreeInsufficientBalanceViewDelegate +- (void)payBalanceAction{ + XPIAPRechargeViewController * webVC =[[XPIAPRechargeViewController alloc] init]; + webVC.type = @"4"; + [self.navigationController pushViewController:webVC animated:YES]; } ///打开红包通知 -(void)openRedPacketNotification:(NSNotification *)not{ @@ -1408,11 +1433,14 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 if (message.session.sessionType != NIMSessionTypeChatroom) { continue; } - - // 非本房间不处理 - if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { - continue; + NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[self.userInfo.partitionId]]; + if(![message.session.sessionId isEqualToString:publicChatRoomId]){ + // 非本房间不处理 + if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { + continue; + } } + if (message.messageType == NIMMessageTypeNotification) { NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; @@ -1663,6 +1691,8 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self.littleGameView handleNIMTextMessage:message]; } else if(message.messageType == NIMMessageTypeTip) { [self.messageContainerView handleNIMTextMessage:message]; + }else if(message.messageType == NIMMessageTypeImage){ + [self.messageContainerView handleNIMImageMessage:message]; } } } @@ -1729,8 +1759,12 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 //发送消息成功回调 - (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error { // 非本房间不处理 - if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { - return; + NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[self.userInfo.partitionId]]; + if(![message.session.sessionId isEqualToString:publicChatRoomId]){ + // 非本房间不处理 + if (![message.session.sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]]) { + return; + } } if (message.yidunAntiSpamRes) { @@ -2131,7 +2165,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 [self enterRoomFail:0]; } } - +-(NSInteger)getPublicScreenType{ + return self.messageContainerView.type; +} #pragma mark - XPFirstRechargeViewDelegate -(void)rechargeHandle{ @@ -2192,9 +2228,9 @@ NSString * const kHadQuitOtherRoomKey = @"kHadQuitOtherRoomKey";//是否退出 return _roomHeaderView; } -- (XPRoomMessageContainerView *)messageContainerView { +- (MsRoomMessageMainView *)messageContainerView { if (!_messageContainerView) { - _messageContainerView = [[XPRoomMessageContainerView alloc] initWithDelegate:self]; + _messageContainerView = [[MsRoomMessageMainView alloc] initWithDelegate:self]; } return _messageContainerView; } diff --git a/YuMi/ar.lproj/Localizable.strings b/YuMi/ar.lproj/Localizable.strings index cb2aa201..53bfcdba 100644 --- a/YuMi/ar.lproj/Localizable.strings +++ b/YuMi/ar.lproj/Localizable.strings @@ -3799,5 +3799,8 @@ ineHeadView12" = "الحمل"; //MSRoomGameWebVC "MSRoomGameWebVC0"="هل أنت متأكد أنك تريد الخروج من اللعبة؟"; - - +"MSSessionPublicChatHallVC0"="غرفة الدردشة العامة"; +"MSSessionPublicChatHallVC1"="~اريد تصدر العناوين"; +"MSSessionReleaseHeadlinesView0"="(الرجاء إدخال المحتوي الذي تريد أن تتصدر عناوينهّ~ )يقتصر على 100 كلمة"; +"MSSessionReleaseHeadlinesView1"=" تصدر العناوين%@"; +"MSSessionContextHeadlinesView0"="~عزيزي%@، هيا تصدر العناوين ";