// // NYTestingCentreCell.m // jiaPei // // Created by Ning.ge on 2023/8/21. // Copyright © 2023 JCZ. All rights reserved. // #import "NYTestingCentreCell.h" @interface NYTestingCentreCell () @property (nonatomic, readwrite, strong) NYExerciseTestingCentreItemViewModel *viewModel; @property (weak, nonatomic) IBOutlet UIImageView *videoCoverImageView; @property (weak, nonatomic) IBOutlet UIView *videoView; @end @implementation NYTestingCentreCell #pragma mark - PublicMethods + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"NYTestingCentreCell-ID"; NYTestingCentreCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [self rq_viewFromXib]; [cell setupUI]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (void)setupUI{ self.bottom_imageview.image = [UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:0.4]; graColor.toColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:1.f]; graColor.type = QQGradualChangeTypeUpToDown; } size:CGSizeMake(self.bottom_view.width,self.bottom_view.height)cornerRadius:QQRadiusZero]; } - (void)bindViewModel:(NYExerciseTestingCentreItemViewModel *)viewModel { _viewModel = viewModel; @weakify(self) RAC(self.title_label, text) = [[RACObserve(viewModel.ydtJSModel, sec_title) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread]; if(RQStringIsNotEmpty(viewModel.ydtJSModel.word)){ NSArray *words = [viewModel.ydtJSModel.word componentsSeparatedByString:@";"]; self.word_label_01.text = words[0]; self.word_label_02.text = words[1]; self.word_label_03.text = words[2]; // RAC(self.word_label_01, text) = [[RACObserve(words, words[0]) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread]; } [[[[RACObserve(viewModel, ydtJSModel) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread] distinctUntilChanged] subscribeNext:^(RQYDTJSModel *ydtJSModel) { @strongify(self) int tryCount = RQ_USER_MANAGER.tryLookCount; if(RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation){//背题模式 tryCount = 0; } if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) { if (RQ_VIP_Module.isSubject1Vip||tryCount>0) { self.bottom_view.hidden = YES; } else { self.bottom_view.hidden = NO; } } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) { if (RQ_VIP_Module.isSubject4Vip||tryCount>0) { self.bottom_view.hidden = YES; } else { self.bottom_view.hidden = NO; } } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne_LI) { if (RQ_VIP_Module.isSpSubject1Vip||tryCount>0) { self.bottom_view.hidden = YES; } else { self.bottom_view.hidden = NO; } } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour_LI) { if (RQ_VIP_Module.isSpSubject4Vip||tryCount>0) { self.bottom_view.hidden = YES; } else { self.bottom_view.hidden = NO; } }else { self.bottom_view.hidden = YES; } // self.skillLabel.hidden = RQObjectIsNil(ydtJSModel); }]; } - (IBAction)showSkillAction:(id)sender { [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; self.lock_jq_button.imagePosition = QMUIButtonImagePositionRight; self.lock_jq_button.spacingBetweenImageAndTitle = 8; [self.lock_jq_button setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FF7E4D"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"#FF4D53"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:CGSizeMake(RQ_FIT_HORIZONTAL(128.f), RQ_FIT_HORIZONTAL(34.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(34.f) / 2.f)] forState:UIControlStateNormal]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; } @end