YMFeesSettingViewController.m 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. //
  2. // YMFeesSettingViewController.m
  3. // MSYOUPAI
  4. //
  5. // Created by YoMi on 2024/2/23.
  6. // Copyright © 2024 MS. All rights reserved.
  7. //
  8. #import "YMFeesSettingViewController.h"
  9. #import "YMFeesSettingViewModel.h"
  10. #import "YMFeesSettingCell.h"
  11. #import "YMFeesSettingNotesView.h"
  12. @interface YMFeesSettingViewController()<UITableViewDataSource, UITableViewDelegate>
  13. /// 收费设置VM
  14. @property (nonatomic, strong) YMFeesSettingViewModel *viewModel;
  15. /// 说明视图
  16. @property (nonatomic, strong) YMFeesSettingNotesView *notesView;
  17. /// 内容列表
  18. @property (nonatomic, strong) UITableView *contentTableView;
  19. @end
  20. @implementation YMFeesSettingViewController
  21. @dynamic viewModel;
  22. - (void)viewDidLoad {
  23. [super viewDidLoad];
  24. }
  25. - (void)ym_setupViews{
  26. [self.view addSubview:self.contentTableView];
  27. [self.view setNeedsUpdateConstraints];
  28. [self.view updateConstraintsIfNeeded];
  29. }
  30. - (void)updateViewConstraints{
  31. [self.contentTableView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.equalTo(self.view).offset(kYMNavHeight);
  33. make.left.equalTo(self.view);
  34. make.right.equalTo(self.view);
  35. make.bottom.equalTo(self.view);
  36. }];
  37. [super updateViewConstraints];
  38. }
  39. - (void)ym_bindViewModel{
  40. [self.notesView ym_bindViewModel:self.viewModel];
  41. __weak typeof(self) weakSelf = self;
  42. self.notesView.notesViewHeightBlock = ^(CGFloat notesViewHeight) {
  43. weakSelf.notesView.frame = CGRectMake(0, 0, kFrameWidth, notesViewHeight);
  44. weakSelf.contentTableView.tableFooterView = weakSelf.notesView;
  45. };
  46. [self.viewModel getFeesSettingBaseInfoData];
  47. [self.viewModel getFeesSettingPriceInfoData];
  48. @weakify(self)
  49. [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
  50. @strongify(self)
  51. [self.contentTableView reloadData];
  52. }];
  53. }
  54. #pragma mark - UITableViewDataSource
  55. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
  56. return 1;
  57. }
  58. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  59. return self.viewModel.listDataArray.count;
  60. }
  61. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  62. YMFeesSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YMFeesSettingCell class])];
  63. if (!cell) {
  64. cell = [[YMFeesSettingCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([YMFeesSettingCell class])];
  65. }
  66. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  67. [cell ym_bindViewModel:self.viewModel.listDataArray[indexPath.item]];
  68. return cell;
  69. }
  70. #pragma mark - UITableViewDelegate
  71. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
  72. return adapt(50);
  73. }
  74. - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
  75. return nil;
  76. }
  77. - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
  78. return CGFLOAT_MIN;
  79. }
  80. - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
  81. UIView *sectionView = [[UIView alloc]init];
  82. sectionView.backgroundColor = HexColorFromRGB(0xF6F6F6);
  83. return sectionView;
  84. }
  85. - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
  86. return adapt(6);
  87. }
  88. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  89. [self.viewModel.feesSettingFunctionsOperationSubject sendNext:@(self.viewModel.listDataArray[indexPath.item].feesSettingFunctionsType)];
  90. }
  91. - (YMFeesSettingNotesView *)notesView{
  92. if (!_notesView) {
  93. _notesView = [[YMFeesSettingNotesView alloc]init];
  94. }
  95. return _notesView;
  96. }
  97. - (UITableView *)contentTableView{
  98. if (!_contentTableView) {
  99. _contentTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
  100. _contentTableView.delegate = self;
  101. _contentTableView.dataSource = self;
  102. _contentTableView.estimatedRowHeight = 0;
  103. _contentTableView.estimatedSectionHeaderHeight = 0;
  104. _contentTableView.estimatedSectionFooterHeight = 0;
  105. _contentTableView.showsVerticalScrollIndicator = NO;
  106. _contentTableView.showsHorizontalScrollIndicator = NO;
  107. _contentTableView.separatorColor = UIColor.clearColor;
  108. _contentTableView.backgroundColor = UIColor.whiteColor;
  109. [_contentTableView registerClass:[YMFeesSettingCell class] forCellReuseIdentifier:NSStringFromClass([YMFeesSettingCell class])];
  110. }
  111. return _contentTableView;
  112. }
  113. @end