房间内的数据提交

This commit is contained in:
linyudan
2023-12-14 16:53:04 -08:00
parent 3472e7c800
commit d983053f29
14 changed files with 355 additions and 49 deletions

View File

@@ -775,6 +775,7 @@
8C2C3F742B2B73AC002C3C34 /* DDMessageCustomRemoteExtModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F732B2B73AC002C3C34 /* DDMessageCustomRemoteExtModel.m */; };
8C2C3F792B2BB4E4002C3C34 /* DDClientConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F782B2BB4E4002C3C34 /* DDClientConfig.m */; };
8C2C3F7C2B2BB66F002C3C34 /* DDClientModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8C2C3F7B2B2BB66F002C3C34 /* DDClientModel.m */; };
8CD77F9F2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CD77F9E2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.m */; };
8CE493992B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */; };
8CE4939C2B23F45C00CA14D5 /* NSArray+DDSafe.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939B2B23F45C00CA14D5 /* NSArray+DDSafe.m */; };
8CE493A02B23F5FA00CA14D5 /* DDUploadFile.m in Sources */ = {isa = PBXBuildFile; fileRef = 8CE4939F2B23F5FA00CA14D5 /* DDUploadFile.m */; };
@@ -2222,6 +2223,8 @@
8C2C3F7A2B2BB66F002C3C34 /* DDClientModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DDClientModel.h; sourceTree = "<group>"; };
8C2C3F7B2B2BB66F002C3C34 /* DDClientModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DDClientModel.m; sourceTree = "<group>"; };
8CAB97312B2259EA00ED8639 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
8CD77F9D2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPRoomMessageContainerView.h; sourceTree = "<group>"; };
8CD77F9E2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPRoomMessageContainerView.m; sourceTree = "<group>"; };
8CE493972B23F44800CA14D5 /* NSMutableDictionary+DDSafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMutableDictionary+DDSafe.h"; sourceTree = "<group>"; };
8CE493982B23F44800CA14D5 /* NSMutableDictionary+DDSafe.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMutableDictionary+DDSafe.m"; sourceTree = "<group>"; };
8CE4939A2B23F45C00CA14D5 /* NSArray+DDSafe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSArray+DDSafe.h"; sourceTree = "<group>"; };
@@ -3376,6 +3379,8 @@
18660DC42A21E54B0032D0C9 /* PublicMessage */,
18660DC72A21E54B0032D0C9 /* ToolView */,
18660DCA2A21E54B0032D0C9 /* InfoView */,
8CD77F9D2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.h */,
8CD77F9E2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.m */,
);
path = View;
sourceTree = "<group>";
@@ -6530,6 +6535,7 @@
188EC0ED2A47CF3200060F03 /* DDMMoreKeyboard.m in Sources */,
18B1EA222A26F28700DDE889 /* DDDynamicModel.m in Sources */,
186C9D192A2A02F700209BB5 /* DDYoungPwdViewController.m in Sources */,
8CD77F9F2B2BD41A00F4CFF3 /* XPRoomMessageContainerView.m in Sources */,
18660CBD2A21913E0032D0C9 /* WRCustomNavigationBar.m in Sources */,
188EC13A2A47CF3300060F03 /* HX_PhotoEditViewController.m in Sources */,
1812EC7E2A54FC9300FF2AC0 /* DDRoomSendGiftsView.m in Sources */,

View File

@@ -20,6 +20,7 @@
#import "RoomEditPassWordView.h"
#import "AccountInfoStorage.h"
#import <NIMSDK/NIMSDK.h>
//#import "XPRoomViewController.h"
static NSString *SAVELOGIN = @"LOGINMODEL";
static NSString *SAVECITYINFO = @"CITYINFO";
static NSString *SAVELOGINVIDEO = @"LOGINVIDEO";

View File

@@ -9,6 +9,7 @@
#import <Foundation/Foundation.h>
#import "GCDMulticastDelegate.h"
#import "RoomInfoModel.h"
#import "RoomUserInfoModel.h"
@class VideoModel;
NS_ASSUME_NONNULL_BEGIN
@protocol AppMessageManagerDelegate <NSObject>

View File

@@ -164,34 +164,34 @@
///
- (void)sendPublicTextMessage:(NSString *)roomID text:(NSString *)text userInfo:(RoomUserInfoModel*)userInfo messageType:(NSInteger)messageType{
[ToolsObject ShowSVProgressHUD:@""];
if(!userInfo){
return;
}
if([ToolsObject IsNullWithObject:userInfo.nickname] ||[ToolsObject IsNullWithObject:userInfo.room_auth]){
return;
}
NSString *meadlBox = @"";
if([ToolsObject isBlankString:userInfo.medal_box].length >0){
meadlBox = userInfo.medal_box;
}
NSString *bubbleBox = @"";
if([ToolsObject isBlankString:userInfo.bubble_box].length >0){
bubbleBox = userInfo.bubble_box;
}
NSDictionary *userInfoDic = @{@"nickname":userInfo.nickname,
@"room_auth":userInfo.room_auth,
@"user_id":userInfo.user_id,
@"level_icon":[ToolsObject isBlankString:userInfo.level_icon],
@"medal_box":meadlBox,
@"bubble_box":bubbleBox,
@"nobility_id":@(userInfo.nobility_id)
};
NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
[dataDic setObject:roomID forKey:@"room_id"];
[dataDic setObject:text forKey:@"content"];
[dataDic setObject:userInfoDic forKey:@"user_info"];
[dataDic setObject:@(messageType) forKey:@"message_type"];
[self sendMesageDic:dataDic messageID:1000];
// if(!userInfo){
// return;
// }
// if([ToolsObject IsNullWithObject:userInfo.nickname] ||[ToolsObject IsNullWithObject:userInfo.room_auth]){
// return;
// }
// NSString *meadlBox = @"";
// if([ToolsObject isBlankString:userInfo.medal_box].length >0){
// meadlBox = userInfo.medal_box;
// }
// NSString *bubbleBox = @"";
// if([ToolsObject isBlankString:userInfo.bubble_box].length >0){
// bubbleBox = userInfo.bubble_box;
// }
// NSDictionary *userInfoDic = @{@"nickname":userInfo.nickname,
// @"room_auth":userInfo.room_auth,
// @"user_id":userInfo.user_id,
// @"level_icon":[ToolsObject isBlankString:userInfo.level_icon],
// @"medal_box":meadlBox,
// @"bubble_box":bubbleBox,
// @"nobility_id":@(userInfo.nobility_id)
// };
// NSMutableDictionary *dataDic = [[NSMutableDictionary alloc] init];
// [dataDic setObject:roomID forKey:@"room_id"];
// [dataDic setObject:text forKey:@"content"];
// [dataDic setObject:userInfoDic forKey:@"user_info"];
// [dataDic setObject:@(messageType) forKey:@"message_type"];
// [self sendMesageDic:dataDic messageID:1000];
}
///

View File

@@ -336,7 +336,7 @@ trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath{
}
NSMutableArray *arr = response.data;
RoomInfoModel *model = [RoomInfoModel yy_modelWithJSON:arr.firstObject];
[[ToolsObject shareTools]jumpToRoomVC:model.user_id followUser:[RoomUserInfoModel new]];
// [[ToolsObject shareTools]jumpToRoomVC:model.user_id followUser:[RoomUserInfoModel new]];
}
}];

View File

@@ -146,6 +146,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic , copy) NSString * roomPwd;
@property (nonatomic , copy) NSString * roomDesc;
@property (nonatomic , assign) NSInteger uid;
///清除公屏的时间(用于拉取此时间后的公屏消息)
@property (nonatomic , assign) double clearScreenTime;
@end
NS_ASSUME_NONNULL_END

View File

@@ -51,6 +51,7 @@
/// Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
#import "DDMessageCustomRemoteExtModel.h"
/// Third
#import <NIMSDK/NIMSDK.h>
@@ -85,6 +86,9 @@ static dispatch_once_t onceToken;
@property (nonatomic,strong) RoomEventView *roomEventView;
/***/
@property (nonatomic,strong) RoomPublicMessageView *publicMessageView;
///
//@property (nonatomic,strong) XPRoomMessageContainerView *messageContainerView;
@property (nonatomic, strong) NSMutableArray *timeArray;
/***/
@property (nonatomic,strong) RoomInfoModel *roomInfoModel;
@@ -256,6 +260,15 @@ static dispatch_once_t onceToken;
///
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
NSLog(@"message:%@",messages);
for (NIMMessage *message in messages) {
if (message.messageType == NIMMessageTypeNotification) {
[self.publicMessageView handleRecvMessages: message];
}
}
}
///
@@ -788,6 +801,10 @@ static dispatch_once_t onceToken;
});
}
#pragma mark --/
- (void)setRoomInfo:(RoomInfoModel *)roomInfo {
_roomInfo = roomInfo;
[self.publicMessageView roomInfo:roomInfo];
}
- (void)tipBtnClick{
KRepeatClickTime(1);
@@ -1834,6 +1851,31 @@ static dispatch_once_t onceToken;
@weakify(self);
/***/
[inputView setSendMsgBlock:^(NSString * _Nonnull message) {
DDMessageCustomRemoteExtModel *model = [[DDMessageCustomRemoteExtModel alloc] initMessageRemoteExtModelWithUserModel:self.userInfo];
NIMMessage *nimMessage = [[NIMMessage alloc] init];
nimMessage.text = message;
NSMutableDictionary *remoteExt = [NSMutableDictionary dictionaryWithObject:model.dd_modelDictionary forKey:[AccountInfoStorage instance].getUid];
// NIMAntiSpamOption *option = [[NIMAntiSpamOption alloc]init];
// option.yidunEnabled = YES;
// option.businessId = KeyWithType(keyType_YiDunBussinessId);
// message.antiSpamOption = option;
NSString * sessionId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
//
NIMSession *session = [NIMSession session:sessionId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:nimMessage toSession:session completion:^(NSError * _Nullable error) {
//
NSLog(@"发送消息成功:%@",error);
[self.publicMessageView.dataArr addObject:[RoomPublicScreenModel initMessage:message user:self.userInfo other_user:[RoomInfoModel new] giftModel:[DDGiftWallModel new] message_type:3 handle_type:0]];
// self.editTextFiled.text = @"";
// [self.editTextFiled resignFirstResponder];
// [self.atUids removeAllObjects];
// [self.atNames removeAllObjects];
// self.inputMessage = nil;
}];
}];
[inputView setSendMsgBlock:^(NSString * _Nonnull message) {
@strongify(self);
NSLog(@"[ToolsObject getUserModel].nobility_id -----%lu",[ToolsObject getUserModel].nobility_id);

View File

@@ -6,6 +6,8 @@
//
#import "WLBaseView.h"
#import <NIMSDK/NIMSDK.h>
#import "RoomInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@@ -14,6 +16,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, strong) NSMutableArray *dataArr;
/**刷新公屏列表**/
- (void)refreshTableView;
- (void)handleRecvMessages:(NIMMessage *)message;
- (void)roomInfo:(RoomInfoModel *)roomInfo;
/**点击**/
@property (nonatomic, copy) void(^cellTapGesActionBlock)(RoomUserInfoModel *userModel);
@end

View File

@@ -11,10 +11,19 @@
#import "RoomPublicScreenEmojiCell.h"
#import "RoomPublicScreenGiftCell.h"
#import "RoomPublicScreenModel.h"
#import "DDClientConfig.h"
static NSInteger kRoomMessageMaxLength = 1000;
@interface RoomPublicMessageView () <UITableViewDelegate, UITableViewDataSource>
/****/
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) RoomInfoModel *roomInfo;
///
//@property (nonatomic,strong) NSMutableArray<message *> *datasource;
///
//@property (nonatomic,strong) NSMutableArray<XPMessageInfoModel *> *datasource;
@end
@implementation RoomPublicMessageView
@@ -51,6 +60,110 @@
}
}
- (void)roomInfo:(RoomInfoModel *)roomInfo {
self.roomInfo = roomInfo;
}
- (void)handleRecvMessages:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
if (content.eventType == NIMChatroomEventTypeEnter) {
NIMChatroomNotificationMember *member = content.targets[0];
if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
[self handleFetchHistoryMessage:message];
}
}
}
- (void)handleFetchHistoryMessage:(NIMMessage *)message {
NSString *roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
option.limit = [DDClientConfig shareConfig].configInfo.roomMessageCount;
option.startTime = self.roomInfo.clearScreenTime / 1000.0;
option.order = NIMMessageSearchOrderAsc;
option.messageTypes = @[@(NIMMessageTypeText)];
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
if (messages.count) {
//50
if (messages.count == [DDClientConfig shareConfig].configInfo.roomMessageCount) {
NIMHistoryMessageSearchOption *option = [[NIMHistoryMessageSearchOption alloc] init];
option.limit = [DDClientConfig shareConfig].configInfo.roomMessageCount;
option.order = NIMMessageSearchOrderDesc;
option.messageTypes = @[@(NIMMessageTypeText)];
[[NIMSDK sharedSDK].chatroomManager fetchMessageHistory:roomId option:option result:^(NSError * _Nullable error, NSArray<NIMMessage *> * _Nullable messages) {
if (self.dataArr.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.dataArr objectsAtIndexes:set];
[self.dataArr removeObjectsInArray:needRemoveMsgArray];
}
//
// for (NIMMessage *item in messages.reverseObjectEnumerator) {
// [self.dataArr addObject:[self.messageParser parseMessageAttribute:item]];
// if (!self.isMiniEnter) { ///
// if (self.roomInfo.isCloseScreen) {
// NIMCustomObject *obj = (NIMCustomObject *)item.messageObject;
// if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
// AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
// if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState){
// [[XPRoomMiniManager shareManager] saveRoomMessage:item];
// }
// }
// } else {
// [[XPRoomMiniManager shareManager] saveRoomMessage:item];
// }
// }
// }
// [self.messageTableView reloadData];
// //
// [self scrollToBottom:YES];
// BOOL hideEnter = [self handleHideEnter:message];
// if (!hideEnter) {
// ///
// [self addRoomMessage:message];
// }
// if (!roomInfo.hasAnimationEffect) {
// [self roomInfoNoGiftAnimationMessage:message];
// }
// [self createUserEnterRoomAddRoomtopicMessage];
}];
// return;
}
if (self.dataArr.count > kRoomMessageMaxLength) {
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
NSArray *needRemoveMsgArray = [self.dataArr objectsAtIndexes:set];
[self.dataArr removeObjectsInArray:needRemoveMsgArray];
}
//
for (NIMMessage *item in messages) {
// [RoomPublicScreenModel initMessage:<#(nonnull NSString *)#> user:<#(nonnull UserInfoModel *)#> other_user:<#(nonnull UserInfoModel *)#> giftModel:<#(nonnull DDGiftWallModel *)#> message_type:<#(NSInteger)#> handle_type:<#(NSInteger)#>]
// self.dataArr addObject:<#(nonnull id)#>
// [self.dataArr addObject:[self.messageParser parseMessageAttribute:item]];
// if (!self.isMiniEnter) {///
// if (self.hostDelegate.getRoomInfo.isCloseScreen) {
// NIMCustomObject *obj = (NIMCustomObject *)item.messageObject;
// if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
// AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
// if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState){
// [[XPRoomMiniManager shareManager] saveRoomMessage:item];
// }
// }
// } else {
// [[XPRoomMiniManager shareManager] saveRoomMessage:item];
// }
// }
}
// [self.messageTableView reloadData];
// //
// [self scrollToBottom:YES];
}
}];
}
#pragma mark --- UITableViewDelegate || UITableViewDataSource ---
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 10;
@@ -159,6 +272,36 @@
// }
}
///
//- (void)appendAndScrollToBottom {
// if (self.incomingMessages.count < 1) {
// ///atincomeatatat
// [self scrollToBottom:YES];
// return;
// }
//
// if (self.datasource.count > kRoomMessageMaxLength) {
// NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
// NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
// [self.datasource removeObjectsInArray:needRemoveMsgArray];
// }
//
// //
// NSMutableArray *indexPaths = [NSMutableArray array];
// for (NIMMessage *item in self.incomingMessages) {
// [self.datasource addObject:[self.messageParser parseMessageAttribute:item]];
// [indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
// }
// [self.incomingMessages removeAllObjects];
// [self.messageTableView reloadData];
//
// //
// [self scrollToBottom:YES];
//}
#pragma mark ------ ------
- (UITableView *)tableView {
if (!_tableView) {

View File

@@ -0,0 +1,16 @@
//
// XPRoomMessageContainerView.h
// DingDangApp
//
// Created by 触海 on 2023/12/14.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomMessageContainerView : UIView
@end
NS_ASSUME_NONNULL_END

View File

@@ -0,0 +1,13 @@
//
// XPRoomMessageContainerView.m
// DingDangApp
//
// Created by on 2023/12/14.
//
#import "XPRoomMessageContainerView.h"
@implementation XPRoomMessageContainerView
@end

View File

@@ -8,6 +8,8 @@
#import <Foundation/Foundation.h>
#import "RoomUserInfoModel.h"
#import "DDGiftWallModel.h"
#import "RoomInfoModel.h"
#import "UserInfoModel.h"
NS_ASSUME_NONNULL_BEGIN
@@ -49,6 +51,39 @@ NS_ASSUME_NONNULL_BEGIN
/**背景高度**/
@property (nonatomic, assign) CGFloat bgHeight;
///显示文本
@property (nonatomic,strong) NSAttributedString *content;
///cell的高度
@property (nonatomic,assign) CGFloat rowHeight;
///文本内容的
@property (nonatomic,assign) CGFloat contentLeftMargin;
///文本右边的间隙
@property (nonatomic,assign) CGFloat contentRightMargin;
///文本上面的间隙
@property (nonatomic,assign) CGFloat contentTopMargin;
///文本底部的间隙
@property (nonatomic,assign) CGFloat contentBottomMargin;
///底部的间隙
@property (nonatomic,assign) CGFloat cellBottomMargin;
///是否要隐藏背景
@property (nonatomic,assign) BOOL isHiddenBubble;
///是否改变内容的区域
@property (nonatomic,assign) BOOL isUpdateContentFrame;
///气泡url
@property (nonatomic, copy) NSString *bubbleImageUrl;
///是否展示头像
@property (nonatomic,assign) BOOL isShowAvatar;
///头像地址
@property (nonatomic,strong) NSString *avatarUrl;
///用户的uid
@property (nonatomic,strong) NSString *uid;
///是否是特权卡消息
@property(nonatomic,assign) BOOL isPrivilegeCard;
@property(nonatomic,copy) NSString *cardUrl;
///cell的高度
@property (nonatomic,assign) CGFloat cardHeight;
/**
若无对应内容,需初始化改对象
msg公屏富文本内容
@@ -58,7 +93,7 @@ NS_ASSUME_NONNULL_BEGIN
message_type消息类型
handle_type
*/
+ (RoomPublicScreenModel *)initMessage:(NSString *)msg user:(RoomUserInfoModel *)user other_user:(RoomUserInfoModel *)other_user giftModel:(DDGiftWallModel *)giftModel message_type:(NSInteger)message_type handle_type:(NSInteger)handle_type;
+ (RoomPublicScreenModel *)initMessage:(NSString *)msg user:(UserInfoModel *)user other_user:(UserInfoModel *)other_user giftModel:(DDGiftWallModel *)giftModel message_type:(NSInteger)message_type handle_type:(NSInteger)handle_type;
@end

View File

@@ -7,9 +7,37 @@
#import "RoomPublicScreenModel.h"
#define kRoomMessageMaxWidth (KScreenWidth - 15 - 90)
@implementation RoomPublicScreenModel
+ (RoomPublicScreenModel *)initMessage:(NSString *)msg user:(RoomUserInfoModel *)user other_user:(RoomUserInfoModel *)other_user giftModel:(DDGiftWallModel *)giftModel message_type:(NSInteger)message_type handle_type:(NSInteger)handle_type {
- (instancetype)init {
if ([super init]) {
self.contentLeftMargin = 12;
self.contentRightMargin = 0;
self.contentTopMargin = 10;
self.contentBottomMargin = 10;
self.cellBottomMargin = 10;
self.isUpdateContentFrame = NO;
self.isHiddenBubble = NO;
}
return self;
}
- (void)setContent:(NSAttributedString *)content {
_content = content;
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - self.contentLeftMargin - self.contentRightMargin - 12, MAXFLOAT);
YYTextContainer *container = [YYTextContainer containerWithSize:maxSize];
container.maximumNumberOfRows = 0;
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:self.content];
if (self.isShowAvatar) {
self.rowHeight = layout.textBoundingSize.height + self.cellBottomMargin;
} else {
self.rowHeight = layout.textBoundingSize.height + self.cellBottomMargin + self.contentTopMargin + self.contentBottomMargin;
}
}
+ (RoomPublicScreenModel *)initMessage:(NSString *)msg user:(UserInfoModel *)user other_user:(UserInfoModel *)other_user giftModel:(DDGiftWallModel *)giftModel message_type:(NSInteger)message_type handle_type:(NSInteger)handle_type {
RoomPublicScreenModel *model = [[RoomPublicScreenModel alloc] init];
model.msg = msg;
model.user = user;
@@ -18,7 +46,7 @@
model.msg_type = message_type;
model.handle_type = handle_type;
if (model.msg_type == 1) {//
NSString *messageStr = [NSString stringWithFormat:@"欢迎%@ 进入本房间",user.nickname];
NSString *messageStr = [NSString stringWithFormat:@"欢迎%@ 进入本房间",user.nick];
//
CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kWidth - KAdaptedWidth(125), CGFLOAT_MAX) andlineSpacing:3];
//cell
@@ -40,7 +68,7 @@
[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)];
NSRange range1 = [[attributedStr string] rangeOfString:user.nickname];
NSRange range1 = [[attributedStr string] rangeOfString:user.nick];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range1];
@@ -50,15 +78,15 @@
if (model.msg_type == 2) {//12345
NSString *messageStr = @"";
if (handle_type == 1) {
messageStr = [NSString stringWithFormat:@"%@ 已被%@ 踢出房间",other_user.nickname,user.nickname];
messageStr = [NSString stringWithFormat:@"%@ 已被%@ 踢出房间",other_user.nick,user.nick];
} else if (handle_type == 2) {
messageStr = [NSString stringWithFormat:@"您已被%@禁言",user.nickname];
messageStr = [NSString stringWithFormat:@"您已被%@禁言",user.nick];
} else if (handle_type == 3) {
messageStr = [NSString stringWithFormat:@"您已被%@禁麦",user.nickname];
messageStr = [NSString stringWithFormat:@"您已被%@禁麦",user.nick];
} else if (handle_type == 4) {
messageStr = [NSString stringWithFormat:@"%@跟随%@进入本房间",other_user.nickname,user.nickname];
messageStr = [NSString stringWithFormat:@"%@跟随%@进入本房间",other_user.nick,user.nick];
} else if (handle_type == 5) {
messageStr = [NSString stringWithFormat:@"%@一键赠送给 %@%@",user.nickname,other_user.nickname,msg];
messageStr = [NSString stringWithFormat:@"%@一键赠送给 %@%@",user.nick,other_user.nick,msg];
}
//
@@ -82,11 +110,11 @@
[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)];
NSRange range1 = [[attributedStr string] rangeOfString:user.nickname ?: @""];
NSRange range1 = [[attributedStr string] rangeOfString:user.nick ?: @""];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range1];
NSRange range2 = [[attributedStr string] rangeOfString:other_user.nickname ?: @""];
NSRange range2 = [[attributedStr string] rangeOfString:other_user.nick ?: @""];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range2];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range2];
@@ -120,7 +148,7 @@
}
if (model.msg_type == 4) {//
NSString *messageStr = [NSString stringWithFormat:@"%@赠送给%@",user.nickname ?: @"无名氏",other_user.nickname ?: @"无名氏"];
NSString *messageStr = [NSString stringWithFormat:@"%@赠送给%@",user.nick ?: @"无名氏",other_user.nick ?: @"无名氏"];
//
CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(KAdaptedWidth(182), CGFLOAT_MAX) andlineSpacing:3];
//cell
@@ -149,11 +177,11 @@
[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"FFFFFF"] range:NSMakeRange(0, attributedStr.length)];
NSRange range1 = [[attributedStr string] rangeOfString:other_user.nickname ?: @"无名氏"];
NSRange range1 = [[attributedStr string] rangeOfString:other_user.nick ?: @"无名氏"];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range1];
NSRange range2 = [[attributedStr string] rangeOfString:user.nickname ?: @"无名氏"];
NSRange range2 = [[attributedStr string] rangeOfString:user.nick ?: @"无名氏"];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range2];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range2];
@@ -197,7 +225,7 @@
}
if (model.msg_type == 7) {//
NSString *messageStr = [NSString stringWithFormat:@"%@已收到您的警告信息",user.nickname ?: @"无名氏"];
NSString *messageStr = [NSString stringWithFormat:@"%@已收到您的警告信息",user.nick ?: @"无名氏"];
//
CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(kWidth - KAdaptedWidth(125), CGFLOAT_MAX) andlineSpacing:3];
//cell
@@ -219,7 +247,7 @@
[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)];
NSRange range1 = [[attributedStr string] rangeOfString:user.nickname ?: @"无名氏"];
NSRange range1 = [[attributedStr string] rangeOfString:user.nick ?: @"无名氏"];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#80AFF5"] range:range1];
@@ -227,7 +255,7 @@
}
if (model.msg_type == 8) {//
NSString *messageStr = [NSString stringWithFormat:@"%@抽中%@",user.nickname ?: @"无名氏",giftModel.title ?: @""];
NSString *messageStr = [NSString stringWithFormat:@"%@抽中%@",user.nick ?: @"无名氏",giftModel.title ?: @""];
//
CGSize msgSize = [self sizeWithText:messageStr andFont:[UIFont systemFontOfSize:14] maxSize:CGSizeMake(KAdaptedWidth(182), CGFLOAT_MAX) andlineSpacing:3];
//cell
@@ -256,11 +284,11 @@
[attributedStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attributedStr.length)];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#FFFFFF"] range:NSMakeRange(0, attributedStr.length)];
NSRange range1 = [[attributedStr string] rangeOfString:other_user.nickname ?: @"无名氏"];
NSRange range1 = [[attributedStr string] rangeOfString:other_user.nick ?: @"无名氏"];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range1];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#97F0FC"] range:range1];
NSRange range2 = [[attributedStr string] rangeOfString:user.nickname ?: @"无名氏"];
NSRange range2 = [[attributedStr string] rangeOfString:user.nick ?: @"无名氏"];
[attributedStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14] range:range2];
[attributedStr addAttribute:NSForegroundColorAttributeName value:[UIColor jk_colorWithHexString:@"#97F0FC"] range:range2];

View File

@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="19206" systemVersion="20G95" minimumToolsVersion="Automatic" sourceLanguage="Objective-C" userDefinedModelVersionIdentifier="">
<entity name="Music" representedClassName="Music" syncable="YES">
<attribute name="author" optional="YES" attributeType="String"/>
<attribute name="filePath" optional="YES" attributeType="String"/>
<attribute name="musicArtists" optional="YES" attributeType="String"/>
<attribute name="musicId" optional="YES" attributeType="String"/>
<attribute name="musicName" optional="YES" attributeType="String"/>
<attribute name="songAlbum" optional="YES" attributeType="Binary"/>
<attribute name="songName" optional="YES" attributeType="String"/>
</entity>
<elements>
<element name="Music" positionX="-63" positionY="-18" width="128" height="134"/>
</elements>
</model>