172 lines
6.8 KiB
Mathematica
172 lines
6.8 KiB
Mathematica
|
|
//
|
||
|
|
// QXSingerSongListView.m
|
||
|
|
// QXLive
|
||
|
|
//
|
||
|
|
// Created by 启星 on 2025/11/14.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "QXSingerSongListView.h"
|
||
|
|
#import "QXSingerSongListSubView.h"
|
||
|
|
#import "QXSingerSongListContentView.h"
|
||
|
|
#import "QXMineNetwork.h"
|
||
|
|
|
||
|
|
@interface QXSingerSongListView()<UIGestureRecognizerDelegate,JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
|
||
|
|
@property (nonatomic,strong)UIView *bgView;
|
||
|
|
@property (nonatomic,strong)JXCategoryTitleView *categoryView;
|
||
|
|
@property (nonatomic,strong)JXCategoryListContainerView *containerView;
|
||
|
|
@property (nonatomic,strong)QXSingerSongListSubView *requestSongView;
|
||
|
|
@property (nonatomic,strong)QXSingerSongListContentView *alreadySongView;
|
||
|
|
@property (nonatomic,strong)QXSingerSongListSubView *historySongView;
|
||
|
|
|
||
|
|
@property (nonatomic,strong)NSString *requestSongTitle;
|
||
|
|
@property (nonatomic,strong)NSString *alreadySongTitle;
|
||
|
|
@property (nonatomic,strong)NSString *historySongTitle;
|
||
|
|
@property (nonatomic,strong)NSMutableArray *titles;
|
||
|
|
@end
|
||
|
|
@implementation QXSingerSongListView
|
||
|
|
|
||
|
|
- (instancetype)init
|
||
|
|
{
|
||
|
|
self = [super init];
|
||
|
|
if (self) {
|
||
|
|
self.frame = UIScreen.mainScreen.bounds;
|
||
|
|
[self initSubviews];
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
-(void)initSubviews{
|
||
|
|
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hide)];
|
||
|
|
tap.delegate = self;
|
||
|
|
[self addGestureRecognizer:tap];
|
||
|
|
self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
|
||
|
|
self.requestSongTitle = @"点歌";
|
||
|
|
self.alreadySongTitle = @"已点歌曲";
|
||
|
|
self.historySongTitle = @"历史记录";
|
||
|
|
self.titles = [NSMutableArray arrayWithArray:@[self.requestSongTitle,self.alreadySongTitle,self.historySongTitle]];
|
||
|
|
|
||
|
|
self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, kSafeAreaBottom+ScaleWidth(510))];
|
||
|
|
self.bgView.backgroundColor = RGB16(0x1B1926);
|
||
|
|
[self.bgView addRoundedCornersWithRadius:16 byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight)];
|
||
|
|
[self addSubview:self.bgView];
|
||
|
|
|
||
|
|
self.categoryView = [[JXCategoryTitleView alloc] init];
|
||
|
|
self.categoryView.frame = CGRectMake(16,12,self.width-32, 44);
|
||
|
|
self.categoryView.delegate = self;
|
||
|
|
self.categoryView.titles = self.titles;
|
||
|
|
self.categoryView.titleSelectedColor = [UIColor colorWithHexString:@"#ffffff"];
|
||
|
|
self.categoryView.titleColor = [UIColor colorWithHexString:@"#BDBBC8"];
|
||
|
|
self.categoryView.cellWidth = JXCategoryViewAutomaticDimension;
|
||
|
|
self.categoryView.cellSpacing = 20;
|
||
|
|
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:16];
|
||
|
|
self.categoryView.averageCellSpacingEnabled = NO;
|
||
|
|
JXCategoryIndicatorLineView *indicatorView = [[JXCategoryIndicatorLineView alloc] init];
|
||
|
|
indicatorView.indicatorHeight = 2;
|
||
|
|
indicatorView.indicatorWidth = 10;
|
||
|
|
indicatorView.indicatorColor = RGB16(0xffffff);
|
||
|
|
indicatorView.indicatorCornerRadius = 1;
|
||
|
|
self.categoryView.indicators = @[indicatorView];
|
||
|
|
self.containerView = [[JXCategoryListContainerView alloc] initWithType:(JXCategoryListContainerType_ScrollView) delegate:self];
|
||
|
|
self.containerView.frame = CGRectMake(0, 44+12, self.width, self.bgView.height-44-12);
|
||
|
|
self.containerView.backgroundColor = RGB16(0x1B1926);
|
||
|
|
[self.bgView addSubview:self.categoryView];
|
||
|
|
[self.bgView addSubview:self.containerView];
|
||
|
|
self.categoryView.listContainer = self.containerView;
|
||
|
|
|
||
|
|
}
|
||
|
|
-(void)setRoomId:(NSString *)roomId{
|
||
|
|
_roomId = roomId;
|
||
|
|
[self getSongListCount];
|
||
|
|
}
|
||
|
|
-(void)getSongListCount{
|
||
|
|
MJWeakSelf
|
||
|
|
[QXMineNetwork requestSongCountWithRoomId:self.roomId successBlock:^(QXUserSongListCount * _Nonnull model) {
|
||
|
|
weakSelf.alreadySongTitle = [NSString stringWithFormat:@"已点歌曲(%@)",model.already];
|
||
|
|
[weakSelf.titles replaceObjectAtIndex:1 withObject:self.alreadySongTitle];
|
||
|
|
weakSelf.categoryView.titles = weakSelf.titles;
|
||
|
|
[weakSelf.categoryView reloadDataWithoutListContainer];
|
||
|
|
} failBlock:^(NSError * _Nonnull error, NSString * _Nonnull msg) {
|
||
|
|
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)updateAlreadyCountWithCount:(NSString*)count{
|
||
|
|
self.alreadySongTitle = [NSString stringWithFormat:@"已点歌曲(%@)",count];
|
||
|
|
[self.titles replaceObjectAtIndex:1 withObject:self.alreadySongTitle];
|
||
|
|
self.categoryView.titles = self.titles;
|
||
|
|
[self.categoryView reloadDataWithoutListContainer];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
|
||
|
|
return touch.view == self;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
|
||
|
|
return 3;
|
||
|
|
}
|
||
|
|
- (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
|
||
|
|
if (index == 0) {
|
||
|
|
return self.requestSongView;
|
||
|
|
}else if (index == 1){
|
||
|
|
return self.alreadySongView;
|
||
|
|
}else{
|
||
|
|
return self.historySongView;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)requestSongListCountDidChanged:(NSString *)count isHistory:(BOOL)isHistory{
|
||
|
|
if (isHistory) {
|
||
|
|
// self.historySongTitle = [NSString stringWithFormat:@"历史记录(%@)",count];;
|
||
|
|
}else{
|
||
|
|
self.alreadySongTitle = [NSString stringWithFormat:@"已点歌曲(%@)",count];;
|
||
|
|
}
|
||
|
|
[self.categoryView reloadData];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(QXSingerSongListSubView *)requestSongView{
|
||
|
|
if (!_requestSongView) {
|
||
|
|
_requestSongView = [[QXSingerSongListSubView alloc] initWithFrame:self.containerView.bounds];
|
||
|
|
_requestSongView.roomId = self.roomId;
|
||
|
|
_requestSongView.type = 0;
|
||
|
|
}
|
||
|
|
return _requestSongView;
|
||
|
|
}
|
||
|
|
-(QXSingerSongListContentView *)alreadySongView{
|
||
|
|
if (!_alreadySongView) {
|
||
|
|
_alreadySongView = [[QXSingerSongListContentView alloc] initWithFrame:self.containerView.bounds];
|
||
|
|
_alreadySongView.roomId = self.roomId;
|
||
|
|
_alreadySongView.type = 1;
|
||
|
|
}
|
||
|
|
return _alreadySongView;
|
||
|
|
}
|
||
|
|
-(QXSingerSongListSubView *)historySongView{
|
||
|
|
if (!_historySongView) {
|
||
|
|
_historySongView = [[QXSingerSongListSubView alloc] initWithFrame:self.containerView.bounds];
|
||
|
|
_historySongView.roomId = self.roomId;
|
||
|
|
_historySongView.type = 2;
|
||
|
|
}
|
||
|
|
return _historySongView;
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)showInView:(UIView *)view pitArray:(nonnull NSArray *)pitArray isCompere:(BOOL)isCompere{
|
||
|
|
self.requestSongView.pitArray = pitArray;
|
||
|
|
self.alreadySongView.isCompere = isCompere;
|
||
|
|
self.bgView.y = SCREEN_HEIGHT;
|
||
|
|
[view addSubview:self];
|
||
|
|
[UIView animateWithDuration:0.3 animations:^{
|
||
|
|
self.bgView.y = SCREEN_HEIGHT- ScaleWidth(510)-kSafeAreaBottom;
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
-(void)hide{
|
||
|
|
[UIView animateWithDuration:0.3 animations:^{
|
||
|
|
self.bgView.y = SCREEN_HEIGHT;
|
||
|
|
} completion:^(BOOL finished) {
|
||
|
|
[self removeFromSuperview];
|
||
|
|
}];
|
||
|
|
}
|
||
|
|
@end
|