// // ReplayMeLikeVC.m // smartRhino // // Created by niuzhen on 2020/6/11. // Copyright © 2020 tederen. All rights reserved. // #import "ReplayMeLikeVC.h" #import "MyTDGroupView.h" #import "ReplayMeCell.h" #import "ReplayLikeSearchVC.h" @interface ReplayMeLikeVC () @property (weak, nonatomic) IBOutlet UIView *navBar; @property (weak, nonatomic) IBOutlet UIView *HeadView; @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (weak, nonatomic) IBOutlet UILabel *titleL; @property (strong, nonatomic) MyTDGroupView *SearchView; @property (strong, nonatomic) NSMutableArray *dataArray; @end @implementation ReplayMeLikeVC +(ReplayMeLikeVC *)initReplayMeLikeVC{ ReplayMeLikeVC *controller = [StoryboardManager.shared.Source instantiateViewControllerWithIdentifier:@"ReplayMeLikeVC"]; return controller; } -(NSMutableArray *)dataArray{ if(!_dataArray){ _dataArray = [NSMutableArray array]; } return _dataArray; } - (MyTDGroupView *)SearchView { if (!_SearchView) { _SearchView = [[MyTDGroupView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 36)]; } return _SearchView; } - (void)viewDidLoad { [super viewDidLoad]; self.fd_prefersNavigationBarHidden = YES; self.tableView.delegate = self; self.tableView.dataSource = self; [self.HeadView addSubview:self.SearchView]; [self.SearchView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_offset(6); make.left.right.mas_equalTo(self.HeadView); make.height.mas_offset(36); }]; self.titleL.text = @"共收到赞"; WS(weakSelf); [self.SearchView.button setAction:^{ ReplayLikeSearchVC * vc = [[ReplayLikeSearchVC alloc] init]; [weakSelf.navigationController pushViewController:vc animated:YES]; }]; [self getData]; } - (void)getData { [self.dataArray removeAllObjects]; NSDictionary * paraDict = @{@"KeyWord":@"", @"TypeValue":@(0), }; WS(weakSelf); SHOWLOADING [[HttpManager sharedHttpManager] POSTUrl:Host(API_APP_Reply_Praise) parameters:paraDict responseStyle:JOSN success:^(id _Nonnull responseObject) { REMOVESHOW if ([responseObject isKindOfClass:[NSArray class]]) { for (NSDictionary * dict in responseObject) { ReplyModel * model = [ReplyModel modelWithDictionary:dict]; [weakSelf.dataArray addObject:model]; } } dispatch_async(dispatch_get_main_queue(), ^{ if (weakSelf.dataArray.count > 0) { weakSelf.titleL.text = [NSString stringWithFormat:@"共收到赞(%ld)",weakSelf.dataArray.count]; }else{ weakSelf.titleL.text = @"共收到赞"; } [weakSelf.tableView reloadData]; }); } failure:^(NSError * _Nonnull error) { REMOVESHOW }]; } #pragma mark -UITableViewDelegate - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.dataArray.count; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewAutomaticDimension; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ReplyModel * model = [self.dataArray objectAtIndex:indexPath.row]; if (model.IsComment) { ReplayMeCell * cell = [ReplayMeCell configCell0:tableView indexPath:indexPath]; cell.redV.hidden = model.IsRead; [cell setDataCommentModel:model]; return cell; }else{ ReplayMeCell * cell = [ReplayMeCell configCell1:tableView indexPath:indexPath]; cell.redV.hidden = model.IsRead; [cell setDataModel:model]; return cell; } } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; ReplyModel * model = [self.dataArray objectAtIndex:indexPath.row]; model.IsRead = YES; dispatch_async(dispatch_get_main_queue(), ^{ [tableView reloadRowAtIndexPath:indexPath withRowAnimation:UITableViewRowAnimationAutomatic]; }); MyTDTopicDetailVC * vc = [MyTDTopicDetailVC initMyTDTopicDetailVC]; vc.type = model.TypeValue; vc.Id = model.SourceId; [self.navigationController pushViewController:vc animated:YES]; } @end