//
//  RDSHomeInfoCell.m
//  Temperature
//
//  Created by RD on 2023/2/2.
//

#import "RDSHomeInfoCell.h"
#import "UIImageView+webImage.h"

@interface RDSHomeInfoCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imgView;
@property (weak, nonatomic) IBOutlet UIImageView *removeImgView;

@end
@implementation RDSHomeInfoCell

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

- (void)setIsAddBtn:(BOOL)isAddBtn{
    _isAddBtn = isAddBtn;
    
    NSString *imgName = isAddBtn ? @"icon_add_3":@"icon_default_user_1";
    UIImage *img = [UIImage imageNamed:imgName];
    _imgView.image = img;
    
    if(_isAddBtn) _removeImgView.hidden = YES;
}

- (void)setIsEditing:(BOOL)isEditing{
    _isEditing = isEditing;
    
    _removeImgView.hidden = !isEditing;
    
    if(_isAddBtn || _isFirstCell) _removeImgView.hidden = YES;
}

// 加载用户头像
- (void)setPhoto:(NSString *)photo{
    _photo = photo;
    
    NSString *url = [NSString stringWithFormat:@"%@%@",TheApiHelper.baseUrlHeadImg,photo];
    
    RDS_WEAKSELF(weakSelf)
    [_imgView rds_downloadImage:url placeHoler:[UIImage imageNamed:@"icon_default_user_1"] success:^(SDImageCacheType cacheType, UIImage *image) {
        [weakSelf.imgView setImage:image];
    } failure:^(NSError *error) {
        //weakSelf.headImg = [UIImage imageNamed:@"icon_default_user_1"];
        DDLog(@"error %@",error.description);
    } received:^(CGFloat progress) {
        
    }];
}
@end
