| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- //
- // MORankListView.m
- // MiMoLive
- //
- // Created by SuperC on 2023/11/30.
- //
- #import "MORankListView.h"
- #import "JXCategoryView.h"
- #import "MORankListTableView.h"
- @interface MORankListView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
- @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
- @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
- @end
- @implementation MORankListView
- - (instancetype)init{
- self = [super init];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (instancetype)initWithFrame:(CGRect)frame
- {
- self = [super initWithFrame:frame];
- if (self)
- {
- [self setupUI];
- }
-
- return self;
- }
- - (void)setupUI{
-
- [self addSubview:self.titleCategoryView];
- [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(10);
- make.left.mas_equalTo(12);
- make.right.mas_equalTo(-12);
- make.height.mas_equalTo(34);
- }];
-
- [self addSubview:self.listContainerView];
- [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.titleCategoryView.mas_bottom).offset(8);
- make.left.right.bottom.mas_equalTo(0);
- }];
- self.titleCategoryView.listContainer = self.listContainerView;
- }
- - (void)setTypeNum:(NSInteger)typeNum {
- _typeNum = typeNum;
-
- if (typeNum == 3) {//收益榜有4个tab
- self.titleCategoryView.titles = @[NSLocalString(@"C60007"), NSLocalString(@"C60008"), NSLocalString(@"C60009"), NSLocalString(@"C60010")];
- } else if (typeNum == 2) {//探索-财富榜
- self.titleCategoryView.titles = @[NSLocalString(@"C60030"), NSLocalString(@"C60031"), NSLocalString(@"C60028")];
- } else if (typeNum == 1) {//房间贡献榜
- self.titleCategoryView.titles = @[NSLocalString(@"C60029"), NSLocalString(@"C60030"), NSLocalString(@"C60031"), NSLocalString(@"C60028")];
- }
-
- _titleCategoryView.cellWidth = kScaleWidth(351) / self.titleCategoryView.titles.count;
- }
- // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
- - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
- MOLogV(@"变换了");
- }
- #pragma mark - JXCategoryListContainerViewDelegate
- - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
- return self.titleCategoryView.titles.count;
- }
- - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
- MORankListTableView *view = [[MORankListTableView alloc] init];
- view.outSideRoom = self.outSideRoom;
- view.isNewer = self.isNewer;
- WEAKSELF
- view.getTopBlock = ^(NSArray<MORankNewerTop *> * _Nonnull topModelArray) {
- if (weakSelf.getTopBlock) {
- weakSelf.getTopBlock(topModelArray);
- }
- };
-
- view.getCurrentIndexBlock = ^(MORankFooter * _Nonnull footer) {
- if (weakSelf.getCurrentIndexBlock) {
- weakSelf.getCurrentIndexBlock(footer);
- }
- };
-
- view.hitBlock = ^(MORankHit * _Nonnull model) {
- if (weakSelf.hitBlock) {
- weakSelf.hitBlock(model);
- }
- };
- view.typeNum = self.typeNum;
- view.roomId = self.roomId;
- if (self.typeNum == 3) {//收益榜单类型(1=日榜,2=周榜,3=月榜,4=小时榜)但是小时榜排在最前面,手动处理一下
- view.typeTime = index;
- if (index == 0) {
- view.typeTime = 4;
- }
- } else if (self.typeNum == 1) {//直播间贡献榜(1=日榜,2=周榜,3=月榜,4=直播榜)但是直播榜排在最前面,手动处理一下
- view.typeTime = index;
- if (index == 0) {
- view.typeTime = 4;
- }
- }
- else {
- view.typeTime = index + 1;
- }
-
- view.countryStr = self.countyStr;
-
- view.headBtnBlock = ^(MOUserBase * _Nonnull model) {
- weakSelf.headBtnBlock ? weakSelf.headBtnBlock(model) : nil;
- };
-
- return view;
- }
- - (void)setRoomId:(NSString *)roomId{
- _roomId = roomId;
-
- WEAKSELF
- if(roomId.length > 0){
-
- [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
- MORankListTableView *listView = (MORankListTableView *)obj;
- listView.roomId = weakSelf.roomId;
- }];
- }
- }
- - (void)setCountyStr:(NSString *)countyStr{
- _countyStr = countyStr;
-
- WEAKSELF
- [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
- MORankListTableView *listView = (MORankListTableView *)obj;
- listView.countryStr = weakSelf.countyStr;
- listView.isNeedUpdata = YES;
- [listView listWillAppear];
- }];
- }
- #pragma mark - Lazy
- - (JXCategoryTitleView *)titleCategoryView {
- if (!_titleCategoryView) {
- NSArray *titles = @[@"Last Week", @"This Week", @"Monthly"];
- _titleCategoryView = [[JXCategoryTitleView alloc] init];
- _titleCategoryView.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
- _titleCategoryView.delegate = self;
- _titleCategoryView.titles = titles;
- _titleCategoryView.layer.cornerRadius = 6.0;
- _titleCategoryView.layer.masksToBounds = YES;
- _titleCategoryView.cellSpacing = 0;
- CGFloat totalItemWidth = kScaleWidth(351);
- _titleCategoryView.cellWidth = totalItemWidth / titles.count;
- _titleCategoryView.titleColor = [MOTools colorWithHexString:@"#878A99"];
- _titleCategoryView.titleSelectedColor = kBaseTextColor_1;
- _titleCategoryView.titleFont = [MOTextTools regularFont:14];
- _titleCategoryView.titleSelectedFont = [MOTextTools semiboldFont:14];
- JXCategoryIndicatorBackgroundView *backgroundTwoView = [[JXCategoryIndicatorBackgroundView alloc] init];
- backgroundTwoView.indicatorHeight = 30.0;
- backgroundTwoView.indicatorWidthIncrement = -3;
-
- UIImageView *imgTwoBgView = [[UIImageView alloc] init];
- imgTwoBgView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF"];
- imgTwoBgView.contentMode = UIViewContentModeScaleToFill;
- [backgroundTwoView addSubview:imgTwoBgView];
- [imgTwoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(backgroundTwoView);
- }];
- imgTwoBgView.layer.cornerRadius = 6.0;
- imgTwoBgView.layer.masksToBounds = YES;
-
- _titleCategoryView.indicators = @[backgroundTwoView];
- }
- return _titleCategoryView;
- }
- - (JXCategoryListContainerView *)listContainerView{
- if(!_listContainerView){
- _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
- }
- return _listContainerView;
- }
- @end
|