个播房上下滑动
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#import "XPArrangeMicViewController.h"
|
||||
#import "XPRoomSettingInputView.h"
|
||||
#import "XPRoomLittleGameContainerView.h"
|
||||
#import "AnchorRoomScrollView.h"
|
||||
///P
|
||||
#import "XPRoomPresenter.h"
|
||||
#import "XPRoomProtocol.h"
|
||||
@@ -59,9 +60,14 @@ UIKIT_EXTERN NSString * const kRoomGiftEffectUpdateNotificationKey;
|
||||
UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
|
||||
|
||||
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate,XPRoomLittleGameContainerViewDelegate>
|
||||
@interface XPRoomViewController ()<XPRoomProtocol, RoomHostDelegate, NIMChatroomManagerDelegate, NIMChatManagerDelegate, NIMConversationManagerDelegate, NIMLoginManagerDelegate, XPRoomSettingInputViewDelegate,XPRoomLittleGameContainerViewDelegate, AnchorRoomScrollViewDelegate>
|
||||
///背景
|
||||
@property (nonatomic,strong) XPRoomBackContainerView *backContainerView;
|
||||
|
||||
///个播上下切换view
|
||||
@property (nonatomic, strong) AnchorRoomScrollView *anchorScrollView;
|
||||
///个播滚动索引
|
||||
@property (nonatomic, assign) int anchorScrollIndex;
|
||||
///房间信息
|
||||
@property (nonatomic,strong) RoomHeaderView *roomHeaderView;
|
||||
///坑位信息
|
||||
@@ -98,6 +104,11 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
@property (nonatomic,assign) BOOL isRequestSuperAdmin;
|
||||
///是否是最小化进房
|
||||
@property (nonatomic,assign) BOOL isMiniEnter;
|
||||
///个播房列表
|
||||
@property (nonatomic, strong) NSMutableArray *cycleAnchorList;
|
||||
///是否获取了个播房列表,只需第一次加载时获取
|
||||
@property (nonatomic, assign) BOOL hadGetAnchorList;
|
||||
|
||||
@end
|
||||
|
||||
@implementation XPRoomViewController
|
||||
@@ -258,6 +269,53 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)updateViewConstraintsOnAnchorRoom {
|
||||
[self.anchorScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.view);
|
||||
}];
|
||||
[self.backContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
}];
|
||||
[self.roomHeaderView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.top.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.height.mas_equalTo(kNavigationHeight);
|
||||
}];
|
||||
|
||||
[self.stageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.top.mas_equalTo(self.roomHeaderView.mas_bottom);
|
||||
make.height.mas_equalTo(self.stageView.hightForStageView);
|
||||
}];
|
||||
|
||||
[self.messageContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.equalTo(self.stageView.mas_bottom);
|
||||
make.bottom.equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.left.equalTo(self.anchorScrollView.middleImageView);
|
||||
make.right.equalTo(self.activityContainerView.mas_left).offset(-10);
|
||||
}];
|
||||
|
||||
[self.menuContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.bottom.mas_equalTo(self.anchorScrollView.middleImageView).mas_offset(-kSafeAreaBottomHeight- 8);
|
||||
make.height.mas_equalTo(40);
|
||||
}];
|
||||
|
||||
[self.activityContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.messageContainerView);
|
||||
make.right.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
|
||||
[self.animationView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
}];
|
||||
|
||||
[self.functionView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)exitOldRoom {
|
||||
NSString * roomUid = [NSString stringWithFormat:@"%ld", [XPRoomMiniManager shareManager].getRoomInfo.uid];
|
||||
if (roomUid.integerValue > 0 && roomUid.integerValue != self.roomUid.integerValue) {
|
||||
@@ -385,6 +443,38 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)changeStageViewOnAnchorRoom {
|
||||
if (self.roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode && ![self.stageView isKindOfClass:[AnchorPKStageView class]]) {
|
||||
[self.stageView removeFromSuperview];
|
||||
self.stageView = nil;
|
||||
self.stageView = [[AnchorPKStageView alloc] initWithDelegate:self];
|
||||
} else if(self.roomInfo.roomModeType == RoomModeType_Normal_Mode && ![self.stageView isKindOfClass:[AnchorStageView class]]) {
|
||||
[self.stageView removeFromSuperview];
|
||||
self.stageView = nil;
|
||||
self.stageView = [[AnchorStageView alloc] initWithDelegate:self];
|
||||
}
|
||||
if (!self.stageView.superview) {
|
||||
[self.anchorScrollView insertSubview:self.stageView belowSubview:self.roomHeaderView];
|
||||
}
|
||||
[self.stageView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.top.mas_equalTo(self.roomHeaderView.mas_bottom);
|
||||
make.height.mas_equalTo(self.stageView.hightForStageView);
|
||||
}];
|
||||
[self.messageContainerView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.stageView.mas_bottom);
|
||||
make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.left.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.right.mas_equalTo(self.activityContainerView.mas_left).offset(-10);
|
||||
}];
|
||||
[self.activityContainerView mas_remakeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.messageContainerView);
|
||||
make.right.mas_equalTo(self.anchorScrollView.middleImageView);
|
||||
make.bottom.mas_equalTo(self.menuContainerView.mas_top).offset(-5);
|
||||
make.width.mas_equalTo(80);
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)cancelRoomArrangeMic {
|
||||
///退出排麦
|
||||
if (self.roomInfo.roomModeType == RoomModeType_Open_Micro_Mode || self.roomInfo.roomModeType == RoomModeType_Open_Blind) {
|
||||
@@ -490,6 +580,10 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
self.hasAnimationEffect = roomInfo.hasAnimationEffect;
|
||||
self.roomInfo = roomInfo;
|
||||
self.userInfo = userInfo;
|
||||
if (!self.hadGetAnchorList) {
|
||||
[self.presenter getCycleAnchorRoomList:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]];
|
||||
self.hadGetAnchorList = YES;
|
||||
}
|
||||
if (roomInfo.valid) { // 房间有效,直接进入房间
|
||||
if (roomInfo.roomPwd.length > 0 && roomInfo.uid != [AccountInfoStorage instance].getUid.integerValue && [XPRoomMiniManager shareManager].getRoomInfo.uid != self.roomUid.integerValue) {//进房密码的情况
|
||||
if (!self.isRequestSuperAdmin) {
|
||||
@@ -503,7 +597,30 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
}
|
||||
} else {
|
||||
self.roomInfo.datingState = roomInfo.roomModeType == RoomModeType_Open_Blind ? RoomDatingStateChangeType_Open : RoomDatingStateChangeType_Normal;
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
if (self.roomInfo.type == RoomType_Anchor) {
|
||||
if (!self.anchorScrollView.superview) {
|
||||
for (UIView *subViews in self.view.subviews) {
|
||||
[subViews removeFromSuperview];
|
||||
}
|
||||
[self.view addSubview:self.anchorScrollView];
|
||||
[self.anchorScrollView addSubview:self.backContainerView];
|
||||
[self.anchorScrollView addSubview:self.stageView];
|
||||
[self.anchorScrollView addSubview:self.messageContainerView];
|
||||
[self.anchorScrollView addSubview:self.menuContainerView];
|
||||
[self.anchorScrollView addSubview:self.activityContainerView];
|
||||
[self.anchorScrollView addSubview:self.roomHeaderView];
|
||||
[self.anchorScrollView addSubview:self.functionView];
|
||||
[self.anchorScrollView addSubview:self.animationView];
|
||||
} else {
|
||||
if (!self.messageContainerView.superview) {
|
||||
[self.anchorScrollView addSubview:self.messageContainerView];
|
||||
}
|
||||
}
|
||||
[self updateViewConstraintsOnAnchorRoom];
|
||||
[self changeStageViewOnAnchorRoom];
|
||||
} else {
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
}
|
||||
[self.roomHeaderView onRoomEntered];
|
||||
[self.activityContainerView onRoomEntered];
|
||||
[self.menuContainerView onRoomEntered];
|
||||
@@ -583,6 +700,17 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
self.isRequestSuperAdmin = YES;
|
||||
self.superMangerList = list;
|
||||
}
|
||||
|
||||
- (void)getCycleAnchorRoomListSuccess:(NSArray *)list {
|
||||
if (self.roomInfo.type != RoomType_Anchor) {
|
||||
return;
|
||||
}
|
||||
[self.cycleAnchorList removeAllObjects];
|
||||
[self.cycleAnchorList addObjectsFromArray:list];
|
||||
[self.cycleAnchorList insertObject:[NSString stringWithFormat:@"%zd", self.roomInfo.uid] atIndex:0];
|
||||
[self.anchorScrollView updateForLives:self.cycleAnchorList withCurrentIndex:0];
|
||||
}
|
||||
|
||||
#pragma mark - NIMChatroomManagerDelegate
|
||||
- (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result {
|
||||
if (result.reason == 2) {
|
||||
@@ -665,7 +793,41 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
newRoomInfo.hadChangeRoomType = self.roomInfo.type != newRoomInfo.type;
|
||||
self.roomInfo = newRoomInfo;
|
||||
[self.backContainerView onRoomUpdate];
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
if (self.roomInfo.type == RoomType_Anchor) {
|
||||
if (self.anchorScrollView.superview) {
|
||||
// for (UIView *view in self.anchorScrollView.upperImageView.subviews) {
|
||||
// [view removeFromSuperview];
|
||||
// }
|
||||
} else {
|
||||
for (UIView *subViews in self.view.subviews) {
|
||||
[subViews removeFromSuperview];
|
||||
}
|
||||
[self.view addSubview:self.anchorScrollView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.backContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.stageView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.messageContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.menuContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.activityContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.roomHeaderView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.functionView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.animationView];
|
||||
// [self updateViewConstraintsOnAnchorRoom];
|
||||
// [self changeStageViewOnAnchorRoom];
|
||||
}
|
||||
// [self.anchorScrollView updateForLives:@[@"123", @"234"] withCurrentIndex:0];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.backContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.stageView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.messageContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.menuContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.activityContainerView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.roomHeaderView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.functionView];
|
||||
// [self.anchorScrollView.upperImageView addSubview:self.animationView];
|
||||
// [self updateViewConstraintsOnAnchorRoom];
|
||||
// [self changeStageViewOnAnchorRoom];
|
||||
} else {
|
||||
[self changeStageViewOnRoomUpdate];
|
||||
}
|
||||
[self.stageView onRoomUpdate];
|
||||
[self.menuContainerView onRoomUpdate];
|
||||
[self.functionView onRoomUpdate];
|
||||
@@ -1004,6 +1166,31 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
[self.functionView hiddenSudGamePostionView];
|
||||
}
|
||||
|
||||
#pragma mark - AnchorRoomScrollViewDelegate
|
||||
- (void)anchorScrollView:(AnchorRoomScrollView *)anchorScrollView currentPlayerIndex:(NSInteger)index {
|
||||
[self exitOldRoom];
|
||||
// [self exitRoom];
|
||||
[self.presenter exitNIMRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.roomId]];
|
||||
[[XPRoomMiniManager shareManager] resetLocalMessage];
|
||||
[[RtcManager instance] exitRoom];
|
||||
[self.presenter reportUserOutRoom:[NSString stringWithFormat:@"%ld", self.roomInfo.uid]];
|
||||
|
||||
[self.messageContainerView removeFromSuperview];
|
||||
self.messageContainerView = nil;
|
||||
[self exitOldRoom];
|
||||
self.roomUid = self.cycleAnchorList[index];
|
||||
[self.presenter initEnterRoom:self.roomUid user:[AccountInfoStorage instance].getUid];
|
||||
/// 公屏 福袋礼物爆出的礼物 需要依赖 当前房间中的礼物列表 需要提前获取礼物列表 可以拿到礼物 没有想到别的方法去解决这个问题 有需要改的在修改吧
|
||||
[self.presenter getNormalGiftList:self.roomUid];
|
||||
///获取房间超管列表
|
||||
[self.presenter getRoomSuperAdmin:self.roomUid];
|
||||
|
||||
// for (UIView *view in anchorScrollView.upperImageView.subviews) {
|
||||
// [view removeFromSuperview];
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - XPRoomSettingInputViewDelegate
|
||||
///点击了完成
|
||||
- (void)xPRoomSettingInputView:(XPRoomSettingInputView *)view didClickConfirm:(NSString *)text type:(RoomSettingInputType)type {
|
||||
@@ -1098,4 +1285,20 @@ UIKIT_EXTERN NSString * const kRoomMiniNotificationKey;
|
||||
return _littleGameView;
|
||||
}
|
||||
|
||||
- (AnchorRoomScrollView *)anchorScrollView {
|
||||
if (!_anchorScrollView) {
|
||||
_anchorScrollView = [[AnchorRoomScrollView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight)];
|
||||
_anchorScrollView.anchorScrollDelegate = self;
|
||||
_anchorScrollView.index = self.anchorScrollIndex;
|
||||
}
|
||||
return _anchorScrollView;
|
||||
}
|
||||
|
||||
- (NSMutableArray *)cycleAnchorList {
|
||||
if (!_cycleAnchorList) {
|
||||
_cycleAnchorList = [NSMutableArray array];
|
||||
}
|
||||
return _cycleAnchorList;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Reference in New Issue
Block a user