123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // 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()<UITableViewDataSource, UITableViewDelegate>
- /// 收费设置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
|