RQVideoDetailSubPageViewController.m 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // RQVideoDetailSubPageViewController.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/10/26.
  6. // 视频详情的视频列表子页面
  7. #import "RQVideoDetailSubPageViewController.h"
  8. @interface RQVideoDetailSubPageViewController ()
  9. /// viewModel
  10. @property (nonatomic, readonly, strong) RQVideoDetailSubPageViewModel *viewModel;
  11. @property (nonatomic, readwrite, copy) void(^scrollCallback)(UIScrollView *scrollView);
  12. @property (nonatomic, readwrite, strong) RQVideoDetailSubPageSectionHeaderView *videoDetailSubPageSectionHeaderView;
  13. @property (nonatomic, readwrite, strong) UIView *tableViewBgView;
  14. /// 顶部视频播放器的高度
  15. @property (nonatomic, readonly, assign) float videoPlayerHeight;
  16. /// 顶部超出背景的高度
  17. @property (nonatomic, readonly, assign) float coverBgViewHeight;
  18. /// 顶部sectionHeaderView的高度
  19. @property (nonatomic, readonly, assign) float sectionHeaderViewHeight;
  20. /// 底部分类筛选栏的高度
  21. @property (nonatomic, readonly, assign) float categoryViewHeight;
  22. @end
  23. @implementation RQVideoDetailSubPageViewController
  24. @dynamic viewModel, tableView;
  25. #pragma mark - SystemMethod
  26. - (void)viewDidLoad {
  27. [super viewDidLoad];
  28. /// 初始化
  29. [self rq_setup];
  30. }
  31. - (void)viewDidLayoutSubviews {
  32. [super viewDidLayoutSubviews];
  33. 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 - self.categoryViewHeight - 20 - self.sectionHeaderViewHeight - 16);
  34. self.tableViewBgView.frame = CGRectMake(16, ((self.videoDetailSubPageSectionHeaderView.headerBtn.height / 2.f) + 22), RQ_SCREEN_WIDTH - 32, RQ_SCREEN_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_APPLICATION_STATUS_BAR_HEIGHT - self.videoPlayerHeight - self.coverBgViewHeight - self.categoryViewHeight - 20);
  35. [self.view sendSubviewToBack:self.tableViewBgView];
  36. }
  37. - (void)viewDidAppear:(BOOL)animated {
  38. [super viewDidAppear:animated];
  39. }
  40. #pragma mark - PrivateMethods
  41. /// 初始化
  42. - (void)rq_setup {
  43. /// set up ...
  44. @weakify(self)
  45. self.tableView.backgroundColor = UIColor.clearColor;
  46. self.tableView.showsVerticalScrollIndicator = NO;
  47. [self.view addSubview:self.tableViewBgView];
  48. [self.videoDetailSubPageSectionHeaderView.headerBtn setTitleNormal:self.viewModel.title];
  49. self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = self.viewModel.subTitle;
  50. [[RACObserve(self.viewModel, updateDataType) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  51. @strongify(self)
  52. if (self.viewModel.updateDataType == RQVideoDetailSubPageUpdateDataType_Complete) {
  53. [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  54. RQPlayVideoItemKey : self.viewModel.videoArr[self.viewModel.indexPath.row],
  55. RQPlayVideoItemArrKey : self.viewModel.videoArr,
  56. }];
  57. }
  58. }];
  59. }
  60. #pragma mark - OverrideMethods
  61. - (UIEdgeInsets)contentInset {
  62. return UIEdgeInsetsMake(0, 0, 0, 0);
  63. }
  64. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  65. switch (indexPath.section) {
  66. case 0: {
  67. RQVideoDetailSubPageCell *cell = [RQVideoDetailSubPageCell cellWithTableView:tableView];
  68. return cell;
  69. }
  70. default:
  71. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  72. }
  73. }
  74. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  75. switch (indexPath.section) {
  76. case 0: {
  77. RQVideoDetailSubPageCell *videoDetailSubPageCell = (RQVideoDetailSubPageCell *)cell;
  78. [videoDetailSubPageCell bindViewModel:object];
  79. break;
  80. }
  81. default: {
  82. [super configureCell:cell atIndexPath:indexPath withObject:object];
  83. break;
  84. }
  85. }
  86. }
  87. //- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  88. // return self.videoDetailSubPageSectionHeaderView;
  89. //}
  90. //
  91. //- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  92. // return self.videoDetailSubPageSectionHeaderView.height;
  93. //}
  94. #pragma mark - JXCategoryListViewDelegate
  95. - (UIView *)listView {
  96. return self.view;
  97. }
  98. - (UIScrollView *)listScrollView {
  99. // NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.viewModel.indexPath.row inSection:0];
  100. // NSArray *tableViewIndexPathArr = self.tableView.indexPathsForVisibleRows;
  101. // if ([tableViewIndexPathArr containsObject:indexPath]) {
  102. // [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
  103. // }
  104. return self.tableView;
  105. }
  106. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  107. self.scrollCallback = callback;
  108. }
  109. #pragma mark - LazyLoad
  110. - (RQVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
  111. if (!_videoDetailSubPageSectionHeaderView) {
  112. _videoDetailSubPageSectionHeaderView = [RQVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
  113. }
  114. return _videoDetailSubPageSectionHeaderView;
  115. }
  116. - (UIView *)tableViewBgView {
  117. if (!_tableViewBgView) {
  118. _tableViewBgView = [[UIView alloc] init];
  119. _tableViewBgView.frame = self.tableView.frame;
  120. _tableViewBgView.alpha = 1.0;
  121. _tableViewBgView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  122. _tableViewBgView.layer.shadowColor = [UIColor colorWithRed:124/255.0 green:129/255.0 blue:136/255.0 alpha:0.20].CGColor;
  123. _tableViewBgView.layer.shadowOffset = CGSizeMake(0,0);
  124. _tableViewBgView.layer.shadowRadius = 8;
  125. _tableViewBgView.layer.shadowOpacity = 1;
  126. _tableViewBgView.layer.cornerRadius = 10;
  127. [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
  128. [self.videoDetailSubPageSectionHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) {
  129. make.top.mas_equalTo(_tableViewBgView.mas_top).mas_offset(- self.coverBgViewHeight);
  130. make.centerX.mas_equalTo(_tableViewBgView);
  131. make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, self.sectionHeaderViewHeight));
  132. }];
  133. }
  134. return _tableViewBgView;
  135. }
  136. - (float)videoPlayerHeight {
  137. return RQ_FIT_HORIZONTAL(210.f);
  138. }
  139. - (float)coverBgViewHeight {
  140. return ((self.videoDetailSubPageSectionHeaderView.headerBtn.height / 2.f) + 22);
  141. }
  142. - (float)sectionHeaderViewHeight {
  143. return RQ_FIT_HORIZONTAL(94.f);
  144. }
  145. - (float)categoryViewHeight {
  146. CGFloat cellWidth = (RQ_SCREEN_WIDTH - (8 * 3) - (16 * 2)) / 4.f;
  147. CGFloat toolHeight = (cellWidth) * (37.f / 80.f) + 2 * ((cellWidth) * (11 / 80.f) * (4.3f / 11.f));
  148. return (self.viewModel.videoSourceType == RQVideoSourceType_LnJppt)? 0 : toolHeight;
  149. }
  150. @end