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 ] ] ;
}
2024-01-02 16:34:32 +08:00
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 ( 0 xFD85C9 ) 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 ( 0 xFE5D7F ) 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 ] ] ;
}
2024-01-02 16:34:32 +08:00
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 ( 0 xFB3D74 ) ;
} else {
groupTypeStr = YMLocalizedString ( @ "XPRoomMessageParser22" ) ;
groupColor = UIColorFromRGB ( 0 x3291FC ) ;
}
[ 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 ) {
2023-08-16 17:03:40 +08:00
[ attribute appendAttributedString : [ self createTextAttribute : [ NSString stringWithFormat : @ "%d" , [ attachment . data [ @ "drawGoldNum" ] intValue ] ] color : [ DJDKMIMOMColor messageNickColor ] font : kRoomMessageDefalutFont ] ] ;
2023-07-14 18:50:55 +08:00
}
2023-08-16 17:03:40 +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.0 f ; // 行 间 距
// 强 制 排 版 ( 从 左 到 右 )
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