RQHomeSubPageVideoCell.m 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // RQHomeSubPageVideoCell.m
  3. // JSJP
  4. //
  5. // Created by 张嵘 on 2021/11/9.
  6. //
  7. #import "RQHomeSubPageVideoCell.h"
  8. @interface RQHomeSubPageVideoCell ()
  9. @property (nonatomic, readwrite, strong) RQHomeSubPageVideoItemViewModel *viewModel;
  10. @property (weak, nonatomic) IBOutlet UIImageView *videoImageView;
  11. @property (weak, nonatomic) IBOutlet UILabel *videoDurationLabel;
  12. @property (weak, nonatomic) IBOutlet UILabel *myTtitleLabel;
  13. @property (weak, nonatomic) IBOutlet QMUIButton *tryLookBtn;
  14. @property (weak, nonatomic) IBOutlet UIButton *vipBtn;
  15. @property (nonatomic, readwrite, strong) RQVideoPermissionStateModel *videoPermissionStateModel;
  16. @end
  17. @implementation RQHomeSubPageVideoCell
  18. #pragma mark - PublicMethods
  19. + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
  20. static NSString *ID = @"RQHomeSubPageVideoCell";
  21. [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
  22. RQHomeSubPageVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
  23. if (!cell) cell = [self rq_viewFromXib];
  24. return cell;
  25. }
  26. - (void)bindViewModel:(RQHomeSubPageVideoItemViewModel *)viewModel {
  27. _viewModel = viewModel;
  28. [_videoImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholder:RQWebVideoImagePlaceholder()];
  29. _videoDurationLabel.text = [NSString getMMSSFromSS:viewModel.videosItem.videoDuration];
  30. _myTtitleLabel.text = viewModel.videosItem.title;
  31. if (!RQ_COMMON_MANAGER.APP_SWITCH) {
  32. [[RACSignal combineLatest:@[RACObserve(RQ_VIP_Module, isSubject2Vip), RACObserve(RQ_VIP_Module, isSubject3Vip)] reduce:^id (NSNumber *isSubjectTwoVip, NSNumber *isSubjectThreeVip) {
  33. if ((viewModel.videosItem.subject == 1 && RQ_VIP_Module.isSubject2Vip) || (viewModel.videosItem.subject == 2 && RQ_VIP_Module.isSubject3Vip)) {
  34. self.videoPermissionStateModel.tryLookShow = NO;
  35. self.videoPermissionStateModel.vipShow = NO;
  36. } else {
  37. self.videoPermissionStateModel.tryLookShow = (viewModel.videosItem.permission == 1);
  38. self.videoPermissionStateModel.vipShow = (viewModel.videosItem.permission == 2);
  39. }
  40. return self.videoPermissionStateModel;
  41. }] subscribeNext:^(RQVideoPermissionStateModel *videoPermissionStateModel) {
  42. _tryLookBtn.hidden = !videoPermissionStateModel.tryLookShow;
  43. _vipBtn.hidden = !videoPermissionStateModel.vipShow;
  44. }];
  45. }
  46. }
  47. #pragma mark - SystemMethods
  48. - (void)awakeFromNib {
  49. [super awakeFromNib];
  50. _tryLookBtn.spacingBetweenImageAndTitle = 3;
  51. [_tryLookBtn setBackgroundColor:[UIColor rq_colorGradientChangeWithFrame:_tryLookBtn.frame startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5) startColor:RQColorFromHexString(@"#FF4C52") endColor:RQColorFromHexString(@"#FC8269")]];
  52. }
  53. #pragma mark - LazyLoad
  54. - (RQVideoPermissionStateModel *)videoPermissionStateModel {
  55. if (!_videoPermissionStateModel) {
  56. _videoPermissionStateModel = [[RQVideoPermissionStateModel alloc] init];
  57. }
  58. return _videoPermissionStateModel;
  59. }
  60. @end