2024-05-11 10:21:48 +08:00
|
|
|
//
|
|
|
|
// MsRoomMessageMainView.m
|
|
|
|
// YuMi
|
|
|
|
//
|
|
|
|
// Created by duoban on 2024/5/10.
|
|
|
|
//
|
|
|
|
#import <JXCategoryView/JXCategoryView.h>
|
|
|
|
#import <JXCategoryView/JXCategoryIndicatorBackgroundView.h>
|
|
|
|
#import <JXCategoryView/JXCategoryListContainerView.h>
|
|
|
|
#import "MsRoomMessageMainView.h"
|
|
|
|
#import "XPRoomMessageContainerView.h"
|
|
|
|
#import "MsRoomMessagChatHallView.h"
|
|
|
|
#import "ClientConfig.h"
|
|
|
|
#import "UserInfoModel.h"
|
|
|
|
#import <NIMSDK/NIMSDK.h>
|
2024-06-04 10:43:58 +08:00
|
|
|
#import "Api+Message.h"
|
|
|
|
#import "MSSessionPublicChatHallTopModel.h"
|
2024-06-04 11:30:58 +08:00
|
|
|
#import "AttachmentModel.h"
|
2024-05-11 10:21:48 +08:00
|
|
|
@interface MsRoomMessageMainView()<JXCategoryViewDelegate, JXCategoryListContainerViewDelegate>
|
|
|
|
///分页标题
|
|
|
|
@property (nonatomic, strong) NSArray<NSString *> *titles;
|
|
|
|
///分页控件
|
|
|
|
@property (nonatomic, strong) JXCategoryTitleView *titleView;
|
|
|
|
///分页lineView
|
|
|
|
@property (nonatomic, strong) JXCategoryListContainerView *pi_containerView;
|
|
|
|
@property(nonatomic,strong) XPRoomMessageContainerView *roomView;
|
|
|
|
@property(nonatomic,strong) MsRoomMessagChatHallView *chatHallView;
|
|
|
|
///房间的代理
|
|
|
|
@property (nonatomic,weak) id<RoomHostDelegate> hostDelegate;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation MsRoomMessageMainView
|
|
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
|
|
|
|
self = [super init];
|
|
|
|
if (self) {
|
|
|
|
self.hostDelegate = delegate;
|
|
|
|
[self installUI];
|
|
|
|
[self installConstraints];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
-(void)installUI{
|
|
|
|
[self addSubview:self.titleView];
|
|
|
|
[self addSubview:self.pi_containerView];
|
2024-06-04 10:43:58 +08:00
|
|
|
[Api getPublicChatHallTopText:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
|
|
|
if(code == 200){
|
|
|
|
MSSessionPublicChatHallTopModel *model = [MSSessionPublicChatHallTopModel modelWithDictionary:data.data];
|
|
|
|
self.chatHallView.topModel = model;
|
|
|
|
self.roomView.topModel = model;
|
|
|
|
|
|
|
|
}
|
|
|
|
}];
|
2024-05-11 10:21:48 +08:00
|
|
|
}
|
|
|
|
-(void)installConstraints{
|
|
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.leading.mas_equalTo(kGetScaleWidth(0));
|
2024-05-23 18:08:07 +08:00
|
|
|
make.width.mas_equalTo(150);
|
2024-05-11 10:21:48 +08:00
|
|
|
make.height.mas_equalTo(kGetScaleWidth(30));
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
[self.pi_containerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.leading.trailing.bottom.mas_equalTo(self);
|
|
|
|
make.top.mas_equalTo(self.titleView.mas_bottom).offset(8);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
- (void)showUserCard:(NSInteger)uid{
|
|
|
|
[self.roomView showUserCard:uid];
|
|
|
|
}
|
|
|
|
#pragma mark - JXCategoryViewDelegate
|
|
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView {
|
|
|
|
return self.titles.count;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index {
|
|
|
|
if (index == 0) {
|
|
|
|
return self.roomView;
|
|
|
|
} else {
|
|
|
|
return self.chatHallView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - RoomGuestDelegate
|
|
|
|
- (void)handleNIMCustomMessage:(NIMMessage *)message {
|
2024-06-04 11:30:58 +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_Chat_Hall_Headlinesn && attachment.second == Custom_Message_Sub_Chat_Hall_Headlinesn){
|
|
|
|
MSSessionPublicChatHallTopModel *topModel = [MSSessionPublicChatHallTopModel modelWithDictionary:attachment.data];
|
|
|
|
if(topModel.recordStatus == 1){
|
|
|
|
self.chatHallView.topModel = nil;
|
|
|
|
self.roomView.topModel = nil;
|
|
|
|
|
|
|
|
}else{
|
|
|
|
self.chatHallView.topModel = topModel;
|
|
|
|
self.roomView.topModel = topModel;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-11 10:21:48 +08:00
|
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
|
|
[self.roomView handleNIMCustomMessage:message];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[self.chatHallView handleNIMCustomMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
|
2024-06-04 11:30:58 +08:00
|
|
|
|
|
|
|
|
2024-05-11 10:21:48 +08:00
|
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
|
|
[self.roomView handleNIMNotificationMessage:message];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self.chatHallView handleNIMNotificationMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- (void)handleNIMTextMessage:(NIMMessage *)message {
|
|
|
|
UserInfoModel *infoModel = self.hostDelegate.getUserInfo;
|
|
|
|
NSString *publicChatRoomId = [NSString stringWithFormat:@"%@",[ClientConfig shareConfig].configInfo.publicChatRoomIdMap[infoModel.partitionId]];
|
|
|
|
if(![message.session.sessionId isEqualToString:publicChatRoomId]){
|
|
|
|
[self.roomView handleNIMTextMessage:message];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
[self.chatHallView handleNIMTextMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)handleNIMImageMessage:(NIMMessage *)message {
|
|
|
|
[self.chatHallView handleNIMImageMessage:message];
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void)onRoomMiniEntered {
|
|
|
|
[self.roomView onRoomMiniEntered];
|
|
|
|
[self.chatHallView onRoomMiniEntered];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)onRoomEntered {
|
|
|
|
[self.roomView onRoomEntered];
|
|
|
|
[self.chatHallView onRoomEntered];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)onRoomUpdate {
|
|
|
|
[self.roomView onRoomUpdate];
|
|
|
|
[self.chatHallView onRoomUpdate];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - 懒加载
|
|
|
|
- (NSInteger)type{
|
|
|
|
return self.titleView.selectedIndex;
|
|
|
|
}
|
|
|
|
- (JXCategoryTitleView *)titleView {
|
|
|
|
if (!_titleView) {
|
|
|
|
_titleView = [[JXCategoryTitleView alloc] init];
|
|
|
|
_titleView.delegate = self;
|
|
|
|
_titleView.titles = self.titles;
|
|
|
|
_titleView.backgroundColor = [UIColor clearColor];
|
2024-05-14 11:13:15 +08:00
|
|
|
_titleView.titleColor = [UIColor colorWithWhite:1 alpha:0.6];
|
2024-05-11 10:21:48 +08:00
|
|
|
_titleView.titleSelectedColor = UIColorFromRGB(0xFFFFFF);
|
|
|
|
_titleView.titleFont = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
|
|
|
_titleView.titleSelectedFont = [UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
|
|
|
|
_titleView.titleLabelAnchorPointStyle = JXCategoryTitleLabelAnchorPointStyleCenter;
|
|
|
|
_titleView.contentScrollViewClickTransitionAnimationEnabled = NO;
|
|
|
|
_titleView.defaultSelectedIndex = 0;
|
|
|
|
_titleView.cellSpacing = 20;
|
|
|
|
_titleView.cellWidthIncrement = 5;
|
2024-05-23 18:08:07 +08:00
|
|
|
_titleView.cellWidth = 30;
|
2024-05-11 10:21:48 +08:00
|
|
|
_titleView.listContainer = self.pi_containerView;
|
|
|
|
|
|
|
|
JXCategoryIndicatorImageView *lineView = [[JXCategoryIndicatorImageView alloc] init];
|
|
|
|
lineView.indicatorImageViewSize = CGSizeMake(8, 1.5);
|
|
|
|
lineView.verticalMargin = 0;
|
|
|
|
lineView.indicatorImageView.image = [UIImage imageWithColor:UIColorFromRGB(0x10ECD6) size:CGSizeMake(8, 1.5)];
|
|
|
|
lineView.indicatorImageView.layer.masksToBounds = YES;
|
|
|
|
lineView.indicatorImageView.layer.cornerRadius = 1.5/2;
|
|
|
|
_titleView.indicators = @[lineView];
|
|
|
|
}
|
|
|
|
return _titleView;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSArray<NSString *> *)titles{
|
|
|
|
if(!_titles){
|
2024-05-23 18:08:07 +08:00
|
|
|
_titles = @[YMLocalizedString(@"XPMineMainGuildListVC1"),YMLocalizedString(@"MSSessionPublicChatHallVC2")];
|
2024-05-11 10:21:48 +08:00
|
|
|
}
|
|
|
|
return _titles;
|
|
|
|
}
|
|
|
|
- (JXCategoryListContainerView *)pi_containerView {
|
|
|
|
if (!_pi_containerView) {
|
|
|
|
_pi_containerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
|
|
|
|
_pi_containerView.defaultSelectedIndex = 0;
|
|
|
|
_pi_containerView.scrollView.tag = 1009;
|
|
|
|
}
|
|
|
|
return _pi_containerView;
|
|
|
|
}
|
|
|
|
- (XPRoomMessageContainerView *)roomView{
|
|
|
|
if(!_roomView){
|
|
|
|
_roomView = [[XPRoomMessageContainerView alloc] initWithDelegate:self.hostDelegate];
|
|
|
|
}
|
|
|
|
return _roomView;
|
|
|
|
}
|
|
|
|
- (MsRoomMessagChatHallView *)chatHallView{
|
|
|
|
if(!_chatHallView){
|
|
|
|
_chatHallView = [[MsRoomMessagChatHallView alloc]initWithDelegate:self.hostDelegate];
|
|
|
|
}
|
|
|
|
return _chatHallView;
|
|
|
|
}
|
|
|
|
@end
|