增加换肤功能
This commit is contained in:
400
QXLive/HomePage(声播)/View/房间/QXRoomTitleView.m
Normal file
400
QXLive/HomePage(声播)/View/房间/QXRoomTitleView.m
Normal file
@@ -0,0 +1,400 @@
|
||||
//
|
||||
// QXRoomTitleView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/6/7.
|
||||
//
|
||||
|
||||
#import "QXRoomTitleView.h"
|
||||
#import "QXRoomOnlineUserListView.h"
|
||||
#import "QXRoomNoticeView.h"
|
||||
#import "QXRoomRankView.h"
|
||||
#import "QXGiftPlayerManager.h"
|
||||
#import "QXAgoraEngine.h"
|
||||
#import "QXRoomMessageManager.h"
|
||||
#import "QXMineNetwork.h"
|
||||
#import "QXDynamicNetwork.h"
|
||||
|
||||
@interface QXRoomTitleView()<QXRoomSeatDelegate>
|
||||
/// 左侧房间信息背景
|
||||
@property (nonatomic,strong) UIView *leftBgView;
|
||||
/// 房间头像
|
||||
@property (nonatomic,strong) UIImageView *roomImageView;
|
||||
/// 房间名称
|
||||
@property (nonatomic,strong) UILabel * nameLabel;
|
||||
/// 房间id
|
||||
@property (nonatomic,strong) UILabel * IdLabel;
|
||||
/// 关注
|
||||
@property (nonatomic,strong) UIButton *followBtn;
|
||||
/// 退出房间按钮
|
||||
@property (nonatomic,strong) UIButton *closeBtn;
|
||||
|
||||
@property (nonatomic,strong) UILabel *countLabel;
|
||||
@property (nonatomic,strong) UIView *onLineBgView;
|
||||
@property (nonatomic,strong) NSMutableArray *onlineHeaderViewArray;
|
||||
|
||||
/// 排行榜
|
||||
@property (nonatomic,strong) UIButton *rankBtn;
|
||||
/// 公告
|
||||
@property (nonatomic,strong) UIButton *noticeBtn;
|
||||
/// 清除魅力
|
||||
@property (nonatomic,strong)UIButton *clearCharmBtn;
|
||||
|
||||
|
||||
@property (nonatomic,strong) QXRoomOnlineUserListView *onlineListView;
|
||||
@property (nonatomic,strong) QXRoomNoticeView *noticeView;
|
||||
|
||||
@end
|
||||
|
||||
@implementation QXRoomTitleView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)initSubviews{
|
||||
self.leftBgView = [[UIView alloc] init];
|
||||
self.leftBgView.backgroundColor = RGB16A(0xFFFFFF,0.2);
|
||||
[self.leftBgView addRoundedCornersWithRadius:ScaleWidth(20)];
|
||||
[self addSubview:self.leftBgView];
|
||||
[self.leftBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(16);
|
||||
make.width.mas_equalTo(ScaleWidth(168));
|
||||
make.height.mas_equalTo(ScaleWidth(40));
|
||||
make.top.equalTo(self);
|
||||
}];
|
||||
|
||||
self.roomImageView = [[UIImageView alloc] init];
|
||||
self.roomImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[self.leftBgView addSubview:self.roomImageView];
|
||||
[self.roomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.left.mas_equalTo(7);
|
||||
make.bottom.mas_equalTo(-7);
|
||||
make.width.equalTo(self.roomImageView.mas_height);
|
||||
}];
|
||||
|
||||
|
||||
self.followBtn = [[UIButton alloc] init];
|
||||
[self.followBtn setTitle:QXText(@"收藏") forState:(UIControlStateNormal)];
|
||||
[self.followBtn setTitle:QXText(@"已收藏") forState:(UIControlStateSelected)];
|
||||
[self.followBtn addRoundedCornersWithRadius:ScaleWidth(12)];
|
||||
[self.followBtn addTarget:self action:@selector(followAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.followBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
|
||||
[self.followBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateSelected)];
|
||||
[self.followBtn setBackgroundImage:[UIImage imageWithColor:QXConfig.themeColor] forState:UIControlStateNormal];
|
||||
[self.followBtn setBackgroundImage:[UIImage imageWithColor:RGB16(0xF1F2F3)] forState:UIControlStateSelected];
|
||||
self.followBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.leftBgView addSubview:self.followBtn];
|
||||
[self.followBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-7);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(46), ScaleWidth(24)));
|
||||
make.centerY.equalTo(self.leftBgView);
|
||||
}];
|
||||
|
||||
self.nameLabel = [[UILabel alloc] init];
|
||||
self.nameLabel.text = @"房间名称";
|
||||
self.nameLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.nameLabel.textColor = [UIColor whiteColor];
|
||||
[self.leftBgView addSubview:self.nameLabel];
|
||||
[self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(3);
|
||||
make.left.equalTo(self.roomImageView.mas_right).offset(4);
|
||||
make.height.mas_equalTo(ScaleWidth(15));
|
||||
make.right.equalTo(self.followBtn.mas_left).offset(-10);
|
||||
}];
|
||||
|
||||
self.IdLabel = [[UILabel alloc] init];
|
||||
self.IdLabel.text = @"ID:0000001";
|
||||
self.IdLabel.font = [UIFont systemFontOfSize:12];
|
||||
self.IdLabel.textColor = [UIColor whiteColor];
|
||||
[self.leftBgView addSubview:self.IdLabel];
|
||||
[self.IdLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.bottom.mas_equalTo(-3);
|
||||
make.left.equalTo(self.nameLabel);
|
||||
make.height.mas_equalTo(ScaleWidth(18));
|
||||
make.right.equalTo(self.nameLabel);
|
||||
}];
|
||||
|
||||
|
||||
|
||||
self.closeBtn = [[UIButton alloc] init];
|
||||
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.closeBtn setImage:[UIImage imageNamed:@"room_close"] forState:(UIControlStateNormal)];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.height.mas_equalTo(ScaleWidth(40));
|
||||
make.right.mas_equalTo(-5);
|
||||
make.centerY.equalTo(self.leftBgView);
|
||||
}];
|
||||
|
||||
self.countLabel = [[UILabel alloc] init];
|
||||
self.countLabel.textColor = [UIColor whiteColor];
|
||||
self.countLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self addSubview:self.countLabel];
|
||||
[self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.height.mas_equalTo(ScaleWidth(40));
|
||||
make.right.equalTo(self.closeBtn.mas_left).offset(-5);
|
||||
make.centerY.equalTo(self.leftBgView);
|
||||
}];
|
||||
|
||||
MJWeakSelf
|
||||
self.onLineBgView = [[UIView alloc] init];
|
||||
[self.onLineBgView addTapBlock:^(id _Nonnull obj) {
|
||||
[weakSelf showOnlineList];
|
||||
}];
|
||||
[self addSubview:self.onLineBgView];
|
||||
[self.onLineBgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.equalTo(self.countLabel.mas_left).offset(-5);
|
||||
make.left.equalTo(self.leftBgView.mas_right);
|
||||
make.height.equalTo(self.leftBgView);
|
||||
make.top.equalTo(self.leftBgView);
|
||||
}];
|
||||
|
||||
|
||||
self.rankBtn = [[UIButton alloc] init];
|
||||
[self.rankBtn setTitle:[NSString stringWithFormat:@" %@",QXText(@"排行榜")] forState:(UIControlStateNormal)];
|
||||
self.rankBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.rankBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
||||
[self.rankBtn addTarget:self action:@selector(rankAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.rankBtn setImage:[UIImage imageNamed:@"room_rank_icon"] forState:(UIControlStateNormal)];
|
||||
self.rankBtn.backgroundColor = RGB16A(0xFFFFFF,0.2);
|
||||
[self.rankBtn addRoundedCornersWithRadius:ScaleWidth(11)];
|
||||
[self addSubview:self.rankBtn];
|
||||
[self.rankBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(ScaleWidth(70));
|
||||
make.height.mas_equalTo(ScaleWidth(22));
|
||||
make.left.mas_equalTo(16);
|
||||
make.top.equalTo(self.leftBgView.mas_bottom).offset(12);
|
||||
}];
|
||||
|
||||
|
||||
self.noticeBtn = [[UIButton alloc] init];
|
||||
[self.noticeBtn setTitle:[NSString stringWithFormat:@" %@",QXText(@"公告")] forState:(UIControlStateNormal)];
|
||||
self.noticeBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.noticeBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
||||
[self.noticeBtn addTarget:self action:@selector(noticeAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.noticeBtn setImage:[UIImage imageNamed:@"room_notice_icon"] forState:(UIControlStateNormal)];
|
||||
self.noticeBtn.backgroundColor = RGB16A(0xFFFFFF,0.2);
|
||||
[self.noticeBtn addRoundedCornersWithRadius:ScaleWidth(11)];
|
||||
[self addSubview:self.noticeBtn];
|
||||
[self.noticeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(ScaleWidth(58));
|
||||
make.height.mas_equalTo(ScaleWidth(22));
|
||||
make.left.equalTo(self.rankBtn.mas_right).offset(12);
|
||||
make.top.equalTo(self.leftBgView.mas_bottom).offset(12);
|
||||
}];
|
||||
|
||||
|
||||
self.clearCharmBtn = [[UIButton alloc] init];
|
||||
self.clearCharmBtn.hidden = YES;
|
||||
[self.clearCharmBtn setTitle:[NSString stringWithFormat:@" %@",QXText(@"清除魅力")] forState:(UIControlStateNormal)];
|
||||
self.clearCharmBtn.titleLabel.font = [UIFont systemFontOfSize:12];
|
||||
[self.clearCharmBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
|
||||
[self.clearCharmBtn addTarget:self action:@selector(clearAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self.clearCharmBtn setImage:[UIImage imageNamed:@"room_clear_charm"] forState:(UIControlStateNormal)];
|
||||
self.clearCharmBtn.backgroundColor = RGB16A(0xFFFFFF,0.2);
|
||||
[self.clearCharmBtn addRoundedCornersWithRadius:ScaleWidth(11)];
|
||||
[self addSubview:self.clearCharmBtn];
|
||||
[self.clearCharmBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(ScaleWidth(78));
|
||||
make.height.mas_equalTo(ScaleWidth(22));
|
||||
make.left.equalTo(self.noticeBtn.mas_right).offset(12);
|
||||
make.top.equalTo(self.leftBgView.mas_bottom).offset(12);
|
||||
}];
|
||||
}
|
||||
|
||||
-(UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
|
||||
UIView *hitView= [super hitTest:point withEvent:event];
|
||||
if (hitView== self)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
return hitView;
|
||||
}
|
||||
}
|
||||
-(void)setIsCompere:(BOOL)isCompere{
|
||||
_isCompere = isCompere;
|
||||
self.clearCharmBtn.hidden = !isCompere;
|
||||
}
|
||||
-(void)layoutSubviews{
|
||||
[super layoutSubviews];
|
||||
[self.roomImageView addRoundedCornersWithRadius:ScaleWidth(40-14)/2];
|
||||
}
|
||||
- (void)setRoomModel:(QXRoomModel *)roomModel{
|
||||
_roomModel = roomModel;
|
||||
[self.roomImageView sd_setImageWithURL:[NSURL URLWithString:roomModel.room_info.room_cover]];
|
||||
self.nameLabel.text = roomModel.room_info.room_name;
|
||||
self.IdLabel.text = [NSString stringWithFormat:@"ID:%@",roomModel.room_info.room_number];
|
||||
if (roomModel.user_info.is_collect.intValue == 1) {
|
||||
self.followBtn.selected = YES;
|
||||
}else{
|
||||
self.followBtn.selected = NO;
|
||||
}
|
||||
self.countLabel.text = roomModel.room_info.online_number?roomModel.room_info.online_number:@"0";
|
||||
}
|
||||
-(void)setOnlineUsers:(NSArray *)onlineUsers{
|
||||
_onlineUsers = onlineUsers;
|
||||
[self.onLineBgView removeAllSubviews];
|
||||
[self.onlineHeaderViewArray removeAllObjects];
|
||||
QXRoomUserInfoModel *md;
|
||||
CGFloat imageWidth = 18;
|
||||
CGFloat margin = 5;
|
||||
int count = 0;
|
||||
for (QXRoomUserInfoModel *md in onlineUsers) {
|
||||
count++;
|
||||
if (count<4) {
|
||||
UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"user_header_placehoulder"]];
|
||||
imageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
[imageView addRoundedCornersWithRadius:imageWidth/2];
|
||||
[self.onLineBgView addSubview:imageView];
|
||||
[imageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-(imageWidth-margin)*count);
|
||||
make.height.width.mas_equalTo(imageWidth);
|
||||
make.centerY.equalTo(self.onLineBgView);
|
||||
}];
|
||||
if (md) {
|
||||
[imageView sd_setImageWithURL:[NSURL URLWithString:md.avatar]];
|
||||
}
|
||||
[self.onlineHeaderViewArray addObject:imageView];
|
||||
}else{
|
||||
break;;
|
||||
}
|
||||
}
|
||||
// for (int i = 0; i < 3; i++) {
|
||||
// if (onlineUsers.count >= 3) {
|
||||
// md = onlineUsers[i];
|
||||
// }else if (onlineUsers.count == 2) {
|
||||
// if (i < 2) {
|
||||
// md = onlineUsers[i];
|
||||
// }
|
||||
// }else if (onlineUsers.count == 1) {
|
||||
// if (i < 1) {
|
||||
// md = onlineUsers[i];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
-(void)clearAction{
|
||||
[QXMineNetwork roomClearCharmWithRoomId:self.roomModel.room_info.room_id userId:@"" successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
showToast(msg);
|
||||
}];
|
||||
}
|
||||
-(void)previewUserInfoWithUserId:(NSString *)userId{
|
||||
[self.onlineListView hide];
|
||||
_onlineListView = nil;
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(previewUserInfoWithUserId:)]) {
|
||||
[self.delegate previewUserInfoWithUserId:userId];
|
||||
}
|
||||
}
|
||||
|
||||
-(void)showOnlineList{
|
||||
self.onlineListView.roomId = self.roomModel.room_info.room_id;
|
||||
[self.onlineListView showInView:self.viewController.view];
|
||||
}
|
||||
|
||||
-(QXRoomOnlineUserListView *)onlineListView{
|
||||
if (!_onlineListView) {
|
||||
_onlineListView = [[QXRoomOnlineUserListView alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
_onlineListView.delegate = self;
|
||||
MJWeakSelf
|
||||
_onlineListView.onlineListBlock = ^(NSArray * _Nonnull onlineUsers) {
|
||||
[weakSelf setOnlineUsers:onlineUsers];
|
||||
weakSelf.countLabel.text = [NSString stringWithFormat:@"%ld",onlineUsers.count];
|
||||
};
|
||||
}
|
||||
return _onlineListView;
|
||||
}
|
||||
-(QXRoomNoticeView *)noticeView{
|
||||
if (!_noticeView) {
|
||||
_noticeView = [[QXRoomNoticeView alloc] init];
|
||||
}
|
||||
return _noticeView;
|
||||
}
|
||||
|
||||
|
||||
-(void)noticeAction{
|
||||
// self.noticeView.roomNotice = @"本房间严禁刷屏,禁止非法广告及宣传,禁止引战,地域黑,语言攻击等本房间严禁刷屏,禁止非法广告及宣传,禁止引战,地域黑,语言攻击等本房间严禁刷屏,禁止非法广告及宣传。本房间严禁刷屏,禁止非法广告及宣传,禁止引战,地域黑,语言攻击等本房间严禁刷屏,禁止非法广告及宣传,禁止引战,地域黑,语言攻击等本房间严禁刷屏,禁止非法广告及宣传。";
|
||||
self.noticeView.roomNotice = self.roomModel.room_info.room_intro;
|
||||
[[QXGlobal shareGlobal] showView:self.noticeView controller:self.viewController popType:(PopViewTypePopFromCenter) tapDismiss:NO finishBlock:^{
|
||||
|
||||
}];
|
||||
}
|
||||
|
||||
-(void)rankAction{
|
||||
QXRoomRankView *rankView = [[QXRoomRankView alloc] initWithFrame:[UIScreen mainScreen].bounds];
|
||||
rankView.roomId = self.roomId;
|
||||
[rankView showInView:self.viewController.view];
|
||||
}
|
||||
|
||||
-(void)followAction:(UIButton*)sender{
|
||||
[QXDynamicNetwork followWithUserId:self.roomId type:@"2" successBlock:^(NSDictionary * _Nonnull dict) {
|
||||
sender.selected = !sender.selected;
|
||||
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
-(void)onlineNumberIsAdd:(BOOL)isAdd{
|
||||
NSInteger number = self.roomModel.room_info.online_number.integerValue;
|
||||
if (isAdd) {
|
||||
number+=1;
|
||||
}else{
|
||||
number-=1;
|
||||
}
|
||||
if (number <= 0) {
|
||||
number = 0;
|
||||
}
|
||||
self.roomModel.room_info.online_number = [NSString stringWithFormat:@"%ld",number];
|
||||
self.countLabel.text = self.roomModel.room_info.online_number;
|
||||
}
|
||||
-(void)setOnlineNumber:(NSString *)onlineNumber{
|
||||
self.roomModel.room_info.online_number = onlineNumber;
|
||||
self.countLabel.text = self.roomModel.room_info.online_number;
|
||||
}
|
||||
|
||||
-(void)closeAction{
|
||||
MJWeakSelf
|
||||
UIAlertController *al = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:(UIAlertControllerStyleActionSheet)];
|
||||
[al addAction:[UIAlertAction actionWithTitle:@"最小化房间" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
|
||||
[weakSelf miniRoom];
|
||||
[[QXGlobal shareGlobal] miniRoomWithRoomId:weakSelf.roomId roomCover:weakSelf.roomModel.room_info.room_cover];
|
||||
}]];
|
||||
[al addAction:[UIAlertAction actionWithTitle:@"退出房间" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
|
||||
[weakSelf leaveRoom];
|
||||
}]];
|
||||
[al addAction:[UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
|
||||
|
||||
}]];
|
||||
[self.viewController presentViewController:al animated:YES completion:nil];
|
||||
|
||||
}
|
||||
-(void)miniRoom{
|
||||
// self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
-(void)leaveRoom{
|
||||
[[QXGlobal shareGlobal]quitRoomWithRoomId:self.roomId];
|
||||
// self.navigationController.interactivePopGestureRecognizer.enabled = YES;
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
|
||||
-(NSMutableArray *)onlineHeaderViewArray{
|
||||
if (!_onlineHeaderViewArray) {
|
||||
_onlineHeaderViewArray = [NSMutableArray array];
|
||||
}
|
||||
return _onlineHeaderViewArray;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user