diff --git a/Monkey/Classes/Module/DiscoveryModule/SearchModule/TableViewProtocol/SearchDataSource.m b/Monkey/Classes/Module/DiscoveryModule/SearchModule/TableViewProtocol/SearchDataSource.m index b3fe6a9..79f5462 100644 --- a/Monkey/Classes/Module/DiscoveryModule/SearchModule/TableViewProtocol/SearchDataSource.m +++ b/Monkey/Classes/Module/DiscoveryModule/SearchModule/TableViewProtocol/SearchDataSource.m @@ -8,6 +8,8 @@ // #import "SearchDataSource.h" +#import "RankTableViewCell.h" +#import "RepositoriesTableViewCell.h" @implementation SearchDataSource @@ -23,37 +25,40 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { - UITableViewCell *cell; if (tableView.tag==11) { + RankTableViewCell *cell; NSString *cellId=@"CellId1"; cell=[tableView dequeueReusableCellWithIdentifier:cellId]; if (cell==nil) { - cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; + cell=[[RankTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } UserModel *model = [(self.DsOfPageListObject1.dsArray) objectAtIndex:indexPath.row]; - cell.textLabel.text=model.login; - [cell.imageView sd_setImageWithURL:[NSURL URLWithString:model.avatar_url]]; - cell.imageView.layer.masksToBounds=YES; - cell.imageView.layer.cornerRadius=8; + cell.mainLabel.text=model.login; + [cell.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.avatar_url]]; return cell; }else if (tableView.tag==12){ - + RepositoriesTableViewCell *cell; + NSString *cellId=@"CellId2"; cell=[tableView dequeueReusableCellWithIdentifier:cellId]; if (cell==nil) { - cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId]; + cell=[[RepositoriesTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellId]; cell.selectionStyle=UITableViewCellSelectionStyleNone; } RepositoryModel *model = [(self.DsOfPageListObject2.dsArray) objectAtIndex:indexPath.row]; - cell.textLabel.text=[NSString stringWithFormat:@"%@",model.full_name]; - cell.detailTextLabel.text=[NSString stringWithFormat:@"%@ %@",model.language,model.repositoryDescription]; - cell.detailTextLabel.textColor=YiTextGray; + cell.repositoryLabel.text=[NSString stringWithFormat:@"%@",model.name]; + cell.userLabel.text=[NSString stringWithFormat:@"Owner:%@",model.user.login]; + [cell.titleImageView sd_setImageWithURL:[NSURL URLWithString:model.user.avatar_url]]; + cell.descriptionLabel.text=[NSString stringWithFormat:@"%@",model.repositoryDescription]; + [cell.homePageBt setTitle:model.homepage forState:UIControlStateNormal]; + cell.starLabel.text=[NSString stringWithFormat:@"Star:%d",model.stargazers_count]; + cell.forkLabel.text=[NSString stringWithFormat:@"Fork:%d",model.forks_count]; return cell; } - return cell; + return nil; } diff --git a/Monkey/Classes/Module/DiscoveryModule/SearchModule/ViewControllers/SearchViewController.m b/Monkey/Classes/Module/DiscoveryModule/SearchModule/ViewControllers/SearchViewController.m index 3e60a67..1e74352 100644 --- a/Monkey/Classes/Module/DiscoveryModule/SearchModule/ViewControllers/SearchViewController.m +++ b/Monkey/Classes/Module/DiscoveryModule/SearchModule/ViewControllers/SearchViewController.m @@ -103,7 +103,7 @@ - (void)viewDidLoad [self segmentAction:buttonTag]; }; self.navigationItem.hidesBackButton =YES; - mySearchBar=[[UISearchBar alloc] initWithFrame:CGRectMake(10, 2, ScreenWidth-80, 40)]; + mySearchBar=[[UISearchBar alloc] initWithFrame:CGRectMake(10, 2, ScreenWidth-90, 40)]; [self.navigationController.navigationBar addSubview:mySearchBar]; mySearchBar.delegate=self; mySearchBar.tintColor=YiBlue; @@ -229,6 +229,13 @@ - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar } #pragma mark - UITableViewDataSource &UITableViewDelegate +- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath +{ + if (tableView.tag==11) { + return RankTableViewCellHeight; + } + return RepositoriesTableViewCellheight; +} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {