RQTestQuestionsViewController.m 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // RQTestQuestionsViewController.m
  3. // JSJP
  4. //
  5. // Created by 张嵘 on 2021/8/12.
  6. //
  7. #import "RQTestQuestionsViewController.h"
  8. @interface RQTestQuestionsViewController ()
  9. /// viewModel
  10. @property (nonatomic, readonly, strong) RQTestQuestionsViewModel *viewModel;
  11. @property (nonatomic, copy) void(^scrollCallback)(UIScrollView *scrollView);
  12. @end
  13. @implementation RQTestQuestionsViewController
  14. @dynamic viewModel;
  15. #pragma mark - SystemMethod
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. /// 初始化
  19. [self rq_setup];
  20. }
  21. - (void)viewWillLayoutSubviews {
  22. [super viewWillLayoutSubviews];
  23. [self updateFrame];
  24. }
  25. - (void)updateFrame {
  26. CGFloat height = RQ_SCREEN_HEIGHT - (RQ_APPLICATION_NAV_BAR_HEIGHT + RQ_APPLICATION_STATUS_BAR_HEIGHT) - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - RQ_FIT_HORIZONTAL(50.f) - (RQ_AD_MANAGER.bannerIsShow? RQ_SCREEN_WIDTH / (640/100.0) : 0.f );
  27. self.tableView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, height);
  28. }
  29. - (void)dealloc {
  30. [[NSNotificationCenter defaultCenter] removeObserver:self];
  31. }
  32. #pragma mark - PrivateMethods
  33. /// 初始化
  34. - (void)rq_setup {
  35. @weakify(self)
  36. self.tableView.backgroundColor = RQ_MAIN_BACKGROUNDCOLOR;
  37. // RQ_Exercise_Module.currrentExerciseModel = self.viewModel.exerciseModel;
  38. [[[[RACObserve(RQ_AD_MANAGER, bannerIsShow) deliverOnMainThread] distinctUntilChanged] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  39. @strongify(self)
  40. [self updateFrame];
  41. }];
  42. }
  43. #pragma mark - OverrideMethods
  44. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  45. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  46. RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  47. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  48. }
  49. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  50. [cell bindViewModel:object];
  51. }
  52. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  53. RQCommonHeaderView *headerView = [RQCommonHeaderView headerViewWithTableView:tableView];
  54. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[section];
  55. if ([self.viewModel.dataSource[section] isKindOfClass:[RQExciseExplainHeaderGroupViewModel class]]) {
  56. headerView = [RQExerciseExplainHeaderView headerViewWithTableView:tableView];
  57. }
  58. [headerView bindViewModel:groupViewModel];
  59. return headerView;
  60. }
  61. #pragma mark - JXPagerSmoothViewListViewDelegate
  62. - (UIView *)listView {
  63. return self.view;
  64. }
  65. - (UIScrollView *)listScrollView {
  66. return self.tableView;
  67. }
  68. @end