RQTestQuestionsViewController.m 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // RQTestQuestionsViewController.m
  3. // SDJK
  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. @end
  12. @implementation RQTestQuestionsViewController
  13. @dynamic viewModel;
  14. #pragma mark - SystemMethod
  15. - (void)viewDidLoad {
  16. [super viewDidLoad];
  17. /// 初始化
  18. [self rq_setup];
  19. }
  20. - (void)dealloc {
  21. }
  22. #pragma mark - PrivateMethods
  23. /// 初始化
  24. - (void)rq_setup {
  25. [RQ_MUSIC_MANAGER rq_cancelStreamer];
  26. self.tableView.backgroundColor = RQ_MAIN_BACKGROUNDCOLOR;
  27. RQ_Exercise_Module.currrentExerciseModel = self.viewModel.exerciseModel;
  28. @weakify(self)
  29. [[[RQNotificationCenter rac_addObserverForName:RQQuestionReloadNotification object:nil] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(NSNotification * _Nullable note) {
  30. @strongify(self)
  31. RQExerciseModel *exerciseModel = note.object[RQQuestionReloadExerciseModelKey];
  32. if (self.viewModel.exerciseModel.issue == exerciseModel.issue) {
  33. self.viewModel.exerciseModel = exerciseModel;
  34. [self reloadData];
  35. }
  36. }];
  37. [[[RACObserve(RQ_Exercise_Module, exerciseFontSize) distinctUntilChanged] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id _Nullable x) {
  38. @strongify(self)
  39. [self.tableView reloadData];
  40. }];
  41. }
  42. - (void)questionReload:(NSNotification *)note {
  43. }
  44. #pragma mark - OverrideMethods
  45. /// 配置tableView的区域
  46. - (UIEdgeInsets)contentInset {
  47. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_TOP_BAR_HEIGHT + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT + (8.f + RQ_FIT_HORIZONTAL(54.f) + 8.f + 50.f + 8.f) + 49, 0);
  48. }
  49. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  50. RQCommonGroupViewModel *groupViewModel = self.viewModel.dataSource[indexPath.section];
  51. RQCommonItemViewModel *itemViewModel = groupViewModel.itemViewModels[indexPath.row];
  52. return [NSClassFromString(itemViewModel.itemClassName) cellWithTableView:tableView];
  53. }
  54. - (void)configureCell:(RQCommonCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  55. [cell bindViewModel:object];
  56. }
  57. @end