RQExerciseSettingViewController.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // RQExerciseSettingViewController.m
  3. // JSJP
  4. //
  5. // Created by RONGQING on 2022/1/14.
  6. //
  7. #import "RQExerciseSettingViewController.h"
  8. @interface RQExerciseSettingViewController ()
  9. /// viewModel
  10. @property (nonatomic, readonly, strong) RQExerciseSettingViewModel *viewModel;
  11. @property (nonatomic, readwrite, strong) RQExerciseSettingHeaderView *exerciseSettingHeaderView;
  12. @end
  13. @implementation RQExerciseSettingViewController
  14. @dynamic viewModel;
  15. #pragma mark - SystemMethod
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. [self.view addSubview:self.exerciseSettingHeaderView];
  19. }
  20. - (void)viewDidLayoutSubviews {
  21. [super viewDidLayoutSubviews];
  22. self.exerciseSettingHeaderView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, 44.f);
  23. self.tableView.frame = CGRectMake(0, 44, RQ_SCREEN_WIDTH, 44 * 3);
  24. }
  25. - (void)viewDidAppear:(BOOL)animated {
  26. [super viewDidAppear:animated];
  27. [self hw_panModalSetNeedsLayoutUpdate];
  28. }
  29. #pragma mark - OverrideMethods
  30. /// 配置tableView的区域
  31. - (UIEdgeInsets)contentInset {
  32. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  33. }
  34. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  35. switch (indexPath.row) {
  36. case 1 : {
  37. return [RQExerciseSettingCell cellWithTableView:tableView];
  38. }
  39. default:
  40. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  41. }
  42. }
  43. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  44. switch (indexPath.row) {
  45. case 1 : {
  46. RQExerciseSettingCell *exerciseSettingCell = (RQExerciseSettingCell *)cell;
  47. [exerciseSettingCell bindViewModel:object];
  48. break;
  49. }
  50. default:
  51. [super configureCell:cell atIndexPath:indexPath withObject:object];
  52. break;
  53. }
  54. }
  55. #pragma mark - HWPanModalPresentable
  56. - (UIScrollView *)panScrollable {
  57. return self.tableView;
  58. }
  59. - (PanModalHeight)longFormHeight {
  60. return PanModalHeightMake(PanModalHeightTypeMaxTopInset, RQ_SCREEN_HEIGHT - RQ_APPLICATION_NAV_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - (44 * 4));
  61. }
  62. - (CGFloat)cornerRadius {
  63. return 0.0;
  64. }
  65. - (BOOL)allowsTapBackgroundToDismiss {
  66. return NO;
  67. }
  68. - (BOOL)showDragIndicator {
  69. return NO;
  70. }
  71. - (BOOL)allowsDragToDismiss {
  72. return NO;
  73. }
  74. - (BOOL)allowsPullDownWhenShortState {
  75. return NO;
  76. }
  77. #pragma mark - LazyLoad
  78. - (RQExerciseSettingHeaderView *)exerciseSettingHeaderView {
  79. if (!_exerciseSettingHeaderView) {
  80. @weakify(self)
  81. _exerciseSettingHeaderView = [RQExerciseSettingHeaderView exerciseSettingHeaderView];
  82. [_exerciseSettingHeaderView.completeBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  83. @strongify(self)
  84. [self dismissViewControllerAnimated:YES completion:^{
  85. }];
  86. }];
  87. [_exerciseSettingHeaderView.cancleBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  88. @strongify(self)
  89. [self dismissViewControllerAnimated:YES completion:^{
  90. }];
  91. }];
  92. }
  93. return _exerciseSettingHeaderView;
  94. }
  95. @end