// // KBAIChatDeleteConfirmView.m // keyBoard // // Created by Codex on 2026/02/03. // #import "KBAIChatDeleteConfirmView.h" #import @interface KBAIChatDeleteConfirmView () @property (nonatomic, strong) UIView *coverView; @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UILabel *titleLabel; @property (nonatomic, strong) UILabel *messageLabel; @property (nonatomic, strong) UIButton *deleteButton; @property (nonatomic, strong) UIButton *cancelButton; @end @implementation KBAIChatDeleteConfirmView - (instancetype)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.backgroundColor = [UIColor clearColor]; self.layer.cornerRadius = 16.0; self.layer.masksToBounds = YES; [self setupUI]; } return self; } #pragma mark - UI - (void)setupUI { [self addSubview:self.coverView]; [self addSubview:self.iconView]; [self.coverView addSubview:self.titleLabel]; [self.coverView addSubview:self.messageLabel]; [self.coverView addSubview:self.deleteButton]; [self.coverView addSubview:self.cancelButton]; [self.coverView mas_makeConstraints:^(MASConstraintMaker *make) { make.height.mas_equalTo(216); make.bottom.left.right.bottom.equalTo(self); }]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self).offset(5); make.centerX.equalTo(self); make.width.height.mas_equalTo(64); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.coverView).offset(50); make.left.equalTo(self.coverView).offset(16); make.right.equalTo(self.coverView).offset(-16); }]; [self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.titleLabel.mas_bottom).offset(16); make.left.equalTo(self.coverView).offset(20); make.right.equalTo(self.coverView).offset(-20); }]; [self.deleteButton mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.coverView).offset(24); make.bottom.equalTo(self.coverView).offset(-20); make.height.mas_equalTo(40); make.right.equalTo(self.coverView.mas_centerX).offset(-15); }]; [self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.coverView).offset(-24); make.bottom.equalTo(self.coverView).offset(-20); make.height.mas_equalTo(40); make.left.equalTo(self.coverView.mas_centerX).offset(15); }]; } #pragma mark - Actions - (void)onTapDelete { if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapDelete:)]) { [self.delegate chatDeleteConfirmViewDidTapDelete:self]; } } - (void)onTapCancel { if ([self.delegate respondsToSelector:@selector(chatDeleteConfirmViewDidTapCancel:)]) { [self.delegate chatDeleteConfirmViewDidTapCancel:self]; } } #pragma mark - Lazy - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"chat_del_icon"]]; _iconView.contentMode = UIViewContentModeScaleAspectFit; } return _iconView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.text = KBLocalized(@"Are you sure to delete?"); _titleLabel.font = [UIFont boldSystemFontOfSize:18]; _titleLabel.textColor = [UIColor colorWithWhite:0.1 alpha:1.0]; _titleLabel.textAlignment = NSTextAlignmentCenter; } return _titleLabel; } - (UILabel *)messageLabel { if (!_messageLabel) { _messageLabel = [[UILabel alloc] init]; _messageLabel.text = KBLocalized(@"The existing conversation history will be cleared."); _messageLabel.font = [UIFont systemFontOfSize:14]; _messageLabel.textColor = [UIColor colorWithWhite:0.45 alpha:1.0]; _messageLabel.textAlignment = NSTextAlignmentCenter; _messageLabel.numberOfLines = 0; } return _messageLabel; } - (UIButton *)deleteButton { if (!_deleteButton) { _deleteButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_deleteButton setTitle:KBLocalized(@"Delete") forState:UIControlStateNormal]; [_deleteButton setTitleColor:[UIColor colorWithWhite:0.2 alpha:1.0] forState:UIControlStateNormal]; _deleteButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; _deleteButton.backgroundColor = [UIColor colorWithWhite:0.93 alpha:1.0]; _deleteButton.layer.cornerRadius = 20; _deleteButton.layer.masksToBounds = YES; [_deleteButton addTarget:self action:@selector(onTapDelete) forControlEvents:UIControlEventTouchUpInside]; } return _deleteButton; } - (UIButton *)cancelButton { if (!_cancelButton) { _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_cancelButton setTitle:KBLocalized(@"Think Again") forState:UIControlStateNormal]; [_cancelButton setTitleColor:[UIColor colorWithWhite:0.15 alpha:1.0] forState:UIControlStateNormal]; _cancelButton.titleLabel.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; _cancelButton.backgroundColor = [UIColor colorWithRed:0.80 green:0.94 blue:0.72 alpha:1.0]; _cancelButton.layer.cornerRadius = 20; _cancelButton.layer.masksToBounds = YES; [_cancelButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside]; } return _cancelButton; } - (UIView *)coverView{ if (!_coverView) { _coverView = [[UIView alloc] init]; _coverView.backgroundColor = [UIColor whiteColor]; _coverView.layer.cornerRadius = 30; _coverView.layer.masksToBounds = true; } return _coverView; } @end