// // NYLIVideoDetailSubPageCell.m // jiaPei // // Created by Ning.ge on 2025/2/11. // Copyright © 2025 JCZ. All rights reserved. // #import "NYLIVideoDetailSubPageCell.h" @interface NYLIVideoDetailSubPageCell () @property (nonatomic, readwrite, strong) NYLIVideoDetailSubPageItemViewModel *viewModel; @property (nonatomic, readwrite, strong) RQVideoPermissionStateModel *videoPermissionStateModel; @property (weak, nonatomic) IBOutlet UIImageView *icon_imageview; @property (weak, nonatomic) IBOutlet UILabel *title_label; @property (weak, nonatomic) IBOutlet UIView *tag_view; @property (weak, nonatomic) IBOutlet QMUIButton *call_play_btn; @property (weak, nonatomic) IBOutlet UIButton *tag_bg_btn; @property (weak, nonatomic) IBOutlet UIImageView *vipImg; @end @implementation NYLIVideoDetailSubPageCell #pragma mark - PublicMethods + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *ID = @"NYLIVideoDetailSubPageCell"; NYLIVideoDetailSubPageCell *cell = [tableView dequeueReusableCellWithIdentifier:ID]; if (!cell) { cell = [self rq_viewFromXib]; cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell.tag_bg_btn setBackgroundImage:[UIImage imageWithGradualChangingColor:^(QQGradualChangingColor *graColor) { graColor.fromColor = [UIColor qmui_colorWithHexString:@"#FFE7B8"]; graColor.toColor = [UIColor qmui_colorWithHexString:@"##FDC67F"]; graColor.type = QQGradualChangeTypeLeftToRight; } size:cell.tag_bg_btn.bounds.size cornerRadius:QQRadiusMake(5, 5, 5, 5)] forState:UIControlStateNormal]; [cell.call_play_btn addTarget:cell action:@selector(callPlaydoVideo:) forControlEvents:UIControlEventTouchUpInside]; } return cell; } - (void)bindViewModel:(NYLIVideoDetailSubPageItemViewModel *)viewModel { @weakify(self) _viewModel = viewModel; [self.icon_imageview sd_setImageWithURL:[NSURL URLWithString:viewModel.videosItem.coverFileUrl] placeholderImage:randomPortrait()]; RAC(self.title_label, text) = [[RACObserve(viewModel.videosItem, title) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal]; RAC(self.call_play_btn, selected) = [[RACObserve(viewModel.videosItem, isPlaying) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal]; [[[RACObserve(viewModel.videosItem, permission) deliverOnMainThread] takeUntil:self.rac_prepareForReuseSignal] subscribeNext:^(id _Nullable x) { @strongify(self) self.vipImg.hidden = NO; if (viewModel.videosItem.permission == 0) { self.vipImg.image = RQImageNamed(@"考场免费"); } else if (viewModel.videosItem.permission == 1) { self.vipImg.image = RQImageNamed(@"考场试看"); } else if (viewModel.videosItem.permission == 2) { self.vipImg.image = RQImageNamed(@"考场VIP"); } else { self.vipImg.hidden = YES; } if(viewModel.videosItem.subject == 5 && RQ_VIP_Module.isSpSubject1Vip) { self.vipImg.hidden = YES; }else if(viewModel.videosItem.subject == 6 && RQ_VIP_Module.isSpSubject4Vip) { self.vipImg.hidden = YES; } // if (viewModel.placeVideoListModel.placeListModel.isCheckVip) { // self.vipImg.hidden = YES; // } }]; } //播放通知 - (void)callPlaydoVideo:(UIButton *)btn { // VideosItem *videosItem = self.viewModel.videosItem; // [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{ // RQPlayVideoItemKey : videosItem, // RQPlayVideoItemArrKey : @[videosItem], // }]; } #pragma mark - SystemMethods - (void)awakeFromNib { [super awakeFromNib]; } - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state } #pragma mark - LazyLoad - (RQVideoPermissionStateModel *)videoPermissionStateModel { if (!_videoPermissionStateModel) { _videoPermissionStateModel = [[RQVideoPermissionStateModel alloc] init]; } return _videoPermissionStateModel; } @end