NYLIVideoDetailSubPageViewController.m 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. if(self.viewModel.homePageSubjectType==RQHomePageSubjectType_SubjectFour_LI){
  41. self.videoDetailSubPageSectionHeaderView.segmentedControl.selectedSegmentIndex = 1;
  42. }
  43. //视频同款题库
  44. [self.videoDetailSubPageSectionHeaderView.right_btn addTarget:self action:@selector(gotoFooterCell:) forControlEvents:UIControlEventTouchUpInside];
  45. }
  46. - (void)viewDidAppear:(BOOL)animated {
  47. [super viewDidAppear:animated];
  48. }
  49. #pragma mark - PrivateMethods
  50. /// 初始化
  51. - (void)rq_setup {
  52. /// set up ...
  53. @weakify(self)
  54. self.tableView.backgroundColor = UIColor.clearColor;
  55. self.tableView.showsVerticalScrollIndicator = NO;
  56. [self.view addSubview:self.tableViewBgView];
  57. // [self.videoDetailSubPageSectionHeaderView.headerBtn setTitleNormal:self.viewModel.title];
  58. // self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = self.viewModel.subTitle;
  59. [[RACObserve(self.viewModel, updateDataType) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  60. @strongify(self)
  61. if (self.viewModel.updateDataType == RQVideoDetailSubPageUpdateDataType_Complete) {
  62. [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  63. RQPlayVideoItemKey : self.viewModel.videoArr[0],
  64. RQPlayVideoItemArrKey : self.viewModel.videoArr,
  65. }];
  66. }
  67. }];
  68. }
  69. #pragma mark - OverrideMethods
  70. - (UIEdgeInsets)contentInset {
  71. return UIEdgeInsetsMake(0, 0, 0, 0);
  72. }
  73. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  74. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  75. RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  76. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  77. }
  78. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  79. switch (indexPath.section) {
  80. case 0: {
  81. if([object isKindOfClass:[NYLIVideoDetailSubFooterViewModel class]]){
  82. NYLIVideoDetailSubFooterCell *videoDetailSubFooterCell = (NYLIVideoDetailSubFooterCell *)cell;
  83. [videoDetailSubFooterCell bindViewModel:object];
  84. }else{
  85. NYLIVideoDetailSubPageCell *videoDetailSubPageCell = (NYLIVideoDetailSubPageCell *)cell;
  86. [videoDetailSubPageCell bindViewModel:object];
  87. }
  88. break;
  89. }
  90. default: {
  91. [super configureCell:cell atIndexPath:indexPath withObject:object];
  92. break;
  93. }
  94. }
  95. }
  96. //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  97. // return self.videoDetailSubPageSectionHeaderView;
  98. //}
  99. //
  100. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  101. // return self.videoDetailSubPageSectionHeaderView.height;
  102. //}
  103. //滚动到底部
  104. - (void)gotoFooterCell:(UIButton *)btn {
  105. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[0];
  106. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:groupViewModel.itemViewModels.count-1 inSection:0];
  107. [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionNone animated:NO];
  108. }
  109. #pragma mark - JXCategoryListViewDelegate
  110. - (UIView *)listView {
  111. return self.view;
  112. }
  113. - (UIScrollView *)listScrollView {
  114. return self.tableView;
  115. }
  116. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  117. self.scrollCallback = callback;
  118. }
  119. #pragma mark - LazyLoad
  120. - (NYLIVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
  121. if (!_videoDetailSubPageSectionHeaderView) {
  122. _videoDetailSubPageSectionHeaderView = [NYLIVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
  123. }
  124. return _videoDetailSubPageSectionHeaderView;
  125. }
  126. - (float)videoPlayerHeight {
  127. return RQ_FIT_HORIZONTAL(210.f);
  128. }
  129. - (UIView *)tableViewBgView {
  130. if (!_tableViewBgView) {
  131. _tableViewBgView = [[UIView alloc] init];
  132. _tableViewBgView.frame = self.tableView.frame;
  133. _tableViewBgView.alpha = 1.0;
  134. _tableViewBgView.backgroundColor = UIColor.clearColor;
  135. [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
  136. }
  137. return _tableViewBgView;
  138. }
  139. - (float)sectionHeaderViewHeight {
  140. return RQ_FIT_HORIZONTAL(94.f);
  141. }
  142. @end