RQVideoDetailSubPageCell.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //
  2. // RQVideoDetailSubPageCell.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/11/5.
  6. //
  7. #import "RQVideoDetailSubPageCell.h"
  8. @interface RQVideoDetailSubPageCell ()
  9. @property (nonatomic, readwrite, strong) RQVideoDetailSubPageItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIView *topLine;
  11. @property (weak, nonatomic) IBOutlet UILabel *indexLabel;
  12. @property (weak, nonatomic) IBOutlet UIView *bottomLine;
  13. @property (weak, nonatomic) IBOutlet UIButton *stateBtn;
  14. @property (weak, nonatomic) IBOutlet UILabel *titleLabel;
  15. @property (weak, nonatomic) IBOutlet UILabel *subTitleLabel;
  16. @property (weak, nonatomic) IBOutlet UIImageView *videoImageView;
  17. @property (weak, nonatomic) IBOutlet UIButton *isLearningBtn;
  18. @end
  19. @implementation RQVideoDetailSubPageCell
  20. #pragma mark - PublicMethods
  21. + (instancetype)cellWithTableView:(UITableView *)tableView {
  22. static NSString *ID = @"RQVideoDetailSubPageCell";
  23. RQVideoDetailSubPageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  24. if (!cell) {
  25. cell = [self rq_viewFromXib];
  26. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  27. [cell.stateBtn borderColor:RQ_MAIN_COLOR width:1 cornorRadius:8];
  28. [cell.stateBtn setTitleColor:RQ_MAIN_COLOR forState:UIControlStateNormal];
  29. cell.indexLabel.textColor = RQ_MAIN_COLOR;
  30. }
  31. return cell;
  32. }
  33. - (void)bindViewModel:(RQVideoDetailSubPageItemViewModel *)viewModel {
  34. _viewModel = viewModel;
  35. _indexLabel.text = [NSString stringWithFormat:@"%ld",viewModel.videosItem.index];
  36. _topLine.hidden = viewModel.videosItem.index == 1;
  37. _bottomLine.hidden = viewModel.videosItem.totalNum == viewModel.videosItem.index;
  38. _titleLabel.text = viewModel.videosItem.title;
  39. _subTitleLabel.text = viewModel.videosItem.videoDescribe? : @"";
  40. [_videoImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholder:RQWebVideoImagePlaceholder()];
  41. [[RACObserve(viewModel.videosItem, isPlaying) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  42. if (viewModel.videosItem.isPlaying) {
  43. _isLearningBtn.hidden = NO;
  44. _titleLabel.textColor = RQ_MAIN_COLOR;
  45. _subTitleLabel.textColor = RQ_MAIN_COLOR;
  46. } else {
  47. _isLearningBtn.hidden = YES;
  48. _titleLabel.textColor = RQ_MAIN_TEXT_COLOR_1;
  49. _subTitleLabel.textColor = RQ_MAIN_TEXT_COLOR_3;
  50. }
  51. }];
  52. }
  53. #pragma mark - SystemMethods
  54. - (void)awakeFromNib {
  55. [super awakeFromNib];
  56. // Initialization code
  57. }
  58. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  59. [super setSelected:selected animated:animated];
  60. // Configure the view for the selected state
  61. }
  62. @end