RQTestQuestionsViewController.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. [[NSNotificationCenter defaultCenter] removeObserver:self];
  22. [RQ_MUSIC_MANAGER rq_cancelStreamer];
  23. }
  24. #pragma mark - PrivateMethods
  25. /// 初始化
  26. - (void)rq_setup {
  27. [RQ_MUSIC_MANAGER rq_cancelStreamer];
  28. self.tableView.backgroundColor = RQ_MAIN_BACKGROUNDCOLOR;
  29. RQ_Exercise_Module.currrentExerciseModel = self.viewModel.exerciseModel;
  30. [[[RQNotificationCenter rac_addObserverForName:RQQuestionReloadNotification object:nil] deliverOnMainThread] subscribeNext:^(NSNotification * note) {
  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. }
  38. #pragma mark - OverrideMethods
  39. /// 配置tableView的区域
  40. - (UIEdgeInsets)contentInset {
  41. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_TOP_BAR_HEIGHT + RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT + 65 + 49, 0);
  42. }
  43. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  44. switch (indexPath.section) {
  45. case 0: {
  46. RQExerciseQuestionCell *cell = [RQExerciseQuestionCell cellWithTableView:tableView];
  47. return cell;
  48. }
  49. case 1: {
  50. RQExerciseOptionCell *cell = [RQExerciseOptionCell cellWithTableView:tableView];
  51. return cell;
  52. }
  53. case 2 : {
  54. RQExerciseAnswerCell *cell = [RQExerciseAnswerCell cellWithTableView:tableView];
  55. return cell;
  56. }
  57. case 3 : {
  58. RQExerciseOptionSureBtnCell *cell = [RQExerciseOptionSureBtnCell cellWithTableView:tableView];
  59. return cell;
  60. }
  61. case 4 : {
  62. RQExerciseToolBarCell *cell = [RQExerciseToolBarCell cellWithTableView:tableView];
  63. return cell;
  64. }
  65. case 5 : {
  66. RQExerciseExamToolBarCell *cell = [RQExerciseExamToolBarCell cellWithTableView:tableView];
  67. return cell;
  68. }
  69. default:
  70. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  71. }
  72. }
  73. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  74. switch (indexPath.section) {
  75. case 0: {
  76. RQExerciseQuestionCell *exerciseQuestionCell = (RQExerciseQuestionCell *)cell;
  77. [exerciseQuestionCell bindViewModel:object];
  78. break;
  79. }
  80. case 1: {
  81. RQExerciseOptionCell *exerciseOptionCell = (RQExerciseOptionCell *)cell;
  82. [exerciseOptionCell bindViewModel:object];
  83. break;
  84. }
  85. case 2: {
  86. RQExerciseAnswerCell *exerciseAnswerCell = (RQExerciseAnswerCell *)cell;
  87. [exerciseAnswerCell bindViewModel:object];
  88. break;
  89. }
  90. case 3: {
  91. RQExerciseOptionSureBtnCell *exerciseOptionSureBtnCell = (RQExerciseOptionSureBtnCell *)cell;
  92. [exerciseOptionSureBtnCell bindViewModel:object];
  93. break;
  94. }
  95. case 4: {
  96. RQExerciseToolBarCell *exerciseToolBarCell = (RQExerciseToolBarCell *)cell;
  97. [exerciseToolBarCell bindViewModel:object];
  98. break;
  99. }
  100. case 5: {
  101. RQExerciseExamToolBarCell *exerciseExamToolBarCell = (RQExerciseExamToolBarCell *)cell;
  102. [exerciseExamToolBarCell bindViewModel:object];
  103. break;
  104. }
  105. default:
  106. [super configureCell:cell atIndexPath:indexPath withObject:object];
  107. break;
  108. }
  109. }
  110. @end