2021-10-14 21:10:04 +08:00
|
|
|
|
//
|
|
|
|
|
// XPRoomMessageView.m
|
|
|
|
|
// xplan-ios
|
|
|
|
|
//
|
|
|
|
|
// Created by 冯硕 on 2021/10/11.
|
|
|
|
|
//
|
|
|
|
|
|
2021-10-18 19:10:13 +08:00
|
|
|
|
#import "XPRoomMessageContainerView.h"
|
2021-10-26 19:10:03 +08:00
|
|
|
|
///Third
|
|
|
|
|
#import <Masonry/Masonry.h>
|
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
2021-10-29 10:50:39 +08:00
|
|
|
|
#import <YYText/YYText.h>
|
2021-10-27 19:07:10 +08:00
|
|
|
|
///Tool
|
|
|
|
|
#import "ThemeColor.h"
|
2021-10-29 10:50:39 +08:00
|
|
|
|
#import "XPMacro.h"
|
|
|
|
|
#import "XPRoomMessageConstant.h"
|
2021-11-04 16:27:39 +08:00
|
|
|
|
#import "XPRoomMessageParser.h"
|
2021-12-27 17:10:36 +08:00
|
|
|
|
#import "AccountInfoStorage.h"
|
2022-03-04 18:31:19 +08:00
|
|
|
|
#import "XPRoomMiniManager.h"
|
2022-03-15 15:03:26 +08:00
|
|
|
|
#import "PLTimeUtil.h"
|
2022-03-16 21:33:02 +08:00
|
|
|
|
#import "ClientConfig.h"
|
2022-03-21 19:27:41 +08:00
|
|
|
|
#import <POP.h>
|
2022-03-30 20:26:16 +08:00
|
|
|
|
#import "ThemeColor+Room.h"
|
2021-10-26 19:10:03 +08:00
|
|
|
|
///Model
|
2021-10-29 10:50:39 +08:00
|
|
|
|
#import "RoomInfoModel.h"
|
2022-01-08 20:15:06 +08:00
|
|
|
|
#import "AttachmentModel.h"
|
2022-03-10 18:49:50 +08:00
|
|
|
|
#import "RoomFaceSendInfoModel.h"
|
2021-10-26 19:10:03 +08:00
|
|
|
|
///View
|
|
|
|
|
#import "XPRoomMessageTableViewCell.h"
|
|
|
|
|
#import "XPRoomMessageHeaderView.h"
|
|
|
|
|
#import "View/XPRoomMessageHeaderView.h"
|
2022-03-18 18:16:40 +08:00
|
|
|
|
#import "XPRoomTrumpetView.h"
|
2021-10-26 19:10:03 +08:00
|
|
|
|
|
2022-03-15 15:03:26 +08:00
|
|
|
|
NSString * const kRoomShowTopicKey = @"kRoomShowTopicKey";
|
2021-10-27 19:07:10 +08:00
|
|
|
|
|
2022-03-24 18:40:23 +08:00
|
|
|
|
@interface XPRoomMessageContainerView ()<UITableViewDelegate, UITableViewDataSource, XPRoomMessageTableViewCellDelegate>
|
2021-11-04 16:27:39 +08:00
|
|
|
|
///房间的代理
|
|
|
|
|
@property (nonatomic,weak) id<RoomHostDelegate> hostDelegate;
|
|
|
|
|
|
2021-10-26 19:10:03 +08:00
|
|
|
|
///列表
|
|
|
|
|
@property (nonatomic,strong) UITableView *messageTableView;
|
|
|
|
|
///头部
|
|
|
|
|
@property (nonatomic,strong) XPRoomMessageHeaderView *headerView;
|
2021-10-27 19:07:10 +08:00
|
|
|
|
///底部有新的消息
|
|
|
|
|
@property (nonatomic,strong) UIButton *messageTipsBtn;
|
|
|
|
|
///是否处于正在爬楼
|
|
|
|
|
@property (nonatomic,assign) BOOL isPending;
|
2022-03-04 18:31:19 +08:00
|
|
|
|
///是否是最小化进房的
|
|
|
|
|
@property (nonatomic,assign) BOOL isMiniEnter;
|
2021-11-04 16:27:39 +08:00
|
|
|
|
///数据源
|
|
|
|
|
@property (nonatomic,strong) NSMutableArray<NSAttributedString *> *datasource;
|
|
|
|
|
///临时存放消息的数组
|
|
|
|
|
@property (nonatomic,strong) NSMutableArray<NIMMessage *> *incomingMessages;
|
2022-03-21 15:52:33 +08:00
|
|
|
|
///气泡数组
|
|
|
|
|
@property (nonatomic, strong) NSMutableArray *messageBubbles;
|
2021-11-26 21:47:00 +08:00
|
|
|
|
///messageView 持有这个工具类 进行数据的分发操作 TODO: 有需要在改
|
|
|
|
|
@property (nonatomic,strong) XPRoomMessageParser *messageParser;
|
2022-03-18 18:16:40 +08:00
|
|
|
|
///小喇叭
|
|
|
|
|
@property (nonatomic, strong) XPRoomTrumpetView *trumpetView;
|
|
|
|
|
///小喇叭队列
|
|
|
|
|
@property (nonatomic, strong) NSMutableArray *trumpetQueue;
|
2022-03-21 19:27:41 +08:00
|
|
|
|
///小喇叭动画定时器
|
|
|
|
|
@property (nonatomic, strong) dispatch_source_t trumpetTimer;
|
2022-03-24 18:40:23 +08:00
|
|
|
|
///是否是大的 只有在小游戏的时候有用
|
|
|
|
|
@property (nonatomic,assign) BOOL isLarge;
|
2021-10-26 19:10:03 +08:00
|
|
|
|
@end
|
|
|
|
|
|
2021-10-14 21:10:04 +08:00
|
|
|
|
|
2021-10-18 19:10:13 +08:00
|
|
|
|
@implementation XPRoomMessageContainerView
|
2021-10-14 21:10:04 +08:00
|
|
|
|
|
2022-01-05 21:48:21 +08:00
|
|
|
|
- (void)dealloc {
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
2022-03-21 19:27:41 +08:00
|
|
|
|
if (self.trumpetTimer != nil) {
|
|
|
|
|
dispatch_source_cancel(self.trumpetTimer);
|
|
|
|
|
}
|
2022-01-05 21:48:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-29 10:50:39 +08:00
|
|
|
|
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
|
|
|
|
self = [super init];
|
2021-10-14 21:10:04 +08:00
|
|
|
|
if (self) {
|
2021-10-29 10:50:39 +08:00
|
|
|
|
self.hostDelegate = delegate;
|
2021-10-14 21:10:04 +08:00
|
|
|
|
[self initSubViews];
|
|
|
|
|
[self initSubViewConstraints];
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
#pragma mark - Response
|
2021-11-05 19:30:41 +08:00
|
|
|
|
- (void)messageTipsBtnAction:(UIButton *)sender {
|
|
|
|
|
self.isPending = NO;
|
2021-11-19 19:32:33 +08:00
|
|
|
|
self.messageTipsBtn.hidden = YES;
|
|
|
|
|
[self appendAndScrollToBottom];
|
2021-10-26 19:10:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-14 21:10:04 +08:00
|
|
|
|
#pragma mark - Private Method
|
|
|
|
|
- (void)initSubViews {
|
2022-01-05 21:48:21 +08:00
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCustomMessage:) name:@"message" object:nil];
|
2021-10-26 19:10:03 +08:00
|
|
|
|
[self addSubview:self.messageTableView];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
[self addSubview:self.messageTipsBtn];
|
2021-10-26 19:10:03 +08:00
|
|
|
|
self.messageTableView.tableHeaderView = self.headerView;
|
2022-03-18 18:16:40 +08:00
|
|
|
|
[self addSubview:self.trumpetView];
|
2021-10-14 21:10:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)initSubViewConstraints {
|
2021-10-26 19:10:03 +08:00
|
|
|
|
[self.messageTableView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.left.mas_equalTo(self).offset(15);
|
2022-03-31 16:09:54 +08:00
|
|
|
|
make.bottom.right.mas_equalTo(self);
|
|
|
|
|
make.top.mas_equalTo(self.trumpetView.mas_bottom);
|
2021-10-26 19:10:03 +08:00
|
|
|
|
}];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
|
|
|
|
|
[self.messageTipsBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.width.mas_equalTo(100);
|
|
|
|
|
make.height.mas_equalTo(30);
|
|
|
|
|
make.bottom.mas_equalTo(self.mas_bottom).offset(-5);
|
|
|
|
|
make.left.mas_equalTo(self);
|
|
|
|
|
}];
|
2022-03-18 18:16:40 +08:00
|
|
|
|
[self.trumpetView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self);
|
|
|
|
|
make.left.mas_equalTo(15);
|
|
|
|
|
make.right.mas_equalTo(0);
|
2022-03-31 16:09:54 +08:00
|
|
|
|
make.height.mas_equalTo(0);
|
2022-03-18 18:16:40 +08:00
|
|
|
|
}];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-29 10:50:39 +08:00
|
|
|
|
///是否是当前房间
|
|
|
|
|
- (BOOL)isCurrentRoom:(NSString *)sessionId {
|
|
|
|
|
if ([sessionId isEqualToString:[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]]) {
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
#pragma mark - 添加数据并且做自动滚动
|
|
|
|
|
///添加信息
|
|
|
|
|
- (void)addRoomMessage:(NIMMessage *)message {
|
2021-11-04 16:27:39 +08:00
|
|
|
|
[self.incomingMessages addObject:message];
|
2022-03-04 18:31:19 +08:00
|
|
|
|
if (!self.isMiniEnter) {/// 最小化进房的话 不需要重新保存
|
|
|
|
|
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
|
|
|
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.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:message];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
[[XPRoomMiniManager shareManager] saveRoomMessage:message];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-19 19:32:33 +08:00
|
|
|
|
if (self.isPending) {
|
2021-11-04 16:27:39 +08:00
|
|
|
|
self.messageTipsBtn.hidden = NO;
|
|
|
|
|
} else {
|
2021-11-19 19:32:33 +08:00
|
|
|
|
[self appendAndScrollToBottom];
|
2021-11-04 16:27:39 +08:00
|
|
|
|
}
|
2021-10-27 19:07:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///追加数据源
|
|
|
|
|
- (void)appendAndScrollToBottom {
|
2021-11-04 16:27:39 +08:00
|
|
|
|
if (self.incomingMessages.count < 1) {
|
2021-10-27 19:07:10 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-11-01 14:14:49 +08:00
|
|
|
|
|
|
|
|
|
if (self.datasource.count > kRoomMessageMaxLength) {
|
|
|
|
|
NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, kRoomMessageMaxLength/2)];
|
|
|
|
|
NSArray *needRemoveMsgArray = [self.datasource objectsAtIndexes:set];
|
|
|
|
|
[self.datasource removeObjectsInArray:needRemoveMsgArray];
|
2022-03-21 15:52:33 +08:00
|
|
|
|
[self.messageBubbles removeObjectsInArray:needRemoveMsgArray];
|
2021-11-01 14:14:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
// 执行插入
|
|
|
|
|
NSMutableArray *indexPaths = [NSMutableArray array];
|
2021-11-04 16:27:39 +08:00
|
|
|
|
for (NIMMessage *item in self.incomingMessages) {
|
2021-11-26 21:47:00 +08:00
|
|
|
|
[self.datasource addObject:[self.messageParser parseMessageAttribute:item]];
|
2022-03-21 15:52:33 +08:00
|
|
|
|
[self.messageBubbles addObject:[self.messageParser parseMessageBubble:item]];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
[indexPaths addObject:[NSIndexPath indexPathForRow:self.datasource.count - 1 inSection:0]];
|
|
|
|
|
}
|
2021-11-05 19:30:41 +08:00
|
|
|
|
[self.incomingMessages removeAllObjects];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
[self.messageTableView reloadData];
|
|
|
|
|
|
|
|
|
|
//执行插入动画并滚动
|
|
|
|
|
[self scrollToBottom:YES];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///执行插入动画并滚动
|
|
|
|
|
- (void)scrollToBottom:(BOOL)animated {
|
|
|
|
|
NSInteger s = [self.messageTableView numberOfSections]; //有多少组
|
|
|
|
|
if (s<1) return;
|
|
|
|
|
NSInteger r = [self.messageTableView numberOfRowsInSection:s-1]; //最后一组行
|
|
|
|
|
if (r<1) return;
|
|
|
|
|
NSIndexPath *ip = [NSIndexPath indexPathForRow:r-1 inSection:s-1]; //取最后一行数据
|
2021-11-05 19:30:41 +08:00
|
|
|
|
[self.messageTableView scrollToRowAtIndexPath:ip atScrollPosition:UITableViewScrollPositionBottom animated:animated]; //滚动到最后一行
|
2021-10-27 19:07:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-11-17 22:20:47 +08:00
|
|
|
|
///自定义消息 是否可以加到 公屏 需要自己维护
|
|
|
|
|
- (BOOL)isCanDisplayMessage:(NIMMessage *)message {
|
|
|
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
|
|
|
|
|
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
|
|
|
|
|
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
|
2022-03-10 18:49:50 +08:00
|
|
|
|
if (attachment.first == CustomMessageType_Face && attachment.second == Custom_Message_Sub_Face_Send) {
|
|
|
|
|
if ([attachment.data[@"data"] isKindOfClass:[NSArray class]]) {
|
|
|
|
|
NSArray * array = [RoomFaceSendInfoModel modelsWithArray:attachment.data[@"data"]];
|
|
|
|
|
for (int i = 0; i< array.count; i++) {
|
|
|
|
|
RoomFaceSendInfoModel * sendInfo = [array objectAtIndex:i];
|
|
|
|
|
if (sendInfo.resultIndexes.count <=0) {
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-17 22:20:47 +08:00
|
|
|
|
return [[[self supportMessageDic] objectForKey:@(attachment.first)] containsObject:@(attachment.second)];
|
|
|
|
|
}
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSDictionary *)supportMessageDic {
|
|
|
|
|
return @{
|
2021-12-06 17:00:15 +08:00
|
|
|
|
@(CustomMessageType_AllMicroSend):
|
2021-11-17 22:20:47 +08:00
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_AllMicroSend),
|
|
|
|
|
@(Custom_Message_Sub_AllMicroLuckySend),
|
|
|
|
|
@(Custom_Message_Sub_AllBatchSend),
|
|
|
|
|
@(Custom_Message_Sub_AllBatchMicroLuckySend),
|
|
|
|
|
nil],
|
|
|
|
|
@(CustomMessageType_Gift):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Gift_Send),
|
|
|
|
|
@(Custom_Message_Sub_Gift_LuckySend),
|
|
|
|
|
nil],
|
2021-11-24 14:58:53 +08:00
|
|
|
|
@(CustomMessageType_Room_Tip):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Room_Tip_ShareRoom),
|
|
|
|
|
@(Custom_Message_Sub_Room_Tip_Attention_Owner),
|
|
|
|
|
nil],
|
2021-11-26 17:31:12 +08:00
|
|
|
|
@(CustomMessageType_Kick_User):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Kick_BeKicked),
|
|
|
|
|
@(Custom_Message_Sub_Kick_BlackList),
|
|
|
|
|
nil],
|
2021-11-26 21:47:00 +08:00
|
|
|
|
@(CustomMessageType_Queue):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Queue_Kick),
|
|
|
|
|
nil],
|
2021-12-10 21:20:34 +08:00
|
|
|
|
@(CustomMessageType_Candy_Tree):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Candy_Tree_Me),
|
|
|
|
|
@(Custom_Message_Sub_Candy_Tree_InRoom),
|
|
|
|
|
@(Custom_Message_Sub_Candy_Tree_AllRoom),
|
|
|
|
|
@(Custom_Message_Sub_Candy_Tree_AllRoom_Notify),
|
|
|
|
|
@(Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend),
|
|
|
|
|
nil],
|
2021-12-20 21:17:12 +08:00
|
|
|
|
@(CustomMessageType_Arrange_Mic):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Arrange_Mic_Mode_Open),
|
|
|
|
|
@(Custom_Message_Sub_Arrange_Mic_Mode_Close),
|
|
|
|
|
@(Custom_Message_Sub_Arrange_Mic_Free_Mic_Open),
|
|
|
|
|
@(Custom_Message_Sub_Arrange_Mic_Free_Mic_Close),
|
|
|
|
|
nil],
|
2021-12-25 16:57:50 +08:00
|
|
|
|
@(CustomMessageType_Update_RoomInfo):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Update_RoomInfo_MessageState),
|
2021-12-27 17:10:36 +08:00
|
|
|
|
@(Custom_Message_Sub_Update_RoomInfo_AnimateEffect),
|
2021-12-25 16:57:50 +08:00
|
|
|
|
nil],
|
2021-12-27 16:40:14 +08:00
|
|
|
|
@(CustomMessageType_Collection_Room):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Collect_Room_Tips),
|
|
|
|
|
nil],
|
2022-01-05 21:48:21 +08:00
|
|
|
|
@(CustomMessageType_RoomPlay_Dating):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Room_Play_Dating_Pick_Heart),
|
|
|
|
|
@(Custom_Message_Sub_Room_Play_Dating_Result_Mutual),
|
|
|
|
|
@(Custom_Message_Sub_Room_Play_Dating_Result_Not_Mutual),
|
|
|
|
|
nil],
|
2022-01-10 19:59:58 +08:00
|
|
|
|
@(CustomMessageType_Noble_VIP):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Room_Open_Noble_VIP),
|
|
|
|
|
@(Custom_Message_Sub_Room_Noble_LevelUp),
|
|
|
|
|
@(Custom_Message_Sub_AllRoom_Noble_LevelUp_Suspend),
|
|
|
|
|
nil],
|
2022-03-10 18:49:50 +08:00
|
|
|
|
@(CustomMessageType_Face):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_Face_Send),
|
|
|
|
|
nil],
|
2022-04-08 15:42:25 +08:00
|
|
|
|
@(CustomMessageType_Anchor_FansTeam):
|
|
|
|
|
[NSSet setWithObjects:
|
|
|
|
|
@(Custom_Message_Sub_FansTeam_Open_Success),
|
|
|
|
|
@(Custom_Message_Sub_FansTeam_Open_Fail),
|
|
|
|
|
@(Custom_Message_Sub_FansTeam_Join_Success),
|
|
|
|
|
@(Custom_Message_Sub_FansTeam_Out_Success),
|
|
|
|
|
nil],
|
2021-11-17 22:20:47 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-05 21:48:21 +08:00
|
|
|
|
- (void)addCustomMessage:(NSNotification *)notification {
|
2022-03-04 18:31:19 +08:00
|
|
|
|
self.isMiniEnter = NO;
|
2022-01-05 21:48:21 +08:00
|
|
|
|
if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;}
|
|
|
|
|
NIMMessage * message = notification.object;
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-15 15:03:26 +08:00
|
|
|
|
///用户进入房间显示 房间话题
|
|
|
|
|
- (void)createUserEnterRoomAddRoomtopicMessage {
|
2022-03-16 21:33:02 +08:00
|
|
|
|
if ([ClientConfig shareConfig].configInfo.appStoreAuditNoticeVersion == YES) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-03-15 15:03:26 +08:00
|
|
|
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
|
|
|
|
if (roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) {return;}
|
|
|
|
|
NSString * key = [NSString stringWithFormat:@"%@_%@_%ld", kRoomShowTopicKey, [AccountInfoStorage instance].getUid, roomInfo.uid];
|
|
|
|
|
NSDate * oldDate = [[NSUserDefaults standardUserDefaults] valueForKey:key];
|
|
|
|
|
NSDate * date = [NSDate date];
|
2022-03-15 18:38:36 +08:00
|
|
|
|
if (roomInfo.introduction.length > 0) {
|
2022-03-15 15:03:26 +08:00
|
|
|
|
if (oldDate) {
|
|
|
|
|
NSDateComponents *compons = [PLTimeUtil compareTwoDate:date secondDate:[NSDate date]];
|
|
|
|
|
if (ABS(compons.year) > 0 || ABS(compons.month) > 0 || ABS(compons.day) > 0) {
|
|
|
|
|
NIMMessage * message = [[NIMMessage alloc] init];
|
|
|
|
|
NSString * content = [NSString stringWithFormat:@"[房间公告] \n %@", roomInfo.introduction];
|
|
|
|
|
message.text = content;
|
|
|
|
|
message.localExt = @{@"isRoomTopic": @(NO)};
|
|
|
|
|
[message setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
|
|
|
|
|
[message setValue:[NIMSession session:[NSString stringWithFormat:@"%ld", roomInfo.roomId] type:NIMSessionTypeChatroom] forKey:@"session"];
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setValue:@(YES) forKey:key];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
NIMMessage * message = [[NIMMessage alloc] init];
|
|
|
|
|
NSString * content = [NSString stringWithFormat:@"[房间公告] \n %@", roomInfo.introduction];
|
|
|
|
|
message.text = content;
|
|
|
|
|
message.localExt = @{@"isRoomTopic": @(NO)};
|
|
|
|
|
[message setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
|
|
|
|
|
[message setValue:[NIMSession session:[NSString stringWithFormat:@"%ld", roomInfo.roomId] type:NIMSessionTypeChatroom] forKey:@"session"];
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setValue:@(YES) forKey:key];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NIMMessage * message = [[NIMMessage alloc] init];
|
|
|
|
|
message.text = @"可点击查看本房间公告";
|
|
|
|
|
message.localExt = @{@"isRoomTopic": @(YES)};
|
|
|
|
|
[message setValue:@(NIMMessageTypeTip) forKey:@"messageType"];
|
|
|
|
|
[message setValue:[NIMSession session:[NSString stringWithFormat:@"%ld", roomInfo.roomId] type:NIMSessionTypeChatroom] forKey:@"session"];
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-25 16:57:50 +08:00
|
|
|
|
#pragma mark - RoomGuestDelegate
|
|
|
|
|
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
2022-03-04 18:31:19 +08:00
|
|
|
|
self.isMiniEnter = NO;
|
2021-12-25 16:57:50 +08:00
|
|
|
|
NIMCustomObject *obj = (NIMCustomObject *)message.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) {
|
|
|
|
|
[self.datasource removeAllObjects];
|
|
|
|
|
[self.incomingMessages removeAllObjects];
|
2022-03-21 15:52:33 +08:00
|
|
|
|
[self.messageBubbles removeAllObjects];
|
2022-03-04 18:31:19 +08:00
|
|
|
|
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
2021-12-25 16:57:50 +08:00
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
return;
|
2022-03-18 18:16:40 +08:00
|
|
|
|
} else if (attachment.first == CustomMessageType_Noble_VIP && attachment.second == Custom_Message_Sub_Room_Trumpet) {
|
2022-03-21 19:27:41 +08:00
|
|
|
|
if (self.trumpetQueue.count) {
|
|
|
|
|
[self.trumpetQueue addObject:attachment.data];
|
|
|
|
|
} else {
|
|
|
|
|
[self.trumpetQueue addObject:attachment.data];
|
|
|
|
|
__block NSInteger time = 5.0; //倒计时时间
|
|
|
|
|
if (_trumpetTimer != nil) {
|
|
|
|
|
dispatch_source_cancel(_trumpetTimer);
|
|
|
|
|
}
|
|
|
|
|
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
|
|
|
|
_trumpetTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
|
|
|
|
|
dispatch_source_set_timer(_trumpetTimer,dispatch_walltime(NULL, 0),time*NSEC_PER_SEC, 0); //每秒执行
|
|
|
|
|
dispatch_source_set_event_handler(_trumpetTimer, ^{
|
|
|
|
|
if (self.trumpetQueue.count) {
|
|
|
|
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
|
|
[self createTrumpetAnimation:self.trumpetQueue.firstObject];
|
|
|
|
|
[self.trumpetQueue removeObjectAtIndex:0];
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
dispatch_sync(dispatch_get_main_queue(), ^{
|
|
|
|
|
self.trumpetView.hidden = YES;
|
2022-03-31 16:09:54 +08:00
|
|
|
|
[self.trumpetView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.height.mas_equalTo(0);
|
|
|
|
|
}];
|
|
|
|
|
[self.messageTableView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.trumpetView.mas_bottom);
|
|
|
|
|
}];
|
2022-03-21 19:27:41 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (self->_trumpetTimer != nil) {
|
|
|
|
|
dispatch_source_cancel(self->_trumpetTimer);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
dispatch_resume(_trumpetTimer);
|
2022-03-18 18:16:40 +08:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-12-25 16:57:50 +08:00
|
|
|
|
}
|
|
|
|
|
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ([self isCanDisplayMessage:message]) {
|
|
|
|
|
[self addRoomMessage:message];
|
2021-10-29 15:53:44 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-29 10:50:39 +08:00
|
|
|
|
|
2021-12-25 16:57:50 +08:00
|
|
|
|
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
|
2022-03-04 18:31:19 +08:00
|
|
|
|
self.isMiniEnter = NO;
|
2021-12-25 16:57:50 +08:00
|
|
|
|
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
|
|
|
|
|
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
|
2022-01-05 21:48:21 +08:00
|
|
|
|
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
|
2021-12-25 16:57:50 +08:00
|
|
|
|
if (content.eventType == NIMChatroomEventTypeEnter) {
|
2022-01-05 21:48:21 +08:00
|
|
|
|
if (roomInfo.isCloseScreen) {
|
2021-12-25 16:57:50 +08:00
|
|
|
|
AttachmentModel *attachement = [[AttachmentModel alloc]init];
|
|
|
|
|
attachement.first = CustomMessageType_Update_RoomInfo;
|
|
|
|
|
attachement.second = Custom_Message_Sub_Update_RoomInfo_MessageState;
|
|
|
|
|
attachement.data = @{@"roomInfo":self.hostDelegate.getRoomInfo.model2dictionary};
|
|
|
|
|
NIMMessage *message = [[NIMMessage alloc]init];
|
|
|
|
|
NIMCustomObject *object = [[NIMCustomObject alloc] init];
|
|
|
|
|
object.attachment = attachement;
|
|
|
|
|
message.messageObject = object;
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
2021-10-29 15:53:44 +08:00
|
|
|
|
[self addRoomMessage:message];
|
2021-12-27 17:10:36 +08:00
|
|
|
|
NIMChatroomNotificationMember *member = content.targets[0];
|
|
|
|
|
if (member.userId.integerValue == [AccountInfoStorage instance].getUid.integerValue) {
|
2022-01-05 21:48:21 +08:00
|
|
|
|
if (!roomInfo.hasAnimationEffect) {
|
2021-12-27 17:10:36 +08:00
|
|
|
|
[self roomInfoNoGiftAnimationMessage:message];
|
|
|
|
|
}
|
2022-03-15 16:05:47 +08:00
|
|
|
|
[self createUserEnterRoomAddRoomtopicMessage];
|
2021-12-27 17:10:36 +08:00
|
|
|
|
}
|
2021-10-29 10:50:39 +08:00
|
|
|
|
}
|
2022-01-05 21:48:21 +08:00
|
|
|
|
} else if(content.eventType == NIMChatroomEventTypeInfoUpdated) {
|
|
|
|
|
if (roomInfo.isCloseScreen) {return;}
|
2022-01-17 18:57:34 +08:00
|
|
|
|
if (roomInfo.datingState == RoomDatingStateChangeType_Open) {
|
2022-01-05 21:48:21 +08:00
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
}
|
2021-12-25 16:57:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-29 15:53:44 +08:00
|
|
|
|
|
2021-12-25 16:57:50 +08:00
|
|
|
|
- (void)handleNIMTextMessage:(NIMMessage *)message {
|
2022-03-04 18:31:19 +08:00
|
|
|
|
self.isMiniEnter = NO;
|
2022-01-05 21:48:21 +08:00
|
|
|
|
if (self.hostDelegate.getRoomInfo.isCloseScreen) {return;}
|
2021-12-25 16:57:50 +08:00
|
|
|
|
[self addRoomMessage:message];
|
2021-10-29 10:50:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-12-27 17:10:36 +08:00
|
|
|
|
- (void)roomInfoNoGiftAnimationMessage:(NIMMessage *)message {
|
2022-03-04 18:31:19 +08:00
|
|
|
|
self.isMiniEnter = NO;
|
2021-12-27 17:10:36 +08:00
|
|
|
|
AttachmentModel *attachement = [[AttachmentModel alloc]init];
|
|
|
|
|
attachement.first = CustomMessageType_Update_RoomInfo;
|
|
|
|
|
attachement.second = Custom_Message_Sub_Update_RoomInfo_AnimateEffect;
|
|
|
|
|
NIMMessage *tempMessage = [[NIMMessage alloc]init];
|
|
|
|
|
NIMCustomObject *customObject = [[NIMCustomObject alloc]init];
|
|
|
|
|
customObject.attachment = attachement;
|
|
|
|
|
tempMessage.messageObject = customObject;
|
|
|
|
|
[self addRoomMessage:tempMessage];
|
|
|
|
|
}
|
2022-03-04 18:31:19 +08:00
|
|
|
|
|
|
|
|
|
- (void)onRoomMiniEntered {
|
|
|
|
|
self.isMiniEnter = YES;
|
|
|
|
|
NSArray * temArray = [XPRoomMiniManager shareManager].getLocalCurrentRoomMessage;
|
|
|
|
|
for (int i = 0; i< temArray.count; i++) {
|
|
|
|
|
NIMMessage * message = [temArray objectAtIndex:i];
|
|
|
|
|
[self addRoomMessage:message];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)onRoomEntered {
|
|
|
|
|
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
2022-03-30 20:26:16 +08:00
|
|
|
|
self.headerView.bubbleColor = self.hostDelegate.getRoomInfo.type == RoomType_MiniGame ? [UIColor colorWithWhite:1 alpha:0.2] : [ThemeColor messageBubbleColor];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)onRoomUpdate {
|
|
|
|
|
///改变公屏的背景样式
|
|
|
|
|
if (self.hostDelegate.getRoomInfo.hadChangeRoomType) {
|
|
|
|
|
self.headerView.bubbleColor = self.hostDelegate.getRoomInfo.type == RoomType_MiniGame ? [UIColor colorWithWhite:1 alpha:0.2] : [ThemeColor messageBubbleColor];
|
|
|
|
|
[self.messageTableView reloadData];
|
|
|
|
|
}
|
2022-03-04 18:31:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
#pragma mark - ScrollViewDelegate
|
|
|
|
|
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
|
|
|
|
|
// 手动拖拽开始
|
|
|
|
|
self.isPending = YES;
|
|
|
|
|
}
|
|
|
|
|
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
|
|
|
|
|
// 手动拖拽结束(decelerate:0松手时静止;1松手时还在运动,会触发DidEndDecelerating方法)
|
|
|
|
|
if (!decelerate) {
|
|
|
|
|
[self finishDraggingWith:scrollView];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
|
|
|
|
|
// 静止后触发(手动)
|
|
|
|
|
[self finishDraggingWith:scrollView];
|
|
|
|
|
}
|
2021-11-05 19:30:41 +08:00
|
|
|
|
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
|
|
|
|
|
if (!self.isPending && self.incomingMessages.count <= 0) {
|
|
|
|
|
[self scrollToBottom:YES];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-27 19:07:10 +08:00
|
|
|
|
|
2021-11-19 19:32:33 +08:00
|
|
|
|
/**
|
|
|
|
|
手动拖拽动作彻底完成(减速到零)
|
|
|
|
|
*/
|
2021-10-27 19:07:10 +08:00
|
|
|
|
- (void)finishDraggingWith:(UIScrollView *)scrollView {
|
|
|
|
|
CGFloat contentSizeH = scrollView.contentSize.height;
|
|
|
|
|
CGFloat contentOffsetY = scrollView.contentOffset.y;
|
|
|
|
|
CGFloat sizeH = scrollView.frame.size.height;
|
|
|
|
|
self.isPending = contentSizeH - contentOffsetY - sizeH > 20.0;
|
2021-11-19 19:32:33 +08:00
|
|
|
|
if (!self.isPending) {
|
|
|
|
|
self.messageTipsBtn.hidden = YES;
|
|
|
|
|
if (self.incomingMessages.count > 0) {
|
|
|
|
|
[self appendAndScrollToBottom];
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-26 19:10:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
|
2021-10-26 19:10:03 +08:00
|
|
|
|
#pragma mark - UITableViewDelegate And UITableViewDataSource
|
|
|
|
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
|
|
|
|
return self.datasource.count;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
|
2021-11-04 16:27:39 +08:00
|
|
|
|
NSAttributedString* attr = [self.datasource objectAtIndex:indexPath.row];
|
2022-03-31 20:05:57 +08:00
|
|
|
|
CGSize maxSize = CGSizeMake(kRoomMessageMaxWidth - 24, MAXFLOAT);
|
2022-03-15 15:03:26 +08:00
|
|
|
|
YYTextContainer *container = [YYTextContainer containerWithSize:maxSize];
|
|
|
|
|
container.maximumNumberOfRows = 0;
|
|
|
|
|
YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:attr];
|
2021-11-04 16:27:39 +08:00
|
|
|
|
return layout.textBoundingSize.height + kRoomMessageTextSpaceHeight * 2 + 10;
|
2021-10-26 19:10:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
|
|
XPRoomMessageTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
|
|
|
|
if (cell == nil) {
|
|
|
|
|
cell = [[XPRoomMessageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
|
|
|
|
}
|
2022-03-24 18:40:23 +08:00
|
|
|
|
cell.delegate = self;
|
2021-11-04 16:27:39 +08:00
|
|
|
|
NSAttributedString* attr = [self.datasource objectAtIndex:indexPath.row];
|
2022-03-21 15:52:33 +08:00
|
|
|
|
NSString *bubbleStr = [self.messageBubbles objectAtIndex:indexPath.row];
|
|
|
|
|
cell.bubbleImageUrl = bubbleStr;
|
2022-03-30 20:26:16 +08:00
|
|
|
|
cell.roomType = self.hostDelegate.getRoomInfo.type;
|
2021-11-04 16:27:39 +08:00
|
|
|
|
cell.attributedString = attr;
|
2021-10-26 19:10:03 +08:00
|
|
|
|
return cell;
|
|
|
|
|
}
|
2022-03-21 19:27:41 +08:00
|
|
|
|
|
2022-03-24 18:40:23 +08:00
|
|
|
|
|
2022-03-21 19:27:41 +08:00
|
|
|
|
- (void)createTrumpetAnimation:(NSDictionary *)attatchment {
|
|
|
|
|
self.trumpetView.data = attatchment;
|
|
|
|
|
self.trumpetView.hidden = NO;
|
2022-03-31 16:09:54 +08:00
|
|
|
|
[self.trumpetView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.height.mas_equalTo(32);
|
|
|
|
|
}];
|
|
|
|
|
[self.messageTableView mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.top.mas_equalTo(self.trumpetView.mas_bottom).mas_offset(4);
|
|
|
|
|
}];
|
2022-03-21 19:27:41 +08:00
|
|
|
|
POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame];
|
|
|
|
|
animation2.beginTime = CACurrentMediaTime();
|
|
|
|
|
animation2.duration = 0.1;
|
|
|
|
|
CGFloat width = self.frame.size.width - 15;
|
|
|
|
|
CGFloat height = 32;
|
|
|
|
|
animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, 0, width, height)];
|
|
|
|
|
animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, -height/2, width, height)];
|
|
|
|
|
animation2.removedOnCompletion = NO;
|
|
|
|
|
animation2.repeatCount = 1;
|
|
|
|
|
|
|
|
|
|
POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity];
|
|
|
|
|
animation3.duration = 0.1;
|
|
|
|
|
animation3.beginTime = CACurrentMediaTime();
|
|
|
|
|
animation3.fromValue = @1;
|
|
|
|
|
animation3.toValue = @0;
|
|
|
|
|
animation3.repeatCount = 1;
|
|
|
|
|
animation3.removedOnCompletion = NO;
|
|
|
|
|
|
|
|
|
|
[animation2 setCompletionBlock:^(POPAnimation *anim, BOOL finished) {
|
|
|
|
|
if (finished) {
|
|
|
|
|
POPBasicAnimation *animation2 = [POPBasicAnimation animationWithPropertyNamed:kPOPViewFrame];
|
|
|
|
|
animation2.beginTime = CACurrentMediaTime();
|
|
|
|
|
animation2.duration = 0.1;
|
|
|
|
|
CGFloat width = self.frame.size.width - 15;
|
|
|
|
|
CGFloat height = 32;
|
|
|
|
|
animation2.fromValue = [NSValue valueWithCGRect:CGRectMake(0, height/2, width, height)];
|
|
|
|
|
animation2.toValue = [NSValue valueWithCGRect:CGRectMake(0, 0, width, height)];
|
|
|
|
|
animation2.removedOnCompletion = NO;
|
|
|
|
|
animation2.repeatCount = 1;
|
|
|
|
|
|
|
|
|
|
POPBasicAnimation *animation3 = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerOpacity];
|
|
|
|
|
animation3.duration = 0.1;
|
|
|
|
|
animation3.beginTime = CACurrentMediaTime();
|
|
|
|
|
animation3.fromValue = @0;
|
|
|
|
|
animation3.toValue = @1;
|
|
|
|
|
animation3.repeatCount = 1;
|
|
|
|
|
animation3.removedOnCompletion = NO;
|
|
|
|
|
[self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation4"];
|
|
|
|
|
[self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation5"];
|
|
|
|
|
}
|
|
|
|
|
}];
|
|
|
|
|
[self.trumpetView.mainView.layer pop_addAnimation:animation2 forKey:@"animation2"];
|
|
|
|
|
[self.trumpetView.mainView.layer pop_addAnimation:animation3 forKey:@"animation3"];
|
|
|
|
|
}
|
2022-03-24 18:40:23 +08:00
|
|
|
|
#pragma mark - XPRoomMessageTableViewCellDelegate
|
|
|
|
|
- (void)xPRoomMessageTableViewCellDidTapEmpty:(XPRoomMessageTableViewCell *)view {
|
|
|
|
|
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
|
|
|
|
|
self.isLarge = !self.isLarge;
|
|
|
|
|
CGFloat height = self.isLarge ? 200 : 80;
|
|
|
|
|
[self mas_updateConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
make.height.mas_equalTo(height);
|
|
|
|
|
}];
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-21 19:27:41 +08:00
|
|
|
|
|
2021-10-26 19:10:03 +08:00
|
|
|
|
#pragma mark - Getters And Setters
|
|
|
|
|
- (UITableView *)messageTableView {
|
|
|
|
|
if (!_messageTableView) {
|
|
|
|
|
_messageTableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
|
|
|
|
_messageTableView.delegate = self;
|
|
|
|
|
_messageTableView.dataSource = self;
|
|
|
|
|
_messageTableView.tableFooterView = [UIView new];
|
|
|
|
|
_messageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
|
|
|
|
|
_messageTableView.backgroundColor = [UIColor clearColor];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
_messageTableView.showsVerticalScrollIndicator = NO;
|
2021-10-26 19:10:03 +08:00
|
|
|
|
if (@available(iOS 11.0, *)) {
|
|
|
|
|
_messageTableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
|
|
|
|
|
}
|
|
|
|
|
[_messageTableView registerClass:[XPRoomMessageTableViewCell class] forCellReuseIdentifier:NSStringFromClass([XPRoomMessageTableViewCell class])];
|
|
|
|
|
}
|
|
|
|
|
return _messageTableView;
|
2021-10-14 21:10:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-26 19:10:03 +08:00
|
|
|
|
- (XPRoomMessageHeaderView *)headerView {
|
|
|
|
|
if (!_headerView) {
|
|
|
|
|
_headerView = [[XPRoomMessageHeaderView alloc] init];
|
|
|
|
|
}
|
|
|
|
|
return _headerView;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-27 19:07:10 +08:00
|
|
|
|
- (UIButton *)messageTipsBtn {
|
|
|
|
|
if (!_messageTipsBtn) {
|
|
|
|
|
_messageTipsBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
[_messageTipsBtn setTitle:@"底部有新消息" forState:UIControlStateNormal];
|
|
|
|
|
[_messageTipsBtn setTitleColor:[ThemeColor appMainColor] forState:UIControlStateNormal];
|
|
|
|
|
_messageTipsBtn.layer.cornerRadius = 15.0;
|
|
|
|
|
_messageTipsBtn.layer.masksToBounds = YES;
|
|
|
|
|
_messageTipsBtn.titleLabel.font = [UIFont systemFontOfSize:12.0];
|
|
|
|
|
_messageTipsBtn.backgroundColor = [UIColor whiteColor];
|
2021-11-05 19:30:41 +08:00
|
|
|
|
[_messageTipsBtn addTarget:self action:@selector(messageTipsBtnAction:) forControlEvents:UIControlEventTouchUpInside];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
_messageTipsBtn.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _messageTipsBtn;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 16:27:39 +08:00
|
|
|
|
- (NSMutableArray<NSAttributedString *> *)datasource {
|
2021-10-27 19:07:10 +08:00
|
|
|
|
if (!_datasource) {
|
|
|
|
|
_datasource = [NSMutableArray array];
|
|
|
|
|
}
|
|
|
|
|
return _datasource;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-04 16:27:39 +08:00
|
|
|
|
- (NSMutableArray<NIMMessage *> *)incomingMessages {
|
|
|
|
|
if (!_incomingMessages) {
|
|
|
|
|
_incomingMessages = [NSMutableArray array];
|
2021-10-27 19:07:10 +08:00
|
|
|
|
}
|
2021-11-04 16:27:39 +08:00
|
|
|
|
return _incomingMessages;
|
2021-10-27 19:07:10 +08:00
|
|
|
|
}
|
2021-10-26 19:10:03 +08:00
|
|
|
|
|
2022-03-21 15:52:33 +08:00
|
|
|
|
- (NSMutableArray *)messageBubbles {
|
|
|
|
|
if (!_messageBubbles) {
|
|
|
|
|
_messageBubbles = [NSMutableArray array];
|
|
|
|
|
}
|
|
|
|
|
return _messageBubbles;
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-26 21:47:00 +08:00
|
|
|
|
- (XPRoomMessageParser *)messageParser {
|
|
|
|
|
if (!_messageParser) {
|
|
|
|
|
_messageParser = [[XPRoomMessageParser alloc] init];
|
|
|
|
|
_messageParser.hostDelegate = self.hostDelegate;
|
|
|
|
|
}
|
|
|
|
|
return _messageParser;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-18 18:16:40 +08:00
|
|
|
|
- (XPRoomTrumpetView *)trumpetView {
|
|
|
|
|
if (!_trumpetView) {
|
|
|
|
|
_trumpetView = [[XPRoomTrumpetView alloc] init];
|
|
|
|
|
_trumpetView.hidden = YES;
|
|
|
|
|
}
|
|
|
|
|
return _trumpetView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSMutableArray *)trumpetQueue {
|
|
|
|
|
if (!_trumpetQueue) {
|
|
|
|
|
_trumpetQueue = [NSMutableArray array];
|
|
|
|
|
}
|
|
|
|
|
return _trumpetQueue;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-14 21:10:04 +08:00
|
|
|
|
@end
|