Files
peko-ios/YuMi/Modules/YMRoom/View/MessageContainerView/Tool/XPRoomMessageParser.m

1420 lines
93 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// YMRoomMessageParser.m
// YUMI
//
// Created by YUMI on 2021/10/26.
//
#import "XPRoomMessageParser.h"
2023-10-28 04:46:10 +08:00
2023-07-14 18:50:55 +08:00
#import <NIMSDK/NIMSDK.h>
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor+Room.h"
#import "XPRoomMessageConstant.h"
#import "AccountInfoStorage.h"
#import "YUMIMacroUitls.h"
#import "XPGiftStorage.h"
#import "XPRoomFaceTool.h"
#import "TTPopup.h"
#import "Api+WishGift.h"
#import "NSArray+Safe.h"
#import "ClientConfig.h"
///Model
#import "XPMessageRemoteExtModel.h"
#import "AttachmentModel.h"
#import "GiftReceiveInfoModel.h"
#import "XPKickUserModel.h"
#import "MicroQueueModel.h"
#import "UserInfoModel.h"
#import "MicroStateModel.h"
#import "RoomInfoModel.h"
#import "DatingInfoModel.h"
#import "RoomFaceInfoModel.h"
#import "RoomFaceSendInfoModel.h"
#import "GuildSuperAdminInfoModel.h"
#import "RoomPKChooseUserModel.h"
#import "RoomPKInfoModel.h"
#import "CandyTreeResultModel.h"
#import "XPGiftBigPrizeModel.h"
#import "XPGiftCompoundModel.h"
#import "RoomSailingPrizeModel.h"
#import "XPOpenRedPacketModel.h"
#import "XPMessageInfoModel.h"
#import "XPRoomStarKitchenModel.h"
2023-08-10 10:12:19 +08:00
#import "TreasureFailryMessageModel.h"
2023-07-14 18:50:55 +08:00
#import "NetImageView.h"
#import "XPUserCardViewController.h"
#import "XPRoomTopicAlertView.h"
#import "XPRoomSendTextView.h"
#import "XPRoomPKResultView.h"
2023-07-19 14:41:04 +08:00
#import "XPWebViewController.h"
#import "XCCurrentVCStackManager.h"
2023-08-10 10:12:19 +08:00
#import "XPTreasureFairyViewController.h"
2024-02-23 14:40:10 +08:00
#import "PIGeneralPublicScreenModel.h"
2023-07-14 18:50:55 +08:00
@implementation XPRoomMessageParser
2023-08-16 15:50:27 +08:00
2023-07-14 18:50:55 +08:00
- (XPMessageInfoModel*)parseMessageAttribute:(NIMMessage *)message {
NIMMessageType messageType = message.messageType;
XPMessageInfoModel * messageInfo = [[XPMessageInfoModel alloc] init];
2023-08-25 16:32:51 +08:00
if([message.messageObject isKindOfClass:[NIMCustomObject class]] ){
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel * attachment = (AttachmentModel *)obj.attachment;
if(attachment.isBroadcast == YES){
return [self makeCustomAttribute:message messageInfo:messageInfo];
}
}
}
2023-07-14 18:50:55 +08:00
switch (messageType) {
case NIMMessageTypeText:
2023-10-26 16:37:53 +08:00
{
XPMessageInfoModel *model = [self makeChatAttribute:message messageInfo:messageInfo];
return model != nil ? model : [XPMessageInfoModel new];
break;
}
2023-07-14 18:50:55 +08:00
case NIMMessageTypeTip:
2023-10-26 16:53:31 +08:00
{
XPMessageInfoModel *model = [self makeTipsAttribute:message messageInfo:messageInfo];
return model != nil ? model : [XPMessageInfoModel new];
break;
}
2023-07-14 18:50:55 +08:00
case NIMMessageTypeNotification:
2023-10-26 16:53:31 +08:00
{
XPMessageInfoModel *model = [self makeNotificationAttribute:message messageInfo:messageInfo];
return model != nil ? model : [XPMessageInfoModel new];
break;
}
2023-07-14 18:50:55 +08:00
case NIMMessageTypeCustom:
2023-10-26 16:53:31 +08:00
{
XPMessageInfoModel *model = [self makeCustomAttribute:message messageInfo:messageInfo];
return model != nil ? model : [XPMessageInfoModel new];
break;
}
2023-07-14 18:50:55 +08:00
default:
2023-10-26 16:53:31 +08:00
return [XPMessageInfoModel new];
2023-07-14 18:50:55 +08:00
}
}
- (NSString *)parseMessageBubble:(NIMMessage *)message {
XPMessageRemoteExtModel * model = [XPMessageRemoteExtModel modelWithJSON:message.remoteExt[message.from]];
return model.iosBubbleUrl ? model.iosBubbleUrl : @"";
}
///
- (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;
2024-03-12 18:17:33 +08:00
int second = attachment.second;
2023-07-14 18:50:55 +08:00
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) {//
return [self createNobleLevelAttribute:attachment messageInfo:messageInfo];
} else if (first == CustomMessageType_Face) {//
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];
} 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_RedPacket && attachment.second == Custom_Message_Sub_OpenRedPacketSuccess) {
return [self createRedPacketAttribute:attachment messageInfo:messageInfo];
2024-03-12 18:17:33 +08:00
} else if (first == CustomMessageType_Treasure_Fairy) {
2023-08-10 10:12:19 +08:00
return [self createTreasureFairyAttribute:attachment messageInfo:messageInfo];
2023-10-17 18:30:14 +08:00
}else if (first == CustomMessageType_Room_Album) {
2023-10-18 17:16:50 +08:00
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"]];
2023-10-17 18:30:14 +08:00
NSString * uid = [AccountInfoStorage instance].getUid;
2023-10-18 17:16:50 +08:00
NSString * nick = @"";
if(userInfo != nil){
nick = [NSString stringWithFormat:@"%@:", userInfo[@"nick"]];
}
2023-10-17 18:30:14 +08:00
if ([message.from isEqualToString:uid]) {
nick = YMLocalizedString(@"XPRoomMessageParser0");
}
messageInfo.first = CustomMessageType_Room_Album;
messageInfo.nameText = nick;
2023-10-18 17:16:50 +08:00
messageInfo.albumModel = albumModel;
2023-10-17 18:30:14 +08:00
return messageInfo;
2024-02-21 10:18:59 +08:00
}else if(first == CustomMessageType_Guardian_Planet){
return [self createGuardianPlanetAttribute:attachment messageInfo:messageInfo];
2024-02-23 14:40:10 +08:00
}else if(first == CustomMessageType_General_Public_Screen){
return [self createGeneralPublicScreenAttribute:attachment messageInfo:messageInfo];
2023-07-14 18:50:55 +08:00
}
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];
if ([message.from isEqualToString:uid]) {
2023-08-09 11:55:27 +08:00
nick = YMLocalizedString(@"XPRoomMessageParser0");
2023-07-14 18:50:55 +08:00
}
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 createLocalImageAttribute:@"common_super_admin"]];
}
if (model.vipIcon) {//icon
[attribute appendAttributedString:[self createUrlImageAttribute:model.vipIcon]];
[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]]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
} else if (model.inRoomNameplatePic.length > 0) {//
[attribute appendAttributedString:[self createUrlImageAttribute:model.inRoomNameplatePic]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
2023-07-14 18:50:55 +08:00
}
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
id nickNameNifo = message.remoteExt[@"atNames"];
NSMutableAttributedString *msgStr;
if (message.text) {
msgStr = [[NSMutableAttributedString alloc] initWithString:message.text];
[msgStr addAttribute:NSForegroundColorAttributeName
value:[DJDKMIMOMColor messageTextColor]
range:NSMakeRange(0, msgStr.length)];
if ([nickNameNifo isKindOfClass:[NSArray class]]) {
for (NSString *nick in nickNameNifo) {
NSRange range = [message.text rangeOfString:nick];
if (range.length) {
[msgStr yy_setTextHighlightRange:range color:UIColorFromRGB(0xFD85C9) backgroundColor:[UIColor clearColor] userInfo:nil];
}
}
}
[attribute appendAttributedString:msgStr];
}
[self attributeAddLongPressHihtLight:attribute uid:message.from nick:((NIMMessageChatroomExtension *)message.messageExt).roomNickname];
messageInfo.content = attribute;
return messageInfo;
}
/// 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;
}
///
/// @param message
- (XPMessageInfoModel*)makeNotificationAttribute:(NIMMessage *)message messageInfo:(XPMessageInfoModel *)messageInfo{
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;
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 createLocalImageAttribute:@"common_super_admin"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (extModel.vipIcon.length > 0) {//icon
[attribute appendAttributedString:[self createUrlImageAttribute:extModel.vipIcon]];
[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]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}else{
if (extModel.inRoomNameplatePic.length > 0 && extModel.inRoomNameplateWord.length > 0) {
[attribute appendAttributedString:[self createNameplateAttibute:extModel.inRoomNameplateWord image:extModel.inRoomNameplatePic textFont:[UIFont systemFontOfSize:9]]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createNickAtrribute:nick uid:message.from.integerValue]];
if (extModel.carName.length > 0) {
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser1") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[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;
default:
return nil;
}
return nil;
}
2023-08-10 10:12:19 +08:00
#pragma mark -
- (XPMessageInfoModel *)createTreasureFairyAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
TreasureFailryMessageModel *info = [TreasureFailryMessageModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L3) {///
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.rewardNum > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L4 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Gift_L5) {///
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser117") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.rewardNum > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"X%ld", info.rewardNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L1) {///
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Draw_Ball_L3) {///
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser117") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L1 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2 || attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3) {///
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser115") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:nickAttriibute uid:info.uid.integerValue];
[attribute appendAttributedString:nickAttriibute];
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser116") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
if(attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L3) {
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser119") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
} else if (attachment.second == Custom_Message_Sub_Treasure_Fairy_Convert_L2) {
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser120") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
} else {
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser121") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
}
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser122") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld", info.rewardShowValue] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
if ([info.rewardType isEqualToString:@"gift"]){
2023-08-16 18:40:56 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser123") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-08-10 10:12:19 +08:00
} else {
[attribute appendAttributedString:[self createTextAttribute:info.rewardUnit color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:info.rewardName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
if (self.hostDelegate.getUserInfo.userLevelVo.experLevelSeq >= info.userLevelLimit) {
2023-08-16 18:40:56 +08:00
NSMutableAttributedString * nickAttriibute = [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser124") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
2023-08-10 10:12:19 +08:00
@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];
}];
[attribute appendAttributedString:nickAttriibute];
}
messageInfo.content = attribute;
return messageInfo;
}
2023-07-14 18:50:55 +08:00
#pragma mark -
2023-07-19 14:41:04 +08:00
//- (NSAttributedString *)createStarKitchenAttribute:(AttachmentModel *)attachment{
// XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
// NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser103"),starModel.nick,starModel.itemMultiple,starModel.diamonds];
// NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.itemMultiple]]];
// [attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.diamonds]]];
// @kWeakify(self)
// [attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
// @kStrongify(self);
// if (starModel.uid.integerValue <= 0) {return;}
// [self showUserCard:starModel.uid.integerValue];
// }];
//
// return attribute;
//}
2023-07-14 18:50:55 +08:00
2024-02-23 14:40:10 +08:00
- (XPMessageInfoModel *)createGeneralPublicScreenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
PIGeneralPublicScreenModel *screenModel = [PIGeneralPublicScreenModel modelWithDictionary:attachment.data];
NSDictionary *textDic = screenModel.template;
if(textDic.allKeys.count == 0)return messageInfo;
NSString *title = textDic[@"zh-CHT"] == nil ? textDic[textDic.allKeys.firstObject] : textDic[@"zh-CHT"];
if(title.length == 0)return messageInfo;
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:screenModel.textColor]}];
for (PIGeneralPublicScreenItemModel *model in screenModel.contents) {
if([model.type isEqualToString:@"TEXT"]){
NSDictionary *subTextDic = model.text;
if(subTextDic.allKeys.count > 0){
NSString *subText = subTextDic[@"zh-CHT"] == nil ? subTextDic[subTextDic.allKeys.firstObject] : subTextDic[@"zh-CHT"];
NSAttributedString *attText = [[NSAttributedString alloc]initWithString:subText attributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor colorWithHexString:model.textColor]}];
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attText];
@kWeakify(self)
[attribute yy_setTextHighlightRange:[attribute.string rangeOfString:subText] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
if(model.skipType == 6){
if(model.skipContent.length == 0)return;
[self showUserCard:model.skipContent.integerValue];
}
}];
}
}else if ([model.type isEqualToString:@"IMAGE"]){
NSMutableAttributedString *attImage = [self createUrlImageAttribute:model.image size:CGSizeMake(model.width, model.height)];
[attImage appendAttributedString:[self createSapceAttribute:2]];
[attribute replaceCharactersInRange:[attribute.string rangeOfString:[NSString stringWithFormat:@"{%@}",model.key]] withAttributedString:attImage];
}
}
messageInfo.content = attribute;
return messageInfo;
}
2024-02-21 10:18:59 +08:00
- (XPMessageInfoModel *)createGuardianPlanetAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser1033334"),starModel.nick,starModel.diamonds];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@"%@",starModel.diamonds]]];
@kWeakify(self)
[attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
if (starModel.uid.integerValue <= 0) {return;}
[self showUserCard:starModel.uid.integerValue];
}];
messageInfo.content = attribute;
return messageInfo;
}
2023-07-19 14:41:04 +08:00
- (XPMessageInfoModel *)createStarredKitchenAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
2023-08-31 17:08:59 +08:00
XPRoomStarKitchenModel *starModel = [XPRoomStarKitchenModel modelWithDictionary:attachment.data];
NSString *title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser1033333"),starModel.nick,starModel.itemMultiple,starModel.diamonds];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:kRoomMessageDefalutFont],NSForegroundColorAttributeName:[DJDKMIMOMColor messageDefaultTextColor]}];
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageNickColor]} range:[title rangeOfString:starModel.nick]];
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.itemMultiple]]];
[attribute addAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor messageTextColor]} range:[title rangeOfString:[NSString stringWithFormat:@" %@",starModel.diamonds]]];
@kWeakify(self)
[attribute yy_setTextHighlightRange:[title rangeOfString:starModel.nick] color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
2023-07-19 14:41:04 +08:00
@kStrongify(self);
2023-08-31 17:08:59 +08:00
if (starModel.uid.integerValue <= 0) {return;}
[self showUserCard:starModel.uid.integerValue];
2023-07-19 14:41:04 +08:00
}];
2023-08-31 17:08:59 +08:00
2023-07-19 14:41:04 +08:00
messageInfo.content = attribute;
return messageInfo;
2023-07-14 18:50:55 +08:00
}
#pragma mark -
- (XPMessageInfoModel *)createRedPacketAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
XPOpenRedPacketModel *info = [XPOpenRedPacketModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createNickAtrribute:info.openRedEnvelopeUserNick uid:info.openRedEnvelopeId.integerValue]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser9") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createNickAtrribute:info.redEnvelopeMasterNick uid:info.redEnvelopeMasterId.integerValue]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser10") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.amount.floatValue>0) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser11"), info.amount] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createRoomSailingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
RoomSailingPrizeModel *info = [RoomSailingPrizeModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomCandyGiftView0") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser13") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.prizeName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
if (info.prizeNum>1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"x%d", info.prizeNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
[self attributeAddHihtLight:attribute uid:info.uid.integerValue];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createRoomGiftCompoundAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
XPGiftCompoundModel *info = [XPGiftCompoundModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser14") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.msg color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[self attributeAddHihtLight:attribute uid:info.uid.integerValue];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createRoomLuckyBigPrizeAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
XPGiftBigPrizeModel * info= [XPGiftBigPrizeModel modelWithDictionary:attachment.data];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser15") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser16") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:info.roomTitle color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser17"), info.luckyBagName] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser18" ), info.giftName] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark - PK
- (XPMessageInfoModel *)createRoomPKAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if (attachment.second == Custom_Message_Sub_Room_PK_Manager_Up_Mic) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser19") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
for (NSDictionary * selectuUser in [attachment.data allValues]) {
RoomPKChooseUserModel * userInfoModel = [RoomPKChooseUserModel modelWithDictionary:selectuUser];
if (userInfoModel.groupType != GroupType_default && userInfoModel.nick.length > 0) {
[attribute appendAttributedString:[self createNickAtrribute:userInfoModel.nick uid:userInfoModel.uid.integerValue]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser20") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSString * groupTypeStr;
UIColor * groupColor;
if (userInfoModel.groupType == GroupType_Red) {
groupTypeStr= YMLocalizedString(@"XPRoomMessageParser21");
groupColor = UIColorFromRGB(0xFB3D74);
}else{
groupTypeStr = YMLocalizedString(@"XPRoomMessageParser22");
groupColor = UIColorFromRGB(0x3291FC);
}
[attribute appendAttributedString:[self createTextAttribute:groupTypeStr color:groupColor font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}
[attribute deleteCharactersInRange:NSMakeRange(attribute.string.length - 1, 1)];
} else {
RoomPKInfoModel * model = [RoomPKInfoModel modelWithDictionary:attachment.data];
if (attachment.second == Custom_Message_Sub_Room_PK_Mode_Close) {
NSString * title = YMLocalizedString(@"XPRoomMessageParser23");
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSRange range = [title rangeOfString:YMLocalizedString(@"XPRoomMessageParser24")];
[attribute addAttribute:NSForegroundColorAttributeName value:[DJDKMIMOMColor messageDefaultTextColor] range:range];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Result) {
NSString * victoryStr;
if (model.result == RoomPKResultType_Draw) {
RoomPKTeamModel * blueTeam;
RoomPKTeamModel * redTeam;
for (int i = 0 ; i < model.teams.count; i++) {
RoomPKTeamModel * team = [model.teams safeObjectAtIndex1:i];
if (team.team == GroupType_Red) {
redTeam = team;
}else{
blueTeam = team;
}
}
RoomPKTeamModel * team = [model.teams firstObject];
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
victoryStr = YMLocalizedString(@"XPRoomMessageParser25");
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
2023-08-09 11:55:27 +08:00
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser26"),victoryStr, resultScale];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}else{
if (team.protecScore > 0) {
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", team.score],[NSString stringWithFormat:@"%lld", team.score]];
victoryStr = YMLocalizedString(@"XPRoomMessageParser27");
2023-08-09 11:55:27 +08:00
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser28"),victoryStr, resultScale];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}else{
victoryStr = YMLocalizedString(@"XPRoomMessageParser29");
2023-08-09 11:55:27 +08:00
NSString * result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser28"),victoryStr, @"0:0"];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}
if (team.protector > 0) {
[attribute appendAttributedString:[[NSMutableAttributedString alloc] initWithString:@"\n"]];
2023-08-09 11:55:27 +08:00
NSString * teamStr = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser31"), blueTeam.protector.nick.length > 0 ? blueTeam.protector.nick : @"", [[NSNumber numberWithLongLong:blueTeam.protecScore] stringValue], redTeam.protector.nick.length > 0 ? redTeam.protector.nick : @"", [[NSNumber numberWithLongLong:redTeam.protecScore] stringValue]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:teamStr color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}else{
RoomPKTeamModel * victoryTeam;
RoomPKTeamModel * failTeam;
for (int i = 0 ; i < model.teams.count; i++) {
RoomPKTeamModel * team = [model.teams safeObjectAtIndex1:i];
if (team.team == (GroupType)model.result) {
victoryTeam = team;
}else{
failTeam = team;
}
}
if (model.result == RoomPKResultType_Red){
victoryStr = YMLocalizedString(@"XPRoomMessageParser32");
}else if (model.result == RoomPKResultType_Blue){
victoryStr = YMLocalizedString(@"XPRoomMessageParser33");
}
NSString * resultScale = [NSString stringWithFormat:@"%@:%@",[NSString stringWithFormat:@"%lld", victoryTeam.score],[NSString stringWithFormat:@"%lld", failTeam.score]];
NSString * result;
if (model.voteMode == RoomPKVoteModeType_NumberPerson) {
2023-08-09 11:55:27 +08:00
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser34"),victoryStr, resultScale,[NSNumber numberWithLongLong:victoryTeam.score]];
2023-07-14 18:50:55 +08:00
}else{
if (victoryTeam.protector) {
NSString * victoryProteror = victoryTeam.protector.nick.length > 0 ? victoryTeam.protector.nick : @"";
2023-08-09 11:55:27 +08:00
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser35"),victoryStr, resultScale,victoryStr, victoryProteror, victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
2023-07-14 18:50:55 +08:00
}else{
2023-08-09 11:55:27 +08:00
result = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser36"),victoryStr, resultScale,victoryStr,[[NSNumber numberWithLongLong:victoryTeam.protecScore] stringValue]];
2023-07-14 18:50:55 +08:00
}
}
[attribute appendAttributedString:[self createTextAttribute:result color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
@kWeakify(self);
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
[self showRoomPKResult:attachment.data];
}];
} else if(attachment.second == Custom_Message_Sub_Room_PK_Mode_Open) {
NSString * pkType;
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
pkType = YMLocalizedString(@"XPRoomMessageParser37");
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
pkType = YMLocalizedString(@"XPRoomMessageParser38");
}
2023-08-09 11:55:27 +08:00
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser114"), model.duration, pkType];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}else if (attachment.second == Custom_Message_Sub_Room_PK_Start){
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser40"), model.duration];
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}else if (attachment.second == Custom_Message_Sub_Room_PK_Re_Start){
NSString * pkType;
if (model.voteMode == RoomPKVoteModeType_GiftValue) {
pkType = YMLocalizedString(@"XPRoomMessageParser41");
}else if (model.voteMode == RoomPKVoteModeType_NumberPerson){
pkType = YMLocalizedString(@"XPRoomMessageParser42");
}
2023-08-09 11:55:27 +08:00
NSString * title = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser43"), model.duration, pkType];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:title color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}
messageInfo.content = attribute;
return messageInfo;
}
- (void)showRoomPKResult:(NSDictionary *)dic {
RoomPKInfoModel * pkInfo = [RoomPKInfoModel modelWithDictionary:dic];
if (pkInfo.pkStatus == RoomPKStatusType_End || pkInfo.pkStatus == RoomPKStatusType_ReStart) {
XPRoomPKResultView * result = [[XPRoomPKResultView alloc] init];
result.roomPKResultInfoModel = pkInfo;
[TTPopup popupView:result style:TTPopupStyleAlert];
}
}
#pragma mark -
- (XPMessageInfoModel*)createRoomFaceAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if ([attachment.data[@"data"] isKindOfClass:[NSArray class]]) {
NSArray * array = [RoomFaceSendInfoModel modelsWithArray:attachment.data[@"data"]];
for (int i = 0; i< array.count; i++) {
RoomFaceSendInfoModel * sendFaceInfo = [array safeObjectAtIndex1:i];
[attribute appendAttributedString:[self createTextAttribute:sendFaceInfo.nick color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@":" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@"\n" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
for (int j = 0; j < sendFaceInfo.resultIndexes.count; j++) {
NSNumber *index = sendFaceInfo.resultIndexes[j];
UIImage *face = [[XPRoomFaceTool shareFaceTool] findFaceImageById:sendFaceInfo.faceId index:[index integerValue]];
if (face) {
UIImageView *imageView = [[UIImageView alloc]init];
imageView.image = face;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.bounds = CGRectMake(0, 0, 30, 30);
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.frame.size.width, imageView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
[attribute appendAttributedString:[self createSapceAttribute:1]];
[attribute appendAttributedString:attrString];
}
}
}
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel*)createCollectRoomAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
NSDictionary *data = attachment.data[@"data"];
NSString *nick = [NSString stringWithFormat:@"%@",data[@"nick"]];
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
NSString *tipString = @"";
if (attachment.second == Custom_Message_Sub_Collect_Room_Tips) {
tipString = YMLocalizedString(@"XPRoomMessageParser44");
}
[attribute appendAttributedString:[self createTextAttribute:tipString color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel*)createRoomInfoUpdateAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
if (attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
NSDictionary * dic= attachment.data[@"roomInfo"];
if (dic.allKeys.count <=0) {
dic = attachment.data;
}
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
if (roomInfo.isCloseScreen) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser46") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser47") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
messageInfo.content = attribute;
} else if(attachment.second == Custom_Message_Sub_Update_RoomInfo_AnimateEffect) {
NSDictionary * dic = attachment.data[@"roomInfo"];
if (dic.allKeys.count <=0) {
dic = attachment.data;
}
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
if (roomInfo.hasAnimationEffect) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser49") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser50") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createImageAttribute:[UIImage imageNamed:@"room_menu_more"]]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser51") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
messageInfo.content = attribute;
} else if (attachment.second == Custom_Message_Sub_Update_RoomInfo_CleanScreen) {
NSNumber *roleType = attachment.data[@"roleType"];
NSString *nick = attachment.data[@"nick"];
NSInteger uid = 0;
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
}
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser45") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
if (roleType.integerValue == 1) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser53") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
} else if (roleType.integerValue == 2) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser54") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
}
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser55") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[self attributeAddHihtLight:attribute uid:uid];
messageInfo.content = attribute;
}
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createRoomDatingAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
if(attachment.second == Custom_Message_Sub_Room_Play_Dating_Pick_Heart) {
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
2023-08-09 11:55:27 +08:00
NSString * targetGender = datingModel.targetGender == GenderType_Male ? YMLocalizedString(@"XPSessionFindNewFiltrateView2") : YMLocalizedString(@"XPRoomMessageParser57");
NSString * pickString = [NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser58"), (datingModel.targetPosition + 1), targetGender];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser59") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:pickString color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
NSString * heartContent = YMLocalizedString(@"XPRoomMessageParser60");
[attribute appendAttributedString:[self createTextAttribute:heartContent color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if(attachment.second == Custom_Message_Sub_Room_Play_Dating_Result_Mutual) {///
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser61") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSString * nick = datingModel.nickname ? datingModel.nickname : @"";
[attribute appendAttributedString:[self createNickAtrribute:nick uid:datingModel.uid]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser62") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
2023-12-29 16:43:37 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser63") color:[UIColor whiteColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
} else if (attachment.second == Custom_Message_Sub_Room_Play_Dating_Result_Not_Mutual) {///
DatingInfoModel * datingModel = [DatingInfoModel modelWithDictionary:attachment.data];
NSString * nick = datingModel.nickname ? datingModel.nickname : @"";
[attribute appendAttributedString:[self createNickAtrribute:nick uid:datingModel.uid]];
if (datingModel.hasSelectUser) {//
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser64") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
NSString * targetNick = datingModel.targetNickname ? datingModel.targetNickname : @"";
[attribute appendAttributedString:[self createNickAtrribute:targetNick uid:datingModel.targetUid]];
} else {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser65") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createArrangeMicAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser66") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (attachment.second == Custom_Message_Sub_Arrange_Mic_Mode_Open) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser67") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser68") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Mode_Close) {
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser69") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser70") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Free_Mic_Open) {
NSDictionary * dic = attachment.data;
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser71") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser72"), ((NSNumber *)dic[@"micPos"]).intValue + 1 ] color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser73") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_Arrange_Mic_Free_Mic_Close) {
NSDictionary * dic = attachment.data;
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser74") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:YMLocalizedString(@"XPRoomMessageParser75"), ((NSNumber *)dic[@"micPos"]).intValue + 1 ] color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser76") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createCandyTreeHighLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
//action
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser77") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
CandyTreeGiftInfoModel * giftInfo = [CandyTreeGiftInfoModel modelWithDictionary:attachment.data];
[attribute appendAttributedString:[self createTextAttribute:giftInfo.nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser78") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:giftInfo.prizeName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (giftInfo.prizeNum > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X %d", giftInfo.prizeNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
if (attachment.second == Custom_Message_Sub_Candy_Tree_Me && giftInfo.uid.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser79") color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
}
[self attributeAddHihtLight:attribute uid:giftInfo.uid.integerValue];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createNobleLevelAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
NSInteger uid = 0;
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
}
if (attachment.second == Custom_Message_Sub_Room_Open_Noble_VIP) {/// 851
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser80") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%@(%@)", attachment.data[@"nick"], attachment.data[@"erbanNo"]] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser81") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"currVipName"] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser82") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
} else if (attachment.second == Custom_Message_Sub_Room_Noble_LevelUp || attachment.second == Custom_Message_Sub_AllRoom_Noble_LevelUp_Suspend) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser83") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"nick"] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser84") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"currVipName"] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:@"" color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
[self attributeAddHihtLight:attribute uid:uid];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createTarotAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-09-14 11:16:47 +08:00
if (attachment.second == Custom_Message_Sub_Tarot_Novice || attachment.second == Custom_Message_Sub_Tarot_Advanced || attachment.second == Custom_Message_Sub_Tarot_Intermediate) {
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser85") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:attachment.data[@"nick"] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-09-14 11:16:47 +08:00
NSString *text = [NSString stringWithFormat:@" %@", YMLocalizedString(@"XPRoomMessageParser125")];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:text color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
if ([attachment.data[@"drawGoldNum"] intValue] > 1) {
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%d",[attachment.data[@"drawGoldNum"] intValue]] color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
}
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPNobleCenterPayView1") color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createAnchorFansTeamAttribute:(AttachmentModel *)attachment messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
NSInteger uid = 0;
if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) {
uid = ((NSNumber *)attachment.data[@"uid"]).integerValue;
} else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) {
uid = ((NSString *)attachment.data[@"uid"]).integerValue;
}
NSString *idString = [NSString stringWithFormat:@"%ld", uid];
NSString *nickName = attachment.data[@"nickname"];
if ([idString isEqualToString:[[AccountInfoStorage instance] getUid]]) {
nickName = YMLocalizedString(@"XPRoomMessageParser86");
}
if (attachment.second == Custom_Message_Sub_FansTeam_Open_Success) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser87") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser88") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_FansTeam_Join_Success) {///
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser89") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser90") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else if (attachment.second == Custom_Message_Sub_FansTeam_Out_Success) {//退
[attribute appendAttributedString:[self createTextAttribute:nickName color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser91") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
[self attributeAddHihtLight:attribute uid:uid];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark - //
- (XPMessageInfoModel *)createKickUserAttribute:(AttachmentModel *)attachment info:(XPKickUserModel *)info messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
[attribute appendAttributedString:[self createNickAtrribute:info.targetNick uid:info.targetUid]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser92") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createNickAtrribute:info.handleNick uid:info.handleUid]];
NSString * content= @"";
if (attachment.second == Custom_Message_Sub_Kick_BeKicked || attachment.second == Custom_Message_Sub_Hall_Super_Admin_Kick_Manager_Out_Room) {
content = YMLocalizedString(@"XPRoomMessageParser93");
} else if(attachment.second == Custom_Message_Sub_Kick_BlackList) {
content = YMLocalizedString(@"XPRoomMessageParser94");
} else if(attachment.second == Custom_Message_Sub_Queue_Kick) {
content = YMLocalizedString(@"XPRoomMessageParser95");
}
[attribute appendAttributedString:[self createTextAttribute:content color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createShareOrAttentionRoomAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo uid:(NSString *)uid messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
2023-07-18 18:26:10 +08:00
NSDictionary *data = attachment.data;
2023-08-16 14:21:58 +08:00
NSString *nick = [NSString stringWithFormat:@"%@",data[@"data"][@"nick"]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
NSString *tipString = @"";
if (attachment.second == Custom_Message_Sub_Room_Tip_ShareRoom) {
tipString = YMLocalizedString(@"XPRoomMessageParser96");
}else if (attachment.second == Custom_Message_Sub_Room_Tip_Attention_Owner) {
tipString = YMLocalizedString(@"XPRoomMessageParser97");
}
[attribute appendAttributedString:[self createTextAttribute:tipString color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[self attributeAddHihtLight:attribute uid:uid.integerValue];
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark -
- (XPMessageInfoModel *)createBatchMicroSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data];
GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift;
if (giftInfo == nil) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
}
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
//nick
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
if (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroSend) {///
if (attachment.second == Custom_Message_Sub_AllBatchSend) {
//
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser98") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createSapceAttribute:2]];
for (int i = 0; i < info.targetUsers.count; i++) {
GiftReceiveUserInfoModel *targetInfo = [info.targetUsers safeObjectAtIndex1:i];
//nick
[attribute appendAttributedString:[self createNickAtrribute:targetInfo.nick uid:targetInfo.uid]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
if (i < (info.targetUsers.count -1)) {
//nick
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
} else {
//
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser99") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
//img
if (giftInfo.giftUrl) {
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
//x N
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
} else if(attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend) {///
//action
2023-08-09 11:55:27 +08:00
NSString * sendTitle = YMLocalizedString(@"XPRoomMessageParser100");
2023-07-14 18:50:55 +08:00
if (attachment.second == Custom_Message_Sub_AllMicroLuckySend) {
2023-08-09 11:55:27 +08:00
sendTitle = YMLocalizedString(@"XPRoomMessageParser101");
2023-07-14 18:50:55 +08:00
}
//
[attribute appendAttributedString:[self createTextAttribute:sendTitle color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser102") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createSapceAttribute:2]];
if (info.luckyGiftList) {
//target
[attribute appendAttributedString:[self createNickAtrribute:info.luckyGiftList.user.nick uid:info.luckyGiftList.user.uid]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser103") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createSapceAttribute:2]];
[info.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
GiftInfoModel *luckGiftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
//
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser104") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld",(NSInteger)luckGiftInfo.goldPrice] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
//
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser105") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
//img
[attribute appendAttributedString:[self createUrlImageAttribute:luckGiftInfo.giftUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//x N
[attribute appendAttributedString:[self createTextAttribute: [NSString stringWithFormat:@" X%ld",giftListInfo.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.luckyGiftList.giftList.count-1 != idx) {
//,
[attribute appendAttributedString:[self createTextAttribute:@"," color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
}];
}
}
messageInfo.content = attribute;
return messageInfo;
}
- (XPMessageInfoModel *)createSendGiftAttribute:(AttachmentModel *)attachment sendInfo:(XPMessageRemoteExtModel *)sendInfo messageInfo:(XPMessageInfoModel *)messageInfo{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
GiftReceiveInfoModel *info = [GiftReceiveInfoModel modelWithJSON:attachment.data];
GiftInfoModel *giftInfo = info.gift == nil ? info.giftInfo : info.gift;
if (giftInfo == nil) {
giftInfo = [[XPGiftStorage shareStorage] findGiftInfo:info.giftId];
}
///
[attribute appendAttributedString:[self createOfficalAndNewuserAttribute:sendInfo.defUser newUser:sendInfo.newUser fromSayHelloChannel:sendInfo.fromSayHelloChannel]];
//nick
[attribute appendAttributedString:[self createNickAtrribute:info.nick uid:info.uid.integerValue]];
[attribute appendAttributedString:[self createSapceAttribute:2]];;
if (attachment.second == Custom_Message_Sub_Gift_LuckySend) {
//action
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser106") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
//
[attribute appendAttributedString:[self createTextAttribute:info.giftName color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser107") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
//target
[attribute appendAttributedString:[self createNickAtrribute:info.luckyGiftList.user.nick uid:info.luckyGiftList.user.uid]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//lucky
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser108") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[info.luckyGiftList.giftList enumerateObjectsUsingBlock:^(GiftListsInfo * _Nonnull giftListInfo, NSUInteger idx, BOOL * _Nonnull stop) {
GiftInfoModel *luckyGiftInfo = [[XPGiftStorage shareStorage] findGiftInfo:[NSString stringWithFormat:@"%ld", giftListInfo.giftId]];
//
[attribute appendAttributedString: [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser109") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@"%ld",(NSInteger)luckyGiftInfo.goldPrice] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
//
[attribute appendAttributedString: [self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser110") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
//img
[attribute appendAttributedString:[self createUrlImageAttribute:luckyGiftInfo.giftUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//x N
[attribute appendAttributedString:[self createTextAttribute: [NSString stringWithFormat:@" X%ld",giftListInfo.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
if (info.luckyGiftList.giftList.count-1 != idx) {
//,
[attribute appendAttributedString: [self createTextAttribute:@"," color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
}];
} else {
//
2023-08-09 11:55:27 +08:00
[attribute appendAttributedString:[self createTextAttribute:YMLocalizedString(@"XPRoomMessageParser111") color:[DJDKMIMOMColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
2023-07-14 18:50:55 +08:00
[attribute appendAttributedString:[self createSapceAttribute:2]];
//target
[attribute appendAttributedString: [self createNickAtrribute:info.targetNick uid:info.targetUid.integerValue]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//img
[attribute appendAttributedString:[self createUrlImageAttribute:giftInfo.giftUrl]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
//x N
[attribute appendAttributedString:[self createTextAttribute:[NSString stringWithFormat:@" X%ld",info.giftNum] color:[DJDKMIMOMColor messageTextColor] font:kRoomMessageDefalutFont]];
}
messageInfo.content = attribute;
return messageInfo;
}
#pragma mark - Commond Mehotd
///
- (BOOL)isCurrentRoomSuperAdmin:(NSString *)uid {
for (GuildSuperAdminInfoModel *info in self.hostDelegate.getRoomSuperAdminList) {
if ([info.uid isEqualToString:uid]) {
return YES;
}
}
return NO;
}
- (NSAttributedString *)createOfficalAndNewuserAttribute:(UserLevelType)levelType newUser:(BOOL)newUser fromSayHelloChannel:(BOOL)fromSayHelloChannel{
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] init];
//offical
if (levelType == UserLevelType_Offical) {
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_offical"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
if (newUser) {
if (fromSayHelloChannel) {
[attribute appendAttributedString:[self createLocalImageAttribute:@"room_new_user_greet_new"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
} else {
[attribute appendAttributedString: [self createLocalImageAttribute:@"common_new_user"]];
[attribute appendAttributedString:[self createSapceAttribute:2]];
}
}
return attribute;
}
///
- (NSMutableAttributedString *)createNickAtrribute:(NSString *)nick uid:(NSInteger)uid {
NSMutableAttributedString * attribute = [self createTextAttribute:nick color:[DJDKMIMOMColor messageNickColor] font:kRoomMessageDefalutFont];
[self attributeAddHihtLight:attribute uid:uid];
return attribute;
}
- (void)attributeAddHihtLight:(NSMutableAttributedString *)attribute uid:(NSInteger)uid {
@kWeakify(self);
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
if (uid <= 0) {return;}
[self showUserCard:uid];
}];
}
- (void)attributeAddLongPressHihtLight:(NSMutableAttributedString *)attribute uid:(NSString *)uid nick:(NSString *)nick {
@kWeakify(self);
[attribute yy_setTextHighlightRange:NSMakeRange(0, attribute.length) color:nil backgroundColor:nil userInfo:nil tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
if (uid <= 0) {return;}
[self showUserCard:uid.integerValue];
} longPressAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
@kStrongify(self);
if ([uid isEqualToString:[AccountInfoStorage instance].getUid] || uid.length < 1) {
return;
}
UIViewController *vc = self.hostDelegate.getCurrentNav.viewControllers[0];
[XPRoomSendTextView showTextView:vc.view delegate:self.hostDelegate atUid:uid atNick:nick];
}];
}
- (void)showUserCard:(NSInteger)uid {
if (![ClientConfig shareConfig].canOpen) {
return;
}
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
NSString * targetUid = [NSString stringWithFormat:@"%ld", uid];
XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init];
[[self.hostDelegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
if (uid == obj.userInfo.uid) {
model.position = [NSString stringWithFormat:@"%d", obj.microState.position];
model.posState = obj.microState.posState;
model.micState = obj.microState.micState;
*stop = YES;
}
}];
model.nick = self.hostDelegate.getUserInfo.nick;
model.uid = targetUid;
model.micQueue = self.hostDelegate.getMicroQueue;
model.roomInfo = roomInfo;
model.delegate = self.hostDelegate;
model.superMangerList = self.hostDelegate.getRoomSuperAdminList;
XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model];
[self.hostDelegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil];
}
#pragma mark - private base methods
///
- (NSMutableAttributedString *)createNameplateAttibute:(NSString *)tagName image:(NSString *)imageName textFont:(UIFont *)textFont {
NetImageConfig *config = [[NetImageConfig alloc]init];
///
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageName config:config];
UIImage* image = imageView.image;
if (image) {
CGFloat scale = image.size.width / image.size.height;
2023-08-10 11:08:11 +08:00
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
2023-07-14 18:50:55 +08:00
} else {
2023-10-26 16:53:31 +08:00
// NSURL *imgUrl = [NSURL URLWithString:imageName];
// UIImage *myImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:imgUrl]];
// if (myImage) {
// CGFloat scale = myImage.size.width / myImage.size.height;
// if (scale == 0) {
// imageView.bounds = CGRectMake(0, 0, 60, 18);
// }else {
// imageView.bounds = CGRectMake(0, 0, 18* scale, 18);
// }
// } else {
2023-08-10 11:08:11 +08:00
imageView.bounds = CGRectMake(0, 0, 60, 18);
2023-10-26 16:53:31 +08:00
// }
2023-07-14 18:50:55 +08:00
}
imageView.contentMode = UIViewContentModeScaleAspectFit;
//
UILabel *label = [[UILabel alloc] init];
label.textAlignment = NSTextAlignmentCenter;
label.font = [UIFont boldSystemFontOfSize:12];
label.adjustsFontSizeToFitWidth = YES;
label.textColor = UIColor.whiteColor;
label.text = tagName;
[imageView addSubview:label];
[label mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(27);
make.right.mas_equalTo(-8);
make.centerY.mas_equalTo(0);
}];
NSMutableAttributedString *string = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:imageView.bounds.size alignToFont:[UIFont boldSystemFontOfSize:12] alignment:YYTextVerticalAlignmentCenter];
return string;
}
///
/// @param imageUrl
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl {
NetImageConfig *config = [[NetImageConfig alloc]init];
///
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
UIImage* image = imageView.image;
if (image) {
CGFloat scale = image.size.width / image.size.height;
2023-08-10 11:08:11 +08:00
imageView.bounds = CGRectMake(0, 0, 18 * scale, 18);
2023-07-14 18:50:55 +08:00
} else {
2023-08-10 11:08:11 +08:00
imageView.bounds = CGRectMake(0, 0, 18, 18);
2023-07-14 18:50:55 +08:00
}
imageView.layer.masksToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFit;
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attrString;
}
2024-02-23 14:40:10 +08:00
///
/// @param imageUrl
- (NSMutableAttributedString *)createUrlImageAttribute:(NSString *)imageUrl size:(CGSize)size {
NetImageConfig *config = [[NetImageConfig alloc]init];
///
config.autoLoad = YES;
NetImageView *imageView = [[NetImageView alloc]initWithUrl:imageUrl config:config];
imageView.bounds = CGRectMake(0, 0, size.width, size.height);
imageView.layer.masksToBounds = YES;
imageView.contentMode = UIViewContentModeScaleAspectFit;
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imageView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imageView.bounds.size.width, imageView.bounds.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attrString;
}
2023-07-14 18:50:55 +08:00
///
/// @param imageName
- (NSMutableAttributedString *)createLocalImageAttribute:(NSString *)imageName {
if (imageName == nil && imageName.length <= 0) {
return nil;
}
2023-08-10 11:08:11 +08:00
UIImageView *imaveView = [[UIImageView alloc]init];
imaveView.image = [UIImage imageNamed:imageName];
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
imaveView.bounds = CGRectMake(0, 0, 16 * scale, 16);
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attrString;
2023-07-14 18:50:55 +08:00
}
///
/// @param image
- (NSMutableAttributedString *)createImageAttribute:(UIImage *)image {
UIImageView *imaveView = [[UIImageView alloc]init];
imaveView.image = image;
CGFloat scale = (CGFloat)imaveView.image.size.width / (CGFloat)imaveView.image.size.height;
imaveView.bounds = CGRectMake(0, 0, 20 * scale, 20);
NSMutableAttributedString * attrString = [NSMutableAttributedString yy_attachmentStringWithContent:imaveView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(imaveView.frame.size.width, imaveView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attrString;
}
///
/// @param text
/// @param color
/// @param font
- (NSMutableAttributedString *)createTextAttribute:(NSString *)text color:(UIColor *)color font:(CGFloat)font {
if (text == nil || text.length <= 0) {
text = @"";
}
NSMutableAttributedString *attribute = [[NSMutableAttributedString alloc] initWithString:text attributes:nil];
attribute.yy_font = [UIFont systemFontOfSize:font];
attribute.yy_color = color;
attribute.yy_paragraphStyle = [self paragraphStyle];
return attribute;
}
/// ...
- (NSMutableParagraphStyle *)paragraphStyle {
NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];
paraStyle.lineSpacing = 4.0f;//
// ()
paraStyle.alignment = NSTextAlignmentLeft;
paraStyle.baseWritingDirection = NSWritingDirectionLeftToRight;
return paraStyle;
}
///
/// @param width
- (NSMutableAttributedString *)createSapceAttribute:(CGFloat)width {
UIView *spaceView = [[UIView alloc]init];
spaceView.backgroundColor = [UIColor clearColor];
spaceView.bounds = CGRectMake(0, 0, width, 10);
NSMutableAttributedString * attribute = [NSMutableAttributedString yy_attachmentStringWithContent:spaceView contentMode:UIViewContentModeScaleAspectFit attachmentSize:CGSizeMake(spaceView.frame.size.width, spaceView.frame.size.height) alignToFont:[UIFont systemFontOfSize:15.0] alignment:YYTextVerticalAlignmentCenter];
return attribute;
}
@end