12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- //
- // RQHomeSubPageVideoCell.m
- // JSJP
- //
- // Created by 张嵘 on 2021/11/9.
- //
- #import "RQHomeSubPageVideoCell.h"
- @interface RQHomeSubPageVideoCell ()
- @property (nonatomic, readwrite, strong) RQHomeSubPageVideoItemViewModel *viewModel;
- @property (weak, nonatomic) IBOutlet UIImageView *videoImageView;
- @property (weak, nonatomic) IBOutlet UILabel *videoDurationLabel;
- @property (weak, nonatomic) IBOutlet UILabel *myTtitleLabel;
- @property (weak, nonatomic) IBOutlet QMUIButton *tryLookBtn;
- @property (weak, nonatomic) IBOutlet UIButton *vipBtn;
- @property (nonatomic, readwrite, strong) RQVideoPermissionStateModel *videoPermissionStateModel;
- @end
- @implementation RQHomeSubPageVideoCell
- #pragma mark - PublicMethods
- + (instancetype)cellWithCollectionView:(UICollectionView *)collectionView forIndexPath:(NSIndexPath *)indexPath {
- static NSString *ID = @"RQHomeSubPageVideoCell";
- [collectionView registerNib:[UINib nibWithNibName:ID bundle:nil] forCellWithReuseIdentifier:ID];
- RQHomeSubPageVideoCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
- if (!cell) cell = [self rq_viewFromXib];
- return cell;
- }
- - (void)bindViewModel:(RQHomeSubPageVideoItemViewModel *)viewModel {
- _viewModel = viewModel;
- [_videoImageView yy_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholder:RQWebVideoImagePlaceholder()];
- _videoDurationLabel.text = [NSString getMMSSFromSS:viewModel.videosItem.videoDuration];
- _myTtitleLabel.text = viewModel.videosItem.title;
- if (!RQ_COMMON_MANAGER.APP_SWITCH) {
- [[RACSignal combineLatest:@[RACObserve(RQ_VIP_Module, isSubject2Vip), RACObserve(RQ_VIP_Module, isSubject3Vip)] reduce:^id (NSNumber *isSubjectTwoVip, NSNumber *isSubjectThreeVip) {
- if ((viewModel.videosItem.subject == 1 && RQ_VIP_Module.isSubject2Vip) || (viewModel.videosItem.subject == 2 && RQ_VIP_Module.isSubject3Vip)) {
- self.videoPermissionStateModel.tryLookShow = NO;
- self.videoPermissionStateModel.vipShow = NO;
- } else {
- self.videoPermissionStateModel.tryLookShow = (viewModel.videosItem.permission == 1);
- self.videoPermissionStateModel.vipShow = (viewModel.videosItem.permission == 2);
- }
- return self.videoPermissionStateModel;
- }] subscribeNext:^(RQVideoPermissionStateModel *videoPermissionStateModel) {
- _tryLookBtn.hidden = !videoPermissionStateModel.tryLookShow;
- _vipBtn.hidden = !videoPermissionStateModel.vipShow;
- }];
- }
- }
- #pragma mark - SystemMethods
- - (void)awakeFromNib {
- [super awakeFromNib];
- _tryLookBtn.spacingBetweenImageAndTitle = 3;
- [_tryLookBtn setBackgroundColor:[UIColor rq_colorGradientChangeWithFrame:_tryLookBtn.frame startPoint:CGPointMake(0, 0.5) endPoint:CGPointMake(1, 0.5) startColor:RQColorFromHexString(@"#FF4C52") endColor:RQColorFromHexString(@"#FC8269")]];
- }
- #pragma mark - LazyLoad
- - (RQVideoPermissionStateModel *)videoPermissionStateModel {
- if (!_videoPermissionStateModel) {
- _videoPermissionStateModel = [[RQVideoPermissionStateModel alloc] init];
- }
- return _videoPermissionStateModel;
- }
- @end
|