RQVideoDetailSubPageViewController.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. [[[[RQNotificationCenter rac_addObserverForName:RQPlayVideoUrlNotification object:nil] takeUntil:self.rac_willDeallocSignal] deliverOnMainThread] subscribeNext:^(NSNotification * note) {
  61. @strongify(self)
  62. VideosItem *videosItem = note.object[RQPlayVideoItemKey];
  63. self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = videosItem.title;
  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. switch (indexPath.section) {
  72. case 0: {
  73. RQVideoDetailSubPageCell *cell = [RQVideoDetailSubPageCell cellWithTableView:tableView];
  74. return cell;
  75. }
  76. default:
  77. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  78. }
  79. }
  80. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  81. switch (indexPath.section) {
  82. case 0: {
  83. RQVideoDetailSubPageCell *videoDetailSubPageCell = (RQVideoDetailSubPageCell *)cell;
  84. [videoDetailSubPageCell bindViewModel:object];
  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. #pragma mark - JXCategoryListViewDelegate
  101. - (UIView *)listView {
  102. return self.view;
  103. }
  104. - (UIScrollView *)listScrollView {
  105. // NSIndexPath *indexPath = [NSIndexPath indexPathForRow:self.viewModel.indexPath.row inSection:0];
  106. // NSArray *tableViewIndexPathArr = self.tableView.indexPathsForVisibleRows;
  107. // if ([tableViewIndexPathArr containsObject:indexPath]) {
  108. // [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
  109. // }
  110. return self.tableView;
  111. }
  112. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  113. self.scrollCallback = callback;
  114. }
  115. #pragma mark - LazyLoad
  116. - (RQVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
  117. if (!_videoDetailSubPageSectionHeaderView) {
  118. _videoDetailSubPageSectionHeaderView = [RQVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
  119. }
  120. return _videoDetailSubPageSectionHeaderView;
  121. }
  122. - (UIView *)tableViewBgView {
  123. if (!_tableViewBgView) {
  124. _tableViewBgView = [[UIView alloc] init];
  125. _tableViewBgView.frame = self.tableView.frame;
  126. _tableViewBgView.alpha = 1.0;
  127. _tableViewBgView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  128. _tableViewBgView.layer.shadowColor = [UIColor colorWithRed:124/255.0 green:129/255.0 blue:136/255.0 alpha:0.20].CGColor;
  129. _tableViewBgView.layer.shadowOffset = CGSizeMake(0,0);
  130. _tableViewBgView.layer.shadowRadius = 8;
  131. _tableViewBgView.layer.shadowOpacity = 1;
  132. _tableViewBgView.layer.cornerRadius = 10;
  133. [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
  134. [self.videoDetailSubPageSectionHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) {
  135. make.top.mas_equalTo(_tableViewBgView.mas_top).mas_offset(- self.coverBgViewHeight);
  136. make.centerX.mas_equalTo(_tableViewBgView);
  137. make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, self.sectionHeaderViewHeight));
  138. }];
  139. }
  140. return _tableViewBgView;
  141. }
  142. - (float)videoPlayerHeight {
  143. return RQ_FIT_HORIZONTAL(210.f);
  144. }
  145. - (float)coverBgViewHeight {
  146. return ((self.videoDetailSubPageSectionHeaderView.headerBtn.height / 2.f) + 22);
  147. }
  148. - (float)sectionHeaderViewHeight {
  149. return RQ_FIT_HORIZONTAL(94.f);
  150. }
  151. - (float)categoryViewHeight {
  152. CGFloat cellWidth = (RQ_SCREEN_WIDTH - (8 * 3) - (16 * 2)) / 4.f;
  153. CGFloat toolHeight = (cellWidth) * (37.f / 80.f) + 2 * ((cellWidth) * (11 / 80.f) * (4.3f / 11.f));
  154. return toolHeight;
  155. }
  156. @end