Files
keyboard/keyBoard/Class/AiTalk/V/PopView/KBChatLimitPopView.m

138 lines
4.6 KiB
Mathematica
Raw Permalink Normal View History

2026-01-27 16:28:17 +08:00
//
// KBChatLimitPopView.m
// keyBoard
//
// Created by Codex on 2026/1/27.
//
#import "KBChatLimitPopView.h"
#import <Masonry/Masonry.h>
2026-02-04 20:23:20 +08:00
static CGFloat const kKBChatLimitIconSize = 252.0;
static CGFloat const kKBChatLimitGotoWidth = 251.0;
static CGFloat const kKBChatLimitGotoHeight = 53.0;
static CGFloat const kKBChatLimitCloseSize = 28.0;
static CGFloat const kKBChatLimitSpacing1 = 18.0;
static CGFloat const kKBChatLimitSpacing2 = 18.0;
2026-01-27 16:28:17 +08:00
@interface KBChatLimitPopView ()
2026-02-04 20:23:20 +08:00
@property (nonatomic, strong) UIImageView *iconImageView;
2026-01-27 16:28:17 +08:00
@property (nonatomic, strong) UILabel *messageLabel;
2026-02-04 20:23:20 +08:00
@property (nonatomic, strong) UIButton *gotoButton;
@property (nonatomic, strong) UIButton *closeButton;
2026-01-27 16:28:17 +08:00
@end
@implementation KBChatLimitPopView
- (instancetype)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
2026-02-04 20:23:20 +08:00
self.backgroundColor = [UIColor clearColor];
2026-01-27 16:28:17 +08:00
[self setupUI];
}
return self;
}
#pragma mark - UI
- (void)setupUI {
2026-02-04 20:23:20 +08:00
[self addSubview:self.iconImageView];
[self.iconImageView addSubview:self.messageLabel];
[self addSubview:self.gotoButton];
[self addSubview:self.closeButton];
2026-01-27 16:28:17 +08:00
2026-02-04 20:23:20 +08:00
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self);
make.centerX.equalTo(self);
make.width.height.mas_equalTo(kKBChatLimitIconSize);
2026-01-27 16:28:17 +08:00
}];
2026-02-04 20:23:20 +08:00
//
2026-01-27 16:28:17 +08:00
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
2026-02-04 20:23:20 +08:00
// make.centerX.equalTo(self.iconImageView);
make.centerY.equalTo(self.iconImageView).offset(10);
make.left.equalTo(self.iconImageView).offset(26);
make.right.equalTo(self.iconImageView).offset(-46);
2026-01-27 16:28:17 +08:00
}];
2026-02-04 20:23:20 +08:00
[self.gotoButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.iconImageView.mas_bottom).offset(kKBChatLimitSpacing1);
make.centerX.equalTo(self);
make.width.mas_equalTo(kKBChatLimitGotoWidth);
make.height.mas_equalTo(kKBChatLimitGotoHeight);
2026-01-27 16:28:17 +08:00
}];
2026-02-04 20:23:20 +08:00
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.gotoButton.mas_bottom).offset(kKBChatLimitSpacing2);
2026-01-27 16:28:17 +08:00
make.centerX.equalTo(self);
2026-02-04 20:23:20 +08:00
make.width.height.mas_equalTo(kKBChatLimitCloseSize);
2026-01-27 16:28:17 +08:00
make.bottom.equalTo(self);
}];
}
#pragma mark - Actions
- (void)onTapCancel {
if ([self.delegate respondsToSelector:@selector(chatLimitPopViewDidTapCancel:)]) {
[self.delegate chatLimitPopViewDidTapCancel:self];
}
}
- (void)onTapRecharge {
if ([self.delegate respondsToSelector:@selector(chatLimitPopViewDidTapRecharge:)]) {
[self.delegate chatLimitPopViewDidTapRecharge:self];
}
}
#pragma mark - Setter
- (void)setMessage:(NSString *)message {
_message = [message copy];
self.messageLabel.text = _message.length > 0 ? _message : @"";
}
#pragma mark - Lazy
2026-02-04 20:23:20 +08:00
- (UIImageView *)iconImageView {
if (!_iconImageView) {
_iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ai_limit_icon"]];
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
_iconImageView.userInteractionEnabled = YES;
2026-01-27 16:28:17 +08:00
}
2026-02-04 20:23:20 +08:00
return _iconImageView;
2026-01-27 16:28:17 +08:00
}
- (UILabel *)messageLabel {
if (!_messageLabel) {
_messageLabel = [[UILabel alloc] init];
2026-02-04 20:23:20 +08:00
_messageLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
_messageLabel.textColor = [UIColor colorWithWhite:0.18 alpha:1.0];
2026-01-27 16:28:17 +08:00
_messageLabel.textAlignment = NSTextAlignmentCenter;
_messageLabel.numberOfLines = 0;
}
return _messageLabel;
}
2026-02-04 20:23:20 +08:00
- (UIButton *)gotoButton {
if (!_gotoButton) {
_gotoButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_gotoButton setBackgroundImage:[UIImage imageNamed:@"ai_limit_goto"] forState:UIControlStateNormal];
[_gotoButton setTitle:KBLocalized(@"Go To Recharge") forState:UIControlStateNormal];
[_gotoButton setTitleColor:[UIColor colorWithWhite:0.1 alpha:1.0] forState:UIControlStateNormal];
_gotoButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
[_gotoButton addTarget:self action:@selector(onTapRecharge) forControlEvents:UIControlEventTouchUpInside];
2026-01-27 16:28:17 +08:00
}
2026-02-04 20:23:20 +08:00
return _gotoButton;
2026-01-27 16:28:17 +08:00
}
2026-02-04 20:23:20 +08:00
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_closeButton setImage:[UIImage imageNamed:@"ai_limit_close"] forState:UIControlStateNormal];
[_closeButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside];
2026-01-27 16:28:17 +08:00
}
2026-02-04 20:23:20 +08:00
return _closeButton;
2026-01-27 16:28:17 +08:00
}
@end
2026-02-04 20:23:20 +08:00