// // XPRoomFunctionContainerView.m // xplan-ios // // Created by 冯硕 on 2021/12/15. // #import "XPRoomFunctionContainerView.h" ///Third #import #import #import ///Tool #import "XPMacro.h" #import "AccountInfoStorage.h" #import "UIImage+Utils.h" #import "ThemeColor.h" #import "TTPopup.h" #import "Api+Room.h" #import "XCHudTool.h" #import "XPHtmlUrl.h" #import "Api+Mine.h" #import "ClientConfig.h" #import "XCCurrentVCStackManager.h" #import "XPConstant.h" #import "Api+RoomSetting.h" ///Model #import "RoomInfoModel.h" #import "MicroQueueModel.h" #import "UserInfoModel.h" #import "AttachmentModel.h" #import "GiftValueInfoModel.h" #import "AcrossRoomPKPanelModel.h" #import "LittleGameInfoModel.h" #import "XPAnchorFansRelationModel.h" #import "XPAnchorFansJoinModel.h" #import "XPAnchorFansTaskModel.h" #import "AnchorPKPanelModel.h" ///View #import "XPRoomHalfWebView.h" #import "XPAnchorAudienceUpMicView.h" #import "XPRoomAnchorInfoCardView.h" #import "AnchorGiftValueView.h" #import "XPRoomTopicViewController.h" #import "XPRoomTopicAlertView.h" #import "XPAcrossRoomPKInviteView.h" #import "XPAcrossRoomPKInviteResultView.h" #import "XPAcrpssRoomPKPanelView.h" #import "XPAcrossRoomPKResultView.h" #import "XPAcrossRoomPKForceEndResultView.h" #import "XPSendGiftView.h" #import "XPUserCardViewController.h" #import "XPRoomViewController.h" #import "XPLittleGameMiniStageView.h" #import "XPLittleGameRoomListView.h" ///个播PK #import "XPAnchorFansTeamEntranceView.h" #import "XPAnchorFansTeamViewController.h" #import "XPAnchorFansTaskViewController.h" #import "XPAnchorPkPanelView.h" #import "XPWebViewController.h" @interface XPRoomFunctionContainerView () ///host 代理 @property (nonatomic,weak) iddelegate; ///房间榜 @property (nonatomic,strong) UIButton *contributionButton; ///相亲阶段的按钮 @property (nonatomic,strong) UIButton *datingProgresButton; ///关注个播房主倒计时 @property (nonatomic, strong) dispatch_source_t followAnchorTimer; ///个播房房主魅力值 @property (nonatomic, strong) AnchorGiftValueView *anchorGiftValueView; ///个播粉丝团入口 @property (nonatomic, strong) XPAnchorFansTeamEntranceView *fansTeamEntranceView; ///话题的容器 @property (nonatomic,strong) UIStackView *topicStackView; ///话题 @property (nonatomic,strong) UILabel *topicLabel; ///编辑 @property (nonatomic,strong) UIButton *editButton; ///跨房pk的面板 @property (nonatomic,strong) XPAcrpssRoomPKPanelView *acrossPKPanelView; ///小游戏 最小化的坑位 @property (nonatomic,strong) XPLittleGameMiniStageView *littleGameMiniView; ///显示游戏的切换 @property (nonatomic,strong) XPLittleGameRoomListView *gameListView; ///粉丝团数据 @property (nonatomic, strong) XPAnchorFansRelationModel *relationFansModel; ///个播PK面板 @property (nonatomic, strong) XPAnchorPkPanelView *anchorPKPanelView; @end @implementation XPRoomFunctionContainerView - (void)dealloc { if (self.followAnchorTimer != nil) { dispatch_source_cancel(self.followAnchorTimer); } } - (instancetype)initWithdelegate:(id)delegate { self = [super init]; if (self) { self.delegate = delegate; [self initSubViews]; [self initSubViewConstraints]; } return self; } - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { for (NSInteger i = (self.subviews.count - 1) ; i >= 0 ; i--) { UIView * subView = [self.subviews objectAtIndex:i]; CGPoint convertPoint = [subView convertPoint:point fromView:self]; if (CGRectContainsPoint(subView.bounds, convertPoint)) { return [subView hitTest:convertPoint withEvent:event]; } } return nil; } #pragma mark - Public Method - (void)hiddenSudGamePostionView { [self.littleGameMiniView hiddenSudGamePostionView]; } #pragma mark - Private Method - (void)initSubViews { [self addSubview:self.contributionButton]; [self addSubview:self.anchorGiftValueView]; [self addSubview:self.topicStackView]; [self addSubview:self.fansTeamEntranceView]; [self.topicStackView addArrangedSubview:self.topicLabel]; [self.topicStackView addArrangedSubview:self.editButton]; } - (void)initSubViewConstraints { [self.contributionButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(-12); make.top.mas_equalTo(kNavigationHeight); make.width.mas_equalTo(90); make.height.mas_equalTo(26); }]; [self.anchorGiftValueView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.contributionButton.mas_right).mas_offset(8); make.centerY.mas_equalTo(self.contributionButton); make.height.mas_equalTo(26); }]; [self.fansTeamEntranceView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.contributionButton.mas_bottom).mas_offset(5); make.left.mas_equalTo(0); make.height.mas_equalTo(37); }]; [self.topicStackView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.height.mas_equalTo(15); make.top.mas_equalTo(58 + 5 + 6 + 12 + 3 + kNavigationHeight); }]; } - (void)showLittleGameMiniView:(RoomType)type { if (type == RoomType_MiniGame) { if (!self.littleGameMiniView.superview) { [self addSubview:self.littleGameMiniView]; [self.littleGameMiniView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(0); make.top.mas_equalTo(kNavigationHeight); make.height.mas_equalTo(23); }]; } } else { if (self.littleGameMiniView.superview) { [self.littleGameMiniView removeFromSuperview]; } } } - (void)configLittleGameState { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; if (roomInfo.isPermitRoom != PermitRoomType_Licnese && roomInfo.roomModeType != RoomModeType_Open_Blind && roomInfo.roomModeType != RoomModeType_Open_PK_Mode && roomInfo.roomModeType != RoomModeType_Open_AcrossRoomPK_mode && roomInfo.roomModeType != RoomModeType_Open_Micro_Mode && !roomInfo.leaveMode && roomInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { if (!self.gameListView.superview) { [self addSubview:self.gameListView]; [self.gameListView mas_makeConstraints:^(MASConstraintMaker *make) { make.right.mas_equalTo(self).offset(-85); make.top.mas_equalTo(self).offset(kNavigationHeight - 14 - 11 - 25.0 / 2.0); }]; } self.gameListView.mgId = roomInfo.mgId > 0 ? [NSString stringWithFormat:@"%lld", roomInfo.mgId] : @"0"; } else { if (self.gameListView.superview) { [self.gameListView removeFromSuperview]; } } } //自己是否在游戏中 - (BOOL)isInSudGame { BOOL isGamePlaying = NO; if (self.delegate.getRoomInfo.type == RoomType_MiniGame) { for (int i = -1; i<5; i++) { NSMutableDictionary * micQueue = self.delegate.getMicroQueue; MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; if (micSequence == nil || micSequence.userInfo == nil) { continue; } if (micSequence.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue && micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { isGamePlaying = YES; break; } } } return isGamePlaying; } ///当前房间是否在游戏中 - (BOOL)currentRoomIsInSudGame { BOOL isGamePlaying = NO; if (self.delegate.getRoomInfo.type == RoomType_MiniGame) { for (int i = -1; i<5; i++) { NSMutableDictionary * micQueue = self.delegate.getMicroQueue; MicroQueueModel *micSequence = [micQueue objectForKey:[NSString stringWithFormat:@"%d", i]]; if (micSequence == nil || micSequence.userInfo == nil) { continue; } if (micSequence.userInfo.gameStatus == LittleGamePlayStatus_Plying) { isGamePlaying = YES; break; } } } return isGamePlaying; } #pragma mark - RoomGuestDelegate - (void)onRoomUpdate { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; MicroQueueModel * model = [self.delegate.getMicroQueue objectForKey:@"-1"]; if (roomInfo.roomModeType == RoomModeType_Open_Blind && model.userInfo && model.userInfo.uid == [AccountInfoStorage instance].getUid.integerValue) { if (!self.datingProgresButton.superview) { [self addSubview:self.datingProgresButton]; [self.datingProgresButton mas_makeConstraints:^(MASConstraintMaker *make) { make.size.mas_equalTo(CGSizeMake(70, 30)); make.centerX.mas_equalTo(self); make.top.mas_equalTo(self).offset(354 + kSafeAreaTopHeight); }]; } switch (roomInfo.blindDateState) { case RoomPlayDateingType_Talk: [self.datingProgresButton setTitle:@"开始选择>" forState:UIControlStateNormal]; break; case RoomPlayDateingType_Pick: [self.datingProgresButton setTitle:@"公布心动>" forState:UIControlStateNormal]; break; case RoomPlayDateingType_Result: [self.datingProgresButton setTitle:@"结束本轮>" forState:UIControlStateNormal]; break; case RoomPlayDateingType_Finish: [self.datingProgresButton setTitle:@"嘉宾交流>" forState:UIControlStateNormal]; break; default: break; } } else { if (self.datingProgresButton.superview) { [self.datingProgresButton removeFromSuperview]; } } if (roomInfo.type == RoomType_Anchor) { [self.contributionButton setTitle:@"主播榜" forState:UIControlStateNormal]; self.anchorGiftValueView.hidden = !roomInfo.showGiftValue; self.fansTeamEntranceView.hidden = NO; if (!roomInfo.showGiftValue) { self.anchorGiftValueView.giftValue = 0; } [self.contributionButton mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(statusbarHeight+49); }]; if (roomInfo.hadChangeRoomType) { ///进房初始化当前用户与房间粉丝团关系 [Api requestInRoomFansTeam:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { XPAnchorFansRelationModel *model = [XPAnchorFansRelationModel modelWithJSON:data.data]; [self updateFansTeamEntranceView:model]; } teamUid:[NSString stringWithFormat:@"%ld", roomInfo.uid]]; } } else { [self.contributionButton setTitle:@"房间榜" forState:UIControlStateNormal]; self.anchorGiftValueView.hidden = YES; self.fansTeamEntranceView.hidden = YES; [self.contributionButton mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(kNavigationHeight); }]; } [self updateRoomTopic]; [self showLittleGameMiniView:roomInfo.type]; [self configLittleGameState]; } - (void)onRoomEntered { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSString * roomUid = [NSString stringWithFormat:@"%ld", roomInfo.uid]; if (roomInfo.type == RoomType_Anchor) {//个播房 if (![[AccountInfoStorage instance].getUid isEqualToString:roomUid]) {//非房主 NSString * uid = [[AccountInfoStorage instance] getUid]; [Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {//是否关注了个播房主 BOOL isLike = ((NSNumber *)data.data).boolValue; if (!isLike) { [self setFollowAnchorTimer]; } } uid:uid isLikeUid:roomUid]; } ///进房初始化当前用户与房间粉丝团关系 [Api requestInRoomFansTeam:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { XPAnchorFansRelationModel *model = [XPAnchorFansRelationModel modelWithJSON:data.data]; [self updateFansTeamEntranceView:model]; } teamUid:roomUid]; } if (roomInfo.roomModeType == RoomModeType_Open_AcrossRoomPK_mode) { [Api getAcrossRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:data.data]; if (acrossPKPanelInfo.aUid.integerValue > 0) { if (!self.acrossPKPanelView.superview) { [self addSubview:self.acrossPKPanelView]; [self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.top.mas_equalTo(self).offset(354 + kSafeAreaTopHeight); }]; } self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo; } } else { [XCHUDTool showErrorWithMessage:msg]; } } roomUid:roomUid]; } else if (roomInfo.roomModeType == RoomModeType_Open_AnchorPK_Mode) { [Api getAcrossRoomPKDetail:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { AnchorPKPanelModel * anchorPKPanelInfo = [AnchorPKPanelModel modelWithJSON:data.data]; if (anchorPKPanelInfo.aUid.integerValue > 0) { if (!self.anchorPKPanelView.superview) { [self addSubview:self.anchorPKPanelView]; [self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.bottom.mas_equalTo(330); }]; } self.anchorPKPanelView.pkPanelInfo = anchorPKPanelInfo; } } else { [XCHUDTool showErrorWithMessage:msg]; } } roomUid:roomUid]; } else { if (!self.anchorPKPanelView.superview) { [self addSubview:self.anchorPKPanelView]; [self.anchorPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.top.mas_equalTo(kNavigationHeight); make.left.mas_equalTo(0); }]; } } if (roomInfo.type == RoomType_Anchor) { [self.contributionButton setTitle:@"主播榜" forState:UIControlStateNormal]; self.anchorGiftValueView.hidden = !roomInfo.showGiftValue; if (!roomInfo.showGiftValue) { self.anchorGiftValueView.giftValue = 0; } [self.contributionButton mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(statusbarHeight+49); }]; } else { [self.contributionButton setTitle:@"房间榜" forState:UIControlStateNormal]; self.anchorGiftValueView.hidden = YES; [self.contributionButton mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(kNavigationHeight); }]; } [self updateRoomTopic]; [self showLittleGameMiniView:roomInfo.type]; [self configLittleGameState]; } - (void)onMicroGiftValueUpdate:(NSDictionary *)data { [self handleAnchorGiftValue:data]; } - (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_AnchorRoom_AudienceUpMic) { [self showAskForUpMic:attachment.data]; } else if(attachment.first == CustomMessageType_Room_GiftValue && attachment.second == Custom_Message_Sub_Room_GiftValue_Sync) { [self handleAnchorGiftValue:attachment.data]; } else if(attachment.first == CustomMessageType_Gift && (attachment.second == Custom_Message_Sub_Gift_Send || attachment.second == Custom_Message_Sub_Gift_LuckySend || attachment.second == Custom_Message_Sub_Gift_ChannelNotify)) { [self handleAnchorGiftValue:attachment.data]; }else if(attachment.first == CustomMessageType_AllMicroSend && (attachment.second == Custom_Message_Sub_AllMicroSend || attachment.second == Custom_Message_Sub_AllBatchSend || attachment.second == Custom_Message_Sub_AllMicroLuckySend || attachment.second == Custom_Message_Sub_AllBatchMicroLuckySend)) { [self handleAnchorGiftValue:attachment.data]; } else if (attachment.first == CustomMessageType_Across_Room_PK) { switch (attachment.second) { case Custom_Message_Sub_AcrossRoomPK_Invite: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteView * inviteView = [[XPAcrossRoomPKInviteView alloc] init]; inviteView.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; inviteView.dataDic = attachment.data; [self addSubview:inviteView]; [inviteView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(self); }]; } } }]; } break; case Custom_Message_Sub_AcrossRoomPK_Accept: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init]; inviteResutView.isAccept = YES; [self addSubview:inviteResutView]; [inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(281, 42)); }]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [inviteResutView removeFromSuperview]; }); } } }]; } break; case Custom_Message_Sub_AcrossRoomPK_Reject: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init]; inviteResutView.isAccept = NO; [self addSubview:inviteResutView]; [inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(201, 42)); }]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [inviteResutView removeFromSuperview]; }); } } }]; } break; case Custom_Message_Sub_AcrossRoomPK_Panel: { if (!self.acrossPKPanelView.superview) { [self addSubview:self.acrossPKPanelView]; [self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(354 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); }]; } AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data]; self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo; } break; case Custom_Message_Sub_AcrossRoomPK_End: { [self.acrossPKPanelView resetAcrossPKViewData]; [self.acrossPKPanelView removeFromSuperview]; AcrossRoomPKPanelModel * model = [AcrossRoomPKPanelModel modelWithJSON:attachment.data]; if (model.isForce) { XPAcrossRoomPKForceEndResultView *view = [[XPAcrossRoomPKForceEndResultView alloc] initWithFrame:CGRectMake(0, 0, 281, 208)]; view.data = model; [TTPopup popupView:view style:TTPopupStyleAlert]; } else { XPAcrossRoomPKResultView *view = [[XPAcrossRoomPKResultView alloc] initWithFrame:CGRectMake(0, 0, 320, 453)]; view.data = model; [TTPopup popupView:view style:TTPopupStyleAlert]; } } break; case Custom_Message_Sub_AnchorPK_Invite: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteView * inviteView = [[XPAcrossRoomPKInviteView alloc] init]; inviteView.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; inviteView.dataDic = attachment.data; [self addSubview:inviteView]; [inviteView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(self); }]; } } }]; } break; case Custom_Message_Sub_AnchorPK_Accept: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init]; inviteResutView.isAccept = YES; [self addSubview:inviteResutView]; [inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(281, 42)); }]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [inviteResutView removeFromSuperview]; }); } } }]; } break; case Custom_Message_Sub_AnchorPK_Reject: { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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) { XPAcrossRoomPKInviteResultView * inviteResutView = [[XPAcrossRoomPKInviteResultView alloc] init]; inviteResutView.isAccept = NO; [self addSubview:inviteResutView]; [inviteResutView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(114 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(201, 42)); }]; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [inviteResutView removeFromSuperview]; }); } } }]; } break; case Custom_Message_Sub_AnchorPK_Panel: { if (!self.acrossPKPanelView.superview) { [self addSubview:self.acrossPKPanelView]; [self.acrossPKPanelView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self).offset(354 + kSafeAreaTopHeight); make.centerX.mas_equalTo(self); }]; } AcrossRoomPKPanelModel * acrossPKPanelInfo = [AcrossRoomPKPanelModel modelWithJSON:attachment.data]; self.acrossPKPanelView.pkPanelInfo = acrossPKPanelInfo; } break; case Custom_Message_Sub_AnchorPK_End: { [self.acrossPKPanelView resetAcrossPKViewData]; [self.acrossPKPanelView removeFromSuperview]; AcrossRoomPKPanelModel * model = [AcrossRoomPKPanelModel modelWithJSON:attachment.data]; if (model.isForce) { XPAcrossRoomPKForceEndResultView *view = [[XPAcrossRoomPKForceEndResultView alloc] initWithFrame:CGRectMake(0, 0, 281, 208)]; view.data = model; [TTPopup popupView:view style:TTPopupStyleAlert]; } else { XPAcrossRoomPKResultView *view = [[XPAcrossRoomPKResultView alloc] initWithFrame:CGRectMake(0, 0, 320, 453)]; view.data = model; [TTPopup popupView:view style:TTPopupStyleAlert]; } } break; default: break; } } else if (attachment.first == CustomMessageType_Anchor_FansTeam) { [self handleAnchorFansTeam:attachment]; } } } - (void)handleNIMNotificationMessage:(NIMMessage *)message { NIMNotificationObject *notiMsg = (NIMNotificationObject *)message.messageObject; NIMChatroomNotificationContent *content = (NIMChatroomNotificationContent *)notiMsg.content; switch (content.eventType) { case NIMChatroomEventTypeAddManager: { for (NIMChatroomNotificationMember * member in content.targets) { if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) { self.editButton.hidden = NO; break; } } } break; case NIMChatroomEventTypeRemoveManager: { for (NIMChatroomNotificationMember * member in content.targets) { if (member.userId.intValue == [AccountInfoStorage instance].getUid.integerValue) { self.editButton.hidden = YES; break; } } } break; default: break; } } - (void)onMicroQueueUpdate:(NSMutableDictionary *)queue { if (self.delegate.getRoomInfo.type == RoomType_MiniGame) { [self.littleGameMiniView needRefreshPosition:queue]; } } #pragma mark - XPAcrpssRoomPKPanelViewDelegate - (void)xPAcrpssRoomPKPanelView:(XPAcrpssRoomPKPanelView *)view onlookRoom:(NSString *)roomUid { [self.delegate exitRoom]; ///这个为啥加个延迟的 因为会先退房 有一个dismiss的动画 所以加个延迟吧 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ [XPRoomViewController openRoom:roomUid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC]; }); } - (void)xPAcrpssRoomPKPanelView:(XPAcrpssRoomPKPanelView *)view sendGiftToUser:(NSString *)uid { NSString * roomUid = [NSString stringWithFormat:@"%ld", [self.delegate getRoomInfo].uid]; XPSendGiftView * giftView = [[XPSendGiftView alloc] initWithType:SendGiftType_Room uid:roomUid]; giftView.delegate = self.delegate; NSArray * giftUses = [self configGiftUsers:[self.delegate getMicroQueue]]; [giftView configGiftUsers:giftUses]; [self.delegate.getCurrentNav presentViewController:giftView animated:YES completion:nil]; } - (NSArray *)configGiftUsers:(NSMutableDictionary *)queue { NSMutableArray * array = [NSMutableArray array]; for (MicroQueueModel * microModel in queue.allValues) { if (microModel.userInfo && microModel.userInfo.uid >0) { UserInfoModel * userInfo = microModel.userInfo; XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init]; userModel.avatar = userInfo.avatar; userModel.position = [NSString stringWithFormat:@"%d", microModel.microState.position]; userModel.uid = userInfo.uid; [array addObject:userModel]; } } if (self.delegate.getRoomInfo.leaveMode) { RoomInfoModel * roomInfo= self.delegate.getRoomInfo; XPGiftUserInfoModel * userModel = [[XPGiftUserInfoModel alloc] init]; userModel.avatar = roomInfo.avatar; userModel.position = @"-1"; userModel.uid = roomInfo.uid; [array addObject:userModel]; } return array; } - (void)xPAcrpssRoomPKPanelView:(XPAcrpssRoomPKPanelView *)view showUserCard:(NSString *)uid { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSString * targetUid = uid; XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init]; [[self.delegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (targetUid.integerValue == obj.userInfo.uid) { model.position = [NSString stringWithFormat:@"%d", obj.microState.position]; model.posState = obj.microState.posState; model.micState = obj.microState.micState; *stop = YES; } }]; model.nick = self.delegate.getUserInfo.nick; model.uid = targetUid; model.delegate = self.delegate; model.roomInfo = roomInfo; model.micQueue = self.delegate.getMicroQueue; XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model]; [self.delegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil]; } #pragma mark - XPAnchorPkPanelViewDelegate - (void)xPAnchorPKPanelView:(XPAnchorPkPanelView *)view showUserCard:(NSString *)uid { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSString * targetUid = uid; XPUserCardInfoModel * model = [[XPUserCardInfoModel alloc] init]; [[self.delegate.getMicroQueue allValues] enumerateObjectsUsingBlock:^(MicroQueueModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { if (targetUid.integerValue == obj.userInfo.uid) { model.position = [NSString stringWithFormat:@"%d", obj.microState.position]; model.posState = obj.microState.posState; model.micState = obj.microState.micState; *stop = YES; } }]; model.nick = self.delegate.getUserInfo.nick; model.uid = targetUid; model.delegate = self.delegate; model.roomInfo = roomInfo; model.micQueue = self.delegate.getMicroQueue; XPUserCardViewController * userCardVC = [[XPUserCardViewController alloc] initWithUser:model]; [self.delegate.getCurrentNav presentViewController:userCardVC animated:YES completion:nil]; } #pragma mark - Event Response - (void)contributionButtonAction:(UIButton *)sender { NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; webView.url = [NSString stringWithFormat:@"%@?roomUid=%@", URLWithType(kRoomRankURL), roomUid]; [TTPopup popupView:webView style:TTPopupStyleActionSheet]; } - (void)datingProgresButtonAction:(UIButton *)sender { [TTPopup dismiss]; RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSString * message = @""; if (roomInfo.blindDateState == RoomPlayDateingType_Talk) { message = @"进入心动选人环节?"; } else if(roomInfo.blindDateState == RoomPlayDateingType_Pick) { message = @"进入心动公布环节?"; } else if(roomInfo.blindDateState == RoomPlayDateingType_Result) { message = @"结束本轮,同时清空魅力值?"; } else if (roomInfo.blindDateState == RoomPlayDateingType_Finish) { message = @"进入嘉宾交流环节?"; } TTAlertConfig * config = [[TTAlertConfig alloc] init]; config.message = message; [TTPopup alertWithConfig:config confirmHandler:^{ NSString * roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; NSString * roundId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.blindDateState]; [Api changeRoomDatingState:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { } else { [XCHUDTool showErrorWithMessage:msg]; } } roomUserId:roomUid roundId:roundId]; } cancelHandler:^{ }]; } - (void)foldButtonAction:(UIButton *)sender { sender.selected = !sender.selected; } - (void)tapGiftValueRecognizer { if (self.anchorGiftValueView.hidden) return; if (self.delegate.getUserInfo && self.delegate.getUserInfo.uid > 0) { XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; webView.roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; webView.url = [NSString stringWithFormat:@"%@?uid=%ld", URLWithType(kRoomCharmRankURL), self.delegate.getRoomInfo.uid]; [TTPopup popupView:webView style:TTPopupStyleActionSheet]; } } - (void)tapFansTeamRecognizer { if (self.fansTeamEntranceView.hidden) { return; } NSString *roomUid = [NSString stringWithFormat:@"%zd", self.delegate.getRoomInfo.uid]; if (self.relationFansModel.isCurrentRoomAnchor) {///是房主 if (self.relationFansModel.hasFansTeamCurrentRoom) { XPRoomHalfWebView * webView = [[XPRoomHalfWebView alloc] init]; webView.url = [NSString stringWithFormat:@"%@?roomUid=%@", URLWithType(kAnchorFansListURL), roomUid]; [TTPopup popupView:webView style:TTPopupStyleActionSheet]; } else { XPWebViewController * webVC =[[XPWebViewController alloc] init]; webVC.roomUid = roomUid; webVC.url = URLWithType(kAnchorFansOpenURL); [self.delegate.getCurrentNav pushViewController:webVC animated:YES]; } } else { if (self.relationFansModel.hasFansTeamCurrentRoom) {//开通了粉丝团 if (self.relationFansModel.isAnchorFans) { [Api requestFansTeamTask:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code != 200) { [XCHUDTool showErrorWithMessage:msg]; return; } XPAnchorFansTaskModel *model = [XPAnchorFansTaskModel modelWithJSON:data.data]; XPAnchorFansTaskViewController *fansTaskVc = [[XPAnchorFansTaskViewController alloc] initWithRoomUid:roomUid]; fansTaskVc.model = model; [self.delegate.getCurrentNav presentViewController:fansTaskVc animated:YES completion:nil]; } teamUid:roomUid]; } else { [Api requestJoinFansTeam:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code != 200) { [XCHUDTool showErrorWithMessage:msg]; return; } XPAnchorFansJoinModel *model = [XPAnchorFansJoinModel modelWithJSON:data.data]; XPAnchorFansTeamViewController *fansTeamVc = [[XPAnchorFansTeamViewController alloc] initWithRoomUid:roomUid]; fansTeamVc.model = model; [self.delegate.getCurrentNav presentViewController:fansTeamVc animated:YES completion:nil]; } teamUid:roomUid]; } } } } #pragma mark - 房间话题 - (void)updateRoomTopicViewConstraint { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; CGFloat offsetY = kNavigationHeight; if (roomInfo.roomModeType == RoomModeType_Open_Blind) { offsetY += ((58 + 5) * kScreenScale + 6 + 12 + 3); } else if (roomInfo.type == RoomType_Anchor) { offsetY += (120 + 5 + 6 + 20 +60 + 3); } else { offsetY += (58 + 5 + 6 + 12 + 3 ); } [self.topicStackView mas_updateConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(offsetY); }]; } - (void)updateRoomTopic { self.topicStackView.hidden= ([ClientConfig shareConfig].configInfo.appStoreAuditNoticeVersion || self.delegate.getRoomInfo.type == RoomType_MiniGame) == YES; [self updateRoomTopicViewConstraint]; NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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 == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) { self.editButton.hidden = NO; } else { self.editButton.hidden = YES; } } }]; self.topicLabel.text = self.delegate.getRoomInfo.roomDesc.length > 0 ? self.delegate.getRoomInfo.roomDesc : @"暂未设置话题"; } - (void)topicGestureRecognizer:(UITapGestureRecognizer *)tap { NIMChatroomMembersByIdsRequest *request = [[NIMChatroomMembersByIdsRequest alloc]init]; request.roomId = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.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; RoomInfoModel * roomInfo= self.delegate.getRoomInfo; if (member.type == NIMChatroomMemberTypeCreator || member.type == NIMChatroomMemberTypeManager) { XPRoomTopicViewController * editTopicVC = [[XPRoomTopicViewController alloc] init]; editTopicVC.roomInfo = roomInfo; [self.delegate.getCurrentNav pushViewController:editTopicVC animated:YES]; } else { TTPopupService * config = [[TTPopupService alloc] init]; XPRoomTopicAlertView * alertView = [[XPRoomTopicAlertView alloc] init]; alertView.title = roomInfo.roomDesc; alertView.message = roomInfo.introduction; config.contentView = alertView; [TTPopup popupWithConfig:config]; } } }]; } #pragma mark - 个播模式弹窗关注主播 - (void)setFollowAnchorTimer { if (self.followAnchorTimer != nil) { dispatch_source_cancel(self.followAnchorTimer); } #ifdef DEBUG NSInteger totalTime = 5; #else NSInteger totalTime = 420; #endif dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); self.followAnchorTimer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue); dispatch_source_set_timer(self.followAnchorTimer,dispatch_walltime(NULL, totalTime*NSEC_PER_SEC), totalTime*NSEC_PER_SEC, 0); //每秒执行 @weakify(self); dispatch_source_set_event_handler(self.followAnchorTimer, ^{ dispatch_async(dispatch_get_main_queue(), ^{ @strongify(self); if (self.followAnchorTimer != nil) { dispatch_source_cancel(self.followAnchorTimer); self.followAnchorTimer = nil; } RoomInfoModel* roomInfo = self.delegate.getRoomInfo; NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; NSString * uid = [[AccountInfoStorage instance] getUid]; [Api attentionStatusCompletion:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { BOOL isLike = ((NSNumber *)data.data).boolValue; if (!isLike) { // 还没有关注 if (self.window) { [self showFollowAnchorView]; } } } uid:uid isLikeUid:roomUid]; }); }); dispatch_resume(self.followAnchorTimer); } //弹出关注主播的窗口 - (void)showFollowAnchorView { RoomInfoModel* roomInfo = self.delegate.getRoomInfo; NSString *roomUid = [NSString stringWithFormat:@"%zd", roomInfo.uid]; [Api getUserInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { UserInfoModel *userInfo = [UserInfoModel modelWithDictionary:data.data]; XPRoomAnchorInfoCardView *view = [[XPRoomAnchorInfoCardView alloc] initWithFrame:CGRectMake(0, 0, KScreenWidth, 300)]; view.userInfo = self.delegate.getUserInfo; view.targetUserInfo = userInfo; view.roomId =roomInfo.roomId; [TTPopup popupView:view style:TTPopupStyleActionSheet]; } uid:roomUid]; } ///个播房用户请求上麦弹窗 - (void)showAskForUpMic:(NSDictionary *)dict { NSString *roomUid = [NSString stringWithFormat:@"%zd", self.delegate.getRoomInfo.uid]; if (![roomUid isEqualToString:[AccountInfoStorage instance].getUid]) { return; } UserInfoModel *model = [UserInfoModel modelWithJSON:dict]; XPAnchorAudienceUpMicView *upMicView = [[XPAnchorAudienceUpMicView alloc] initWithFrame:CGRectMake(0, 0, 300, 226) delegate:self.delegate]; upMicView.info = model; TTPopupConfig *config = [[TTPopupConfig alloc] init]; config.filterIdentifier = @"audienceRequestUpMic"; config.shouldFilterPopup = YES; config.contentView = upMicView; config.style = TTPopupStyleAlert; [TTPopup popupWithConfig:config]; } - (void)handleAnchorGiftValue:(NSDictionary *)dict { if (self.delegate.getRoomInfo.type != RoomType_Anchor) {//个播房房主位置魅力值刷新 return; } GiftValueInfoModel * model = [GiftValueInfoModel modelWithDictionary:dict]; for (int i = 0; i < model.giftValueVos.count; i++) { GiftValueDetailModel * giftValueModel = [model.giftValueVos objectAtIndex:i]; if (![giftValueModel.uid isEqualToString:[NSString stringWithFormat:@"%zd", self.delegate.getRoomInfo.uid]]) { continue; } self.anchorGiftValueView.giftValue = giftValueModel.giftValue; } } #pragma mark - 个播粉丝团 - (void)updateFansTeamEntranceView:(XPAnchorFansRelationModel *)model { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; self.fansTeamEntranceView.hidden = roomInfo.type != RoomType_Anchor; self.fansTeamEntranceView.model = model; self.relationFansModel = model; } - (void)handleAnchorFansTeam:(AttachmentModel *)attachment { if (attachment.second == Custom_Message_Sub_FansTeam_Open_Success || attachment.second == Custom_Message_Sub_FansTeam_Join_Success || attachment.second == Custom_Message_Sub_FansTeam_Out_Success) { NSString *roomUid = [NSString stringWithFormat:@"%ld", self.delegate.getRoomInfo.uid]; NSString *uid; if ([attachment.data[@"uid"] isKindOfClass:[NSNumber class]]) { uid = [NSString stringWithFormat:@"%@", attachment.data[@"uid"]]; } else if ([attachment.data[@"uid"] isKindOfClass:[NSString class]]) { uid = attachment.data[@"uid"]; } if ([uid isEqualToString:[AccountInfoStorage instance].getUid] || [[AccountInfoStorage instance].getUid isEqualToString:roomUid]) { [Api requestInRoomFansTeam:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { XPAnchorFansRelationModel *model = [XPAnchorFansRelationModel modelWithJSON:data.data]; [self updateFansTeamEntranceView:model]; } teamUid:roomUid]; } } else if (attachment.second == Custom_Message_Sub_FansTeam_Open_Fail) { } } #pragma mark - XPRoomLittleGameListViewDelegate - (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectItem:(LittleGameInfoModel *)itemInfo { RoomInfoModel * roomInfo = self.delegate.getRoomInfo; NSMutableDictionary * params = [NSMutableDictionary dictionary]; NSString * uid = [AccountInfoStorage instance].getUid; NSString * ticket = [AccountInfoStorage instance].getTicket; [params setObject:ticket forKey:@"ticket"]; [params setObject:uid forKey:@"uid"]; [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.uid] forKey:@"roomUid"]; if (roomInfo.title.length > 0) { [params setObject:roomInfo.title forKey:@"title"]; } if (roomInfo.roomPwd.length > 0) { [params setObject:roomInfo.roomPwd forKey:@"roomPwd"]; } else{ [params setObject:@"" forKey:@"roomPwd"]; } if (roomInfo.tagId > 0) { [params setObject:[NSString stringWithFormat:@"%ld", roomInfo.tagId] forKey:@"tagId"]; } if ([itemInfo.mgId isEqualToString:@"0"]) { [params setObject:@(RoomType_Game) forKey:@"type"]; [params setObject:@"0" forKey:@"mgId"]; } else { [params setObject:@(RoomType_MiniGame) forKey:@"type"]; [params setObject:itemInfo.mgId forKey:@"mgId"]; } [params setObject:@(roomInfo.hasAnimationEffect) forKey:@"hasAnimationEffect"]; [Api ownerUpdateRoomInfo:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) { if (code == 200) { } else { [XCHUDTool showErrorWithMessage:msg]; } } params:params]; } - (void)xPRoomLittleGameListView:(XPLittleGameRoomListView *)view didSelectChooseType:(UIButton *)sender { if ([self currentRoomIsInSudGame]) { [XCHUDTool showErrorWithMessage:@"游戏中不可切换游戏或玩法!"]; } else { sender.selected = !sender.selected; view.tableView.hidden = !sender.selected; } } #pragma mark - Getters And Setters - (UIButton *)contributionButton { if (!_contributionButton) { _contributionButton = [[UIButton alloc]init]; [_contributionButton addTarget:self action:@selector(contributionButtonAction:) forControlEvents:UIControlEventTouchUpInside]; _contributionButton.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2]; [_contributionButton setTitle:@"房间榜" forState:UIControlStateNormal]; [_contributionButton setImage:[UIImage imageNamed:@"room_rank_enter_icon"] forState:UIControlStateNormal]; [_contributionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _contributionButton.titleLabel.font = [UIFont systemFontOfSize:12]; _contributionButton.layer.cornerRadius = 13; _contributionButton.layer.masksToBounds = YES; _contributionButton.imageEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0); _contributionButton.titleEdgeInsets = UIEdgeInsetsMake(0, 20, 0, 0); } return _contributionButton; } - (UIButton *)datingProgresButton { if (!_datingProgresButton) { _datingProgresButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_datingProgresButton setBackgroundImage:[UIImage gradientColorImageFromColors:@[UIColorFromRGB(0xFA7186), UIColorFromRGB(0xFA4972)] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(65, 30)] forState:UIControlStateNormal]; [_datingProgresButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; _datingProgresButton.titleLabel.font = [UIFont systemFontOfSize:13]; [_datingProgresButton setTitle:@"开始选择>" forState:UIControlStateNormal]; [_datingProgresButton addTarget:self action:@selector(datingProgresButtonAction:) forControlEvents:UIControlEventTouchUpInside]; _datingProgresButton.layer.masksToBounds = YES; _datingProgresButton.layer.cornerRadius = 15; } return _datingProgresButton; } - (AnchorGiftValueView *)anchorGiftValueView { if (!_anchorGiftValueView) { _anchorGiftValueView = [[AnchorGiftValueView alloc] init]; _anchorGiftValueView.hidden = YES; _anchorGiftValueView.layer.cornerRadius = 13; _anchorGiftValueView.layer.masksToBounds = YES; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGiftValueRecognizer)]; [_anchorGiftValueView addGestureRecognizer:tap]; } return _anchorGiftValueView; } - (XPAnchorFansTeamEntranceView *)fansTeamEntranceView { if (!_fansTeamEntranceView) { _fansTeamEntranceView = [[XPAnchorFansTeamEntranceView alloc]init]; _fansTeamEntranceView.hidden = YES; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapFansTeamRecognizer)]; [_fansTeamEntranceView addGestureRecognizer:tap]; } return _fansTeamEntranceView; } - (UIStackView *)topicStackView { if (!_topicStackView) { _topicStackView = [[UIStackView alloc] init]; _topicStackView.axis = UILayoutConstraintAxisHorizontal; _topicStackView.distribution = UIStackViewDistributionFill; _topicStackView.alignment = UIStackViewAlignmentFill; _topicStackView.spacing = 3; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(topicGestureRecognizer:)]; [_topicStackView addGestureRecognizer:tap]; } return _topicStackView; } - (UILabel *)topicLabel { if (!_topicLabel) { _topicLabel = [[UILabel alloc] init]; _topicLabel.font = [UIFont systemFontOfSize:12]; _topicLabel.textColor = [UIColor whiteColor]; } return _topicLabel; } - (UIButton *)editButton { if (!_editButton) { _editButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_editButton setImage:[UIImage imageNamed:@"room_postion_topic_edit"] forState:UIControlStateNormal]; [_editButton setImage:[UIImage imageNamed:@"room_postion_topic_edit"] forState:UIControlStateSelected]; _editButton.hidden = YES; } return _editButton; } - (XPAcrpssRoomPKPanelView *)acrossPKPanelView { if (!_acrossPKPanelView) { _acrossPKPanelView = [[XPAcrpssRoomPKPanelView alloc] init]; _acrossPKPanelView.delegate = self; } return _acrossPKPanelView; } - (XPLittleGameMiniStageView *)littleGameMiniView { if (!_littleGameMiniView) { _littleGameMiniView = [[XPLittleGameMiniStageView alloc] init]; } return _littleGameMiniView; } - (XPLittleGameRoomListView *)gameListView { if (!_gameListView) { _gameListView = [[XPLittleGameRoomListView alloc] init]; _gameListView.delegate = self; } return _gameListView; } - (XPAnchorPkPanelView *)anchorPKPanelView { if (!_anchorPKPanelView) { _anchorPKPanelView = [[XPAnchorPkPanelView alloc] init]; _anchorPKPanelView.delegate = self; } return _anchorPKPanelView; } @end