//
//  ChatSettingCell.m
//  AIIM
//
//  Created by qitewei on 2025/5/22.
//

#import "ChatSettingCell.h"

@implementation ChatSettingCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.separatorInset = UIEdgeInsetsMake(0, 0, 0, 0);
        self.backgroundColor = UIColor.clearColor;
        [self configUI];
    }
    return self;
}

- (void)configUI{
    [self.contentView addSubview:self.titleLbl];
    [self.titleLbl mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(18);
        make.left.mas_equalTo(20);
        make.top.mas_equalTo(16);
        make.bottom.mas_equalTo(-16);
    }];
    
    [self.contentView addSubview:self.stateSwitch];
    [self.stateSwitch mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(CGSizeMake(50, 30));
        make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
        make.centerY.mas_equalTo(self.titleLbl.mas_centerY);
    }];
}

#pragma mark event
- (void)stateSwitchChange:(UISwitch *)stateSwitch{
    !self.stateSwitchChangeValue?:self.stateSwitchChangeValue(stateSwitch.isOn);
}

#pragma mark lazy
- (UILabel *)titleLbl{
    if (!_titleLbl) {
        _titleLbl = [[UILabel alloc] init];
        _titleLbl.textColor = UIColor.whiteColor;
        _titleLbl.font = SYSFONT(16);
    }
    return _titleLbl;
}

- (CustomSwitch *)stateSwitch{
    if (!_stateSwitch) {
        _stateSwitch = [[CustomSwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 30)];
//        _stateSwitch.onTintColor = [UIColor jk_colorWithHexString:@"#1EEC99"];
//        _stateSwitch.offBackgroundColor = [UIColor jk_colorWithHexString:@"#545966"];
        [_stateSwitch addTarget:self action:@selector(stateSwitchChange:) forControlEvents:UIControlEventValueChanged];
    }
    return _stateSwitch;
}

@end
