//
//  ICContactsListCell.m
//  superCleaner
//
//  Created by GY.Z on 2020/7/4.
//  Copyright © 2020 Mazy. All rights reserved.
//

#import "ICContactsListCell.h"
#import "ICContactListModel.h"

@interface ICContactsListCell ()

@end


@implementation ICContactsListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.chooseBtn.hidden = YES;
}

-(void)setModel:(ICContactListModel *)model
{
    _model = model;
    self.nameL.text = [NSString stringWithFormat:@"%@%@",model.contact.familyName,model.contact.givenName];
   if (model.contact.imageData != nil) {
       self.imageV.image = [UIImage imageWithData:[NSData dataWithData:model.contact.imageData]];
       self.iconLabel.text = @"";
   }else{
       self.imageV.image = [UIImage new];
       if (model.contact.familyName.length) {
           self.iconLabel.text = [model.contact.familyName substringToIndex:1];
       }else if (model.contact.givenName.length){
           self.iconLabel.text = [model.contact.givenName substringToIndex:1];
       }
   }
   self.chooseBtn.hidden = model.choose;
    
   if (model.choose) {
       [self.chooseBtn setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
   }else{
       [self.chooseBtn setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
   }
}

-(void)setChooseCount:(NSInteger)chooseCount
{
    _chooseCount = chooseCount;
    if (chooseCount >= 1) {
        self.imageLeftMargin.constant = 48;
        self.chooseBtn.hidden = NO;
    }else{
        self.imageLeftMargin.constant = 16;
        self.chooseBtn.hidden = YES;
    }
}

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

    // Configure the view for the selected state
}

@end
