//
//  ChatNewRowCell.m
//  smartRhino
//
//  Created by niuzhen on 2019/12/10.
//  Copyright © 2019 tederen. All rights reserved.
//

#import "ChatNewRowCell.h"

@implementation ChatNewRowCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+ (CGFloat)configCell0Height{
    return 50;
}
+ (CGFloat)configCell1Height{
    return 65;
}
+ (CGFloat)configCell2Height{
    return 65;
}

+ (ChatNewRowCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell0";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:0];
    }
  
    cell.cell0SearchBgView.layer.masksToBounds = YES;
    cell.cell0SearchBgView.layer.cornerRadius = 15;
    cell.cell0SearchBgView.backgroundColor = RGB(245, 246, 248);
    
    return cell;
}
+ (ChatNewRowCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell1";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:1];
    }
  
    return cell;
}
+ (ChatNewRowCell *)configCell2:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell2";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:2];
    }
  
    cell.cell2TimeLabel.hidden = NO;
    return cell;
}
+ (ChatNewRowCell *)configCell5:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell5";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:7];
    }
  
    cell.cell2TimeLabel.hidden = NO;
    return cell;
}
+ (ChatNewRowCell *)configCell50:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell50";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:8];
    }
  
    cell.cell2TimeLabel.hidden = NO;
    return cell;
}
+ (ChatNewRowCell *)configCell10:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell10";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:3];
    }
  
    return cell;
}
+ (ChatNewRowCell *)configCell20:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell20";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:4];
    }
  
    
    cell.cell2TimeLabel.hidden = NO;
    return cell;
}
+ (ChatNewRowCell *)configCell30:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell30";
       ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
       if (cell == nil) {
           cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:5];
       }
     
       return cell;
}
+ (ChatNewRowCell *)configCell40:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
    static NSString *cellIdentifer = @"ChatNewRowCell40";
    ChatNewRowCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ChatNewRowCell" owner:nil options:nil] objectAtIndex:6];
    }
  
    return cell;
}

- (void)layoutSubviews
{
    [super layoutSubviews];

    CGRect rect = self.contentView.frame;
    rect.size.width += rect.origin.x;
    rect.origin.x = 0;
    self.contentView.frame = rect;
    for (UIView *supView in self.subviews){
        if ([supView isKindOfClass:NSClassFromString(@"UITableViewCellReorderControl")]){
            for (UIView *view in supView.subviews)
            {
                if ([view isKindOfClass: [UIImageView class]])
                {
                    view.hidden = !self.isSort;
                    UIImageView * imagV = (UIImageView *)view;
                    [imagV setFrame:CGRectMake(0, 0, 32, 20)];
                    imagV.center = supView.center;
                    imagV.contentMode = UIViewContentModeCenter;
                    imagV.image = [UIImage imageNamed: @"list_sort"];
                    UIView * label = [UIView new];
                    label.backgroundColor = UIColorHex(0xEEEEEE);
                    [supView addSubview:label];
                    [label setFrame:CGRectMake(0, supView.frame.size.height - 0.5, supView.frame.size.width, 0.5)];
                }else{
                    view.hidden = YES;
                }
            }
        }
        if ([supView isKindOfClass:NSClassFromString(@"UITableViewCellEditControl")]){
            [supView removeFromSuperview];
        }
    }
}
@end