//
//  FavoritesTextCell.m
//  AIIM
//
//  Created by qitewei on 2025/4/30.
//

#import "FavoritesTextCell.h"
#import "CryptoAES.h"

@interface FavoritesTextCell()
@property (nonatomic, strong) UILabel * contentLbl;
@property (nonatomic, strong) UILabel * timeLbl;
@end

@implementation FavoritesTextCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}

- (void)configUI{
    self.contentView.backgroundColor = globalColor(GCTypeDark6);
    
    [self.contentView addSubview:self.contentLbl];
    [self.contentView addSubview:self.timeLbl];
    UIEdgeInsets padding = UIEdgeInsetsMake(16, 20, 16, 20);
    
    
    [self.contentLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(padding.left);
        make.right.equalTo(self.contentView.mas_right).offset(-padding.right);
        make.top.equalTo(self.contentView.mas_top).offset(padding.top);
    }];
    
    [self.timeLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentLbl.mas_bottom).offset(12);
        make.left.equalTo(self.contentView.mas_left).offset(padding.left);
        make.right.equalTo(self.contentView.mas_right).offset(-padding.right);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(-padding.bottom);
        make.height.equalTo(@12);
    }];
}

- (void)setMsg:(NSDictionary *)msg{
    self.contentLbl.text = [CryptoAES.shareInstance decryptDataL:msg[@"content"]];
    self.timeLbl.text = msg[@"createTime"];
}

#pragma mark lazy
- (UILabel *)contentLbl{
    if (!_contentLbl) {
        _contentLbl = [[UILabel alloc] init];
        _contentLbl.textColor = UIColor.whiteColor;
        _contentLbl.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        _contentLbl.numberOfLines = 4;
    }
    return _contentLbl;
}

- (UILabel *)timeLbl{
    if (!_timeLbl) {
        _timeLbl = [[UILabel alloc] init];
        _timeLbl.textColor = globalColor(GCTypeDark7);
        _timeLbl.font = [UIFont systemFontOfSize:12 weight:UIFontWeightRegular];
    }
    return _timeLbl;
}

@end
