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

#import "ICContactsRepeatCell.h"
#import "UIColor+HExtension.h"
#import "ICContactListModel.h"

@implementation ICContactsRepeatCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.contactView.layer.borderColor = [UIColor colorWithHexString:@"#dddddd"].CGColor;
}

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

    // Configure the view for the selected state
}

-(void)setModel:(ICContactListModel *)model
{
    _model = model;
    self.nameLabel.text = [NSString stringWithFormat:@"%@%@", model.contact.familyName, model.contact.givenName];
    if (model.contact.phoneNumbers.count) {
        NSArray *phones = model.contact.phoneNumbers;
        CNLabeledValue *labeledValue = phones[0];
        CNPhoneNumber *phoneNumer = labeledValue.value;
        NSString *phoneNumber = phoneNumer.stringValue;
        self.phoneLabel.text = [NSString stringWithFormat:@"%@", phoneNumber];
    }else{
        self.phoneLabel.text = @"";
    }
    self.chooseButton.selected = model.choose;
    if (model.choose) {
        [self.chooseButton setImage:[UIImage imageNamed:@"contact_choosed"] forState:UIControlStateNormal];
    }else{
        [self.chooseButton setImage:[UIImage imageNamed:@"contact_choose"] forState:UIControlStateNormal];
    }
}


@end
