RQVideoDetailSubPageViewController.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // RQVideoDetailSubPageViewController.m
  3. // JSJP
  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. @weakify(self)
  34. 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);
  35. 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);
  36. [self.view sendSubviewToBack:self.tableViewBgView];
  37. [self.videoDetailSubPageSectionHeaderView mas_remakeConstraints:^(MASConstraintMaker *make) {
  38. @strongify(self)
  39. make.top.mas_equalTo(self.tableViewBgView.mas_top).mas_offset(- self.coverBgViewHeight);
  40. make.centerX.mas_equalTo(self.tableViewBgView);
  41. make.size.mas_equalTo(CGSizeMake(RQ_SCREEN_WIDTH, self.sectionHeaderViewHeight));
  42. }];
  43. }
  44. - (void)viewDidAppear:(BOOL)animated {
  45. [super viewDidAppear:animated];
  46. }
  47. #pragma mark - PrivateMethods
  48. /// 初始化
  49. - (void)rq_setup {
  50. /// set up ...
  51. @weakify(self)
  52. self.tableView.backgroundColor = UIColor.clearColor;
  53. self.tableView.showsVerticalScrollIndicator = NO;
  54. [self.view addSubview:self.tableViewBgView];
  55. [self.videoDetailSubPageSectionHeaderView.headerBtn setTitleNormal:self.viewModel.title];
  56. self.videoDetailSubPageSectionHeaderView.headerSubTitleLabel.text = self.viewModel.subTitle;
  57. [[RACObserve(self.viewModel, updateDataType) takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  58. @strongify(self)
  59. if (self.viewModel.updateDataType == RQVideoDetailSubPageUpdateDataType_Complete) {
  60. if (self.viewModel.indexPath.row < self.viewModel.videoArr.count) {
  61. [RQNotificationCenter postNotificationName:RQPlayVideoUrlNotification object:@{
  62. RQPlayVideoItemKey : self.viewModel.videoArr[self.viewModel.indexPath.row],
  63. RQPlayVideoItemArrKey : self.viewModel.videoArr,
  64. }];
  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. switch (indexPath.section) {
  75. case 0: {
  76. RQVideoDetailSubPageCell *cell = [RQVideoDetailSubPageCell cellWithTableView:tableView];
  77. return cell;
  78. }
  79. default:
  80. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  81. }
  82. }
  83. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  84. switch (indexPath.section) {
  85. case 0: {
  86. RQVideoDetailSubPageCell *videoDetailSubPageCell = (RQVideoDetailSubPageCell *)cell;
  87. [videoDetailSubPageCell bindViewModel:object];
  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. #pragma mark - JXCategoryListViewDelegate
  104. - (UIView *)listView {
  105. return self.view;
  106. }
  107. - (UIScrollView *)listScrollView {
  108. return self.tableView;
  109. }
  110. - (void)listViewDidScrollCallback:(void (^)(UIScrollView *))callback {
  111. self.scrollCallback = callback;
  112. }
  113. #pragma mark - LazyLoad
  114. - (RQVideoDetailSubPageSectionHeaderView *)videoDetailSubPageSectionHeaderView {
  115. if (!_videoDetailSubPageSectionHeaderView) {
  116. _videoDetailSubPageSectionHeaderView = [RQVideoDetailSubPageSectionHeaderView videoDetailSubPageSectionHeaderView];
  117. }
  118. return _videoDetailSubPageSectionHeaderView;
  119. }
  120. - (UIView *)tableViewBgView {
  121. if (!_tableViewBgView) {
  122. _tableViewBgView = [[UIView alloc] init];
  123. _tableViewBgView.frame = self.tableView.frame;
  124. _tableViewBgView.alpha = 1.0;
  125. _tableViewBgView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  126. _tableViewBgView.layer.shadowColor = [UIColor colorWithRed:124/255.0 green:129/255.0 blue:136/255.0 alpha:0.20].CGColor;
  127. _tableViewBgView.layer.shadowOffset = CGSizeMake(0,0);
  128. _tableViewBgView.layer.shadowRadius = 8;
  129. _tableViewBgView.layer.shadowOpacity = 1;
  130. _tableViewBgView.layer.cornerRadius = 10;
  131. [_tableViewBgView addSubview:self.videoDetailSubPageSectionHeaderView];
  132. }
  133. return _tableViewBgView;
  134. }
  135. - (float)videoPlayerHeight {
  136. return RQ_FIT_HORIZONTAL(210.f);
  137. }
  138. - (float)coverBgViewHeight {
  139. return ((self.videoDetailSubPageSectionHeaderView.headerBtn.height / 2.f) + 22);
  140. }
  141. - (float)sectionHeaderViewHeight {
  142. return RQ_FIT_HORIZONTAL(94.f);
  143. }
  144. - (float)categoryViewHeight {
  145. CGFloat cellWidth = (RQ_SCREEN_WIDTH - (8 * 3) - (16 * 2)) / 4.f;
  146. CGFloat toolHeight = (cellWidth) * (37.f / 80.f) + 2 * ((cellWidth) * (11 / 80.f) * (4.3f / 11.f));
  147. return toolHeight;
  148. }
  149. @end