//
//  KBGuideKFCell.m
//  keyBoard
//

#import "KBGuideKFCell.h"

@interface KBGuideKFCell ()
@property (nonatomic, strong) UIView *avatarView;   // 左侧头像
@property (nonatomic, strong) UIView *bubbleView;   // 气泡
@property (nonatomic, strong) UILabel *contentLabel; // 文案
@end

@implementation KBGuideKFCell

- (void)setupUI {
    self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];

    [self.contentView addSubview:self.avatarView];
    [self.avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(16);
        make.top.equalTo(self.contentView).offset(10);
        make.width.height.mas_equalTo(36);
    }];

    [self.contentView addSubview:self.bubbleView];
    [self.bubbleView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.avatarView.mas_right).offset(8);
        make.top.equalTo(self.contentView).offset(8);
        make.right.lessThanOrEqualTo(self.contentView).offset(-80);
        make.bottom.equalTo(self.contentView).offset(-8);
    }];

    [self.bubbleView addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.bubbleView).insets(UIEdgeInsetsMake(10, 12, 10, 12));
    }];
}

- (void)configText:(NSString *)text {
    self.contentLabel.text = text;
}

#pragma mark - Lazy

- (UIView *)avatarView {
    if (!_avatarView) {
        _avatarView = [UIView new];
        _avatarView.backgroundColor = [UIColor colorWithRed:0.23 green:0.47 blue:0.96 alpha:1.0];
        _avatarView.layer.cornerRadius = 18;
        _avatarView.layer.masksToBounds = YES;
    }
    return _avatarView;
}

- (UIView *)bubbleView {
    if (!_bubbleView) {
        _bubbleView = [UIView new];
        _bubbleView.backgroundColor = [UIColor whiteColor];
        _bubbleView.layer.cornerRadius = 18;
        _bubbleView.layer.masksToBounds = YES;
    }
    return _bubbleView;
}

- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [UILabel new];
        _contentLabel.numberOfLines = 0;
        _contentLabel.font = [UIFont systemFontOfSize:15];
        _contentLabel.textColor = [UIColor colorWithWhite:0.15 alpha:1.0];
    }
    return _contentLabel;
}

@end

