NYVideoListCell.m 3.2 KB

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