NYTestingCentreCell.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. int tryCount = RQ_USER_MANAGER.tryLookCount;
  47. if(RQ_Exercise_Module.currentExerciseType == RQExerciseType_Recitation){//背题模式
  48. tryCount = 0;
  49. }
  50. if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne) {
  51. if (RQ_VIP_Module.isSubject1Vip||tryCount>0) {
  52. self.bottom_view.hidden = YES;
  53. } else {
  54. self.bottom_view.hidden = NO;
  55. }
  56. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour) {
  57. if (RQ_VIP_Module.isSubject4Vip||tryCount>0) {
  58. self.bottom_view.hidden = YES;
  59. } else {
  60. self.bottom_view.hidden = NO;
  61. }
  62. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectOne_LI) {
  63. if (RQ_VIP_Module.isSpSubject1Vip||tryCount>0) {
  64. self.bottom_view.hidden = YES;
  65. } else {
  66. self.bottom_view.hidden = NO;
  67. }
  68. } else if (RQ_YDTQuestion_Module.subject == RQHomePageSubjectType_SubjectFour_LI) {
  69. if (RQ_VIP_Module.isSpSubject4Vip||tryCount>0) {
  70. self.bottom_view.hidden = YES;
  71. } else {
  72. self.bottom_view.hidden = NO;
  73. }
  74. }else {
  75. self.bottom_view.hidden = YES;
  76. }
  77. // self.skillLabel.hidden = RQObjectIsNil(ydtJSModel);
  78. }];
  79. }
  80. - (IBAction)showSkillAction:(id)sender {
  81. [RQ_VIP_Module gotoBuyVipWithVipPageType:RQVIPPageType_Full];
  82. }
  83. #pragma mark - SystemMethods
  84. - (void)awakeFromNib {
  85. [super awakeFromNib];
  86. self.lock_jq_button.imagePosition = QMUIButtonImagePositionRight;
  87. self.lock_jq_button.spacingBetweenImageAndTitle = 8;
  88. [self.lock_jq_button setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  89. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FF7E4D"];
  90. graColor.toColor = [UIColor qmui_colorWithHexString:@"#FF4D53"];
  91. graColor.type = QQGradualChangeTypeLeftToRight;
  92. } size:CGSizeMake(RQ_FIT_HORIZONTAL(128.f), RQ_FIT_HORIZONTAL(34.f)) cornerRadius:QQRadiusMakeSame(RQ_FIT_HORIZONTAL(34.f) / 2.f)] forState:UIControlStateNormal];
  93. }
  94. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  95. [super setSelected:selected animated:animated];
  96. }
  97. @end