NYTestingCentreCell.m 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //
  2. // NYTestingCentreCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2023/8/21.
  6. // Copyright © 2023 JCZ. All rights reserved.
  7. //
  8. #import "NYTestingCentreCell.h"
  9. @interface NYTestingCentreCell ()
  10. @property (nonatomic, readwrite, strong) NYExerciseTestingCentreItemViewModel *viewModel;
  11. @property (weak, nonatomic) IBOutlet UIImageView *videoCoverImageView;
  12. @property (weak, nonatomic) IBOutlet UIView *videoView;
  13. @end
  14. @implementation NYTestingCentreCell
  15. #pragma mark - PublicMethods
  16. + (instancetype)cellWithTableView:(UITableView *)tableView {
  17. static NSString *ID = @"NYTestingCentreCell-ID";
  18. NYTestingCentreCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  19. if (!cell) {
  20. cell = [self rq_viewFromXib];
  21. [cell setupUI];
  22. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  23. }
  24. return cell;
  25. }
  26. - (void)setupUI{
  27. self.bottom_imageview.image = [UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  28. graColor.fromColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:0.4];
  29. graColor.toColor = [UIColor colorWithHexString:@"#F2F3F5" alpha:1.f];
  30. graColor.type = QQGradualChangeTypeUpToDown;
  31. } size:CGSizeMake(self.bottom_view.width,self.bottom_view.height)cornerRadius:QQRadiusZero];
  32. }
  33. - (void)bindViewModel:(NYExerciseTestingCentreItemViewModel *)viewModel {
  34. _viewModel = viewModel;
  35. @weakify(self)
  36. RAC(self.title_label, text) = [[RACObserve(viewModel.ydtJSModel, sec_title) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  37. if(RQStringIsNotEmpty(viewModel.ydtJSModel.word)){
  38. NSArray *words = [viewModel.ydtJSModel.word componentsSeparatedByString:@";"];
  39. self.word_label_01.text = words[0];
  40. self.word_label_02.text = words[1];
  41. self.word_label_03.text = words[2];
  42. // RAC(self.word_label_01, text) = [[RACObserve(words, words[0]) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread];
  43. }
  44. [[[[RACObserve(viewModel, ydtJSModel) takeUntil:self.rac_prepareForReuseSignal] deliverOnMainThread] distinctUntilChanged] subscribeNext:^(RQYDTJSModel *ydtJSModel) {
  45. @strongify(self)
  46. if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {
  47. if (RQ_VIP_Module.isSubject1Vip||RQ_USER_MANAGER.tryLookCount>0) {
  48. self.bottom_view.hidden = YES;
  49. } else {
  50. self.bottom_view.hidden = NO;
  51. }
  52. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) {
  53. if (RQ_VIP_Module.isSubject4Vip||RQ_USER_MANAGER.tryLookCount>0) {
  54. self.bottom_view.hidden = YES;
  55. } else {
  56. self.bottom_view.hidden = NO;
  57. }
  58. } else {
  59. self.bottom_view.hidden = YES;
  60. }
  61. // self.skillLabel.hidden = RQObjectIsNil(ydtJSModel);
  62. }];
  63. }
  64. - (IBAction)showSkillAction:(id)sender {
  65. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  66. }
  67. #pragma mark - SystemMethods
  68. - (void)awakeFromNib {
  69. [super awakeFromNib];
  70. self.lock_jq_button.imagePosition = QMUIButtonImagePositionRight;
  71. self.lock_jq_button.spacingBetweenImageAndTitle = 8;
  72. [self.lock_jq_button setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  73. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FF7E4D"];
  74. graColor.toColor = [UIColor qmui_colorWithHexString:@"#FF4D53"];
  75. graColor.type = QQGradualChangeTypeLeftToRight;
  76. } size:CGSizeMake(RQ_FIT_HORIZONTAL(128.f), RQ_FIT_HORIZONTAL(34.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(34.f) / 2.f)] forState:UIControlStateNormal];
  77. }
  78. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  79. [super setSelected:selected animated:animated];
  80. }
  81. @end