// // RQTeachSchoolVideoCell.m // JiaPei // // Created by 张嵘 on 2023/4/6. // #import "RQTeachSchoolVideoCell.h" @interface RQTeachSchoolVideoCell () @property (nonatomic, readwrite, strong) RQTeachSchoolVideoItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet QMUIButton *goBtn; @property (weak, nonatomic) IBOutlet QMUIButton *myGoBtn; @property (weak, nonatomic) IBOutlet UIScrollView *placeScrollView; @property (weak, nonatomic) IBOutlet UIImageView *downArrowImageView; @property (weak, nonatomic) IBOutlet NSLayoutConstraint *downImageViewLeadingToCOntentView; @property (weak, nonatomic) IBOutlet QMUIButton *tipBtn; @property (nonatomic, readwrite, copy) NSArray *btnArr; @end @implementation RQTeachSchoolVideoCell + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"RQTeachSchoolVideoCell"; [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID]; RQTeachSchoolVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath]; if (!cell) cell = [self rq_viewFromXib]; cell.goBtn.layer.cornerRadius = RQ_FIT_HORIZONTAL(46.f) / 2.f; cell.myGoBtn.imagePosition = QMUIButtonImagePositionRight; return cell; } - (void)bindViewModel:(RQTeachSchoolVideoItemViewModel *)viewModel { _viewModel = viewModel; } - (void)awakeFromNib { [super awakeFromNib]; @weakify(self) CGFloat btnWidth = (RQ_SCREEN_WIDTH - 32.f) * (134.f / 345.f); CGFloat btnHeight = btnWidth * (32.f / 134.f); CGFloat downImageViewWidth = (RQ_SCREEN_WIDTH - 32.f) * (18.f / 345.f); CGFloat space = 10.f; self.goBtn.hidden = RQ_COMMON_MANAGER.APP_SWITCH; [[[self.btnArr.rac_sequence.signal deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(NSString *btnTitleStr) { @strongify(self) NSInteger index = [self.btnArr indexOfObject:btnTitleStr]; QMUIButton *btn = [[QMUIButton alloc] initWithFrame:CGRectMake((index * btnWidth) + (space * (((index - 1) > 0)? (index - 1) : 0)), 0, btnWidth, btnHeight)]; [btn setTitleNormal:btnTitleStr]; btn.titleLabel.font = RQMediumFont(14.f); [btn setTitleColor:UIColor.whiteColor forState:UIControlStateNormal]; [btn setBackgroundColor:RQ_MAIN_COLOR]; btn.layer.masksToBounds = YES; btn.layer.cornerRadius = btnHeight / 2.f; btn.userInteractionEnabled = NO; [self.placeScrollView addSubview:btn]; self.downArrowImageView.hidden = NO; } completed:^{ @strongify(self) self.placeScrollView.contentSize = CGSizeMake((btnWidth * self.btnArr.count) + (space * (((self.btnArr.count - 1) > 0)? (self.btnArr.count - 1) : 0)), btnHeight); }]; self.downImageViewLeadingToCOntentView.constant = 16.f + (btnWidth / 2.f) - (downImageViewWidth / 2.f); [self.tipBtn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = RQColorFromHexString(@"#26A1EE"); graColor.toColor = RQColorFromHexString(@"#498EF5"); graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(44.f), RQ_FIT_HORIZONTAL(20.f)) cornerRadius:QQRadiusMake(10.f, 0, 0, 10.f)] forState:UIControlStateNormal]; } - (NSArray *)btnArr { if (!_btnArr) { _btnArr = @[@"社会化驾驶人考场"]; } return _btnArr; } @end