// // YMFeesSettingViewController.m // MSYOUPAI // // Created by YoMi on 2024/2/23. // Copyright © 2024 MS. All rights reserved. // #import "YMFeesSettingViewController.h" #import "YMFeesSettingViewModel.h" #import "YMFeesSettingCell.h" #import "YMFeesSettingNotesView.h" @interface YMFeesSettingViewController() /// 收费设置VM @property (nonatomic, strong) YMFeesSettingViewModel *viewModel; /// 说明视图 @property (nonatomic, strong) YMFeesSettingNotesView *notesView; /// 内容列表 @property (nonatomic, strong) UITableView *contentTableView; @end @implementation YMFeesSettingViewController @dynamic viewModel; - (void)viewDidLoad { [super viewDidLoad]; } - (void)ym_setupViews{ [self.view addSubview:self.contentTableView]; [self.view setNeedsUpdateConstraints]; [self.view updateConstraintsIfNeeded]; } - (void)updateViewConstraints{ [self.contentTableView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.view).offset(kYMNavHeight); make.left.equalTo(self.view); make.right.equalTo(self.view); make.bottom.equalTo(self.view); }]; [super updateViewConstraints]; } - (void)ym_bindViewModel{ [self.notesView ym_bindViewModel:self.viewModel]; __weak typeof(self) weakSelf = self; self.notesView.notesViewHeightBlock = ^(CGFloat notesViewHeight) { weakSelf.notesView.frame = CGRectMake(0, 0, kFrameWidth, notesViewHeight); weakSelf.contentTableView.tableFooterView = weakSelf.notesView; }; [self.viewModel getFeesSettingBaseInfoData]; [self.viewModel getFeesSettingPriceInfoData]; @weakify(self) [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) { @strongify(self) [self.contentTableView reloadData]; }]; } #pragma mark - UITableViewDataSource - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.viewModel.listDataArray.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ YMFeesSettingCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YMFeesSettingCell class])]; if (!cell) { cell = [[YMFeesSettingCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([YMFeesSettingCell class])]; } cell.selectionStyle = UITableViewCellSelectionStyleNone; [cell ym_bindViewModel:self.viewModel.listDataArray[indexPath.item]]; return cell; } #pragma mark - UITableViewDelegate - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return adapt(50); } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{ return nil; } - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { return CGFLOAT_MIN; } - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *sectionView = [[UIView alloc]init]; sectionView.backgroundColor = HexColorFromRGB(0xF6F6F6); return sectionView; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return adapt(6); } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.viewModel.feesSettingFunctionsOperationSubject sendNext:@(self.viewModel.listDataArray[indexPath.item].feesSettingFunctionsType)]; } - (YMFeesSettingNotesView *)notesView{ if (!_notesView) { _notesView = [[YMFeesSettingNotesView alloc]init]; } return _notesView; } - (UITableView *)contentTableView{ if (!_contentTableView) { _contentTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped]; _contentTableView.delegate = self; _contentTableView.dataSource = self; _contentTableView.estimatedRowHeight = 0; _contentTableView.estimatedSectionHeaderHeight = 0; _contentTableView.estimatedSectionFooterHeight = 0; _contentTableView.showsVerticalScrollIndicator = NO; _contentTableView.showsHorizontalScrollIndicator = NO; _contentTableView.separatorColor = UIColor.clearColor; _contentTableView.backgroundColor = UIColor.whiteColor; [_contentTableView registerClass:[YMFeesSettingCell class] forCellReuseIdentifier:NSStringFromClass([YMFeesSettingCell class])]; } return _contentTableView; } @end