123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- //
- // YMAboutUsViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/2/21.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMAboutUsViewController.h"
- #import "YMAboutUsViewModel.h"
- #import "YMAboutUsInfoView.h"
- #import "YMAboutUsCell.h"
- @interface YMAboutUsViewController()<UITableViewDataSource, UITableViewDelegate>
- /// 关于我们VM
- @property (nonatomic, strong) YMAboutUsViewModel *viewModel;
- /// 信息视图
- @property (nonatomic, strong) YMAboutUsInfoView *infoView;
- /// 内容列表
- @property (nonatomic, strong) UITableView *contentTableView;
- @end
- @implementation YMAboutUsViewController
- @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.infoView ym_bindViewModel:self.viewModel];
-
- [self.viewModel getAboutUsListData];
-
- @weakify(self)
- [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
- @strongify(self)
- [self.contentTableView reloadData];
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.viewModel.listDataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- YMAboutUsCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YMAboutUsCell class])];
- if (!cell) {
- cell = [[YMAboutUsCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([YMAboutUsCell class])];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell ym_bindViewModel:self.viewModel.listDataArray[indexPath.item]];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return adapt(50);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- [self.viewModel.aboutUsFunctionsOperationSubject sendNext:@(self.viewModel.listDataArray[indexPath.item].aboutUsFunctionsType)];
- }
- - (YMAboutUsInfoView *)infoView{
- if (!_infoView) {
- _infoView = [[YMAboutUsInfoView alloc]initWithFrame:CGRectMake(0, 0, kFrameWidth, adapt(300))];
- }
- return _infoView;
- }
- - (UITableView *)contentTableView{
- if (!_contentTableView) {
- _contentTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStylePlain];
- _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:[YMAboutUsCell class] forCellReuseIdentifier:NSStringFromClass([YMAboutUsCell class])];
- _contentTableView.tableHeaderView = self.infoView;
- }
- return _contentTableView;
- }
- @end
|