MOAchorTaskShowView.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. //
  2. // MOAchorTaskShowView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/6/2.
  6. //
  7. #import "MOAchorTaskShowView.h"
  8. #import "JXCategoryTitleBackgroundView.h"
  9. #import "MOAnchorTaskTableView.h"
  10. #import "MOAnchorTaskRuleView.h"
  11. #import "MOClickConfigManager.h"
  12. @interface MOAchorTaskShowView ()<JXCategoryViewDelegate,JXCategoryListContainerViewDelegate>
  13. @property (weak, nonatomic) IBOutlet UILabel *titleLab;
  14. @property (weak, nonatomic) IBOutlet UIView *bgView;
  15. @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView;
  16. @property (nonatomic, strong) UIView *titleBgView;
  17. @property (nonatomic, strong) JXCategoryListContainerView *listContainerView;
  18. @property (nonatomic, strong) MOAnchorTaskRuleView *ruleView;
  19. @property (nonatomic, strong) MODurationTask *durationTask;
  20. @end
  21. @implementation MOAchorTaskShowView
  22. + (instancetype)moAchorTaskShowView{
  23. return [[[NSBundle mainBundle] loadNibNamed:@"MOAchorTaskShowView" owner:self options:nil] firstObject];
  24. }
  25. - (void)awakeFromNib{
  26. [super awakeFromNib];
  27. self.titleLab.text = NSLocalString(@"mimo_anchor_task_title");
  28. self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalTitleFontStr];
  29. self.bgView.layer.cornerRadius = 16.0;
  30. self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner;
  31. MOClickConfigManager *configManager = [MOClickConfigManager shareManager];
  32. self.durationTask = configManager.durationTask;
  33. NSMutableArray *needTitleArr = [NSMutableArray array];
  34. if(self.durationTask.daily){
  35. [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_day_title")];
  36. }
  37. if(self.durationTask.day10){
  38. [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_ten_day_title")];
  39. }
  40. if(self.durationTask.month){
  41. [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_months_day_title")];
  42. }
  43. CGFloat totalItemWidth = SCREENWIDTH;
  44. CGFloat cellWidth = totalItemWidth / 3.0;
  45. CGFloat width = cellWidth * needTitleArr.count;
  46. CGFloat titleBgViewWidth = width - 10.0;
  47. [self.bgView addSubview:self.titleBgView];
  48. [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.top.equalTo(self.bgView).offset(50.0);
  50. make.centerX.equalTo(self.bgView);
  51. make.width.equalTo(@(titleBgViewWidth));
  52. make.height.equalTo(@32.0);
  53. }];
  54. self.titleBgView.layer.cornerRadius = 32.0 / 2.0;
  55. [self.bgView addSubview:self.titleCategoryView];
  56. [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.centerY.equalTo(self.titleBgView.mas_centerY);
  58. make.centerX.equalTo(self.bgView);
  59. make.width.equalTo(@(width));
  60. make.height.equalTo(@70.0);
  61. }];
  62. self.titleCategoryView.titles = needTitleArr;
  63. self.titleCategoryView.cellSpacing = 0.0;
  64. self.titleCategoryView.cellWidth = cellWidth;
  65. self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0];
  66. self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor;
  67. self.titleCategoryView.titleLabelMaskEnabled = YES;
  68. self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr];
  69. self.titleCategoryView.backgroundColor = [UIColor clearColor];
  70. JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init];
  71. backgroundView.indicatorHeight = 70.0;
  72. backgroundView.indicatorWidth = 148.0;
  73. backgroundView.indicatorWidthIncrement = 0;
  74. backgroundView.indicatorColor = [UIColor clearColor];
  75. backgroundView.verticalMargin = 4.0;
  76. UIImageView *imgBgView = [[UIImageView alloc] init];
  77. imgBgView.contentMode = UIViewContentModeScaleToFill;
  78. [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]];
  79. [backgroundView addSubview:imgBgView];
  80. [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  81. make.edges.equalTo(backgroundView);
  82. }];
  83. self.titleCategoryView.indicators = @[backgroundView];
  84. [self.bgView addSubview:self.listContainerView];
  85. [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  86. make.top.equalTo(self.bgView).offset(102.0);
  87. make.left.right.bottom.equalTo(self.bgView);
  88. }];
  89. self.titleCategoryView.listContainer = self.listContainerView;
  90. }
  91. - (IBAction)ruleBtnClick:(id)sender {
  92. [self addSubview:self.ruleView];
  93. [self.ruleView mas_makeConstraints:^(MASConstraintMaker *make) {
  94. make.left.equalTo(self).offset(0);
  95. make.width.equalTo(@(SCREENWIDTH));
  96. make.height.equalTo(@443.0);
  97. make.bottom.equalTo(self);
  98. }];
  99. [self.ruleView showAnchorTaskRuleView];
  100. }
  101. - (IBAction)closeBtnClick:(id)sender {
  102. [self dismissAchorTaskShowView];
  103. }
  104. // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。
  105. - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{
  106. MOLogV(@"变换了");
  107. }
  108. #pragma mark - JXCategoryListContainerViewDelegate
  109. - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{
  110. return self.titleCategoryView.titles.count;
  111. }
  112. - (id<JXCategoryListContentViewDelegate>)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{
  113. WEAKSELF
  114. MOAnchorTaskTableView *view = [[MOAnchorTaskTableView alloc] init];
  115. NSString *titleStr = self.titleCategoryView.titles[index];
  116. if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_day_title")]){
  117. view.viewType = 0;
  118. }
  119. if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_ten_day_title")]){
  120. view.viewType = 1;
  121. }
  122. if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_months_day_title")]){
  123. view.viewType = 2;
  124. }
  125. view.doneTaskBlock = ^(double rubine) {
  126. weakSelf.doneTaskBlock ? weakSelf.doneTaskBlock(rubine) : nil;
  127. };
  128. return view;
  129. }
  130. - (void)showAchorTaskShowView{
  131. self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT);
  132. CGRect actionViewRect = self.bgView.frame;
  133. actionViewRect.origin.y = SCREENHEIGHT;
  134. self.bgView.frame = actionViewRect;
  135. WEAKSELF
  136. [UIView animateWithDuration:0.3 animations:^{
  137. CGRect actionViewRect = weakSelf.bgView.frame;
  138. actionViewRect.origin.y = SCREENHEIGHT - 443.0;
  139. weakSelf.bgView.frame = actionViewRect;
  140. }];
  141. //不能滑动
  142. SendNotification(@"MOShowLivePagesVCCannotScroll")
  143. }
  144. - (void)dismissAchorTaskShowView{
  145. //完成下移动画
  146. WEAKSELF
  147. [UIView animateWithDuration:0.3 animations:^
  148. {
  149. CGRect actionSheetViewRect = weakSelf.bgView.frame;
  150. actionSheetViewRect.origin.y = SCREENHEIGHT;
  151. weakSelf.bgView.frame = actionSheetViewRect;
  152. } completion:^(BOOL finished)
  153. {
  154. [self removeFromSuperview];
  155. }];
  156. //可以滑动
  157. SendNotification(@"MOShowLivePagesVCCanScroll")
  158. }
  159. #pragma mark - Lazy
  160. - (JXCategoryTitleView *)titleCategoryView{
  161. if(!_titleCategoryView){
  162. _titleCategoryView = [[JXCategoryTitleView alloc] init];
  163. _titleCategoryView.delegate = self;
  164. }
  165. return _titleCategoryView;
  166. }
  167. - (JXCategoryListContainerView *)listContainerView{
  168. if(!_listContainerView){
  169. _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self];
  170. }
  171. return _listContainerView;
  172. }
  173. - (MOAnchorTaskRuleView *)ruleView{
  174. if(!_ruleView){
  175. _ruleView = [MOAnchorTaskRuleView moAnchorTaskRuleView];
  176. }
  177. return _ruleView;
  178. }
  179. - (UIView *)titleBgView{
  180. if(!_titleBgView){
  181. _titleBgView = [[UIView alloc] init];
  182. _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05];
  183. }
  184. return _titleBgView;
  185. }
  186. @end