Files
peko-ios/YuMi/Modules/YMRoom/View/ActivityContainerView/XPRoomActivityContainerView.m
eggmanQQQ 34c70c1e76 处理需求 #64
1. /miniGame/record/miniGameList 补充参数 roomUid
2024-06-03 14:59:42 +08:00

688 lines
29 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 "PIRoomActivityClickView.h"
#import "PIRoomActivityChoosePlayView.h"
#import "MSRoomMenuGameVC.h"
UIKIT_EXTERN NSString *kShowFirstRechargeView;
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate,PIRoomEnterRedPacketViewDelegate,PIRoomActivityClickViewDelegate,PIRoomActivityChoosePlayViewDelegate>
///容器
@property (nonatomic,strong) UIStackView *stackView;
///轮播图
@property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView;
///红包
@property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView;
///游戏菜单按钮
@property(nonatomic, strong) UIButton *gameMenuButton;
///参加相亲
@property (nonatomic,strong) UIImageView *joinDatingView;
///host 代理
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
///房间活动的列表
@property (nonatomic,strong) NSMutableArray<ActivityInfoModel *> *activityList;
///是否加载了活动
@property (nonatomic,assign) BOOL isLoadActivity;
@property(nonatomic,assign) BOOL isShowChoosePlayView;
@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.gameMenuButton];
}
- (void)initSubViewConstraints {
[self.stackView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.mas_equalTo(self);
}];
CGFloat itemWidth = KScreenHeight > 667 ? 65 : 55 * kScreenHeightScale;
[self.pi_cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth));
}];
[self.redPacketView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(58));
}];
[self.gameMenuButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.leading.mas_equalTo(0);
make.size.mas_equalTo(CGSizeMake(76, 76));
}];
[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];
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_Anchor) {
[self.gameMenuButton removeFromSuperview];
} else {
self.gameMenuButton.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)onRoomUpdate {
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
self.redPacketView.type = roomInfo.type;
if (roomInfo.type == RoomType_MiniGame) {
if(self.isShowChoosePlayView == YES){
PIRoomActivityChoosePlayView *choosePlayView = [self.hostDelegate.getSuperView viewWithTag:98021];
self.isShowChoosePlayView = NO;
CGFloat y = self.frame.size.height + self.frame.origin.y - 124;
[UIView animateWithDuration:0.1 animations:^{
choosePlayView.frame = CGRectMake(KScreenWidth, y, 201, 124);
}completion:^(BOOL finished) {
[choosePlayView removeFromSuperview];
}];
}
self.redPacketView.hidden = YES;
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
[self requestActivityList];
}
} else {
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];
[[NIMSDK sharedSDK].chatroomManager fetchChatroomMembersByIds:request completion:^(NSError * _Nullable error, NSArray<NIMChatroomMember *> * _Nullable members) {
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:MSRoomMenuTypeLittleGame];
vc.modalPresentationStyle = UIModalPresentationOverFullScreen;
[self.hostDelegate.getCurrentNav presentViewController:vc animated:YES completion:nil];
}
#pragma mark- PIRoomEnterRedPacketViewDelegate
-(void)openRedPacketWithModel:(XPRedPacketModel *)redModel{
if(self.openRedPacketHandle){
self.openRedPacketHandle(redModel,self.hostDelegate.getRoomInfo.type,NO);
}
}
#pragma mark - PIRoomActivityClickViewDelegate
- (void)showChoosePlayViewAction{
// self.isShowChoosePlayView = YES;
PIRoomActivityChoosePlayView *choosePlayView = [[PIRoomActivityChoosePlayView alloc]initWithFrame:CGRectZero];
choosePlayView.delegate = self;
CGFloat y = self.frame.size.height + self.frame.origin.y - 124;
choosePlayView.tag = 98021;
[self.hostDelegate.getSuperView addSubview:choosePlayView];
choosePlayView.frame = isMSRTL() ? CGRectMake(-201, y, 201, 124) : CGRectMake(KScreenWidth, y, 201, 124);
[UIView animateWithDuration:0.1 animations:^{
choosePlayView.frame = isMSRTL() ? CGRectMake(15, y, 201, 124) : CGRectMake(KScreenWidth - 201, y, 201, 124);
}];
}
-(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- PIRoomActivityChoosePlayViewDelegate
-(void)choosePlayTypeWithView:(PIRoomActivityChoosePlayView *)view model:(ActivityInfoModel *)model{
[self clickPlayTypeWithModel:model];
}
-(void)hiddenViewActionWithView:(PIRoomActivityChoosePlayView *)view{
self.isShowChoosePlayView = NO;
CGFloat y = self.frame.size.height + self.frame.origin.y - 124;
[UIView animateWithDuration:0.1 animations:^{
view.frame = isMSRTL() ? CGRectMake(-201, y, 201, 124) : CGRectMake(KScreenWidth, y, 201, 124);
}completion:^(BOOL finished) {
[view removeFromSuperview];
}];
}
#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 *)gameMenuButton {
if (!_gameMenuButton) {
UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];
[b setImage:[UIImage imageNamed:@"ms_room_game_button"] forState:UIControlStateNormal];
[b addTarget:self action:@selector(didTapGameMenuButton) forControlEvents:UIControlEventTouchUpInside];
b.hidden = YES;
_gameMenuButton = b;
}
return _gameMenuButton;
}
@end