NYLIVideoDetailSubPageViewController.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // NYLIVideoDetailSubPageViewController.m
  3. // jiaPei
  4. //
  5. // Created by Ning.ge on 2025/2/10.
  6. // Copyright © 2025 JCZ. All rights reserved.
  7. //
  8. #import "NYLIVideoDetailSubPageViewController.h"
  9. @interface NYLIVideoDetailSubPageViewController ()
  10. /// viewModel
  11. @property (nonatomic, readonly, strong) NYLIVideoDetailSubPageViewModel *viewModel;
  12. @property (nonatomic, readwrite, copy) void(^scrollCallback)(UIScrollView *scrollView);
  13. @property (nonatomic, readwrite, strong) NYLIVideoDetailSubPageSectionHeaderView *videoDetailSubPageSectionHeaderView;
  14. @property (nonatomic, readwrite, strong) UIView *tableViewBgView;
  15. /// 顶部视频播放器的高度
  16. @property (nonatomic, readonly, assign) float videoPlayerHeight;
  17. /// 顶部sectionHeaderView的高度
  18. @property (nonatomic, readonly, assign) float sectionHeaderViewHeight;
  19. @end
  20. @implementation NYLIVideoDetailSubPageViewController
  21. @dynamic viewModel, tableView;
  22. #pragma mark - SystemMethod
  23. - (void)viewDidLoad {
  24. [super viewDidLoad];
  25. /// 初始化
  26. [self rq_setup];
  27. }
  28. - (void)viewDidLayoutSubviews {
  29. [super viewDidLayoutSubviews];
  30. @weakify(self)
  31. 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);
  32. self.tableViewBgView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
  33. [self.view sendSubviewToBack:self.tableViewBgView];
  34. [self.videoDetailSubPageSectionHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) {
  35. @strongify(self)
  36. make.top.mas_equalTo(self.tableViewBgView.mas_top).mas_offset(0);
  37. make.centerX.mas_equalTo(self.tableViewBgView);
  38. make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, self.sectionHeaderViewHeight));
  39. }];
  40. //视频同款题库
  41. [self.videoDetailSubPageSectionHeaderView.right_btn addTarget:self action:@selector(gotoFooterCell:) forControlEvents:UIControlEventTouchUpInside];
  42. }
  43. - (void)viewDidAppear:(BOOL)animated {
  44. [super viewDidAppear:animated];
  45. }
  46. #pragma mark - PrivateMethods
  47. /// 初始化
  48. - (void)rq_setup {
  49. /// set up ...
  50. @weakify(self)
  51. self.tableView.backgroundColor = UIColor.clearColor;
  52. self.tableView.showsVerticalScrollIndicator = NO;
  53. [self.view addSubview:self.tableViewBgView];
  54. // [self.videoDetailSubPageSectionHeaderView.headerBtn setTitleNormal:self.viewModel.title];
  55. // self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = self.viewModel.subTitle;
  56. [[RACObserve(self.viewModel, updateDataType) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  57. @strongify(self)
  58. if (self.viewModel.updateDataType == RQVideoDetailSubPageUpdateDataType_Complete) {
  59. [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  60. RQPlayVideoItemKey : self.viewModel.videoArr[0],
  61. RQPlayVideoItemArrKey : self.viewModel.videoArr,
  62. }];
  63. }
  64. }];
  65. }
  66. #pragma mark - OverrideMethods
  67. - (UIEdgeInsets)contentInset {
  68. return UIEdgeInsetsMake(0, 0, 0, 0);
  69. }
  70. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  71. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  72. RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  73. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  74. }
  75. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  76. switch (indexPath.section) {
  77. case 0: {
  78. if([object isKindOfClass:[NYLIVideoDetailSubFooterViewModel class]]){
  79. NYLIVideoDetailSubFooterCell *videoDetailSubFooterCell = (NYLIVideoDetailSubFooterCell *)cell;
  80. [videoDetailSubFooterCell bindViewModel:object];
  81. }else{
  82. NYLIVideoDetailSubPageCell *videoDetailSubPageCell = (NYLIVideoDetailSubPageCell *)cell;
  83. [videoDetailSubPageCell bindViewModel:object];
  84. }
  85. break;
  86. }
  87. default: {
  88. [super configureCell:cell atIndexPath:indexPath withObject:object];
  89. break;
  90. }
  91. }
  92. }
  93. //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  94. // return self.videoDetailSubPageSectionHeaderView;
  95. //}
  96. //
  97. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  98. // return self.videoDetailSubPageSectionHeaderView.height;
  99. //}
  100. //滚动到底部
  101. - (void)gotoFooterCell:(UIButton *)btn {
  102. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[0];
  103. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:groupViewModel.itemViewModels.count-1 inSection:0];
  104. [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
  105. }
  106. #pragma mark - JXCategoryListViewDelegate
  107. - (UIView *)listView {
  108. return self.view;
  109. }
  110. - (UIScrollView *)listScrollView {
  111. return self.tableView;
  112. }
  113. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  114. self.scrollCallback = callback;
  115. }
  116. #pragma mark - LazyLoad
  117. - (NYLIVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
  118. if (!_videoDetailSubPageSectionHeaderView) {
  119. _videoDetailSubPageSectionHeaderView = [NYLIVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
  120. }
  121. return _videoDetailSubPageSectionHeaderView;
  122. }
  123. - (float)videoPlayerHeight {
  124. return RQ_FIT_HORIZONTAL(210.f);
  125. }
  126. - (UIView *)tableViewBgView {
  127. if (!_tableViewBgView) {
  128. _tableViewBgView = [[UIView alloc] init];
  129. _tableViewBgView.frame = self.tableView.frame;
  130. _tableViewBgView.alpha = 1.0;
  131. _tableViewBgView.backgroundColor = UIColor.clearColor;
  132. [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
  133. }
  134. return _tableViewBgView;
  135. }
  136. - (float)sectionHeaderViewHeight {
  137. return RQ_FIT_HORIZONTAL(94.f);
  138. }
  139. @end