Files
featherVoice/QXLive/Room(房间)/View/点唱/QXSingerSongListSubView.m
2025-11-21 16:17:05 +08:00

123 lines
4.4 KiB
Objective-C

//
// QXSingerSongListSubView.m
// QXLive
//
// Created by 启星 on 2025/11/14.
//
#import "QXSingerSongListSubView.h"
#import "QXSingerSongListContentView.h"
@interface QXSingerSongListSubView()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
@property (nonatomic,strong)NSMutableArray *titles;
@property (nonatomic,strong)NSString *todayTitle;
@property (nonatomic,strong)NSString *yestoryTitle;
@property (nonatomic,strong)NSString *weekTitle;
@property (nonatomic,strong)NSString *lastweekTitle;
@end
@implementation QXSingerSongListSubView
-(UIView *)listView{
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.categoryView = [[JXCategoryTitleView alloc] init];
self.categoryView.frame = CGRectMake(16,0,SCREEN_WIDTH-32, 64);
self.categoryView.delegate = self;
// self.categoryView.titles = @[@"全部",@"1号麦",@"2号麦"];
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#ffffff"];
self.categoryView.titleColor = [UIColor colorWithHexString:@"#BBB9C6"];
self.categoryView.cellWidth = 60;
self.categoryView.cellSpacing = 16;
self.categoryView.contentEdgeInsetLeft = 8;
// self.categoryView.contentEdgeInsetRight = 8;
// self.categoryView.titleLabelZoomScale = 1.1;
// self.categoryView.titleLabelZoomEnabled = YES;
self.categoryView.titleFont = [UIFont boldSystemFontOfSize:14];
self.categoryView.titleSelectedFont = [UIFont boldSystemFontOfSize:14];
self.categoryView.averageCellSpacingEnabled = NO;
JXCategoryIndicatorBackgroundView *indicatorView = [[JXCategoryIndicatorBackgroundView alloc] init];
indicatorView.indicatorHeight = 32;
indicatorView.indicatorWidth = 60;
indicatorView.indicatorColor = RGB16(0x3ABC6D);
indicatorView.indicatorCornerRadius = 16;
self.categoryView.indicators = @[indicatorView];
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_CollectionView) delegate:self];
self.containerView.frame = CGRectMake(0, 60, self.width, self.height-60);
self.containerView.listCellBackgroundColor = RGB16(0x1B1926);
self.containerView.scrollView.backgroundColor = RGB16(0x1B1926);
[self addSubview:self.categoryView];
[self addSubview:self.containerView];
self.categoryView.listContainer = self.containerView;
}
-(void)setType:(NSInteger)type{
_type = type;
if (type == 0) {
/// 点歌
}else if(type == 1){
/// 已点歌曲
}else{
/// 历史歌曲
self.todayTitle = @"今日";
self.yestoryTitle = @"昨日";
self.weekTitle = @"本周";
self.lastweekTitle = @"上周";
[self.titles removeAllObjects];
[self.titles addObject:self.todayTitle];
[self.titles addObject:self.yestoryTitle];
[self.titles addObject:self.weekTitle];
[self.titles addObject:self.lastweekTitle];
self.categoryView.titles = self.titles;
}
}
-(void)setPitArray:(NSArray *)pitArray{
_pitArray = pitArray;
[self.titles removeAllObjects];
[self.titles addObject:@"全部"];
for (QXRoomPitModel*pitModel in pitArray) {
[self.titles addObject:[NSString stringWithFormat:@"%@号麦",pitModel.pit_number]];
}
self.categoryView.titles = self.titles;
[self.categoryView reloadData];
[self.containerView reloadData];
}
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
return self.titles.count;
}
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
QXSingerSongListContentView *view = [[QXSingerSongListContentView alloc] initWithFrame:self.containerView.bounds];
view.type = self.type;
if (self.type == 0) {
if (self.titles.count > 1 && index>0) {
view.pitModel = self.pitArray[index-1];
}
}
if (self.type == 2) {
view.historyType = index+2;
}
view.roomId = self.roomId;
return view;
}
-(NSMutableArray *)titles{
if (!_titles) {
_titles = [NSMutableArray arrayWithArray:@[@"全部"]];
}
return _titles;
}
@end