Files
peko-ios/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m

794 lines
34 KiB
Objective-C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// XPRoomActivityView.m
// xplan-ios
//
// Created by 冯硕 on 2021/10/12.
//
#import "XPRoomActivityContainerView.h"
#import <ReactiveObjC/ReactiveObjC.h>
///Third
#import <Masonry/Masonry.h>
#import <SDCycleScrollView/SDCycleScrollView.h>
///Tool
#import "AccountInfoStorage.h"
#import "Api+Room.h"
#import "Api+TreasureFairy.h"
#import "Api+LittleGame.h"
#import "ClientConfig.h"
#import "NetImageView.h"
#import "TTPopup.h"
///Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
#import "AttachmentModel.h"
#import "FirstRechargeModel.h"
#import "TreasureFairyLimitModel.h"
#import "XPRedPacketResultModel.h"
///View
#import "XPRoomHalfWebView.h"
#import "XPCandyTreeViewController.h"
#import "XPWebViewController.h"
#import "XPRoomViewController.h"
#import "XPFirstRechargeSuccessView.h"
#import "XPArrangeMicViewController.h"
#import "XPSailingViewController.h"
#import "XCCurrentVCStackManager.h"
#import "XPTreasureFairyViewController.h"
#import "PIRoomEnterRedPacketView.h"
#import "BaseNavigationController.h"
#import "PIRoomActivityWebView.h"
#import "MSRoomGameWebVC.h"
#import "XPRoomAnimationView.h"
#import "MSRoomMenuGameVC.h"
UIKIT_EXTERN NSString *kShowFirstRechargeView;
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate,PIRoomEnterRedPacketViewDelegate>
///容器
@property (nonatomic,strong) UIStackView *stackView;
///轮播图
@property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView;
///红包
@property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView;
/// 配置的入口,逻辑由 API 返回数据决定
@property(nonatomic, strong) UIButton *configEntranceMenuButton;
///游戏菜单按钮
@property(nonatomic, strong) UIButton *gambleMenuButton;
///游戏菜单按钮
@property(nonatomic, strong) UIButton *pkMenuButton;
///参加相亲
@property (nonatomic,strong) UIImageView *joinDatingView;
///host 代理
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
///房间活动的列表
@property (nonatomic,strong) NSMutableArray<ActivityInfoModel *> *activityList;
///是否加载了活动
@property (nonatomic,assign) BOOL isLoadActivity;
@end
@implementation XPRoomActivityContainerView
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
- (instancetype)initWithDelegate:(id<RoomHostDelegate>)delegate {
self = [super init];
if (self) {
self.hostDelegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
- (void)updateView {
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
[self requestActivityList];
}
}
#pragma mark - Private Method
- (void)initSubViews {
[self addSubview:self.stackView];
UIView *emptyView = [UIView new];
[self.stackView addArrangedSubview:self.pi_cycleScrollView];
[self.stackView addArrangedSubview:emptyView];
[self.stackView addArrangedSubview:self.redPacketView];
[self.stackView addArrangedSubview:self.joinDatingView];
[self.stackView addArrangedSubview:self.pkMenuButton];
[self.stackView addArrangedSubview:self.configEntranceMenuButton];
[self.stackView addArrangedSubview:self.gambleMenuButton];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
CGFloat scrollItemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
CGSize itemSize = CGSizeMake(scrollItemWidth , scrollItemWidth);
[self.pi_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(itemSize);
}];
[self.redPacketView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(58));
}];
[self.pkMenuButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.size.mas_equalTo(itemSize);
}];
[self.gambleMenuButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.size.mas_equalTo(itemSize);
}];
[self.configEntranceMenuButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.size.mas_equalTo(itemSize);
}];
[self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(35 * kScreenHeightScale);
}];
}
- (void)requestActivityList {
@kWeakify(self);
RACSubject* playRAC = [RACSubject subject];
RACSubject* littleGameRAC = [RACSubject subject];
[[RACSignal combineLatest:@[playRAC, littleGameRAC]
reduce:^id(NSArray<ActivityInfoModel*> *playModels, NSArray<LittleGameInfoModel*> *littleGameModels){
@kStrongify(self);
self.playList = [NSMutableArray arrayWithArray:playModels];
self.littleGameList = [NSMutableArray arrayWithArray:littleGameModels];
self.gambleMenuButton.hidden = self.playList.count > 0 ? NO : YES;
[self onRoomUpdate];
return nil;
}] subscribeError:^(NSError * _Nullable error) {}];
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
NSString * roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
@kStrongify(self);
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
self.activityList = [NSMutableArray arrayWithArray:array];
[self dealWithData];
}
} roomId:roomId];
[Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
[playRAC sendNext:array];
[playRAC sendCompleted];
} else {
[playRAC sendError:nil];
}
} roomId:roomId];
NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
[Api getLittleGameList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray * array = [LittleGameInfoModel modelsWithArray:data.data];
[littleGameRAC sendNext:array];
[littleGameRAC sendCompleted];
} else {
[littleGameRAC sendError:nil];
}
}
roomUid:roomUid];
}
-(void)dealWithData{
self.isLoadActivity = YES;
self.pi_cycleScrollView.hidden = NO;
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
[self configLittleGameActivity];
} else {
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.icon];
}
self.pi_cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.pi_cycleScrollView setAutoScroll:YES];
self.pi_cycleScrollView.autoScrollTimeInterval = 3;
} else {
[self.pi_cycleScrollView setAutoScroll:NO];
}
}
}
- (void)configLittleGameActivity {
NSMutableArray *list = [NSMutableArray array];
[list addObjectsFromArray:self.activityList];
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in list) {
[picArray addObject:model.icon ?: @""];
}
self.pi_cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.pi_cycleScrollView setAutoScroll:YES];
self.pi_cycleScrollView.autoScrollTimeInterval = 3;
}else{
[self.pi_cycleScrollView setAutoScroll:NO];
}
}
- (void)setRedPacketList:(NSMutableArray *)redPacketList{
_redPacketList = redPacketList;
self.redPacketView.redPacketList = redPacketList;
if(self.openRedPacketHandle){
self.openRedPacketHandle(nil,self.hostDelegate.getRoomInfo.type,YES);
}
}
#pragma mark - RoomGuestDelegat
- (void)updateConfigEntranceButtons:(RoomInfoModel *)roomInfo {
RoomBottomEntranceModel *model = roomInfo.rightBottomIconConfig;
if (model) {
@kWeakify(self);
if (model.icon2Url.length > 0) {
NetImageView *loader = [[NetImageView alloc] init];
[loader loadImageWithUrl:model.icon2Url
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
@kStrongify(self);
[self.gambleMenuButton setImage:image forState:UIControlStateNormal];
}];
}
if (model.icon1Url.length > 0) {
NetImageView *loader = [[NetImageView alloc] init];
[loader loadImageWithUrl:model.icon1Url
completion:^(UIImage * _Nullable image, NSURL * _Nonnull url) {
@kStrongify(self);
[self.configEntranceMenuButton setImage:image forState:UIControlStateNormal];
self.configEntranceMenuButton.hidden = NO;
} fail:^(NSError * _Nonnull error) {
self.configEntranceMenuButton.hidden = YES;
}];
} else {
[self.configEntranceMenuButton removeFromSuperview];
}
}
}
- (void)onRoomUpdate {
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
[self updateConfigEntranceButtons:roomInfo];
if (roomInfo.type == RoomType_Anchor || roomInfo.roomModeType == RoomModeType_Open_Blind) {
self.pkMenuButton.hidden = YES;
} else {
self.pkMenuButton.hidden = NO;
}
if (roomInfo.roomModeType != RoomModeType_Open_PK_Mode) {
[self.pkMenuButton removeFromSuperview];
[self.stackView insertArrangedSubview:self.gambleMenuButton atIndex:0];
} else {
[self.gambleMenuButton removeFromSuperview];
[self.stackView addArrangedSubview:self.pkMenuButton];
}
self.redPacketView.type = roomInfo.type;
if (roomInfo.type == RoomType_MiniGame) {
self.redPacketView.hidden = YES;
[self.pi_cycleScrollView removeFromSuperview];
[self.stackView addArrangedSubview:self.pi_cycleScrollView];
[self.gambleMenuButton bringSubviewToFront:self.stackView];
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
[self requestActivityList];
}
} else {
[self.gambleMenuButton removeFromSuperview];
[self.pi_cycleScrollView removeFromSuperview];
[self.stackView insertArrangedSubview:self.pi_cycleScrollView atIndex:0];
[self.stackView addArrangedSubview:self.gambleMenuButton];
self.redPacketView.redPacketList = self.redPacketList;
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
[picArray addObject:model.icon];
}
self.pi_cycleScrollView.imageURLStringsGroup = picArray;
if (self.activityList.count > 1) {
[self.pi_cycleScrollView setAutoScroll:YES];
self.pi_cycleScrollView.autoScrollTimeInterval = 3;
} else {
[self.pi_cycleScrollView setAutoScroll:NO];
}
if (roomInfo.roomModeType == RoomModeType_Open_Blind || roomInfo.roomModeType == RoomModeType_Open_PK_Mode || roomInfo.roomModeType == RoomModeType_Open_Micro_Mode) {
if (roomInfo.roomModeType == RoomModeType_Open_PK_Mode ) {
self.joinDatingView.image = [UIImage getLanguageImage:@"room_pk_normal_member_enter"];
} else {
self.joinDatingView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
request.userIds = @[[AccountInfoStorage instance].getUid];
@kWeakify(self);
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
@kStrongify(self);
if (error == nil) {
NIMChatroomMember * member = members.firstObject;
if (member.type == NIMTeamMemberTypeOwner || member.type == NIMTeamMemberTypeManager) {
self.joinDatingView.hidden = YES;
return;
}
}
self.joinDatingView.hidden = NO;
}];
} else {
self.joinDatingView.hidden = YES;
}
}
if(self.openRedPacketHandle){
self.openRedPacketHandle(nil,self.hostDelegate.getRoomInfo.type,YES);
}
}
- (void)onRoomEntered {
[self onRoomUpdate];
}
- (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];
}
}
}
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject;
NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content;
switch (content.eventType) {
case NIMChatroomEventTypeAddManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = YES;
break;
}
}
}
}
break;
case NIMChatroomEventTypeRemoveManager:
{
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_Blind || self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode) {
for (NIMChatroomNotificationMember * member in content.targets) {
if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) {
self.joinDatingView.hidden = NO;
break;
}
}
}
}
break;
default:
break;
}
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
if (imageUrlList.count > index) {
NSString *pic = imageUrlList[index];
NSMutableArray *inftList = [NSMutableArray array];
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
[self jumpPlayActionWithIndex:index imageUrlList:imageUrlList];
return;
}
ActivityInfoModel * info;
for (ActivityInfoModel * getInfo in self.activityList) {
if([getInfo.icon isEqualToString:pic]){
info = getInfo;
}
if(getInfo.skipType == 3 ){
[inftList addObject:getInfo];
}
}
if(info == nil)return;
if([info.code isEqualToString:@"FIRST_CHARGE"]) {
[self firstRechargeTapRecognizer];
}else if ([info.code isEqualToString:@"FIND_LOVE"]) {
[self lookLoveTapRecognizer];
} else if([info.code isEqualToString:@"NAUTICAL_ADVENTURE"]) {
[self sailTapRecognizer];
}else if([info.code isEqualToString:@"SEIZE_TREASURE"]){
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
fairyVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:fairyVC];
// [fairyVC.navigationController setNavigationBarHidden:YES animated:NO];
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:fairyVC.view];
[UIView animateWithDuration:0.2 animations:^{
fairyVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
}];
}else {
if (info.skipType == ActivitySkipType_Room) {
[self.hostDelegate exitRoom];
[XPRoomViewController openRoom:info.skipContent viewController:kWindow.rootViewController];
} else if(info.skipType == ActivitySkipType_Web) {
PIRoomActivityWebView * webView = [[PIRoomActivityWebView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webView.url = info.skipContent;
webView.infoList = inftList;
[kWindow addSubview:webView];
[UIView animateWithDuration:0.2 animations:^{
webView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}];
}
}
}
}
-(void)jumpPlayActionWithIndex:(NSInteger)index imageUrlList:(NSArray *)imageUrlList{
if (imageUrlList.count > index) {
NSString *pic = imageUrlList[index];
NSMutableArray *inftList = [NSMutableArray array];
NSMutableArray *modelList = [NSMutableArray array];
[modelList addObjectsFromArray:self.activityList];
ActivityInfoModel * info;
for (int i = 0 ; i < modelList.count; i++) {
ActivityInfoModel * getInfo = modelList[i];
if([getInfo.icon isEqualToString:pic]){
info = getInfo;
}
if(getInfo.skipType == 3){
[inftList addObject:getInfo];
}
}
if(info == nil)return;
if([info.code isEqualToString:@"FIRST_CHARGE"]) {
[self firstRechargeTapRecognizer];
}else if ([info.code isEqualToString:@"FIND_LOVE"]) {
[self lookLoveTapRecognizer];
} else if([info.code isEqualToString:@"NAUTICAL_ADVENTURE"]) {
[self sailTapRecognizer];
}else if([info.code isEqualToString:@"SEIZE_TREASURE"]){
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
fairyVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:fairyVC];
[fairyVC.navigationController setNavigationBarHidden:YES animated:NO];
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:fairyVC.view];
[UIView animateWithDuration:0.2 animations:^{
fairyVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
}];
}else {
// if(index < self.playList.count){
// if(info.showType == ActivityShowType_Half){
// XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
// webView.isPlayView = YES;
// webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
// webView.url = info.skipContent;
// [TTPopup popupView:webView style:TTPopupStyleActionSheet];
// return;
// }
// XPWebViewController * webVC = [[XPWebViewController alloc] init];
// webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
// webVC.url = info.skipContent;
// [self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
// return;
// }
if (info.skipType == ActivitySkipType_Room) {
[self.hostDelegate exitRoom];
[XPRoomViewController openRoom:info.skipContent viewController:kWindow.rootViewController];
} else if(info.skipType == ActivitySkipType_Web) {
PIRoomActivityWebView * webView = [[PIRoomActivityWebView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webView.url = info.skipContent;
webView.infoList = inftList;
[kWindow addSubview:webView];
[UIView animateWithDuration:0.2 animations:^{
webView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}];
}
}
}
}
#pragma mark - Event Response
- (void)lookLoveTapRecognizer {
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
candyTreeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:candyTreeVC.view];
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:candyTreeVC];
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
[UIView animateWithDuration:0.1 animations:^{
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
}];
}
- (void)firstRechargeTapRecognizer {
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:nil];
}
- (void)didTapJoinDatingRecognizer {
if (self.hostDelegate.getRoomInfo.roomModeType == RoomModeType_Open_PK_Mode && self.hostDelegate.isRoomPKPlaying) {
[XNDJTDDLoadingTool showErrorWithMessage:YMLocalizedString(@"XPRoomActivityContainerView2")];
return;
}
NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init];
request.roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.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;
}
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
XPArrangeMicInfoModel * info = [[XPArrangeMicInfoModel alloc] init];
info.roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid];
info.roomId = [NSString stringWithFormat:@"%ld", roomInfo.roomId];
info.nick = roomInfo.nick;
info.roomAvatar = roomInfo.avatar;
info.roomTitle = roomInfo.title;
info.micQueue = [self.hostDelegate getMicroQueue];
info.isManager = (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager);
info.type = roomInfo.roomModeType == RoomModeType_Open_Blind ? ArrangeMicType_Dating : roomInfo.roomModeType == RoomModeType_Open_PK_Mode ? ArrangeMicType_Room_PK : ArrangeMicType_Normal;
XPArrangeMicViewController * arrangeMicVC = [[XPArrangeMicViewController alloc] initWithInfo:info];
[self.hostDelegate.getCurrentNav presentViewController:arrangeMicVC animated:YES completion:nil];
}];
}
- (void)sailTapRecognizer {
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
}
- (void)didTapGameMenuButton {
MSRoomMenuGameVC *vc = [[MSRoomMenuGameVC alloc] initWithDelegate:self.hostDelegate roomMenuType:MSRoomMenuTypeGame];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:vc animated:YES completion:nil];
}
- (void)didTapConfigEntranceButton {
RoomInfoModel *roomInfo = self.hostDelegate.getRoomInfo;
RoomBottomEntranceModel *model = roomInfo.rightBottomIconConfig;
if (!model) {
return;
}
if (model.skipUrl.length == 0) {
return;
}
switch (model.skipType) {
case 1: {
XPWebViewController *vc = [[XPWebViewController alloc]init];
vc.url = model.skipUrl;
[self.hostDelegate.getCurrentNav pushViewController:vc animated:YES];
}
break;
case 2: {
if ([self.hostDelegate isKindOfClass:[XPRoomViewController class]]){
ActivityInfoModel *activityModel = [[ActivityInfoModel alloc] init];
activityModel.skipContent = model.skipUrl;
activityModel.skipType = ActivitySkipType_Web;
activityModel.showType = 1;
activityModel.code = @"BAISHUN";
activityModel.ruleValue = model.reserve;
if (activityModel.gameModel) {
MSRoomGameWebVC *vc = [[MSRoomGameWebVC alloc] initWithDelegate:self.hostDelegate
gameModel:activityModel];
vc.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
XPRoomViewController *roomVC = (XPRoomViewController *)self.hostDelegate;
[roomVC addChildViewController:vc];
XPRoomAnimationView *animationView;
for (id obj in self.hostDelegate.getSuperView.subviews) {
if ([obj isKindOfClass:[XPRoomAnimationView class]]){
animationView = obj;
break;
}
}
[self.hostDelegate.getSuperView addSubview:vc.view];
[self.hostDelegate.getSuperView bringSubviewToFront:animationView];
}
}
}
default:
break;
}
}
- (void)didTapPKMenuButton {
[self.hostDelegate showPKPanel];
}
#pragma mark- PIRoomEnterRedPacketViewDelegate
-(void)openRedPacketWithModel:(XPRedPacketModel *)redModel{
if(self.openRedPacketHandle){
self.openRedPacketHandle(redModel,self.hostDelegate.getRoomInfo.type,NO);
}
}
-(void)clickPlayTypeWithModel:(ActivityInfoModel *)model{
if ([model.code isEqualToString:@"FIND_LOVE"]) {
[self lookLoveTapRecognizer];
} else if([model.code isEqualToString:@"NAUTICAL_ADVENTURE"]) {
[self sailTapRecognizer];
}else if([model.code isEqualToString:@"SEIZE_TREASURE"]){
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
fairyVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:fairyVC];
[fairyVC.navigationController setNavigationBarHidden:YES animated:NO];
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:fairyVC.view];
[UIView animateWithDuration:0.2 animations:^{
fairyVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
}];
} else if(model.skipType == ActivitySkipType_Web) {
if(model.showType == ActivityShowType_Half){
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
webView.isPlayView = YES;
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webView.url = model.skipContent;
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
return;
}
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
webVC.url = model.skipContent;
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
}
}
#pragma mark - Getters And Setters
- (SDCycleScrollView *)pi_cycleScrollView {
if (!_pi_cycleScrollView) {
_pi_cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:self placeholderImage:nil];
_pi_cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
_pi_cycleScrollView.currentPageDotColor = [UIColor whiteColor];
_pi_cycleScrollView.pageDotColor = [UIColor colorWithWhite:1 alpha:0.2];
_pi_cycleScrollView.pageControlDotSize = CGSizeMake(5, 2);
_pi_cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
_pi_cycleScrollView.currentPageDotImage = [UIImage imageNamed:@"room_activity_banner_select"];
_pi_cycleScrollView.pageDotImage = [UIImage imageNamed:@"room_activity_banner_normal"];
_pi_cycleScrollView.backgroundColor = [UIColor colorWithWhite:1 alpha:0.00];
_pi_cycleScrollView.bannerImageViewContentMode = UIViewContentModeScaleAspectFit;
_pi_cycleScrollView.pageControlBottomOffset = -10;
_pi_cycleScrollView.hidden = YES;
// SDCycleScrollView没有适配阿语在RTL下会乱滚都用LTR算了
_pi_cycleScrollView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
for (UIView *subView in _pi_cycleScrollView.subviews) {
subView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
}
return _pi_cycleScrollView;
}
- (UIStackView *)stackView {
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
_stackView.spacing = 0;
}
return _stackView;
}
- (UIImageView *)joinDatingView {
if (!_joinDatingView) {
_joinDatingView = [[UIImageView alloc] init];
_joinDatingView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
_joinDatingView.userInteractionEnabled = YES;
_joinDatingView.hidden = YES;
_joinDatingView.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapJoinDatingRecognizer)];
[_joinDatingView addGestureRecognizer:tap];
}
return _joinDatingView;
}
- (NSMutableArray<ActivityInfoModel *> *)activityList {
if (!_activityList) {
_activityList = [NSMutableArray array];
}
return _activityList;
}
- (PIRoomEnterRedPacketView *)redPacketView{
if(!_redPacketView){
_redPacketView = [[PIRoomEnterRedPacketView alloc]initWithFrame:CGRectZero];
_redPacketView.hidden = YES;
_redPacketView.delegate = self;
}
return _redPacketView;
}
- (UIButton *)gambleMenuButton {
if (!_gambleMenuButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[UIImage imageNamed:@"ms_room_game_button"] forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapGameMenuButton) forControlEvents:UIControlEventTouchUpInside];
b.imageView.contentMode = UIViewContentModeScaleAspectFit;
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
b.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
b.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
b.hidden = YES;
_gambleMenuButton = b;
}
return _gambleMenuButton;
}
- (UIButton *)configEntranceMenuButton {
if (!_configEntranceMenuButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[UIImage imageNamed:@"ms_room_game_add_coin"] forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapConfigEntranceButton) forControlEvents:UIControlEventTouchUpInside];
b.imageView.contentMode = UIViewContentModeScaleAspectFit;
b.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
b.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;
b.imageEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
b.hidden = YES;
_configEntranceMenuButton = b;
}
return _configEntranceMenuButton;
}
- (UIButton *)pkMenuButton {
if (!_pkMenuButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[UIImage imageNamed:@"room_pk_panel_mini_icon"] forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapPKMenuButton) forControlEvents:UIControlEventTouchUpInside];
b.imageView.contentMode = UIViewContentModeScaleAspectFill;
b.hidden = YES;
_pkMenuButton = b;
}
return _pkMenuButton;
}
@end