//
//  FriendsListCell.m
//  Unity-iPhone
//
//  Created by duowan123 on 2022/9/2.
//

#import "FriendsListCell.h"

#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCALEoefficient(num)   (SCREEN_WIDTH/667.0)*(num)

@interface FriendsListCell ()<UIGestureRecognizerDelegate>
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *titleStr;
@property (weak, nonatomic) IBOutlet UILabel *statusLabel;

@end

@implementation FriendsListCell

- (void)awakeFromNib{
    
    [super awakeFromNib];
    
    self.covierView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    self.covierView.layer.shadowColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.16].CGColor;
    self.covierView.layer.shadowOffset = CGSizeMake(0,3);
    self.covierView.layer.shadowRadius = 6;
    self.covierView.layer.shadowOpacity = 1;
    self.covierView.layer.cornerRadius = 10;
    
    self.imageView.layer.masksToBounds = YES;
    self.imageView.layer.cornerRadius = 50;
    
    self.titleStr.font = [UIFont systemFontOfSize: SCALEoefficient(20)];
    
    self.statusLabel.font = [UIFont systemFontOfSize: SCALEoefficient(15)];

    
    //cell添加点击事件
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myTableViewClick:)];
    [self.contentView addGestureRecognizer:tapGesture];
    
    
}

#pragma mark - 点击事件
- (void)myTableViewClick:(UIGestureRecognizer *)gestureRecognizer{
    if (self.tapGestureBlock){
        self.tapGestureBlock(self.model.numberId);
    }
}

/**
 加载数据
 @param model ShoesPeripheralMolde
 */
-(void)setCarouselCellModel:(UserFriendsModel *)model{
    
    if (self.model!=model){
        self.model = model;
    }
    NSLog(@"model.nickname = %@",model.nickname);
    if (model.nickname!=nil){
        self.titleStr.text = model.nickname;
        self.imageView.image= [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:model.avatar]]];
    }
    
    if ([model.status isEqualToString:@"1"]){
        self.stateLable.text = @"·在线";
        self.stateLable.textColor = [UIColor greenColor];
    }else{
        self.stateLable.text = @"·离线";
        self.stateLable.textColor = [UIColor grayColor];
    }
    
}

//更新状态
-(void)setCusSelected:(BOOL)cusSelected{
   
    if (cusSelected == YES){
        
        NSLog(@"cusSelected %ld ",(long)self.model.trans_id);

        self.covierView.layer.masksToBounds = YES;
        self.covierView.layer.borderColor = [UIColor colorWithRed:255/255.0 green:196/255.0 blue:0/255.0 alpha:1.0].CGColor;
        self.covierView.layer.borderWidth = 3;
        self.covierView.backgroundColor = [UIColor colorWithRed:255/255.0 green:245/255.0 blue:210/255.0 alpha:1.0];
        self.covierView.layer.cornerRadius = 15;

    }else{
        
        self.covierView.layer.masksToBounds = YES;
        self.covierView.layer.borderColor = [UIColor whiteColor].CGColor;
        self.covierView.layer.borderWidth = 3;
        self.covierView.backgroundColor = [UIColor whiteColor];
        self.covierView.layer.cornerRadius = 15;
             
    }
    
}

@end

