123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- //
- // NYLIVideoDetailSubPageViewController.m
- // jiaPei
- //
- // Created by Ning.ge on 2025/2/10.
- // Copyright © 2025 JCZ. All rights reserved.
- //
- #import "NYLIVideoDetailSubPageViewController.h"
- @interface NYLIVideoDetailSubPageViewController ()
- /// viewModel
- @property (nonatomic, readonly, strong) NYLIVideoDetailSubPageViewModel *viewModel;
- @property (nonatomic, readwrite, copy) void(^scrollCallback)(UIScrollView *scrollView);
- @property (nonatomic, readwrite, strong) NYLIVideoDetailSubPageSectionHeaderView *videoDetailSubPageSectionHeaderView;
- @property (nonatomic, readwrite, strong) UIView *tableViewBgView;
- /// 顶部视频播放器的高度
- @property (nonatomic, readonly, assign) float videoPlayerHeight;
- /// 顶部sectionHeaderView的高度
- @property (nonatomic, readonly, assign) float sectionHeaderViewHeight;
- @end
- @implementation NYLIVideoDetailSubPageViewController
- @dynamic viewModel, tableView;
- #pragma mark - SystemMethod
- - (void)viewDidLoad {
- [super viewDidLoad];
- /// 初始化
- [self rq_setup];
-
- }
- - (void)viewDidLayoutSubviews {
- [super viewDidLayoutSubviews];
- @weakify(self)
- self.tableView.frame = CGRectMake(0, self.sectionHeaderViewHeight, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_APPLICATION_STATUS_BAR_HEIGHT - self.videoPlayerHeight - 20 - self.sectionHeaderViewHeight - 16);
- self.tableViewBgView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
- [self.view sendSubviewToBack:self.tableViewBgView];
-
- [self.videoDetailSubPageSectionHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) {
- @strongify(self)
- make.top.mas_equalTo(self.tableViewBgView.mas_top).mas_offset(0);
- make.centerX.mas_equalTo(self.tableViewBgView);
- make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, self.sectionHeaderViewHeight));
- }];
- if(self.viewModel.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI){
- self.videoDetailSubPageSectionHeaderView.segmentedControl.selectedSegmentIndex = 1;
- }
- //视频同款题库
- [self.videoDetailSubPageSectionHeaderView.right_btn addTarget:self action:@selector(gotoFooterCell:) forControlEvents:UIControlEventTouchUpInside];
- }
- - (void)viewDidAppear:(BOOL)animated {
- [super viewDidAppear:animated];
- }
- #pragma mark - PrivateMethods
- /// 初始化
- - (void)rq_setup {
- /// set up ...
- @weakify(self)
- self.tableView.backgroundColor = UIColor.clearColor;
- self.tableView.showsVerticalScrollIndicator = NO;
- [self.view addSubview:self.tableViewBgView];
- // [self.videoDetailSubPageSectionHeaderView.headerBtn setTitleNormal:self.viewModel.title];
- // self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = self.viewModel.subTitle;
- [[RACObserve(self.viewModel, updateDataType) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
- @strongify(self)
- if (self.viewModel.updateDataType == RQVideoDetailSubPageUpdateDataType_Complete) {
- [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
- RQPlayVideoItemKey : self.viewModel.videoArr[0],
- RQPlayVideoItemArrKey : self.viewModel.videoArr,
- }];
- }
- }];
- }
- #pragma mark - OverrideMethods
- - (UIEdgeInsets)contentInset {
- return UIEdgeInsetsMake(0, 0, 0, 0);
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
- RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
- return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
- }
- - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
- switch (indexPath.section) {
- case 0: {
- if([object isKindOfClass:[NYLIVideoDetailSubFooterViewModel class]]){
- NYLIVideoDetailSubFooterCell *videoDetailSubFooterCell = (NYLIVideoDetailSubFooterCell *)cell;
- [videoDetailSubFooterCell bindViewModel:object];
- }else{
- NYLIVideoDetailSubPageCell *videoDetailSubPageCell = (NYLIVideoDetailSubPageCell *)cell;
- [videoDetailSubPageCell bindViewModel:object];
- }
- break;
- }
-
- default: {
- [super configureCell:cell atIndexPath:indexPath withObject:object];
- break;
- }
- }
-
- }
- //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
- // return self.videoDetailSubPageSectionHeaderView;
- //}
- //
- //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
- // return self.videoDetailSubPageSectionHeaderView.height;
- //}
- //滚动到底部
- - (void)gotoFooterCell:(UIButton *)btn {
- RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[0];
- NSIndexPath *indexPath = [NSIndexPath indexPathForRow:groupViewModel.itemViewModels.count-1 inSection:0];
- [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
- }
- #pragma mark - JXCategoryListViewDelegate
- - (UIView *)listView {
- return self.view;
- }
- - (UIScrollView *)listScrollView {
- return self.tableView;
- }
- - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
- self.scrollCallback = callback;
- }
- #pragma mark - LazyLoad
- - (NYLIVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
- if (!_videoDetailSubPageSectionHeaderView) {
- _videoDetailSubPageSectionHeaderView = [NYLIVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
- }
- return _videoDetailSubPageSectionHeaderView;
- }
- - (float)videoPlayerHeight {
- return RQ_FIT_HORIZONTAL(210.f);
- }
- - (UIView *)tableViewBgView {
- if (!_tableViewBgView) {
- _tableViewBgView = [[UIView alloc] init];
- _tableViewBgView.frame = self.tableView.frame;
- _tableViewBgView.alpha = 1.0;
- _tableViewBgView.backgroundColor = UIColor.clearColor;
- [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
-
- }
- return _tableViewBgView;
- }
- - (float)sectionHeaderViewHeight {
- return RQ_FIT_HORIZONTAL(94.f);
- }
- @end
|