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

705 lines
29 KiB
Mathematica
Raw Normal View History

2023-07-14 18:50:55 +08:00
//
// XPRoomActivityView.m
2023-08-10 10:12:19 +08:00
// xplan-ios
2023-07-14 18:50:55 +08:00
//
2023-08-10 10:12:19 +08:00
// Created by on 2021/10/12.
2023-07-14 18:50:55 +08:00
//
#import "XPRoomActivityContainerView.h"
2024-02-21 10:18:59 +08:00
#import <ReactiveObjC/ReactiveObjC.h>
2023-07-14 18:50:55 +08:00
///Third
#import <Masonry/Masonry.h>
#import <SDCycleScrollView/SDCycleScrollView.h>
///Tool
#import "AccountInfoStorage.h"
#import "Api+Room.h"
2023-08-10 10:12:19 +08:00
#import "Api+TreasureFairy.h"
2023-07-14 18:50:55 +08:00
#import "ClientConfig.h"
#import "NetImageView.h"
#import "TTPopup.h"
2023-08-10 10:12:19 +08:00
2023-07-14 18:50:55 +08:00
///Model
#import "UserInfoModel.h"
#import "RoomInfoModel.h"
2024-04-30 19:30:11 +08:00
2023-07-14 18:50:55 +08:00
#import "AttachmentModel.h"
#import "FirstRechargeModel.h"
2023-08-10 10:12:19 +08:00
#import "TreasureFairyLimitModel.h"
2023-10-27 16:17:05 +08:00
#import "XPRedPacketResultModel.h"
2023-07-14 18:50:55 +08:00
///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"
2023-08-10 10:12:19 +08:00
#import "XPTreasureFairyViewController.h"
2023-10-20 19:30:20 +08:00
#import "PIRoomEnterRedPacketView.h"
2023-10-24 19:01:30 +08:00
#import "BaseNavigationController.h"
2023-11-15 16:49:59 +08:00
#import "PIRoomActivityWebView.h"
2024-02-21 10:18:59 +08:00
#import "PIRoomActivityClickView.h"
#import "PIRoomActivityChoosePlayView.h"
2023-07-14 18:50:55 +08:00
UIKIT_EXTERN NSString *kShowFirstRechargeView;
2024-02-21 10:18:59 +08:00
@interface XPRoomActivityContainerView ()<SDCycleScrollViewDelegate,PIRoomEnterRedPacketViewDelegate,PIRoomActivityClickViewDelegate,PIRoomActivityChoosePlayViewDelegate>
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) UIStackView *stackView;
///
@property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView;
2023-10-20 19:30:20 +08:00
///
@property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView;
2024-02-21 10:18:59 +08:00
///
@property(nonatomic,strong) PIRoomActivityClickView *clickPlayView;
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,strong) UIImageView *joinDatingView;
///host
@property (nonatomic,weak) id<RoomHostDelegate>hostDelegate;
///
2024-02-21 10:18:59 +08:00
@property (nonatomic,strong) NSMutableArray<ActivityInfoModel *> *activityList;
2023-07-14 18:50:55 +08:00
///
@property (nonatomic,assign) BOOL isLoadActivity;
2024-02-21 17:22:50 +08:00
@property(nonatomic,assign) BOOL isShowChoosePlayView;
2023-07-14 18:50:55 +08:00
@end
@implementation XPRoomActivityContainerView
2023-10-25 19:26:20 +08:00
-(void)dealloc{
[[NSNotificationCenter defaultCenter]removeObserver:self];
}
2023-07-14 18:50:55 +08:00
- (instancetype)initWithdelegate:(id<RoomHostDelegate>)delegate {
2023-08-10 10:12:19 +08:00
self = [super init];
if (self) {
self.hostDelegate = delegate;
[self initSubViews];
[self initSubViewConstraints];
[self requestActivityList];
2024-02-21 10:18:59 +08:00
2023-08-10 10:12:19 +08:00
}
return self;
2023-07-14 18:50:55 +08:00
}
#pragma mark - Private Method
- (void)initSubViews {
2023-08-10 10:12:19 +08:00
[self addSubview:self.stackView];
2023-10-20 19:30:20 +08:00
UIView *emptyView = [UIView new];
[self.stackView addArrangedSubview:self.pi_cycleScrollView];
2023-10-20 19:30:20 +08:00
[self.stackView addArrangedSubview:emptyView];
[self.stackView addArrangedSubview:self.redPacketView];
2023-08-10 10:12:19 +08:00
[self.stackView addArrangedSubview:self.joinDatingView];
2024-02-21 10:18:59 +08:00
[self.stackView addArrangedSubview:self.clickPlayView];
2024-02-21 17:22:50 +08:00
2023-10-30 14:38:33 +08:00
2023-10-25 19:26:20 +08:00
}
2023-10-27 18:28:50 +08:00
2023-07-14 18:50:55 +08:00
- (void)initSubViewConstraints {
2023-08-10 10:12:19 +08:00
[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) {
2023-08-10 10:12:19 +08:00
make.size.mas_equalTo(CGSizeMake(itemWidth , itemWidth));
}];
2023-10-20 19:30:20 +08:00
[self.redPacketView mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(kGetScaleWidth(58));
2023-08-10 10:12:19 +08:00
}];
2023-10-20 19:30:20 +08:00
2023-08-10 10:12:19 +08:00
2024-02-21 10:18:59 +08:00
[self.clickPlayView mas_makeConstraints:^(MASConstraintMaker *make) {
2024-04-11 17:05:27 +08:00
make.leading.mas_equalTo(0);
2024-02-21 10:18:59 +08:00
make.size.mas_equalTo(CGSizeMake(81, 66));
2023-08-10 10:12:19 +08:00
}];
[self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) {
2024-02-21 10:18:59 +08:00
make.height.mas_equalTo(35 * kScreenHeightScale);
2023-08-10 10:12:19 +08:00
}];
2023-07-14 18:50:55 +08:00
}
- (void)requestActivityList {
2023-08-10 10:12:19 +08:00
2024-02-21 10:18:59 +08:00
RACSubject* list = [RACSubject subject];
RACSubject* play = [RACSubject subject];
[[RACSignal combineLatest:@[list, play] reduce:^id(NSArray<ActivityInfoModel*> * listModel, NSArray<ActivityInfoModel*> * playModel){
self.activityList = [NSMutableArray arrayWithArray:listModel];
self.playList = [NSMutableArray arrayWithArray:playModel];
[self dealWithData];
return nil;
}] subscribeError:^(NSError * _Nullable error) {
}];
2023-08-10 10:12:19 +08:00
NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId];
[Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
2024-02-21 10:18:59 +08:00
[list sendNext:array];
[list sendCompleted];
return;
2023-08-10 10:12:19 +08:00
}
2024-02-21 10:18:59 +08:00
[list sendError:nil];
} roomId:roomId];
2023-08-10 10:12:19 +08:00
2024-02-21 10:18:59 +08:00
[Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
if (code == 200) {
NSArray <ActivityInfoModel *>* array = [ActivityInfoModel modelsWithArray:data.data];
[play sendNext:array];
[play sendCompleted];
return;
}
[play sendError:nil];
} roomId:roomId];
2023-08-10 10:12:19 +08:00
2023-07-14 18:50:55 +08:00
}
2024-02-21 10:18:59 +08:00
-(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];
2023-08-10 10:12:19 +08:00
}
2024-02-21 10:18:59 +08:00
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];
2023-08-10 10:12:19 +08:00
}
2024-02-21 17:22:50 +08:00
2024-02-21 10:18:59 +08:00
if(self.playList.count > 0){
ActivityInfoModel *playModel = self.playList.firstObject;
self.clickPlayView.model = playModel;
2024-04-30 19:30:11 +08:00
// if(self.isShowChoosePlayView == NO){
// self.clickPlayView.hidden = NO;
// }
2024-02-21 10:18:59 +08:00
}else{
self.clickPlayView.hidden = YES;
2023-08-10 10:12:19 +08:00
}
}
2023-07-14 18:50:55 +08:00
}
2024-02-21 10:18:59 +08:00
2023-08-10 10:12:19 +08:00
- (void)configLittleGameActivity {
2024-02-21 10:18:59 +08:00
NSMutableArray *list = [NSMutableArray array];
2024-04-30 19:30:11 +08:00
2024-02-21 10:18:59 +08:00
[list addObjectsFromArray:self.activityList];
2023-08-10 10:12:19 +08:00
NSMutableArray *picArray = [NSMutableArray array];
2024-02-21 10:18:59 +08:00
for (ActivityInfoModel *model in list) {
2024-04-30 19:30:11 +08:00
[picArray addObject:model.icon ?: @""];
2023-08-10 10:12:19 +08:00
}
self.pi_cycleScrollView.imageURLStringsGroup = picArray;
2023-08-10 10:12:19 +08:00
if (self.activityList.count > 1) {
[self.pi_cycleScrollView setAutoScroll:YES];
self.pi_cycleScrollView.autoScrollTimeInterval = 3;
2023-08-10 10:12:19 +08:00
}else{
[self.pi_cycleScrollView setAutoScroll:NO];
2023-08-10 10:12:19 +08:00
}
2023-07-14 18:50:55 +08:00
}
2023-10-27 16:17:05 +08:00
- (void)setRedPacketList:(NSMutableArray *)redPacketList{
_redPacketList = redPacketList;
2023-10-30 14:38:33 +08:00
self.redPacketView.redPacketList = redPacketList;
if(self.openRedPacketHandle){
self.openRedPacketHandle(nil,self.hostDelegate.getRoomInfo.type,YES);
2023-10-27 16:17:05 +08:00
}
2023-10-25 19:26:20 +08:00
}
2023-07-14 18:50:55 +08:00
#pragma mark - RoomGuestDelegat
- (void)onRoomUpdate {
2023-08-10 10:12:19 +08:00
RoomInfoModel * roomInfo = self.hostDelegate.getRoomInfo;
2023-10-30 14:38:33 +08:00
self.redPacketView.type = roomInfo.type;
2023-08-10 10:12:19 +08:00
if (roomInfo.type == RoomType_MiniGame) {
2024-02-21 17:22:50 +08:00
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];
}];
}
2023-10-30 14:38:33 +08:00
self.redPacketView.hidden = YES;
2024-02-21 10:18:59 +08:00
self.clickPlayView.hidden = YES;
2024-02-21 17:22:50 +08:00
2023-08-10 10:12:19 +08:00
if (self.isLoadActivity) {
[self configLittleGameActivity];
} else {
[self requestActivityList];
}
} else {
2023-10-30 14:38:33 +08:00
self.redPacketView.redPacketList = self.redPacketList;
2023-08-10 10:12:19 +08:00
NSMutableArray *picArray = [NSMutableArray array];
for (ActivityInfoModel *model in self.activityList) {
2024-02-21 10:18:59 +08:00
[picArray addObject:model.icon];
2023-08-10 10:12:19 +08:00
}
self.pi_cycleScrollView.imageURLStringsGroup = picArray;
2023-08-10 10:12:19 +08:00
if (self.activityList.count > 1) {
[self.pi_cycleScrollView setAutoScroll:YES];
self.pi_cycleScrollView.autoScrollTimeInterval = 3;
2023-08-10 10:12:19 +08:00
} else {
[self.pi_cycleScrollView setAutoScroll:NO];
2023-08-10 10:12:19 +08:00
}
2024-02-21 17:22:50 +08:00
2024-02-21 10:18:59 +08:00
if(self.playList.count > 0){
ActivityInfoModel *playModel = self.playList.firstObject;
self.clickPlayView.model = playModel;
2024-04-30 19:30:11 +08:00
// if(self.isShowChoosePlayView == NO){
// self.clickPlayView.hidden = NO;
// }
2024-02-21 10:18:59 +08:00
}else{
self.clickPlayView.hidden = YES;
}
2023-08-10 10:12:19 +08:00
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 ) {
2024-04-08 18:55:15 +08:00
self.joinDatingView.image = [UIImage getLanguageImage:@"room_pk_normal_member_enter"];
2023-08-10 10:12:19 +08:00
} else {
2024-04-08 18:55:15 +08:00
self.joinDatingView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
2023-08-10 10:12:19 +08:00
}
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;
}
2024-02-21 17:22:50 +08:00
2023-08-10 10:12:19 +08:00
}
2023-10-30 14:38:33 +08:00
if(self.openRedPacketHandle){
self.openRedPacketHandle(nil,self.hostDelegate.getRoomInfo.type,YES);
}
2023-07-14 18:50:55 +08:00
}
- (void)onRoomEntered {
2023-08-10 10:12:19 +08:00
[self onRoomUpdate];
2023-07-14 18:50:55 +08:00
}
- (void)handleNIMCustomMessage:(NIMMessage *)message {
2023-08-10 10:12:19 +08:00
NIMCustomObject *obj = (NIMCustomObject *)message.messageObject;
if (obj.attachment != nil && [obj.attachment isKindOfClass:[AttachmentModel class]]) {
AttachmentModel *attachment = (AttachmentModel *)obj.attachment;
if (attachment.first == CustomMessageType_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];
}
}
2023-07-14 18:50:55 +08:00
}
- (void)handleNIMNotificationMessage:(NIMMessage *)message {
2023-08-10 10:12:19 +08:00
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;
}
2023-07-14 18:50:55 +08:00
}
#pragma mark - SDCycleScrollViewDelegate
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index {
2023-08-10 10:12:19 +08:00
NSArray *imageUrlList = cycleScrollView.imageURLStringsGroup;
if (imageUrlList.count > index) {
NSString *pic = imageUrlList[index];
2023-11-15 16:49:59 +08:00
NSMutableArray *inftList = [NSMutableArray array];
2024-02-21 10:18:59 +08:00
if (self.hostDelegate.getRoomInfo.type == RoomType_MiniGame) {
2024-02-21 17:22:50 +08:00
[self jumpPlayActionWithIndex:index imageUrlList:imageUrlList];
return;
2024-02-21 10:18:59 +08:00
}
2023-08-10 10:12:19 +08:00
ActivityInfoModel * info;
2024-02-21 17:22:50 +08:00
for (ActivityInfoModel * getInfo in self.activityList) {
2024-02-21 10:18:59 +08:00
if([getInfo.icon isEqualToString:pic]){
2023-08-10 10:12:19 +08:00
info = getInfo;
2023-11-15 16:49:59 +08:00
}
2024-02-21 17:22:50 +08:00
if(getInfo.skipType == 3 ){
2023-11-15 16:49:59 +08:00
[inftList addObject:getInfo];
2023-08-10 10:12:19 +08:00
}
}
if(info == nil)return;
2024-02-21 10:18:59 +08:00
if([info.code isEqualToString:@"FIRST_CHARGE"]) {
2023-08-10 10:12:19 +08:00
[self firstRechargeTapRecognizer];
2024-02-21 10:18:59 +08:00
}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"]){
2023-08-10 10:12:19 +08:00
XPTreasureFairyViewController * fairyVC = [[XPTreasureFairyViewController alloc] initWithdelegate:self.hostDelegate];
fairyVC.roomUid =[NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
2023-10-24 19:01:30 +08:00
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) {
}];
2023-08-10 10:12:19 +08:00
}else {
if (info.skipType == ActivitySkipType_Room) {
[self.hostDelegate exitRoom];
2023-11-23 10:56:01 +08:00
2024-02-21 10:51:08 +08:00
[XPRoomViewController openRoom:info.skipContent viewController:kWindow.rootViewController];
2023-11-23 10:56:01 +08:00
2023-08-10 10:12:19 +08:00
} else if(info.skipType == ActivitySkipType_Web) {
2024-02-21 10:18:59 +08:00
PIRoomActivityWebView * webView = [[PIRoomActivityWebView alloc]initWithFrame:CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight)];
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
2024-02-21 10:51:08 +08:00
webView.url = info.skipContent;
2024-02-21 10:18:59 +08:00
webView.infoList = inftList;
[kWindow addSubview:webView];
[UIView animateWithDuration:0.2 animations:^{
webView.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}];
2023-11-15 16:49:59 +08:00
2023-08-10 10:12:19 +08:00
}
}
}
2023-07-14 18:50:55 +08:00
}
2024-02-21 17:22:50 +08:00
-(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.playList];
[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 && i > self.playList.count){
[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];
2024-02-22 15:58:48 +08:00
webView.isPlayView = YES;
2024-02-21 17:22:50 +08:00
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);
}];
}
}
}
}
2023-07-14 18:50:55 +08:00
#pragma mark - Event Response
- (void)lookLoveTapRecognizer {
2023-08-10 10:12:19 +08:00
XPCandyTreeViewController * candyTreeVC = [[XPCandyTreeViewController alloc] initWithDelegate:self.hostDelegate];
2024-04-21 14:03:57 +08:00
candyTreeVC.view.frame = CGRectMake(0, KScreenHeight, KScreenWidth, KScreenHeight);
[[XCCurrentVCStackManager shareManager].getCurrentVC.view addSubview:candyTreeVC.view];
2023-08-10 10:12:19 +08:00
[[XCCurrentVCStackManager shareManager].getCurrentVC addChildViewController:candyTreeVC];
[candyTreeVC.navigationController setNavigationBarHidden:YES animated:NO];
2024-04-21 14:03:57 +08:00
[UIView animateWithDuration:0.1 animations:^{
candyTreeVC.view.frame = CGRectMake(0, 0, KScreenWidth, KScreenHeight);
}completion:^(BOOL finished) {
2024-04-24 20:08:24 +08:00
2024-04-21 14:03:57 +08:00
}];
2023-07-14 18:50:55 +08:00
}
- (void)firstRechargeTapRecognizer {
2023-08-10 10:12:19 +08:00
[[NSNotificationCenter defaultCenter]postNotificationName:kShowFirstRechargeView object:nil];
2023-07-14 18:50:55 +08:00
}
- (void)didTapJoinDatingRecognizer {
2023-08-10 10:12:19 +08:00
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];
}];
2023-07-14 18:50:55 +08:00
}
- (void)sailTapRecognizer {
2023-08-10 10:12:19 +08:00
NSString * roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
XPSailingViewController * sailingVC = [[XPSailingViewController alloc] initWithRoomUid:roomUid];
[self.hostDelegate.getCurrentNav presentViewController:sailingVC animated:YES completion:nil];
2023-07-14 18:50:55 +08:00
}
2023-10-30 14:38:33 +08:00
#pragma mark- PIRoomEnterRedPacketViewDelegate
-(void)openRedPacketWtihModel:(XPRedPacketModel *)redModel{
if(self.openRedPacketHandle){
self.openRedPacketHandle(redModel,self.hostDelegate.getRoomInfo.type,NO);
}
2023-10-25 19:26:20 +08:00
}
2024-02-21 10:18:59 +08:00
#pragma mark - PIRoomActivityClickViewDelegate
- (void)showChoosePlayViewAction{
self.clickPlayView.hidden = YES;
2024-02-21 17:22:50 +08:00
self.isShowChoosePlayView = YES;
2024-02-21 10:18:59 +08:00
PIRoomActivityChoosePlayView *choosePlayView = [[PIRoomActivityChoosePlayView alloc]initWithFrame:CGRectZero];
choosePlayView.delegate = self;
choosePlayView.playList = self.playList;
CGFloat y = self.frame.size.height + self.frame.origin.y - 124;
2024-02-21 17:22:50 +08:00
choosePlayView.tag = 98021;
2024-02-21 10:18:59 +08:00
[self.hostDelegate.getSuperView addSubview:choosePlayView];
2024-04-18 18:37:21 +08:00
choosePlayView.frame = isMSRTL() ? CGRectMake(-201, y, 201, 124) : CGRectMake(KScreenWidth, y, 201, 124);
2024-02-21 10:18:59 +08:00
[UIView animateWithDuration:0.1 animations:^{
2024-04-18 18:37:21 +08:00
choosePlayView.frame = isMSRTL() ? CGRectMake(15, y, 201, 124) : CGRectMake(KScreenWidth - 201, y, 201, 124);
2024-02-21 10:18:59 +08:00
}];
}
-(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) {
2024-02-21 17:22:50 +08:00
if(model.showType == ActivityShowType_Half){
2024-02-21 10:18:59 +08:00
XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init];
2024-02-22 15:58:48 +08:00
webView.isPlayView = YES;
2024-02-21 10:18:59 +08:00
webView.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
2024-02-21 10:51:08 +08:00
webView.url = model.skipContent;
2024-02-21 10:18:59 +08:00
[TTPopup popupView:webView style:TTPopupStyleActionSheet];
return;
}
XPWebViewController * webVC = [[XPWebViewController alloc] init];
webVC.roomUid = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.uid];
2024-02-21 10:51:08 +08:00
webVC.url = model.skipContent;
2024-02-21 10:18:59 +08:00
[self.hostDelegate.getCurrentNav pushViewController:webVC animated:YES];
}
}
#pragma mark- PIRoomActivityChoosePlayViewDelegate
-(void)choosePlayTypeWithView:(PIRoomActivityChoosePlayView *)view model:(ActivityInfoModel *)model{
[self clickPlayTypeWithModel:model];
}
-(void)hiddenViewActionWithView:(PIRoomActivityChoosePlayView *)view{
2024-02-21 17:22:50 +08:00
self.isShowChoosePlayView = NO;
2024-02-21 10:18:59 +08:00
CGFloat y = self.frame.size.height + self.frame.origin.y - 124;
[UIView animateWithDuration:0.1 animations:^{
2024-04-18 18:37:21 +08:00
view.frame = isMSRTL() ? CGRectMake(-201, y, 201, 124) : CGRectMake(KScreenWidth, y, 201, 124);
2024-02-21 10:18:59 +08:00
}completion:^(BOOL finished) {
2024-04-30 19:30:11 +08:00
// self.clickPlayView.hidden = NO;
2024-02-21 10:18:59 +08:00
[view removeFromSuperview];
}];
}
2023-07-14 18:50:55 +08:00
#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];
2023-08-10 10:12:19 +08:00
_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;
2024-04-17 16:02:42 +08:00
// SDCycleScrollViewRTLLTR
_pi_cycleScrollView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
for (UIView *subView in _pi_cycleScrollView.subviews) {
subView.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
}
2023-08-10 10:12:19 +08:00
}
return _pi_cycleScrollView;
2023-07-14 18:50:55 +08:00
}
2023-10-20 19:30:20 +08:00
2023-07-14 18:50:55 +08:00
- (UIStackView *)stackView {
2023-08-10 10:12:19 +08:00
if (!_stackView) {
_stackView = [[UIStackView alloc] init];
_stackView.axis = UILayoutConstraintAxisVertical;
_stackView.distribution = UIStackViewDistributionFill;
_stackView.alignment = UIStackViewAlignmentCenter;
2023-10-25 19:26:20 +08:00
_stackView.spacing = 0;
2024-02-21 10:18:59 +08:00
2023-08-10 10:12:19 +08:00
}
return _stackView;
2023-07-14 18:50:55 +08:00
}
2023-10-20 19:30:20 +08:00
2023-07-14 18:50:55 +08:00
- (UIImageView *)joinDatingView {
2023-08-10 10:12:19 +08:00
if (!_joinDatingView) {
_joinDatingView = [[UIImageView alloc] init];
2024-04-08 18:55:15 +08:00
_joinDatingView.image = [UIImage getLanguageImage:@"room_mode_dating_enter"];
2023-08-10 10:12:19 +08:00
_joinDatingView.userInteractionEnabled = YES;
_joinDatingView.hidden = YES;
_joinDatingView.contentMode = UIViewContentModeScaleAspectFit;
UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(didTapJoinDatingRecognizer)];
[_joinDatingView addGestureRecognizer:tap];
}
return _joinDatingView;
2023-07-14 18:50:55 +08:00
}
- (NSMutableArray<ActivityInfoModel *> *)activityList {
2023-08-10 10:12:19 +08:00
if (!_activityList) {
_activityList = [NSMutableArray array];
}
return _activityList;
2023-07-14 18:50:55 +08:00
}
2024-02-21 17:22:50 +08:00
2024-02-21 10:18:59 +08:00
2023-10-20 19:30:20 +08:00
- (PIRoomEnterRedPacketView *)redPacketView{
if(!_redPacketView){
_redPacketView = [[PIRoomEnterRedPacketView alloc]initWithFrame:CGRectZero];
2023-10-25 19:26:20 +08:00
_redPacketView.hidden = YES;
2023-10-30 14:38:33 +08:00
_redPacketView.delegate = self;
2023-10-20 19:30:20 +08:00
}
return _redPacketView;
}
2024-02-21 10:18:59 +08:00
- (PIRoomActivityClickView *)clickPlayView{
if(!_clickPlayView){
_clickPlayView = [[PIRoomActivityClickView alloc]initWithFrame:CGRectZero];
_clickPlayView.hidden = YES;
_clickPlayView.delegate = self;
}
return _clickPlayView;
}
2023-07-14 18:50:55 +08:00
@end