RQExerciseSettingViewController.m 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. - (void)dealloc {
  16. RQ_Exercise_Module.isShow_CatalogueView = NO;
  17. }
  18. #pragma mark - SystemMethod
  19. - (void)viewDidLoad {
  20. [super viewDidLoad];
  21. [self.view addSubview:self.exerciseSettingHeaderView];
  22. }
  23. - (void)viewDidLayoutSubviews {
  24. [super viewDidLayoutSubviews];
  25. self.exerciseSettingHeaderView.frame = CGRectMake(0, 0, RQ_SCREEN_WIDTH, 44.f);
  26. self.tableView.frame = CGRectMake(0, 44, RQ_SCREEN_WIDTH, 44 * 4);
  27. }
  28. - (void)viewDidAppear:(BOOL)animated {
  29. [super viewDidAppear:animated];
  30. [self hw_panModalSetNeedsLayoutUpdate];
  31. }
  32. #pragma mark - OverrideMethods
  33. /// 配置tableView的区域
  34. - (UIEdgeInsets)contentInset {
  35. return UIEdgeInsetsMake(0, 0, RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT, 0);
  36. }
  37. - (UITableViewCell *)tableView:(UITableView *)tableView dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath {
  38. switch (indexPath.row) {
  39. case 1 : {
  40. return [RQExerciseSettingCell cellWithTableView:tableView];
  41. }
  42. default:
  43. return [super tableView:tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
  44. }
  45. }
  46. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  47. if(indexPath.row==2){
  48. //删除
  49. if(self.viewModel.homeSubPageType == RQHomeSubPageType_SequentialPractice){
  50. [NYTools delExerciseListUserKey:RQ_USER_MANAGER.currentUser.outId carType:RQ_YDTQuestion_Module.carType subject:RQ_YDTQuestion_Module.subject exerciseType:RQ_Exercise_Module.currentExerciseType];
  51. [self dismissViewControllerAnimated:YES completion:^{
  52. //跳出当前页
  53. [RQControllerHelper.currentViewController.navigationController popViewControllerAnimated:YES];
  54. }];
  55. }
  56. }
  57. }
  58. - (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath withObject:(id)object {
  59. switch (indexPath.row) {
  60. case 1 : {
  61. RQExerciseSettingCell *exerciseSettingCell = (RQExerciseSettingCell *)cell;
  62. [exerciseSettingCell bindViewModel:object];
  63. break;
  64. }
  65. default:
  66. [super configureCell:cell atIndexPath:indexPath withObject:object];
  67. break;
  68. }
  69. }
  70. #pragma mark - HWPanModalPresentable
  71. - (UIScrollView *)panScrollable {
  72. return self.tableView;
  73. }
  74. - (PanModalHeight)longFormHeight {
  75. return PanModalHeightMake(PanModalHeightTypeMaxTopInset, RQ_SCREEN_HEIGHT - RQ_APPLICATION_NAV_BAR_HEIGHT - RQ_APPLICATION_SAFEAREA_BOTTOM_HEIGHT - (44 * 5));
  76. }
  77. - (CGFloat)cornerRadius {
  78. return 0.0;
  79. }
  80. - (BOOL)allowsTapBackgroundToDismiss {
  81. return NO;
  82. }
  83. - (BOOL)showDragIndicator {
  84. return NO;
  85. }
  86. - (BOOL)allowsDragToDismiss {
  87. return NO;
  88. }
  89. - (BOOL)allowsPullDownWhenShortState {
  90. return NO;
  91. }
  92. #pragma mark - LazyLoad
  93. - (RQExerciseSettingHeaderView *)exerciseSettingHeaderView {
  94. if (!_exerciseSettingHeaderView) {
  95. @weakify(self)
  96. _exerciseSettingHeaderView = [RQExerciseSettingHeaderView exerciseSettingHeaderView];
  97. [_exerciseSettingHeaderView.completeBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  98. @strongify(self)
  99. [self dismissViewControllerAnimated:YES completion:^{
  100. }];
  101. }];
  102. [_exerciseSettingHeaderView.cancleBtn setTapActionWithBlock:^(UITapGestureRecognizer *tap) {
  103. @strongify(self)
  104. [self dismissViewControllerAnimated:YES completion:^{
  105. }];
  106. }];
  107. }
  108. return _exerciseSettingHeaderView;
  109. }
  110. @end