// // QXRoomSettingView.m // QXLive // // Created by 启星 on 2025/6/12. // #import "QXRoomSettingView.h" #import "UIButton+QX.h" #import "QXGiftPlayerManager.h" #import "QXMineNetwork.h" #import "QXDressViewController.h" #import "QXDirectListView.h" #import "QXSingerConfigView.h" #import "QXRoomWelcomeView.h" #import "QXAlertView.h" #import "QXGiftDriftView.h" #import "QXMeetActivityDriftView.h" @interface QXRoomSettingView() @property (nonatomic,strong)UIView *bgView; @property (nonatomic,strong)UIView *topView; @property (nonatomic,strong)NSArray *titles; @property (nonatomic,strong)NSDictionary *dataDict; /// @property (nonatomic,strong)UIView *bottomBgView; @property (nonatomic,strong)UITableView *tableView; /// 房间类型 /// 点唱房间类型 @property (nonatomic,strong)QXRoomSettingModel *roomTypeSing; /// 排麦房间类型 @property (nonatomic,strong)QXRoomSettingModel *roomTypeAuction; /// 男神房 @property (nonatomic,strong)QXRoomSettingModel *roomTypeBoy; /// 女神房 @property (nonatomic,strong)QXRoomSettingModel *roomTypeGirl; /// 交友房 以前的交友换成互娱 @property (nonatomic,strong)QXRoomSettingModel *roomTypeFriend; /// 互娱 曾经的男神女神合并为交友 @property (nonatomic,strong)QXRoomSettingModel *roomTypeFunny; /// 常用工具 /// 房间补贴 @property (nonatomic,strong)QXRoomSettingModel *roomSubsidy; /// 主持设置 @property (nonatomic,strong)QXRoomSettingModel *roomCompere; /// 清除消息 @property (nonatomic,strong)QXRoomSettingModel *roomMessage; /// 麦序模式 @property (nonatomic,strong)QXRoomSettingModel *roomOrderMic; /// 背景音乐 @property (nonatomic,strong)QXRoomSettingModel *roomBgMusic; /// 房间背景 @property (nonatomic,strong)QXRoomSettingModel *roomBgImage; /// 更多操作 /// 离开房间 @property (nonatomic,strong)QXRoomSettingModel *roomLeave; /// 分享房间 @property (nonatomic,strong)QXRoomSettingModel *roomShare; /// 个性装扮 @property (nonatomic,strong)QXRoomSettingModel *roomVoiceSet; /// 房间设置 @property (nonatomic,strong)QXRoomSettingModel *roomSetting; /// 欢迎语 @property (nonatomic,strong)QXRoomSettingModel *roomWelcome; /// 礼物特效 @property (nonatomic,strong)QXRoomSettingModel *roomEffects; /// 意见反馈 @property (nonatomic,strong)QXRoomSettingModel *roomReport; /// 飘屏开关 @property (nonatomic,strong)QXRoomSettingModel *drifPop; /// 主持列表 @property (nonatomic,strong)QXDirectListView *directView; /// 调音台 @property (nonatomic,strong)QXSingerConfigView *singerConifgView; /// @property (nonatomic,strong)QXRoomWelcomeView *welcomeView; @property (nonatomic,strong)QXAlertView *alertView; @end @implementation QXRoomSettingView - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubiews]; } return self; } -(void)initSubiews{ self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3]; UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)]; tap.delegate = self; [self addGestureRecognizer:tap]; self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT, self.width, ScaleWidth(407)+kSafeAreaBottom)]; [self addSubview:self.bgView]; self.topView = [[UIView alloc] initWithFrame:CGRectMake(16, 0, SCREEN_WIDTH-16*2, ScaleWidth(54))]; UIImageView *topicBgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"room_topic_bg"]]; topicBgImageView.frame = self.topView.bounds; [self.topView addSubview:topicBgImageView]; UIButton *sendTopic = [[UIButton alloc] initWithFrame:CGRectMake(self.topView.width - 120-ScaleWidth(23), self.topView.height-ScaleWidth(13)-15, 120, 15)]; [sendTopic setImage:[UIImage imageNamed:@"arrowRight"] forState:(UIControlStateNormal)]; [sendTopic setTitle:QXText(@"立即发送头条") forState:(UIControlStateNormal)]; sendTopic.titleLabel.font = [UIFont systemFontOfSize:12]; [sendTopic setTitleColor:QXConfig.textColor forState:(UIControlStateNormal)]; [sendTopic qx_layoutButtonNOSizeToFitWithEdgeInsetsStyle:(QXButtonEdgeInsetsStyleRight) imageTitleSpace:2]; [self.topView addSubview:sendTopic]; sendTopic.userInteractionEnabled = NO; [self.bgView addSubview:self.topView]; MJWeakSelf [self.topView addTapBlock:^(id _Nonnull obj) { [weakSelf hide]; if (weakSelf.delegate && [self.delegate respondsToSelector:@selector(didClickHeadLine)]) { [weakSelf.delegate didClickHeadLine]; } }]; self.bottomBgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.topView.bottom+4, self.width, self.bgView.height-self.topView.bottom-4)]; self.bottomBgView.backgroundColor = [UIColor whiteColor]; [self.bottomBgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)]; [self.bgView addSubview:self.bottomBgView]; self.titles = @[QXText(@"房间类型"),QXText(@"常用工具"),QXText(@"更多操作")]; self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 10, self.width, self.bottomBgView.height-10) style:(UITableViewStyleGrouped)]; self.tableView.dataSource = self; self.tableView.delegate = self; self.tableView.backgroundColor = [UIColor clearColor]; self.tableView.rowHeight = ScaleWidth(54)+5; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.scrollEnabled = NO; [self.bottomBgView addSubview:self.tableView]; } -(void)setRoomModel:(QXRoomModel *)roomModel{ _roomModel = roomModel; /// 排麦 if (self.roomModel.room_info.room_up_pit_type.intValue == 1) { self.roomOrderMic.isSelected = NO; }else{ self.roomOrderMic.isSelected = YES; } BOOL isEffectsCLose = [[NSUserDefaults standardUserDefaults] boolForKey:kEffectsCLose]; BOOL isDrifPopCLose = [[NSUserDefaults standardUserDefaults] boolForKey:kIsCloseDrifPop]; self.roomEffects.isSelected = isEffectsCLose; self.drifPop.isSelected = isDrifPopCLose; [self.tableView reloadData]; } // isUpSeat true 麦上 false 麦下 -(void)updateRole:(QXRoomRoleType)roleType isUpSeat:(BOOL)isUpSeat{ NSArray *roomTypeArr; NSArray *toolsArr; NSArray *moreArr; switch (roleType) { // 主持 case QXRoomRoleTypeCompere:{ if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2) { // toolsArr = @[self.roomSubsidy,self.roomMessage,self.roomOrderMic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeFunny,self.roomTypeFriend]; moreArr = @[self.roomLeave,self.roomVoiceSet,self.roomSetting,self.roomEffects,self.drifPop,self.roomReport]; // roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeBoy,self.roomTypeGirl,self.roomTypeFriend]; // moreArr = @[self.roomLeave,self.roomShare,self.roomVoiceSet,self.roomSetting,self.roomWelcome,self.roomEffects,self.roomReport]; }else{ // toolsArr = @[self.roomSubsidy,self.roomMessage,self.roomOrderMic,self.roomBgMusic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeFunny,self.roomTypeFriend]; moreArr = @[self.roomLeave,self.roomVoiceSet,self.roomSetting,self.roomEffects,self.drifPop,self.roomReport]; // roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeBoy,self.roomTypeGirl,self.roomTypeFriend]; // moreArr = @[self.roomLeave,self.roomShare,self.roomVoiceSet,self.roomSetting,self.roomWelcome,self.roomEffects,self.roomReport]; } self.titles = @[QXText(@"房间类型"),QXText(@"常用工具"),QXText(@"更多操作")]; } break; case QXRoomRoleTypeAudience:{ // 观众 更多操作 不区分麦上麦下 roomTypeArr = @[]; toolsArr = @[]; moreArr = @[self.roomLeave,self.roomVoiceSet,self.roomEffects,self.drifPop,self.roomReport]; self.titles = @[QXText(@"更多操作")]; } break; case QXRoomRoleTypeOwner:{ /// 房主 全量 不区分麦上麦下 // if (isUpSeat) { // }else{ // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; // } if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2) { // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; }else{ // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgMusic,self.roomBgImage]; // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; } roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeFunny,self.roomTypeFriend]; moreArr = @[self.roomLeave,self.roomVoiceSet,self.roomSetting,self.roomEffects,self.drifPop,self.roomReport]; // moreArr = @[self.roomLeave,self.roomShare,self.roomVoiceSet,self.roomSetting,self.roomWelcome,self.roomEffects,self.roomReport]; // roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeBoy,self.roomTypeGirl,self.roomTypeFriend]; self.titles = @[QXText(@"房间类型"),QXText(@"常用工具"),QXText(@"更多操作")]; } break; case QXRoomRoleTypeManager:{ /// 管理员 除去设置管理外,展示所有功能, 不区分麦上麦下 // if (isUpSeat) { // }else{ // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; // } if ((self.roomModel.room_info.type_id.intValue == 1 || self.roomModel.room_info.type_id.intValue == 3 || self.roomModel.room_info.type_id.intValue == 4 || self.roomModel.room_info.type_id.intValue == 8) && self.roomModel.room_info.label_id.intValue == 2) { // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; }else{ // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgMusic,self.roomBgImage]; // toolsArr = @[self.roomSubsidy,self.roomCompere,self.roomMessage,self.roomOrderMic,self.roomBgImage]; /// 暂时不需要房间补贴 toolsArr = @[self.roomMessage,self.roomOrderMic,self.roomBgImage]; } // roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeBoy,self.roomTypeGirl,self.roomTypeFriend]; roomTypeArr = @[self.roomTypeSing,self.roomTypeAuction,self.roomTypeFunny,self.roomTypeFriend]; // moreArr = @[self.roomLeave,self.roomShare,self.roomVoiceSet,self.roomSetting,self.roomWelcome,self.roomEffects,self.roomReport]; moreArr = @[self.roomLeave,self.roomVoiceSet,self.roomSetting,self.roomEffects,self.drifPop,self.roomReport]; self.titles = @[QXText(@"房间类型"),QXText(@"常用工具"),QXText(@"更多操作")]; } break; default: break; } self.dataDict = @{ QXText(@"房间类型"):roomTypeArr, QXText(@"常用工具"):toolsArr, QXText(@"更多操作"):moreArr }; [self.tableView reloadData]; } -(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{ return touch.view == self; } -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return self.titles.count; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return 1; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ QXRoomSettingCell *cell = [QXRoomSettingCell cellWithTableView:tableView]; NSArray *arr = self.dataDict[self.titles[indexPath.section]]; cell.dataArray = arr; cell.roomId = self.roomModel.room_info.room_id; cell.delegate = self; return cell; } -(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.width, 44)]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, SCREEN_WIDTH-32, 44)]; label.font = [UIFont boldSystemFontOfSize:16]; label.textColor = RGB16(0x333333); label.text = self.titles [section]; [headerView addSubview:label]; return headerView; } -(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 44; } -(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{ return [UIView new]; } -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{ return 0.01; } -(void)didClickSetModel:(QXRoomSettingModel *)model{ [self hide]; if (model.type == QXRoomSettingTypeRoomVoiceSet) { [self.singerConifgView showInView:KEYWINDOW]; return; } if (model.type == QXRoomSettingTypeRoomLeave) { [self.navigationController popViewControllerAnimated:YES]; [[QXGlobal shareGlobal] quitRoomWithRoomId:self.roomModel.room_info.room_id]; return; } if (model.type == QXRoomSettingTypeRoomCompere) { self.directView.roomId = self.roomModel.room_info.room_id; [self.directView showInView:self.viewController.view]; return; } if (model.type == QXRoomSettingTypeRoomWelcome) { // MJWeakSelf /// 房间欢迎语 暂时注销 // self.welcomeView.roomId = self.roomModel.room_info.room_id; // self.welcomeView.setIntroduceBlock = ^(NSString * _Nonnull introduce) { // weakSelf.roomModel.room_info.room_intro = introduce; // }; // [self.welcomeView showInView:self.viewController.view]; return; } if (model.type == QXRoomSettingTypeRoomTypeAuction || model.type == QXRoomSettingTypeRoomTypeSing || model.type == QXRoomSettingTypeRoomTypeBoy || model.type == QXRoomSettingTypeRoomTypeGirl || model.type == QXRoomSettingTypeRoomTypeFriend || model.type == QXRoomSettingTypeRoomTypeFunny) { self.alertView.message = [NSString stringWithFormat:@"您确定要修改为%@房吗?",model.name]; [[QXGlobal shareGlobal] showView:self.alertView controller:self.viewController popType:(PopViewTypeTopToCenter) tapDismiss:NO finishBlock:^{ }]; MJWeakSelf self.alertView.commitBlock = ^{ [weakSelf changeRoomType:model.type]; }; return; } if (self.delegate && [self.delegate respondsToSelector:@selector(didClickSetModel:)]) { [self.delegate didClickSetModel:model]; } } -(void)changeRoomType:(QXRoomSettingType)roomType{ NSString *type = @""; if (roomType == QXRoomSettingTypeRoomTypeAuction) { type = @"2"; }else if (roomType == QXRoomSettingTypeRoomTypeSing) { type = @"1"; }else if (roomType == QXRoomSettingTypeRoomTypeBoy) { type = @"3"; }else if (roomType == QXRoomSettingTypeRoomTypeGirl) { type = @"4"; }else if (roomType == QXRoomSettingTypeRoomTypeFriend) { type = @"7"; }else if (roomType == QXRoomSettingTypeRoomTypeFunny) { type = @"8"; } [QXMineNetwork changeRoomTypeWithRoomId:self.roomModel.room_info.room_id type:type successBlock:^(NSDictionary * _Nonnull dict) { } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; } -(void)showInView:(UIView *)view{ [view addSubview:self]; [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT- ScaleWidth(407)-kSafeAreaBottom; }]; } -(void)hide{ [UIView animateWithDuration:0.3 animations:^{ self.bgView.y = SCREEN_HEIGHT; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; } -(QXRoomSettingModel *)roomTypeSing{ if (!_roomTypeSing) { _roomTypeSing = [[QXRoomSettingModel alloc] init]; _roomTypeSing.name = QXText(@"点唱"); _roomTypeSing.type = QXRoomSettingTypeRoomTypeSing; _roomTypeSing.icon = @"room_set_room_type_sing"; } return _roomTypeSing; } -(QXRoomSettingModel *)roomTypeAuction{ if (!_roomTypeAuction) { _roomTypeAuction = [[QXRoomSettingModel alloc] init]; _roomTypeAuction.name = QXText(@"拍卖"); _roomTypeAuction.type = QXRoomSettingTypeRoomTypeAuction; _roomTypeAuction.icon = @"room_set_room_type_auction"; } return _roomTypeAuction; } -(QXRoomSettingModel *)roomTypeBoy{ if (!_roomTypeBoy) { _roomTypeBoy = [[QXRoomSettingModel alloc] init]; _roomTypeBoy.name = QXText(@"男神"); _roomTypeBoy.type = QXRoomSettingTypeRoomTypeBoy; _roomTypeBoy.icon = @"room_set_room_type_boy"; } return _roomTypeBoy; } -(QXRoomSettingModel *)roomTypeGirl{ if (!_roomTypeGirl) { _roomTypeGirl = [[QXRoomSettingModel alloc] init]; _roomTypeGirl.name = QXText(@"女神"); _roomTypeGirl.type = QXRoomSettingTypeRoomTypeGirl; _roomTypeGirl.icon = @"room_set_room_type_girl"; } return _roomTypeGirl; } -(QXRoomSettingModel *)roomTypeFriend{ if (!_roomTypeFriend) { _roomTypeFriend = [[QXRoomSettingModel alloc] init]; _roomTypeFriend.name = QXText(@"互娱"); _roomTypeFriend.type = QXRoomSettingTypeRoomTypeFriend; _roomTypeFriend.icon = @"room_set_room_type_friend"; } return _roomTypeFriend; } -(QXRoomSettingModel *)roomTypeFunny{ if (!_roomTypeFunny) { _roomTypeFunny = [[QXRoomSettingModel alloc] init]; _roomTypeFunny.name = QXText(@"交友"); _roomTypeFunny.type = QXRoomSettingTypeRoomTypeFunny; _roomTypeFunny.icon = @"room_set_room_type_funny"; } return _roomTypeFunny; } -(QXRoomSettingModel *)roomSubsidy{ if (!_roomSubsidy) { _roomSubsidy = [[QXRoomSettingModel alloc] init]; _roomSubsidy.name = QXText(@"房间补贴"); _roomSubsidy.type = QXRoomSettingTypeRoomSubsidy; _roomSubsidy.icon = @"room_set_room_subsidy"; } return _roomSubsidy; } -(QXRoomSettingModel *)roomCompere{ if (!_roomCompere) { _roomCompere = [[QXRoomSettingModel alloc] init]; _roomCompere.name = QXText(@"主持设置"); _roomCompere.type = QXRoomSettingTypeRoomCompere; _roomCompere.icon = @"room_set_room_compere"; } return _roomCompere; } -(QXRoomSettingModel *)roomMessage{ if (!_roomMessage) { _roomMessage = [[QXRoomSettingModel alloc] init]; _roomMessage.name = QXText(@"清空消息"); _roomMessage.type = QXRoomSettingTypeRoomClearMessage; _roomMessage.icon = @"room_set_room_message"; } return _roomMessage; } -(QXRoomSettingModel *)roomOrderMic{ if (!_roomOrderMic) { _roomOrderMic = [[QXRoomSettingModel alloc] init]; _roomOrderMic.name = QXText(@"排麦模式"); _roomOrderMic.selName = QXText(@"排麦模式"); _roomOrderMic.type = QXRoomSettingTypeRoomOrderMic; _roomOrderMic.icon = @"room_set_room_orderMic"; _roomOrderMic.selIcon = @"room_set_room_orderMic_free"; } return _roomOrderMic; } -(QXRoomSettingModel *)roomBgMusic{ if (!_roomBgMusic) { _roomBgMusic = [[QXRoomSettingModel alloc] init]; _roomBgMusic.name = QXText(@"背景音乐"); _roomBgMusic.type = QXRoomSettingTypeRoomBgMusic; _roomBgMusic.icon = @"room_set_room_bg_music"; } return _roomBgMusic; } -(QXRoomSettingModel *)roomBgImage{ if (!_roomBgImage) { _roomBgImage = [[QXRoomSettingModel alloc] init]; _roomBgImage.name = QXText(@"背景图片"); _roomBgImage.type = QXRoomSettingTypeRoomBgImage; _roomBgImage.icon = @"room_set_room_bg_image"; } return _roomBgImage; } -(QXRoomSettingModel *)roomLeave{ if (!_roomLeave) { _roomLeave = [[QXRoomSettingModel alloc] init]; _roomLeave.name = QXText(@"离开房间"); _roomLeave.type = QXRoomSettingTypeRoomLeave; _roomLeave.icon = @"room_set_room_leave"; } return _roomLeave; } -(QXRoomSettingModel *)roomShare{ if (!_roomShare) { _roomShare = [[QXRoomSettingModel alloc] init]; _roomShare.name = QXText(@"分享房间"); _roomShare.type = QXRoomSettingTypeRoomShare; _roomShare.icon = @"room_set_room_share"; } return _roomShare; } -(QXRoomSettingModel *)roomVoiceSet{ if (!_roomVoiceSet) { _roomVoiceSet = [[QXRoomSettingModel alloc] init]; _roomVoiceSet.name = QXText(@"调音台"); _roomVoiceSet.type = QXRoomSettingTypeRoomVoiceSet; _roomVoiceSet.icon = @"room_set_room_voice"; } return _roomVoiceSet; } -(QXRoomSettingModel *)roomSetting{ if (!_roomSetting) { _roomSetting = [[QXRoomSettingModel alloc] init]; _roomSetting.name = QXText(@"房间设置"); _roomSetting.type = QXRoomSettingTypeRoomSetting; _roomSetting.icon = @"room_set_room_setting"; } return _roomSetting; } -(QXRoomSettingModel *)roomEffects{ if (!_roomEffects) { _roomEffects = [[QXRoomSettingModel alloc] init]; _roomEffects.name = QXText(@"关闭特效"); _roomEffects.selName = QXText(@"开启特效"); _roomEffects.type = QXRoomSettingTypeRoomCloseEffects; _roomEffects.icon = @"room_set_room_effects_off"; _roomEffects.selIcon = @"room_set_room_effects_on"; } return _roomEffects; } -(QXRoomSettingModel *)roomWelcome{ if (!_roomWelcome) { _roomWelcome = [[QXRoomSettingModel alloc] init]; _roomWelcome.name = QXText(@"欢迎语"); _roomWelcome.type = QXRoomSettingTypeRoomWelcome; _roomWelcome.icon = @"room_set_room_welcome"; } return _roomWelcome; } -(QXRoomSettingModel *)roomReport{ if (!_roomReport) { _roomReport = [[QXRoomSettingModel alloc] init]; _roomReport.name = QXText(@"举报"); _roomReport.type = QXRoomSettingTypeRoomReport; _roomReport.icon = @"room_set_room_report"; } return _roomReport; } -(QXRoomSettingModel *)drifPop{ if (!_drifPop) { _drifPop = [[QXRoomSettingModel alloc] init]; _drifPop.name = QXText(@"关闭飘屏"); _drifPop.selName = QXText(@"开启飘屏"); _drifPop.type = QXRoomSettingTypeDrifPop; _drifPop.icon = @"room_set_drif_pop_off"; _drifPop.selIcon = @"room_set_drif_pop_on"; } return _drifPop; } -(QXDirectListView *)directView{ if (!_directView) { _directView = [[QXDirectListView alloc] init]; } return _directView; } -(QXSingerConfigView *)singerConifgView{ if (!_singerConifgView) { _singerConifgView = [[QXSingerConfigView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } return _singerConifgView; } -(QXRoomWelcomeView *)welcomeView{ if (!_welcomeView) { _welcomeView = [[QXRoomWelcomeView alloc] initWithFrame:[UIScreen mainScreen].bounds]; } return _welcomeView; } -(QXAlertView *)alertView{ if (!_alertView) { _alertView = [[QXAlertView alloc] initWithFrame:CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(175))]; } return _alertView; } @end @implementation QXRoomSettingCell +(instancetype)cellWithTableView:(UITableView *)tableView{ static NSString* cellId = @"QXRoomSettingCell"; QXRoomSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId]; if (!cell) { cell = [[QXRoomSettingCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:cellId]; } return cell; } -(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { self.contentView.backgroundColor = [UIColor clearColor]; self.backgroundColor = [UIColor clearColor]; self.selectionStyle = UITableViewCellSelectionStyleNone; [self initSubviews]; } return self; } -(void)initSubviews{ UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init]; layout.itemSize = CGSizeMake(ScaleWidth(50), ScaleWidth(54)+5); layout.minimumLineSpacing = 6; layout.sectionInset = UIEdgeInsetsMake(0, 16, 0, 16); layout.scrollDirection = UICollectionViewScrollDirectionHorizontal; self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout]; [self.collectionView registerClass:[QXRoomSettingSubCell class] forCellWithReuseIdentifier:@"QXRoomSettingSubCell"]; self.collectionView.delegate = self; self.collectionView.backgroundColor = [UIColor clearColor]; self.collectionView.dataSource = self; self.collectionView.showsHorizontalScrollIndicator = NO; self.collectionView.bounces = NO; self.contentView.backgroundColor = [UIColor clearColor]; [self.contentView addSubview:self.collectionView]; [self.collectionView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.top.equalTo(self.contentView); }]; } -(void)setDataArray:(NSArray *)dataArray{ _dataArray = dataArray; [self.collectionView reloadData]; } -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{ return self.dataArray.count; } -(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{ QXRoomSettingSubCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"QXRoomSettingSubCell" forIndexPath:indexPath]; QXRoomSettingModel *model = self.dataArray[indexPath.row]; cell.model = model; cell.roomId = self.roomId; return cell; } -(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{ QXRoomSettingModel *model = self.dataArray[indexPath.row]; if (model.type == QXRoomSettingTypeRoomCloseEffects) { model.isSelected = !model.isSelected; QXRoomSettingSubCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; cell.model = model; [[NSUserDefaults standardUserDefaults] setBool:model.isSelected forKey:kEffectsCLose]; [[QXGiftPlayerManager shareManager] openOrCloseEffectViewWith:!model.isSelected]; return; } if (model.type == QXRoomSettingTypeDrifPop) { model.isSelected = !model.isSelected; QXRoomSettingSubCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; cell.model = model; [[NSUserDefaults standardUserDefaults] setBool:model.isSelected forKey:kIsCloseDrifPop]; [[QXGiftDriftView shareView] drifPopIsClose:model.isSelected]; [[QXMeetActivityDriftView shareView] drifPopIsClose:model.isSelected]; return; } if (model.type == QXRoomSettingTypeRoomOrderMic) { [QXMineNetwork roomChangeUpSeatTypeWithRoomId:self.roomId successBlock:^(NSDictionary * _Nonnull dict) { // model.isSelected = !model.isSelected; // QXRoomSettingSubCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; // cell.model = model; } failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) { showToast(msg); }]; return; } if (self.delegate && [self.delegate respondsToSelector:@selector(didClickSetModel:)]) { [self.delegate didClickSetModel:model]; } // if (model.selIcon.length > 0) { // model.isSelected = !model.isSelected; // QXRoomSettingSubCell *cell = [collectionView cellForItemAtIndexPath:indexPath]; // cell.model = model; // } } @end @implementation QXRoomSettingSubCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self initSubviews]; } return self; } -(void)initSubviews{ self.contentView.backgroundColor = [UIColor clearColor]; self.imageView = [[UIImageView alloc] init]; self.imageView.contentMode = UIViewContentModeScaleAspectFit; [self.contentView addSubview:self.imageView]; [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.top.equalTo(self); make.height.equalTo(self.imageView.mas_height); }]; self.titleLabel = [[UILabel alloc] init]; self.titleLabel.font = [UIFont systemFontOfSize:12]; self.titleLabel.textColor = RGB16(0x666666); self.titleLabel.textAlignment = NSTextAlignmentCenter; [self.contentView addSubview:self.titleLabel]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.bottom.equalTo(self); make.top.equalTo(self.imageView.mas_bottom).offset(5); }]; } -(void)setModel:(QXRoomSettingModel *)model{ _model = model; if (model.isSelected) { if ([model.selIcon hasPrefix:@"https"] || [model.selIcon hasPrefix:@"http"]) { [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.selIcon]]; }else{ self.imageView.image = [UIImage imageNamed:model.selIcon]; } self.titleLabel.text = model.selName; }else{ if ([model.icon hasPrefix:@"https"] || [model.icon hasPrefix:@"http"]) { [self.imageView sd_setImageWithURL:[NSURL URLWithString:model.icon]]; }else{ self.imageView.image = [UIImage imageNamed:model.icon]; } self.titleLabel.text = model.name; } } @end @implementation QXRoomSettingModel @end