// // MOAchorTaskShowView.m // MiMoLive // // Created by SuperC on 2024/6/2. // #import "MOAchorTaskShowView.h" #import "JXCategoryTitleBackgroundView.h" #import "MOAnchorTaskTableView.h" #import "MOAnchorTaskRuleView.h" #import "MOClickConfigManager.h" @interface MOAchorTaskShowView () @property (weak, nonatomic) IBOutlet UILabel *titleLab; @property (weak, nonatomic) IBOutlet UIView *bgView; @property (nonatomic, strong) JXCategoryTitleView *titleCategoryView; @property (nonatomic, strong) UIView *titleBgView; @property (nonatomic, strong) JXCategoryListContainerView *listContainerView; @property (nonatomic, strong) MOAnchorTaskRuleView *ruleView; @property (nonatomic, strong) MODurationTask *durationTask; @end @implementation MOAchorTaskShowView + (instancetype)moAchorTaskShowView{ return [[[NSBundle mainBundle] loadNibNamed:@"MOAchorTaskShowView" owner:self options:nil] firstObject]; } - (void)awakeFromNib{ [super awakeFromNib]; self.titleLab.text = NSLocalString(@"mimo_anchor_task_title"); self.titleLab.font = [MOTextTools getTheFontWithSize:16.0 AndFontName:kNormalTitleFontStr]; self.bgView.layer.cornerRadius = 16.0; self.bgView.layer.maskedCorners = kCALayerMinXMinYCorner | kCALayerMaxXMinYCorner; MOClickConfigManager *configManager = [MOClickConfigManager shareManager]; self.durationTask = configManager.durationTask; NSMutableArray *needTitleArr = [NSMutableArray array]; if(self.durationTask.daily){ [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_day_title")]; } if(self.durationTask.day10){ [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_ten_day_title")]; } if(self.durationTask.month){ [needTitleArr addObject:NSLocalString(@"mimo_anchor_task_months_day_title")]; } CGFloat totalItemWidth = SCREENWIDTH; CGFloat cellWidth = totalItemWidth / 3.0; CGFloat width = cellWidth * needTitleArr.count; CGFloat titleBgViewWidth = width - 10.0; [self.bgView addSubview:self.titleBgView]; [self.titleBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.bgView).offset(50.0); make.centerX.equalTo(self.bgView); make.width.equalTo(@(titleBgViewWidth)); make.height.equalTo(@32.0); }]; self.titleBgView.layer.cornerRadius = 32.0 / 2.0; [self.bgView addSubview:self.titleCategoryView]; [self.titleCategoryView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.equalTo(self.titleBgView.mas_centerY); make.centerX.equalTo(self.bgView); make.width.equalTo(@(width)); make.height.equalTo(@70.0); }]; self.titleCategoryView.titles = needTitleArr; self.titleCategoryView.cellSpacing = 0.0; self.titleCategoryView.cellWidth = cellWidth; self.titleCategoryView.titleColor = [MOTools colorWithHexString:@"#737373" alpha:1.0]; self.titleCategoryView.titleSelectedColor = kBaseBtnBgColor; self.titleCategoryView.titleLabelMaskEnabled = YES; self.titleCategoryView.titleFont = [MOTextTools getTheFontWithSize:14.0 AndFontName:kNormalContentFontStr]; self.titleCategoryView.backgroundColor = [UIColor clearColor]; JXCategoryIndicatorBackgroundView *backgroundView = [[JXCategoryIndicatorBackgroundView alloc] init]; backgroundView.indicatorHeight = 70.0; backgroundView.indicatorWidth = 148.0; backgroundView.indicatorWidthIncrement = 0; backgroundView.indicatorColor = [UIColor clearColor]; backgroundView.verticalMargin = 4.0; UIImageView *imgBgView = [[UIImageView alloc] init]; imgBgView.contentMode = UIViewContentModeScaleToFill; [imgBgView setImage:[UIImage imageNamed:@"icon_rank_btn_bg_apple"]]; [backgroundView addSubview:imgBgView]; [imgBgView mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(backgroundView); }]; self.titleCategoryView.indicators = @[backgroundView]; [self.bgView addSubview:self.listContainerView]; [self.listContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.bgView).offset(102.0); make.left.right.bottom.equalTo(self.bgView); }]; self.titleCategoryView.listContainer = self.listContainerView; } - (IBAction)ruleBtnClick:(id)sender { [self addSubview:self.ruleView]; [self.ruleView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self).offset(0); make.width.equalTo(@(SCREENWIDTH)); make.height.equalTo(@443.0); make.bottom.equalTo(self); }]; [self.ruleView showAnchorTaskRuleView]; } - (IBAction)closeBtnClick:(id)sender { [self dismissAchorTaskShowView]; } // 点击选中或者滚动选中都会调用该方法。适用于只关心选中事件,不关心具体是点击还是滚动选中的。 - (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index{ MOLogV(@"变换了"); } #pragma mark - JXCategoryListContainerViewDelegate - (NSInteger)numberOfListsInlistContainerView:(JXCategoryListContainerView *)listContainerView{ return self.titleCategoryView.titles.count; } - (id)listContainerView:(JXCategoryListContainerView *)listContainerView initListForIndex:(NSInteger)index{ WEAKSELF MOAnchorTaskTableView *view = [[MOAnchorTaskTableView alloc] init]; NSString *titleStr = self.titleCategoryView.titles[index]; if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_day_title")]){ view.viewType = 0; } if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_ten_day_title")]){ view.viewType = 1; } if([titleStr isEqualToString:NSLocalString(@"mimo_anchor_task_months_day_title")]){ view.viewType = 2; } view.doneTaskBlock = ^(double rubine) { weakSelf.doneTaskBlock ? weakSelf.doneTaskBlock(rubine) : nil; }; return view; } - (void)showAchorTaskShowView{ self.frame = CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT); CGRect actionViewRect = self.bgView.frame; actionViewRect.origin.y = SCREENHEIGHT; self.bgView.frame = actionViewRect; WEAKSELF [UIView animateWithDuration:0.3 animations:^{ CGRect actionViewRect = weakSelf.bgView.frame; actionViewRect.origin.y = SCREENHEIGHT - 443.0; weakSelf.bgView.frame = actionViewRect; }]; //不能滑动 SendNotification(@"MOShowLivePagesVCCannotScroll") } - (void)dismissAchorTaskShowView{ //完成下移动画 WEAKSELF [UIView animateWithDuration:0.3 animations:^ { CGRect actionSheetViewRect = weakSelf.bgView.frame; actionSheetViewRect.origin.y = SCREENHEIGHT; weakSelf.bgView.frame = actionSheetViewRect; } completion:^(BOOL finished) { [self removeFromSuperview]; }]; //可以滑动 SendNotification(@"MOShowLivePagesVCCanScroll") } #pragma mark - Lazy - (JXCategoryTitleView *)titleCategoryView{ if(!_titleCategoryView){ _titleCategoryView = [[JXCategoryTitleView alloc] init]; _titleCategoryView.delegate = self; } return _titleCategoryView; } - (JXCategoryListContainerView *)listContainerView{ if(!_listContainerView){ _listContainerView = [[JXCategoryListContainerView alloc] initWithType:JXCategoryListContainerType_ScrollView delegate:self]; } return _listContainerView; } - (MOAnchorTaskRuleView *)ruleView{ if(!_ruleView){ _ruleView = [MOAnchorTaskRuleView moAnchorTaskRuleView]; } return _ruleView; } - (UIView *)titleBgView{ if(!_titleBgView){ _titleBgView = [[UIView alloc] init]; _titleBgView.backgroundColor = [MOTools colorWithHexString:@"#000000" alpha:0.05]; } return _titleBgView; } @end