RQVideoDetailSubPageCell.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. }
  29. return cell;
  30. }
  31. - (void)bindViewModel:(RQVideoDetailSubPageItemViewModel *)viewModel {
  32. _viewModel = viewModel;
  33. _indexLabel.text = [NSString stringWithFormat:@"%ld",viewModel.videosItem.index];
  34. _topLine.hidden = viewModel.videosItem.index == 1;
  35. _bottomLine.hidden = viewModel.videosItem.totalNum == viewModel.videosItem.index;
  36. _titleLabel.text = viewModel.videosItem.title;
  37. _subTitleLabel.text = viewModel.videosItem.videoDescribe? : @"";
  38. [_videoImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholder:RQWebVideoImagePlaceholder()];
  39. [[RACObserve(viewModel.videosItem, isPlaying) takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  40. if (viewModel.videosItem.isPlaying) {
  41. _isLearningBtn.hidden = NO;
  42. _titleLabel.textColor = RQ_MAIN_COLOR;
  43. _subTitleLabel.textColor = RQ_MAIN_COLOR;
  44. } else {
  45. _isLearningBtn.hidden = YES;
  46. _titleLabel.textColor = RQ_MAIN_TEXT_COLOR_1;
  47. _subTitleLabel.textColor = RQ_MAIN_TEXT_COLOR_3;
  48. }
  49. }];
  50. }
  51. #pragma mark - SystemMethods
  52. - (void)awakeFromNib {
  53. [super awakeFromNib];
  54. // Initialization code
  55. }
  56. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  57. [super setSelected:selected animated:animated];
  58. // Configure the view for the selected state
  59. }
  60. @end