关闭公屏可以使用

This commit is contained in:
fengshuo
2021-12-25 16:57:50 +08:00
parent 23de6ab02e
commit 1abf40cea0
39 changed files with 498 additions and 139 deletions

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_gift_effect_close@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_gift_effect_close@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_gift_effect_open@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_gift_effect_open@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 998 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_invite_friend@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_invite_friend@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_message_close@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_message_close@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_message_open@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_message_open@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 984 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "room_more_menu_setting@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "room_more_menu_setting@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@@ -26,6 +26,8 @@ typedef NS_ENUM(NSUInteger, CustomMessageType) {
CustomMessageType_Kick_User = 18,
///小秘书消息
CustomMessageType_Secretary = 19,
///房间信息更新
CustomMessageType_Update_RoomInfo = 20,
///糖果树
CustomMessageType_Candy_Tree = 26,
///排麦
@@ -96,12 +98,25 @@ typedef NS_ENUM(NSUInteger, CustomNotificationSubKick) {
Custom_Message_Sub_Kick_BeKicked = 181,
};
///first = CustomMessageType_Secretary
typedef NS_ENUM(NSUInteger, CustomNotificationSecretary) {
///跳转页面
Custom_Message_Sub_Secretary_Router = 191,
};
///first = CustomMessageType_Update_RoomInfo
typedef NS_ENUM(NSUInteger, CustomMessageSubUpdateRoomInfo) {
///动画开关状态更新
Custom_Message_Sub_Update_RoomInfo_AnimateEffect = 201,
///公屏开关更新
Custom_Message_Sub_Update_RoomInfo_MessageState = 203,
///通用公屏提示文案, 公屏纯文本展示消息 data[@"tip"]
Custom_Message_Sub_Update_RoomInfo_Notice = 204,
///红包开关通知
Custom_Message_Sub_Update_RoomInfo_RedPacket = 205,
};
///first = CustomMessageType_Candy_Tree
typedef NS_ENUM(NSUInteger, CustomMessageSubCandyTree) {
//.自己可见 一级礼物(最小)

View File

@@ -133,12 +133,16 @@
self.firstRechargeImageView.hidden = !self.hostDelegate.getUserInfo.isFirstCharge;
}
- (void)handleNIMCustomMessage:(AttachmentModel *)attachment {
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
FirstRechargeModel *model = [FirstRechargeModel modelWithJSON:attachment.data];
XPFirstRechargeSuccessView * firstRechargeView= [[XPFirstRechargeSuccessView alloc] init];
firstRechargeView.rechargeInfo = model;
[TTPopup popupView:firstRechargeView style:TTPopupStyleAlert];
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
FirstRechargeModel *model = [FirstRechargeModel modelWithJSON:attachment.data];
XPFirstRechargeSuccessView * firstRechargeView= [[XPFirstRechargeSuccessView alloc] init];
firstRechargeView.rechargeInfo = model;
[TTPopup popupView:firstRechargeView style:TTPopupStyleAlert];
}
}
}
#pragma mark - SDCycleScrollViewDelegate

View File

@@ -133,25 +133,29 @@
}
}
#pragma mark - RoomGuestDelegate
- (void)handleNIMCustomMessage:(AttachmentModel *)attachment {
if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = YES;
[self receiveGiftHandleSendGiftAnimation:attachment];
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_LuckyBag) {//
[self receiveLuckyGiftBigPrize:attachment];
} else if (attachment.first == CustomMessageType_Candy_Tree && (attachment.second == Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend || attachment.second == Custom_Message_Sub_Candy_Tree_AllRoom_Notify) ) {//
[self receiveCandyTreeGiftHighLevle:attachment];
} else if (attachment.first == CustomMessageType_Car_Notify && attachment.second == Custom_Message_Sub_Car_EnterRoom ) {//
[self receiveDriveCarEnterRoom:attachment];
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Gift) {
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = attachment.second == Custom_Message_Sub_Gift_LuckySend;
receiveInfo.isBatch = YES;
[self receiveGiftHandleSendGiftAnimation:attachment];
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_AllMicroSend) { //
GiftReceiveInfoModel * receiveInfo = [GiftReceiveInfoModel modelWithJSON:attachment.data];
receiveInfo.isLuckyBagGift = (attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
receiveInfo.isBatch = (attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend);
[self receiveGiftHandleSendGiftAnimation:attachment];
[self receiveGift:receiveInfo];
} else if (attachment.first == CustomMessageType_LuckyBag) {//
[self receiveLuckyGiftBigPrize:attachment];
} else if (attachment.first == CustomMessageType_Candy_Tree && (attachment.second == Custom_Message_Sub_Candy_Tree_InRoom_NeedAllMicSend || attachment.second == Custom_Message_Sub_Candy_Tree_AllRoom_Notify) ) {//
[self receiveCandyTreeGiftHighLevle:attachment];
} else if (attachment.first == CustomMessageType_Car_Notify && attachment.second == Custom_Message_Sub_Car_EnterRoom ) {//
[self receiveDriveCarEnterRoom:attachment];
}
}
}

View File

@@ -12,6 +12,7 @@
#import "AccountInfoStorage.h"
#import "TTPopup.h"
#import "RtcManager.h"
#import "XCHudTool.h"
///Model
#import "XPRoomMenuItem.h"
#import "MicroQueueModel.h"
@@ -68,7 +69,13 @@
XPRoomMenuItemType type = sender.tag;
switch (type) {
case XPRoomMenuItemType_Input:
{
if (self.delegate.getRoomInfo.isCloseScreen) {
[XCHUDTool showErrorWithMessage:@"房间公屏已关闭"];
return;
}
[XPRoomSendTextView showTextView:self.superview delegate:self.delegate];
}
break;
case XPRoomMenuItemType_Mic: {
@@ -219,21 +226,25 @@
}
}
- (void)handleNIMCustomMessage:(AttachmentModel *)attachment {
if (attachment.first == CustomMessageType_Arrange_Mic) {
if (attachment.second == Custom_Message_Sub_Arrange_Mic_Non_Empty || attachment.second == Custom_Message_Sub_Arrange_Mic_Empty) {
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NIMChatroomMember * member;
if (error == nil) {
member = members.firstObject;
}
if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) {
self.arrangeMicButton.selected = attachment.second == Custom_Message_Sub_Arrange_Mic_Non_Empty;
};
}];
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_Arrange_Mic) {
if (attachment.second == Custom_Message_Sub_Arrange_Mic_Non_Empty || attachment.second == Custom_Message_Sub_Arrange_Mic_Empty) {
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NIMChatroomMember * member;
if (error == nil) {
member = members.firstObject;
}
if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) {
self.arrangeMicButton.selected = attachment.second == Custom_Message_Sub_Arrange_Mic_Non_Empty;
};
}];
}
}
}
}

View File

@@ -70,6 +70,8 @@
return [self createCandyTreeHighLevelAttribute:attachment];
} else if(first == CustomMessageType_Arrange_Mic) {
return [self createArrangeMicAttribute:attachment];
}else if(first == CustomMessageType_Update_RoomInfo) {
return [self createRoomInfoUpdateAttribute:attachment];
}
return nil;
}
@@ -137,9 +139,7 @@
[self attributeAddHihtLight:attribute uid:message.from.integerValue];
return attribute;
}
case NIMChatroomEventTypeInfoUpdated:///
return [self createRoomInfoUpdateAttribute:content.notifyExt];
break;
default:
return nil;
}
@@ -147,7 +147,22 @@
#pragma mark -
///
- (NSAttributedString*)createRoomInfoUpdateAttribute:(NSString *)notifyExt {
- (NSAttributedString*)createRoomInfoUpdateAttribute:(AttachmentModel *)attachment {
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];
[attribute appendAttributedString:[self createTextAttribute:@"消息:" color:[ThemeColor messageNickColor] font:kRoomMessageDefalutFont]];
if (roomInfo.isCloseScreen) {
[attribute appendAttributedString:[self createTextAttribute:@"管理员已关闭聊天公屏" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
} else {
[attribute appendAttributedString:[self createTextAttribute:@"管理员已开启聊天公屏" color:[ThemeColor messageDefaultTextColor] font:kRoomMessageDefalutFont]];
}
return attribute;
}
return nil;
}

View File

@@ -7,9 +7,10 @@
#import <UIKit/UIKit.h>
#import "RoomHostDelegate.h"
#import "RoomGuestDelegate.h"
NS_ASSUME_NONNULL_BEGIN
@interface XPRoomMessageContainerView : UIView
@interface XPRoomMessageContainerView : UIView<RoomGuestDelegate>
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate;

View File

@@ -24,7 +24,7 @@
#import "View/XPRoomMessageHeaderView.h"
@interface XPRoomMessageContainerView ()<UITableViewDelegate, UITableViewDataSource, NIMChatManagerDelegate>
@interface XPRoomMessageContainerView ()<UITableViewDelegate, UITableViewDataSource>
///
@property (nonatomic,weak) id<RoomHostDelegate> hostDelegate;
@@ -52,7 +52,6 @@
self = [super init];
if (self) {
self.hostDelegate = delegate;
[[NIMSDK sharedSDK].chatManager addDelegate:self];
[self initSubViews];
[self initSubViewConstraints];
}
@@ -194,41 +193,59 @@
@(Custom_Message_Sub_Arrange_Mic_Free_Mic_Open),
@(Custom_Message_Sub_Arrange_Mic_Free_Mic_Close),
nil],
@(CustomMessageType_Update_RoomInfo):
[NSSet setWithObjects:
@(Custom_Message_Sub_Update_RoomInfo_MessageState),
nil],
};
}
#pragma mark - NIMChatManagerDelegate
- (void)onRecvMessages:(NSArray<NIMMessage *> *)messages {
for (NIMMessage * message in messages) {
[self handleMessage:message];
}
}
//
- (void)sendMessage:(NIMMessage *)message didCompleteWithError:(NSError *)error {
[self handleMessage:message];
}
- (void)handleMessage:(NIMMessage *)message {
///
if (message.session.sessionType == NIMSessionTypeChatroom && [self isCurrentRoom:message.session.sessionId]) {
if (message.messageType == NIMMessageTypeText || message.messageType == NIMMessageTypeTip) {
#pragma mark - RoomGuestDelegate
- (void)handleNIMCustomMessage:(NIMMessage *)message {
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];
[self addRoomMessage:message];
} else if (message.messageType == NIMMessageTypeNotification) {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
if (content.eventType == NIMChatroomEventTypeEnter) {
[self addRoomMessage:message];
}
}else if (message.messageType == NIMMessageTypeCustom) {//
///TODO :
if ([self isCanDisplayMessage:message]) {
[self addRoomMessage:message];
}
return;
}
} else {
}
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
return;
}
if ([self isCanDisplayMessage:message]) {
[self addRoomMessage:message];
}
}
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
if (content.eventType == NIMChatroomEventTypeEnter) {
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
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 {
[self addRoomMessage:message];
}
}
}
- (void)handleNIMTextMessage:(NIMMessage *)message {
if (self.hostDelegate.getRoomInfo.isCloseScreen) {
return;
}
[self addRoomMessage:message];
}
#pragma mark - ScrollViewDelegate

View File

@@ -22,6 +22,14 @@ NS_ASSUME_NONNULL_BEGIN
/// @param roomUid 房主的uid
+ (void)closeRoomGiftValue:(HttpRequestHelperCompletion)completion uid:(NSString *)uid roomUid:(NSString *)roomUid;
/// 更新房间信息 公屏开关
/// @param complection 完成
/// @param roomId 房间的id
/// @param isCloseScreen 是否关闭公屏
/// @param ticket ticket
/// @param uid uid
+ (void)updateRoomInfoMessageState:(HttpRequestHelperCompletion)complection roomId:(NSString *)roomId isCloseScreen:(NSString *)isCloseScreen ticket:(NSString *)ticket uid:(NSString *)uid;
@end
NS_ASSUME_NONNULL_END

View File

@@ -17,7 +17,6 @@
[self makeRequest:@"room/gift/value/open" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, uid, roomUid, nil];
}
///
/// @param completion
/// @param uid uid
@@ -26,5 +25,14 @@
[self makeRequest:@"room/gift/value/close" method:HttpRequestHelperMethodPOST completion:completion, __FUNCTION__, uid, roomUid, nil];
}
///
/// @param complection
/// @param roomId id
/// @param isCloseScreen
/// @param ticket ticket
/// @param uid uid
+ (void)updateRoomInfoMessageState:(HttpRequestHelperCompletion)complection roomId:(NSString *)roomId isCloseScreen:(NSString *)isCloseScreen ticket:(NSString *)ticket uid:(NSString *)uid {
[self makeRequest:@"room/setCloseScreen" method:HttpRequestHelperMethodPOST completion:complection, __FUNCTION__, roomId, isCloseScreen, ticket, uid, nil];
}
@end

View File

@@ -14,6 +14,18 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
RoomMoreMenuType_Gift_Value_Close = 1,
///礼物值开启
RoomMoreMenuType_Gift_Value_Open = 2,
///公屏关闭
RoomMoreMenuType_Message_Screen_Close = 3,
///公屏开启
RoomMoreMenuType_Message_Screen_Open = 4,
///我的礼物特效关闭
RoomMoreMenuType_Gift_Effect_Close = 5,
///我的礼物特效开启
RoomMoreMenuType_Gift_Effect_Open = 6,
///房间设置
RoomMoreMenuType_Room_Setting = 7,
///邀请粉丝
RoomMoreMenuType_Invite_Friend = 8,
};
@interface XPRoomMoreItemModel : NSObject
@@ -21,10 +33,12 @@ typedef NS_ENUM(NSInteger, RoomMoreMenuType) {
@property (nonatomic,copy) NSString *imageName;
///显示的文字
@property (nonatomic,copy) NSString *title;
///标题的颜色
@property (nonatomic,strong) UIColor *titleColor;
///类型
@property (nonatomic,assign) RoomMoreMenuType type;
+(XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type;
+(XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type titleColor:(UIColor *)titleColor;
@end

View File

@@ -9,11 +9,12 @@
@implementation XPRoomMoreItemModel
+ (XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type {
+ (XPRoomMoreItemModel *)initWithTitle:(NSString *)title imageName:(NSString *)imageName type:(RoomMoreMenuType)type titleColor:(UIColor *)titleColor {
XPRoomMoreItemModel * model = [[self alloc] init];
model.title = title;
model.imageName = imageName;
model.type = type;
model.titleColor = titleColor;
return model;
}

View File

@@ -21,6 +21,11 @@ NS_ASSUME_NONNULL_BEGIN
/// 关闭房间礼物值
/// @param roomUid 房间的uid
- (void)closeRoomGiftValue:(NSString *)roomUid;
/// 更新公屏状态
/// @param isCloseScreen 是否关闭公屏
/// @param roomId 房间的id
- (void)updateRoomMessageScreenState:(BOOL)isCloseScreen roomId:(NSString *)roomId;
@end
NS_ASSUME_NONNULL_END

View File

@@ -6,7 +6,9 @@
//
#import "XPMoreMenuPresenter.h"
#import <NIMSDK/NIMSDK.h>
#import "Api+MoreMenu.h"
#import "ThemeColor+Room.h"
#import "AccountInfoStorage.h"
#import "XPRoomMoreItemModel.h"
#import "RoomInfoModel.h"
@@ -15,12 +17,60 @@
@implementation XPMoreMenuPresenter
- (void)getMoreMenuDataSource:(RoomInfoModel *)roomInfo {
NSString * giftValueTitle = roomInfo.showGiftValue ? @"关闭礼物值" : @"开启礼物值";
NSString * giftValueImage = roomInfo.showGiftValue ? @"room_more_menu_gift_value_close" : @"room_more_menu_gift_value_open";
RoomMoreMenuType giftValueType = roomInfo.showGiftValue ? RoomMoreMenuType_Gift_Value_Close : RoomMoreMenuType_Gift_Value_Open;
XPRoomMoreItemModel * giftValue = [XPRoomMoreItemModel initWithTitle:giftValueTitle imageName:giftValueImage type:giftValueType];
NSArray * array = @[giftValue];
[[self getView] getMoreMenuDataSuccess:array];
XPRoomMoreItemModel * giftValue = [[XPRoomMoreItemModel alloc] init];
giftValue.title = roomInfo.showGiftValue ? @"关闭礼物值" : @"开启礼物值";
giftValue.imageName= roomInfo.showGiftValue ? @"room_more_menu_gift_value_close" : @"room_more_menu_gift_value_open";
giftValue.type = roomInfo.showGiftValue ? RoomMoreMenuType_Gift_Value_Close : RoomMoreMenuType_Gift_Value_Open;
giftValue.titleColor = roomInfo.showGiftValue ? [ThemeColor roomMoreMenuTextColor] : nil;
XPRoomMoreItemModel * giftEffect = [[XPRoomMoreItemModel alloc] init];
giftEffect.title = roomInfo.hasAnimationEffect ? @"关闭我的特效" : @"开启我的特效";
giftEffect.imageName = roomInfo.hasAnimationEffect ? @"room_more_menu_gift_effect_close" : @"room_more_menu_gift_effect_open";
giftEffect.type = roomInfo.hasAnimationEffect ? RoomMoreMenuType_Gift_Effect_Close : RoomMoreMenuType_Gift_Effect_Open;
giftEffect.titleColor = roomInfo.hasAnimationEffect ? [ThemeColor roomMoreMenuTextColor] : nil;
XPRoomMoreItemModel * messageScreen = [[XPRoomMoreItemModel alloc] init];
messageScreen.title = roomInfo.isCloseScreen ? @"开启公屏" : @"关闭公屏";
messageScreen.imageName = roomInfo.isCloseScreen ? @"room_more_menu_message_open" : @"room_more_menu_message_close";
messageScreen.type = roomInfo.isCloseScreen ? RoomMoreMenuType_Message_Screen_Open : RoomMoreMenuType_Message_Screen_Close;
messageScreen.titleColor = roomInfo.isCloseScreen ? nil : [ThemeColor roomMoreMenuTextColor];
XPRoomMoreItemModel * roomSetting = [[XPRoomMoreItemModel alloc] init];
roomSetting.title = @"房间设置";
roomSetting.imageName = @"room_more_menu_setting";
roomSetting.type = RoomMoreMenuType_Room_Setting;
roomSetting.titleColor = [ThemeColor roomMoreMenuTextColor];
XPRoomMoreItemModel * inviteFriend = [[XPRoomMoreItemModel alloc] init];
inviteFriend.title = @"邀请粉丝";
inviteFriend.imageName = @"room_more_menu_invite_friend";
inviteFriend.type = RoomMoreMenuType_Invite_Friend;
inviteFriend.titleColor = [ThemeColor roomMoreMenuTextColor];
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = roomId;
request.userIds = @[uid];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
NSMutableArray * array = [NSMutableArray array];
[array addObject:giftEffect];
if (error == nil) {
NIMChatroomMember * member = members.firstObject;
BOOL isCreator = member.type == NIMChatroomMemberTypeCreator;
BOOL isManager = member.type == NIMChatroomMemberTypeManager;
if (isCreator || isManager) {
[array addObject:messageScreen];
[array addObject:giftValue];
[array addObject:roomSetting];
[array addObject:inviteFriend];
}
}
[[self getView] getMoreMenuDataSuccess:array];
}];
}
///
@@ -40,4 +90,19 @@
[[self getView] closeRoomGiftValueSuccess];
}] uid:uid roomUid:roomUid];
}
///
/// @param isCloseScreen
/// @param roomId id
- (void)updateRoomMessageScreenState:(BOOL)isCloseScreen roomId:(NSString *)roomId {
NSString * uid = [AccountInfoStorage instance].getUid;
NSString * ticket = [AccountInfoStorage instance].getTicket;
NSString * isCleScreenStr = isCloseScreen ? @"1" : @"0";
[Api updateRoomInfoMessageState:[self createHttpCompletion:^(BaseModel * _Nonnull data) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:data.data];
[[self getView] updateRoomMessageScreenStateSuccess:roomInfo];
}] roomId:roomId isCloseScreen:isCleScreenStr ticket:ticket uid:uid];
}
@end

View File

@@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class XPRoomMoreItemModel;
@class XPRoomMoreItemModel, RoomInfoModel;
@protocol XPMoreMenuProtocol <NSObject>
///更多菜单要展示的内容
@@ -17,7 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)openRoomGiftValueSuccess;
///关闭房间礼物值成功
- (void)closeRoomGiftValueSuccess;
///更新房间信息 成功 公屏的开启和关闭
- (void)updateRoomMessageScreenStateSuccess:(RoomInfoModel * )roomInfo;
@end
NS_ASSUME_NONNULL_END

View File

@@ -55,6 +55,7 @@
if (_itemModel) {
self.logoImageView.image = [UIImage imageNamed:_itemModel.imageName];
self.titleLabel.text = _itemModel.title;
self.titleLabel.textColor = _itemModel.titleColor ? _itemModel.titleColor : [ThemeColor mainTextColor];
}
}

View File

@@ -14,6 +14,7 @@
///Model
#import "XPRoomMoreItemModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
///View
#import "XPRoomMoreMenuCollectionViewCell.h"
///P
@@ -38,7 +39,7 @@
self.roomInfo = roomInfo;
}
return self;
}
}
- (XPMoreMenuPresenter *)createPresenter {
return [[XPMoreMenuPresenter alloc] init];
@@ -103,6 +104,23 @@
[self dismissViewControllerAnimated:YES completion:nil];
}
///
- (void)updateRoomMessageScreenStateSuccess:(RoomInfoModel *)roomInfo {
AttachmentModel *attachement = [[AttachmentModel alloc]init];
attachement.first = CustomMessageType_Update_RoomInfo;
attachement.second = Custom_Message_Sub_Update_RoomInfo_MessageState;
attachement.data = @{@"roomInfo":roomInfo.model2dictionary};
NIMMessage *message = [[NIMMessage alloc]init];
NIMCustomObject *object = [[NIMCustomObject alloc] init];
object.attachment = attachement;
message.messageObject = object;
//
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
NIMSession *session = [NIMSession session:roomId type:NIMSessionTypeChatroom];
[[NIMSDK sharedSDK].chatManager sendMessage:message toSession:session error:nil];
[self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - UICollectionViewDelegate And UICollectionViewDatasource
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return self.datasource.count;
@@ -118,6 +136,7 @@
[collectionView deselectItemAtIndexPath:indexPath animated:YES];
XPRoomMoreItemModel * item = [self.datasource objectAtIndex:indexPath.row];
NSString * roomUid = [NSString stringWithFormat:@"%ld",self.roomInfo.uid];
NSString * roomId = [NSString stringWithFormat:@"%ld", self.roomInfo.roomId];
switch (item.type) {
case RoomMoreMenuType_Gift_Value_Close:
{
@@ -138,6 +157,12 @@
case RoomMoreMenuType_Gift_Value_Open:
[self.presenter openRoomGiftValue:roomUid];
break;
case RoomMoreMenuType_Message_Screen_Open:
[self.presenter updateRoomMessageScreenState:NO roomId:roomId];
break;
case RoomMoreMenuType_Message_Screen_Close:
[self.presenter updateRoomMessageScreenState:YES roomId:roomId];
break;
default:
break;
}

View File

@@ -20,8 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)onUserUpdate;
- (void)onRoomEntered;
- (void)handleNIMNotificationMessage:(NIMMessage *)message;
- (void)handleNIMCustomMessage:(AttachmentModel *)attachment;
- (void)handleNIMCustomMessage:(NIMMessage *)message;
- (void)handleNIMTextMessage:(NIMMessage *)message;
@end
NS_ASSUME_NONNULL_END

View File

@@ -333,49 +333,52 @@
}
}
- (void)handleNIMCustomMessage:(AttachmentModel *)attachment {
if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) {
NSDictionary *dic = attachment.data;
NSString *uid = dic[@"uid"];
if (uid.integerValue == self.hostDelegate.getUserInfo.uid) {
NSNumber *micPosition = dic[@"micPosition"];
NSString *position = micPosition.stringValue;
MicroQueueModel *micro = [self.micQueue objectForKey:position];
if (!micro || micro.userInfo) return; //
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
UserInfoModel* userInfo = self.hostDelegate.getUserInfo;
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = position;
request.value = [[self configUpdateChatRoomQueueExt:userInfo] toJSONString];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
if (error) return;
[RtcManager instance].localMuted = YES;
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"房主或管理员拉你上麦";
config.message = @"你已被房主或管理员拉上麦,但并未开启麦克风。如需要说话,请打开麦克风。";
[TTPopup alertWithConfig:config confirmHandler:^{
} cancelHandler:^{
}];
}];
}
} else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) {
[self giftValueUpdate:attachment.data];
} else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) {
[self giftValueUpdate:attachment.data];
}else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) {
[self giftValueUpdate:attachment.data];
- (void)handleNIMCustomMessage:(NIMMessage *)message {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if(attachment.first == CustomMessageType_Queue && attachment.second == Custom_Message_Sub_Queue_Invite) {
NSDictionary *dic = attachment.data;
NSString *uid = dic[@"uid"];
if (uid.integerValue == self.hostDelegate.getUserInfo.uid) {
NSNumber *micPosition = dic[@"micPosition"];
NSString *position = micPosition.stringValue;
MicroQueueModel *micro = [self.micQueue objectForKey:position];
if (!micro || micro.userInfo) return; //
RoomInfoModel* roomInfo = self.hostDelegate.getRoomInfo;
NSString* roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
UserInfoModel* userInfo = self.hostDelegate.getUserInfo;
NIMChatroomQueueUpdateRequest *request = [[NIMChatroomQueueUpdateRequest alloc]init];
request.key = position;
request.value = [[self configUpdateChatRoomQueueExt:userInfo] toJSONString];
request.roomId = roomId;
request.transient = YES;
[[NIMSDK sharedSDK].chatroomManager updateChatroomQueueObject:request completion:^(NSError * _Nullable error) {
if (error) return;
[RtcManager instance].localMuted = YES;
TTAlertConfig *config = [[TTAlertConfig alloc] init];
config.title = @"房主或管理员拉你上麦";
config.message = @"你已被房主或管理员拉上麦,但并未开启麦克风。如需要说话,请打开麦克风。";
[TTPopup alertWithConfig:config confirmHandler:^{
} cancelHandler:^{
}];
}];
}
} else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) {
[self giftValueUpdate:attachment.data];
} else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) {
[self giftValueUpdate:attachment.data];
}else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) {
[self giftValueUpdate:attachment.data];
}
}
}
#pragma mark - RtcDelegate -

View File

@@ -52,6 +52,8 @@ NS_ASSUME_NONNULL_BEGIN
///动画礼物个数的颜色 0xFFF226
+ (UIColor *)animationGiftNumberColor;
///更多menu文字颜色 0xFFFFFF
+ (UIColor *)roomMoreMenuTextColor;
@end
NS_ASSUME_NONNULL_END

View File

@@ -96,4 +96,9 @@
+ (UIColor *)animationGiftNumberColor {
return UIColorFromRGB(0xFFF226);
}
///menu 0xFFFFFF
+ (UIColor *)roomMoreMenuTextColor {
return UIColorFromRGB(0xFFFFFF);
}
@end

View File

@@ -327,21 +327,34 @@
[self.roomHeaderView onRoomUpdate];
[self.stageView handleNIMNotificationMessage:message];
[self.animationView handleNIMNotificationMessage:message];
[self.messageContainerView handleNIMNotificationMessage:message];
} else if (message.messageType == NIMMessageTypeCustom) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel * attachment = obj.attachment;
[self.stageView handleNIMCustomMessage:attachment];
[self.animationView handleNIMCustomMessage:attachment];
[self.menuContainerView handleNIMCustomMessage:attachment];
[self.activityContainerView handleNIMCustomMessage:attachment];
[self.stageView handleNIMCustomMessage:message];
[self.animationView handleNIMCustomMessage:message];
[self.menuContainerView handleNIMCustomMessage:message];
[self.activityContainerView handleNIMCustomMessage:message];
if (attachment.first == CustomMessageType_First_Recharge_Reward && attachment.second == Custom_Message_Sub_Room_First_Recharge_Reward) {
self.userInfo.isFirstCharge = NO;
[self.menuContainerView onRoomUpdate];
[self.activityContainerView onRoomUpdate];
} else if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
///iOS
NSDictionary * dic= attachment.data[@"roomInfo"];
if (dic.allKeys.count <=0) {
dic = attachment.data;
}
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:dic];
self.roomInfo.isCloseScreen = roomInfo.isCloseScreen;
[self.menuContainerView onRoomUpdate];
}
[self.messageContainerView handleNIMCustomMessage:message];
}
}
} else if(message.messageType == NIMMessageTypeText) {
[self.messageContainerView handleNIMTextMessage:message];
}
}
}
@@ -351,9 +364,18 @@
if (message.messageType == NIMMessageTypeCustom) {
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
[self.stageView handleNIMCustomMessage:obj.attachment];
[self.animationView handleNIMCustomMessage:obj.attachment];
AttachmentModel * attachment = obj.attachment;
[self.stageView handleNIMCustomMessage:message];
[self.animationView handleNIMCustomMessage:message];
if (attachment.first == CustomMessageType_Update_RoomInfo && attachment.second == Custom_Message_Sub_Update_RoomInfo_MessageState) {
RoomInfoModel * roomInfo = [RoomInfoModel modelWithDictionary:attachment.data[@"roomInfo"]];
self.roomInfo.isCloseScreen = roomInfo.isCloseScreen;
[self.menuContainerView onRoomUpdate];
}
[self.messageContainerView handleNIMCustomMessage:message];
}
}else if(message.messageType == NIMMessageTypeText) {
[self.messageContainerView handleNIMTextMessage:message];
}
}