RQVideoListCell.m 3.2 KB

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