//
//  KBSkinDetailTagCell.m
//  keyBoard
//
//  Created by Mac on 2025/11/8.
//

#import "KBSkinDetailTagCell.h"
@interface KBSkinDetailTagCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@end
@implementation KBSkinDetailTagCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
        self.contentView.layer.cornerRadius = 16;
        self.contentView.layer.masksToBounds = YES;
        [self.contentView addSubview:self.titleLabel];
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView).insets(UIEdgeInsetsMake(6, 12, 6, 12));
        }];
    }
    return self;
}

- (void)config:(NSString *)text {
    self.titleLabel.text = text ?: @"";
}

+ (CGSize)sizeForText:(NSString *)text {
    if (text.length == 0) { return CGSizeMake(40, 32); }
    CGSize s = [text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14]}];
    // 两侧内边距 12 + 12，高度固定 32
    return CGSizeMake(ceil(s.width) + 24, 32);
}

#pragma mark - Lazy

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont systemFontOfSize:14];
        _titleLabel.textColor = [UIColor colorWithHex:0x1B1F1A];
    }
    return _titleLabel;
}

@end
