123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- //
- // YMSearchUserViewController.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/17.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMSearchUserViewController.h"
- #import "YMSearchUserViewModel.h"
- #import "YMSearchUserSearchInputBoxView.h"
- #import "YMSearchUserCell.h"
- @interface YMSearchUserViewController()<UITableViewDataSource, UITableViewDelegate>
- /// 搜索用户VM
- @property (nonatomic, strong) YMSearchUserViewModel *viewModel;
- /// 搜索输入框视图
- @property (nonatomic, strong) YMSearchUserSearchInputBoxView *searchInputBoxView;
- /// 内容列表
- @property (nonatomic, strong) UITableView *contentTableView;
- @end
- @implementation YMSearchUserViewController
- @dynamic viewModel;
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self setNavHidden:YES];
-
- }
- - (void)ym_setupViews{
- [self.view addSubview:self.searchInputBoxView];
- [self.view addSubview:self.contentTableView];
- [self.view setNeedsUpdateConstraints];
- [self.view updateConstraintsIfNeeded];
- }
- - (void)updateViewConstraints{
-
- [self.searchInputBoxView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.view);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- }];
-
- [self.contentTableView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.searchInputBoxView.mas_bottom);
- make.left.equalTo(self.view);
- make.right.equalTo(self.view);
- make.bottom.equalTo(self.view);
- }];
-
- [super updateViewConstraints];
- }
- - (void)ym_bindViewModel{
-
- [self.searchInputBoxView ym_bindViewModel:self.viewModel];
-
- @weakify(self)
- [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
- @strongify(self)
- [self.contentTableView reloadData];
- [self.contentTableView ym_endLoading];
- }];
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
- return self.viewModel.listDataArray.count;
- }
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
-
- YMSearchUserCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([YMSearchUserCell class])];
- if (!cell) {
- cell = [[YMSearchUserCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:NSStringFromClass([YMSearchUserCell class])];
- }
- cell.selectionStyle = UITableViewCellSelectionStyleNone;
- [cell ym_bindViewModel:self.viewModel.listDataArray[indexPath.item]];
- return cell;
- }
- - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
- return adapt(85);
- }
- - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
- if (self.viewModel.listDataArray[indexPath.item].userId != 0) {
- [self.viewModel.gotoPersonalPageSubject sendNext:@(self.viewModel.listDataArray[indexPath.item].userId)];
- }
-
- }
- - (YMSearchUserSearchInputBoxView *)searchInputBoxView{
- if (!_searchInputBoxView) {
- _searchInputBoxView = [[YMSearchUserSearchInputBoxView alloc]init];
- }
- return _searchInputBoxView;
- }
- - (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:[YMSearchUserCell class] forCellReuseIdentifier:NSStringFromClass([YMSearchUserCell class])];
- YMEmptyView *empty = [YMEmptyView emptyViewWithImageStr:@"ym_common_no_data_icon" titleStr:@"暂无数据" detailStr:@""];
- empty.imageSize = kEmptyViewSize;
- _contentTableView.ym_emptyView = empty;
- _contentTableView.ym_emptyView.autoShowEmptyView = YES;
- }
- return _contentTableView;
- }
- @end
|