RQSimulationTestTopicsViewController.m 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // RQSimulationTestTopicsViewController.m
  3. // SDJK
  4. //
  5. // Created by 张嵘 on 2021/8/6.
  6. //
  7. #import "RQSimulationTestTopicsViewController.h"
  8. @interface RQSimulationTestTopicsViewController ()
  9. // viewModel
  10. @property (nonatomic, readwrite, strong) RQSimulationTestTopicsViewModel *viewModel;
  11. @property (strong, readwrite, nonatomic) RQSimulationTestTopicsHeaderView *simulationTestTopicsHeaderView;
  12. @property (nonatomic, readwrite, strong) UIButton *backBtn;
  13. @end
  14. @implementation RQSimulationTestTopicsViewController
  15. @dynamic viewModel;
  16. #pragma mark - SystemMethod
  17. - (void)viewDidLoad {
  18. [super viewDidLoad];
  19. /// 初始化
  20. [self rq_setup];
  21. }
  22. - (void)viewDidLayoutSubviews {
  23. [super viewDidLayoutSubviews];
  24. self.simulationTestTopicsHeaderView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, RQSimulationTestTopicsViewHeight - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT);
  25. self.backBtn.frame = CGRectMake(0, - (RQSimulationTestTopicsViewHeight - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT - 82) + RQ_APPLICATION_STATUS_BAR_HEIGHT, 44, 44);
  26. }
  27. #pragma mark - PrivateMethods
  28. - (void)rq_setup {
  29. self.tableView.backgroundColor = UIColor.clearColor;
  30. [self.view addSubview:self.simulationTestTopicsHeaderView];
  31. [self.view sendSubviewToBack:self.simulationTestTopicsHeaderView];
  32. [self.tableView addSubview:self.backBtn];
  33. }
  34. #pragma mark - OverrideMethods
  35. /// 配置tableView的区域
  36. - (UIEdgeInsets)contentInset {
  37. return UIEdgeInsetsMake(RQSimulationTestTopicsViewHeight - 20 + RQ_APPLICATION_STATUS_BAR_HEIGHT - 82, 0, 0, 0);
  38. }
  39. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  40. RQSimulationTestTopicsCell *cell = [RQSimulationTestTopicsCell cellWithTableView:tableView];
  41. return cell;
  42. }
  43. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  44. RQSimulationTestTopicsCell *simulationTestTopicsCell = (RQSimulationTestTopicsCell *)cell;
  45. [simulationTestTopicsCell bindViewModel:object];
  46. }
  47. #pragma mark - LazyLoad
  48. - (RQSimulationTestTopicsHeaderView *)simulationTestTopicsHeaderView {
  49. if (!_simulationTestTopicsHeaderView) {
  50. _simulationTestTopicsHeaderView = [RQSimulationTestTopicsHeaderView simulationTestTopicsHeaderView];
  51. }
  52. return _simulationTestTopicsHeaderView;
  53. }
  54. - (UIButton *)backBtn {
  55. if (!_backBtn) {
  56. @weakify(self);
  57. _backBtn = [UIButton buttonWithType:UIButtonTypeSystem];
  58. [_backBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  59. @strongify(self);
  60. [self.viewModel.services popViewModelAnimated:YES];
  61. }];
  62. }
  63. return _backBtn;
  64. }
  65. @end