NYLIVideoDetailSubPageCell.m 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // NYLIVideoDetailSubPageCell.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2025/2/11.
  6. // Copyright © 2025 JCZ. All rights reserved.
  7. //
  8. #import "NYLIVideoDetailSubPageCell.h"
  9. @interface NYLIVideoDetailSubPageCell ()
  10. @property (nonatomic, readwrite, strong) NYLIVideoDetailSubPageItemViewModel *viewModel;
  11. @property (nonatomic, readwrite, strong) RQVideoPermissionStateModel *videoPermissionStateModel;
  12. @property (weak, nonatomic) IBOutlet UIImageView *icon_imageview;
  13. @property (weak, nonatomic) IBOutlet UILabel *title_label;
  14. @property (weak, nonatomic) IBOutlet UIView *tag_view;
  15. @property (weak, nonatomic) IBOutlet QMUIButton *call_play_btn;
  16. @property (weak, nonatomic) IBOutlet UIButton *tag_bg_btn;
  17. @property (weak, nonatomic) IBOutlet UIImageView *vipImg;
  18. @end
  19. @implementation NYLIVideoDetailSubPageCell
  20. #pragma mark - PublicMethods
  21. + (instancetype)cellWithTableView:(UITableView *)tableView {
  22. static NSString *ID = @"NYLIVideoDetailSubPageCell";
  23. NYLIVideoDetailSubPageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
  24. if (!cell) {
  25. cell = [self rq_viewFromXib];
  26. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  27. [cell.tag_bg_btn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) {
  28. graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFE7B8"];
  29. graColor.toColor = [UIColor qmui_colorWithHexString:@"##FDC67F"];
  30. graColor.type = QQGradualChangeTypeLeftToRight;
  31. } size:cell.tag_bg_btn.bounds.size cornerRadius:QQRadiusMake(5, 5, 5, 5)] forState:UIControlStateNormal];
  32. [cell.call_play_btn addTarget:cell action:@selector(callPlaydoVideo:) forControlEvents:UIControlEventTouchUpInside];
  33. }
  34. return cell;
  35. }
  36. - (void)bindViewModel:(NYLIVideoDetailSubPageItemViewModel *)viewModel {
  37. @weakify(self)
  38. _viewModel = viewModel;
  39. [self.icon_imageview sd_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholderImage:randomPortrait()];
  40. RAC(self.title_label, text) = [[RACObserve(viewModel.videosItem, title) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal];
  41. RAC(self.call_play_btn, selected) = [[RACObserve(viewModel.videosItem, isPlaying) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal];
  42. [[[RACObserve(viewModel.videosItem, permission) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) {
  43. @strongify(self)
  44. self.vipImg.hidden = NO;
  45. if (viewModel.videosItem.permission == 0) {
  46. self.vipImg.image = RQImageNamed(@"考场免费");
  47. } else if (viewModel.videosItem.permission == 1) {
  48. self.vipImg.image = RQImageNamed(@"考场试看");
  49. } else if (viewModel.videosItem.permission == 2) {
  50. self.vipImg.image = RQImageNamed(@"考场VIP");
  51. } else {
  52. self.vipImg.hidden = YES;
  53. }
  54. if(viewModel.videosItem.subject == 5 && RQ_VIP_Module.isSpSubject1Vip) {
  55. self.vipImg.hidden = YES;
  56. }else if(viewModel.videosItem.subject == 6 && RQ_VIP_Module.isSpSubject4Vip) {
  57. self.vipImg.hidden = YES;
  58. }
  59. // if (viewModel.placeVideoListModel.placeListModel.isCheckVip) {
  60. // self.vipImg.hidden = YES;
  61. // }
  62. }];
  63. }
  64. //播放通知
  65. - (void)callPlaydoVideo:(UIButton *)btn {
  66. // VideosItem *videosItem = self.viewModel.videosItem;
  67. // [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  68. // RQPlayVideoItemKey : videosItem,
  69. // RQPlayVideoItemArrKey : @[videosItem],
  70. // }];
  71. }
  72. #pragma mark - SystemMethods
  73. - (void)awakeFromNib {
  74. [super awakeFromNib];
  75. }
  76. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  77. [super setSelected:selected animated:animated];
  78. // Configure the view for the selected state
  79. }
  80. #pragma mark - LazyLoad
  81. - (RQVideoPermissionStateModel *)videoPermissionStateModel {
  82. if (!_videoPermissionStateModel) {
  83. _videoPermissionStateModel = [[RQVideoPermissionStateModel alloc] init];
  84. }
  85. return _videoPermissionStateModel;
  86. }
  87. @end