RQSimulationResultsViewController.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // RQSimulationResultsViewController.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/6.
  6. //
  7. #import "RQSimulationResultsViewController.h"
  8. @interface RQSimulationResultsViewController ()
  9. // viewModel
  10. @property (nonatomic, readwrite, strong) RQSimulationResultsViewModel *viewModel;
  11. @property (nonatomic, readwrite, strong) RQSimulationResultsHeaderView *simulationResultsHeaderView;
  12. @property (nonatomic, readwrite, strong) RQSimulationResultsSeectionHeaderView *simulationResultsSeectionHeaderView;
  13. @property (nonatomic, readwrite, strong) UIView *tableViewBgView;
  14. @end
  15. @implementation RQSimulationResultsViewController
  16. @dynamic viewModel;
  17. #pragma mark - SystemMethod
  18. - (void)viewDidLoad {
  19. [super viewDidLoad];
  20. /// 初始化
  21. [self rq_setup];
  22. }
  23. - (void)viewDidLayoutSubviews {
  24. [super viewDidLayoutSubviews];
  25. self.simulationResultsHeaderView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQSimulationResultsHeaderViewHeight + 24 - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT);
  26. self.tableView.frame = CGRectMake(0, CGRectGetMaxY(self.simulationResultsHeaderView.frame) + 10 + 40, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT - CGRectGetMaxY(self.simulationResultsHeaderView.frame) - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - 10 - 40 - 15);
  27. self.tableViewBgView.frame = CGRectMake(16, CGRectGetMaxY(self.simulationResultsHeaderView.frame) + 10, RQ_SCREEN_WIDTH - 32, RQ_SCREEN_HEIGHT - CGRectGetMaxY(self.simulationResultsHeaderView.frame) - RQ_APPLICATION_TOP_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - 10);
  28. self.simulationResultsSeectionHeaderView.frame = CGRectMake(16, 0, RQ_SCREEN_WIDTH - 32 - 32, 40);
  29. [self.view sendSubviewToBack:self.tableViewBgView];
  30. self.emptyView.frame = CGRectMake(0, (RQSimulationResultsHeaderViewHeight + 24 - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT) / 2.f, RQ_SCREEN_WIDTH, RQ_SCREEN_HEIGHT);
  31. }
  32. #pragma mark - PrivateMethods
  33. - (void)rq_setup {
  34. self.tableView.backgroundColor = UIColor.clearColor;
  35. self.tableView.showsVerticalScrollIndicator = NO;
  36. [self.view addSubview:self.tableViewBgView];
  37. [self.view addSubview:self.simulationResultsHeaderView];
  38. }
  39. #pragma mark - OverrideMethods
  40. /// 配置tableView的区域
  41. - (UIEdgeInsets)contentInset {
  42. return UIEdgeInsetsMake(0, 0, 0, 0);
  43. }
  44. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  45. RQSimulationResultsListCell *cell = [RQSimulationResultsListCell cellWithTableView:tableView];
  46. cell.myContentView.backgroundColor = (indexPath.section %2 == 0)? [UIColor colorWithRed:73/255.0 green:142/255.0 blue:245/255.0 alpha:0.15] : RQ_MAIN_BACKGROUNDCOLOR;
  47. return cell;
  48. }
  49. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  50. RQSimulationResultsListCell *simulationResultsListCell = (RQSimulationResultsListCell *)cell;
  51. [simulationResultsListCell bindViewModel:object];
  52. }
  53. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
  54. return [[UIView alloc] initWithFrame:CGRectMake(0, 0, RQ_SCREEN_WIDTH, 40)];
  55. }
  56. #pragma mark - LazyLoad
  57. - (RQSimulationResultsHeaderView *)simulationResultsHeaderView {
  58. if (!_simulationResultsHeaderView) {
  59. _simulationResultsHeaderView = [RQSimulationResultsHeaderView simulationResultsHeaderView];
  60. RAC(_simulationResultsHeaderView.examTotalLabel, text) = [RACObserve(self.viewModel, totalStr) distinctUntilChanged];
  61. }
  62. return _simulationResultsHeaderView;
  63. }
  64. - (RQSimulationResultsSeectionHeaderView *)simulationResultsSeectionHeaderView {
  65. if (!_simulationResultsSeectionHeaderView) {
  66. _simulationResultsSeectionHeaderView = [RQSimulationResultsSeectionHeaderView simulationResultsSeectionHeaderView];
  67. }
  68. return _simulationResultsSeectionHeaderView;
  69. }
  70. - (UIView *)tableViewBgView {
  71. if (!_tableViewBgView) {
  72. _tableViewBgView = [[UIView alloc] init];
  73. _tableViewBgView.frame = self.tableView.frame;
  74. _tableViewBgView.alpha = 1.0;
  75. _tableViewBgView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
  76. _tableViewBgView.layer.shadowColor = [UIColor colorWithRed:124/255.0 green:129/255.0 blue:136/255.0 alpha:0.20].CGColor;
  77. _tableViewBgView.layer.shadowOffset = CGSizeMake(0,0);
  78. _tableViewBgView.layer.shadowRadius = 8;
  79. _tableViewBgView.layer.shadowOpacity = 1;
  80. _tableViewBgView.layer.cornerRadius = 10;
  81. [_tableViewBgView addSubview:self.simulationResultsSeectionHeaderView];
  82. }
  83. return _tableViewBgView;
  84. }
  85. @end