//
//  RDSDeviceTypeCell.m
//  Temperature
//
//  Created by 姓二名哈字富贵儿 on 2023/8/24.
//

#import "RDSDeviceTypeCell.h"

@interface RDSDeviceTypeCell ()

@property (nonatomic, strong) UIImageView *deviceTypeView;
@property (nonatomic, strong) NSDictionary *codeToNameDic;

@end

@implementation RDSDeviceTypeCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor colorWithHexString:@"#FBFBFB"];
        self.deviceTypeView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.deviceTypeView];
        [self.deviceTypeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.mas_equalTo(UIEdgeInsetsMake(0, 20, 0, 20));
            make.height.equalTo(self.deviceTypeView.mas_width).multipliedBy(0.328);
        }];
    }
    return self;
}

- (void)setDeviceTypeModel:(RDSDeviceTypeModel *)deviceTypeModel {
    _deviceTypeModel = deviceTypeModel;
    self.deviceTypeView.image = [UIImage imageNamed:self.codeToNameDic[deviceTypeModel.code]];
}

- (NSDictionary *)codeToNameDic {
    if (!_codeToNameDic) {
        _codeToNameDic = @{@"YXK-Z/86-FG-A": @"type_fluorine_main_controller",
                           @"YXK-F/86-FG-A": @"type_fluorine_sub_controller",
                           @"YXK-Z/86-FC-B": @"type_water_main_controller",
                           @"YXK-F/86-FC-B": @"type_water_sub_controller",
                           @"YXK-P/DN-JF-8": @"type_intelligent_water_collector"};
    }
    return _codeToNameDic;
}

@end
