MORankListView.m 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. //
  2. // MORankListView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2023/11/30.
  6. //
  7. #import "MORankListView.h"
  8. #import "JXCategoryView.h"
  9. #import "MORankListTableView.h"
  10. @interface MORankListView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  11. @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
  12. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  13. @end
  14. @implementation MORankListView
  15. - (instancetype)init{
  16. self = [super init];
  17. if (self)
  18. {
  19. [self setupUI];
  20. }
  21. return self;
  22. }
  23. - (instancetype)initWithFrame:(CGRect)frame
  24. {
  25. self = [super initWithFrame:frame];
  26. if (self)
  27. {
  28. [self setupUI];
  29. }
  30. return self;
  31. }
  32. - (void)setupUI{
  33. [self addSubview:self.titleCategoryView];
  34. [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.mas_equalTo(10);
  36. make.left.mas_equalTo(12);
  37. make.right.mas_equalTo(-12);
  38. make.height.mas_equalTo(34);
  39. }];
  40. [self addSubview:self.listContainerView];
  41. [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.equalTo(self.titleCategoryView.mas_bottom).offset(8);
  43. make.left.right.bottom.mas_equalTo(0);
  44. }];
  45. self.titleCategoryView.listContainer = self.listContainerView;
  46. }
  47. - (void)setTypeNum:(NSInteger)typeNum {
  48. _typeNum = typeNum;
  49. if (typeNum == 3) {//收益榜有4个tab
  50. self.titleCategoryView.titles = @[NSLocalString(@"C60007"), NSLocalString(@"C60008"), NSLocalString(@"C60009"), NSLocalString(@"C60010")];
  51. } else if (typeNum == 2) {//探索-财富榜
  52. self.titleCategoryView.titles = @[NSLocalString(@"C60030"), NSLocalString(@"C60031"), NSLocalString(@"C60028")];
  53. } else if (typeNum == 1) {//房间贡献榜
  54. self.titleCategoryView.titles = @[NSLocalString(@"C60029"), NSLocalString(@"C60030"), NSLocalString(@"C60031"), NSLocalString(@"C60028")];
  55. }
  56. _titleCategoryView.cellWidth = kScaleWidth(351) / self.titleCategoryView.titles.count;
  57. }
  58. // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  59. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  60. MOLogV(@"变换了");
  61. }
  62. #pragma mark - JXCategoryListContainerViewDelegate
  63. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  64. return self.titleCategoryView.titles.count;
  65. }
  66. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  67. MORankListTableView *view = [[MORankListTableView alloc] init];
  68. view.outSideRoom = self.outSideRoom;
  69. view.isNewer = self.isNewer;
  70. WEAKSELF
  71. view.getTopBlock = ^(NSArray<MORankNewerTop *> * _Nonnull topModelArray) {
  72. if (weakSelf.getTopBlock) {
  73. weakSelf.getTopBlock(topModelArray);
  74. }
  75. };
  76. view.getCurrentIndexBlock = ^(MORankFooter * _Nonnull footer) {
  77. if (weakSelf.getCurrentIndexBlock) {
  78. weakSelf.getCurrentIndexBlock(footer);
  79. }
  80. };
  81. view.hitBlock = ^(MORankHit * _Nonnull model) {
  82. if (weakSelf.hitBlock) {
  83. weakSelf.hitBlock(model);
  84. }
  85. };
  86. view.typeNum = self.typeNum;
  87. view.roomId = self.roomId;
  88. if (self.typeNum == 3) {//收益榜单类型(1=日榜,2=周榜,3=月榜,4=小时榜)但是小时榜排在最前面,手动处理一下
  89. view.typeTime = index;
  90. if (index == 0) {
  91. view.typeTime = 4;
  92. }
  93. } else if (self.typeNum == 1) {//直播间贡献榜(1=日榜,2=周榜,3=月榜,4=直播榜)但是直播榜排在最前面,手动处理一下
  94. view.typeTime = index;
  95. if (index == 0) {
  96. view.typeTime = 4;
  97. }
  98. }
  99. else {
  100. view.typeTime = index + 1;
  101. }
  102. view.countryStr = self.countyStr;
  103. view.headBtnBlock = ^(MOUserBase * _Nonnull model) {
  104. weakSelf.headBtnBlock ? weakSelf.headBtnBlock(model) : nil;
  105. };
  106. return view;
  107. }
  108. - (void)setRoomId:(NSString *)roomId{
  109. _roomId = roomId;
  110. WEAKSELF
  111. if(roomId.length > 0){
  112. [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
  113. MORankListTableView *listView = (MORankListTableView *)obj;
  114. listView.roomId = weakSelf.roomId;
  115. }];
  116. }
  117. }
  118. - (void)setCountyStr:(NSString *)countyStr{
  119. _countyStr = countyStr;
  120. WEAKSELF
  121. [self.listContainerView.validListDict enumerateKeysAndObjectsUsingBlock:^(NSNumber * _Nonnull key, id<JXCategoryListContentViewDelegate> _Nonnull obj, BOOL * _Nonnull stop) {
  122. MORankListTableView *listView = (MORankListTableView *)obj;
  123. listView.countryStr = weakSelf.countyStr;
  124. listView.isNeedUpdata = YES;
  125. [listView listWillAppear];
  126. }];
  127. }
  128. #pragma mark - Lazy
  129. - (JXCategoryTitleView *)titleCategoryView {
  130. if (!_titleCategoryView) {
  131. NSArray *titles = @[@"Last Week", @"This Week", @"Monthly"];
  132. _titleCategoryView = [[JXCategoryTitleView alloc] init];
  133. _titleCategoryView.backgroundColor = [MOTools colorWithHexString:@"#F3F4FA"];
  134. _titleCategoryView.delegate = self;
  135. _titleCategoryView.titles = titles;
  136. _titleCategoryView.layer.cornerRadius = 6.0;
  137. _titleCategoryView.layer.masksToBounds = YES;
  138. _titleCategoryView.cellSpacing = 0;
  139. CGFloat totalItemWidth = kScaleWidth(351);
  140. _titleCategoryView.cellWidth = totalItemWidth / titles.count;
  141. _titleCategoryView.titleColor = [MOTools colorWithHexString:@"#878A99"];
  142. _titleCategoryView.titleSelectedColor = kBaseTextColor_1;
  143. _titleCategoryView.titleFont = [MOTextTools regularFont:14];
  144. _titleCategoryView.titleSelectedFont = [MOTextTools semiboldFont:14];
  145. JXCategoryIndicatorBackgroundView *backgroundTwoView = [[JXCategoryIndicatorBackgroundView alloc] init];
  146. backgroundTwoView.indicatorHeight = 30.0;
  147. backgroundTwoView.indicatorWidthIncrement = -3;
  148. UIImageView *imgTwoBgView = [[UIImageView alloc] init];
  149. imgTwoBgView.backgroundColor = [MOTools colorWithHexString:@"#FFFFFF"];
  150. imgTwoBgView.contentMode = UIViewContentModeScaleToFill;
  151. [backgroundTwoView addSubview:imgTwoBgView];
  152. [imgTwoBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  153. make.edges.equalTo(backgroundTwoView);
  154. }];
  155. imgTwoBgView.layer.cornerRadius = 6.0;
  156. imgTwoBgView.layer.masksToBounds = YES;
  157. _titleCategoryView.indicators = @[backgroundTwoView];
  158. }
  159. return _titleCategoryView;
  160. }
  161. - (JXCategoryListContainerView *)listContainerView{
  162. if(!_listContainerView){
  163. _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  164. }
  165. return _listContainerView;
  166. }
  167. @end