// // XPRoomActivityView.m // xplan-ios // // Created by 冯硕 on 2021/10/12. // #import "XPRoomActivityContainerView.h" #import ///Third #import #import ///Tool #import "AccountInfoStorage.h" #import "Api+Room.h" #import "Api+TreasureFairy.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" UIKIT_EXTERN NSString *kShowFirstRechargeView; @interface XPRoomActivityContainerView () ///容器 @property (nonatomic,strong) UIStackView *stackView; ///轮播图 @property (nonatomic,strong) SDCycleScrollView *pi_cycleScrollView; ///红包 @property(nonatomic,strong) PIRoomEnterRedPacketView *redPacketView; ///玩法 @property(nonatomic,strong) PIRoomActivityClickView *clickPlayView; ///参加相亲 @property (nonatomic,strong) UIImageView *joinDatingView; ///host 代理 @property (nonatomic,weak) idhostDelegate; ///房间活动的列表 @property (nonatomic,strong) NSMutableArray *activityList; ///是否加载了活动 @property (nonatomic,assign) BOOL isLoadActivity; @property(nonatomic,assign) BOOL isShowChoosePlayView; @end @implementation XPRoomActivityContainerView -(void)dealloc{ [[NSNotificationCenter defaultCenter]removeObserver:self]; } - (instancetype)initWithdelegate:(id)delegate { self = [super init]; if (self) { self.hostDelegate = delegate; [self initSubViews]; [self initSubViewConstraints]; [self requestActivityList]; } return self; } #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.clickPlayView]; } - (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.clickPlayView mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.mas_equalTo(0); make.size.mas_equalTo(CGSizeMake(81, 66)); }]; [self.joinDatingView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(35 * kScreenHeightScale); }]; } - (void)requestActivityList { RACSubject* list = [RACSubject subject]; RACSubject* play = [RACSubject subject]; [[RACSignal combineLatest:@[list, play] reduce:^id(NSArray * listModel, NSArray * playModel){ self.activityList = [NSMutableArray arrayWithArray:listModel]; self.playList = [NSMutableArray arrayWithArray:playModel]; [self dealWithData]; return nil; }] subscribeError:^(NSError * _Nullable error) { }]; NSString * roomId = [NSString stringWithFormat:@"%ld", self.hostDelegate.getRoomInfo.roomId]; [Api roomActivityList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; [list sendNext:array]; [list sendCompleted]; return; } [list sendError:nil]; } roomId:roomId]; [Api getPlayList:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { NSArray * array = [ActivityInfoModel modelsWithArray:data.data]; [play sendNext:array]; [play sendCompleted]; return; } [play sendError:nil]; } roomId:roomId]; } -(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]; } if(self.playList.count > 0){ ActivityInfoModel *playModel = self.playList.firstObject; self.clickPlayView.model = playModel; // if(self.isShowChoosePlayView == NO){ // self.clickPlayView.hidden = NO; // } }else{ self.clickPlayView.hidden = YES; } } } - (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; self.clickPlayView.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(self.playList.count > 0){ ActivityInfoModel *playModel = self.playList.firstObject; self.clickPlayView.model = playModel; // if(self.isShowChoosePlayView == NO){ // self.clickPlayView.hidden = NO; // } }else{ self.clickPlayView.hidden = YES; } 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 * _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.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]; 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 * _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]; } #pragma mark- PIRoomEnterRedPacketViewDelegate -(void)openRedPacketWtihModel:(XPRedPacketModel *)redModel{ if(self.openRedPacketHandle){ self.openRedPacketHandle(redModel,self.hostDelegate.getRoomInfo.type,NO); } } #pragma mark - PIRoomActivityClickViewDelegate - (void)showChoosePlayViewAction{ self.clickPlayView.hidden = YES; self.isShowChoosePlayView = YES; PIRoomActivityChoosePlayView *choosePlayView = [[PIRoomActivityChoosePlayView alloc]initWithFrame:CGRectZero]; choosePlayView.delegate = self; choosePlayView.playList = self.playList; 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) { // self.clickPlayView.hidden = NO; [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 *)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; } - (PIRoomActivityClickView *)clickPlayView{ if(!_clickPlayView){ _clickPlayView = [[PIRoomActivityClickView alloc]initWithFrame:CGRectZero]; _clickPlayView.hidden = YES; _clickPlayView.delegate = self; } return _clickPlayView; } @end