MTAddFriendViewController.m 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // MTAddFriendViewController.m
  3. //
  4. // Created by Simon on 2019/3/22.
  5. // Copyright © 2019 Simon. All rights reserved.
  6. //
  7. #import "MTAddFriendViewController.h"
  8. #import "MTAddFriendNoView.h"
  9. #import "MTMsgSearchTableViewCell.h"
  10. #import "MTAddFriendHeaderView.h"
  11. #import "MTSearchNavView.h"
  12. #import "MTFriendInfoViewController.h"
  13. @interface MTAddFriendViewController ()<UITableViewDelegate,UITableViewDataSource>
  14. @property (strong, nonatomic) MTBaseTableView *tableView;
  15. @property (nonatomic, strong) MTAddFriendViewModel *viewModel;
  16. @property (nonatomic, strong) MTAddFriendHeaderView *headerView;
  17. @property (nonatomic, strong) MTAddFriendNoView *noView;
  18. @property (nonatomic, strong) MTSearchNavView *navView;
  19. @end
  20. @implementation MTAddFriendViewController
  21. #pragma mark -- system
  22. -(void)viewWillAppear:(BOOL)animated{
  23. [super viewWillAppear:animated];
  24. }
  25. - (void)viewDidLoad {
  26. [super viewDidLoad];
  27. self.view.backgroundColor = HColor(@"#F0F0F0");
  28. [self.view addSubview:self.tableView];
  29. [self.navgationView removeFromSuperview];
  30. self.navView = [[MTSearchNavView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, navHeight)];
  31. [self.view addSubview:self.navView];
  32. [self.navView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.left.right.top.mas_equalTo(self.view);
  34. make.height.mas_equalTo(navHeight);
  35. }];
  36. self.noView = [[MTAddFriendNoView alloc]initWithFrame:CGRectMake(0, navHeight, ScreenWidth, ScreenHeight-navHeight)];
  37. self.noView.hidden = NO;
  38. [self.view addSubview:self.noView];
  39. [self.noView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.mas_equalTo(navHeight);
  41. make.left.right.bottom.mas_equalTo(self.view);
  42. }];
  43. }
  44. -(void)mt_layoutNavigation{
  45. [self.navgationView removeFromSuperview];
  46. }
  47. - (void)mt_bindViewModel{
  48. // @weakify(self)
  49. [self.viewModel.refreshUISubject subscribeNext:^(id _Nullable x) {
  50. // @strongify(self)
  51. [self.tableView.mj_header endRefreshing];
  52. }];
  53. [self.viewModel.errorSubject subscribeNext:^(id _Nullable x) {
  54. // @strongify(self)
  55. }];
  56. }
  57. #pragma mark -- lazy
  58. -(MTAddFriendViewModel *)viewModel{
  59. if (!_viewModel) {
  60. _viewModel = [[MTAddFriendViewModel alloc]init];
  61. _viewModel.pageIndex = 1;
  62. }
  63. return _viewModel;
  64. }
  65. -(MTAddFriendHeaderView *)headerView{
  66. if (!_headerView) {
  67. _headerView = [[MTAddFriendHeaderView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, kNumFrom375(85))];
  68. _headerView.viewModel = self.viewModel;
  69. }
  70. return _headerView;
  71. }
  72. - (MTBaseTableView *)tableView {
  73. if (!_tableView) {
  74. _tableView = [[MTBaseTableView alloc]initWithFrame:CGRectMake(0, navHeight, ScreenWidth, ScreenHeight - navHeight) style:UITableViewStylePlain];
  75. _tableView.delegate = self;
  76. _tableView.dataSource = self;
  77. _tableView.tableHeaderView.userInteractionEnabled = YES;
  78. _tableView.tableHeaderView = self.headerView;
  79. _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  80. // [_tableView registerClass:[MTAddFriendTableViewCell class] forCellReuseIdentifier:@"MTAddFriendTableViewCellID"];
  81. _tableView.showsVerticalScrollIndicator = NO;
  82. _tableView.backgroundColor = [UIColor clearColor];
  83. // _tableView.estimatedRowHeight = 160;
  84. // _tableView.rowHeight = UITableViewAutomaticDimension;
  85. }
  86. return _tableView;
  87. }
  88. #pragma mark -- Constraints
  89. -(void)updateViewConstraints{
  90. [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.mas_equalTo(navHeight);
  92. make.left.right.bottom.equalTo(self.view);
  93. }];
  94. [super updateViewConstraints];
  95. }
  96. #pragma mark - UITableViewDataSource & UITableViewDelegate
  97. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  98. return 10;
  99. }
  100. - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
  101. return kNumFrom375(54);
  102. }
  103. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  104. // MTAddFriendTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MTAddFriendTableViewCellID" forIndexPath:indexPath];
  105. //
  106. // // cell.model = self.viewModel.orderDetail.kuaidi_list[indexPath.row];
  107. // return cell;
  108. static NSString *cellID = @"MTMsgSearchTableViewCell";
  109. MTMsgSearchTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  110. if (!cell)
  111. {
  112. [tableView registerNib:[UINib nibWithNibName:cellID bundle:nil] forCellReuseIdentifier:cellID];
  113. cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  114. }
  115. cell.selectionStyle=UITableViewCellSelectionStyleNone;
  116. // [cell layoutIfNeeded];
  117. // cell.model = self.viewModel.listArray[indexPath.row];
  118. return cell;
  119. }
  120. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
  121. MTFriendInfoViewController *vc = [[MTFriendInfoViewController alloc]init];
  122. [CURRENT_NAV pushViewController:vc animated:YES];
  123. }
  124. @end