138 lines
4.6 KiB
Objective-C
138 lines
4.6 KiB
Objective-C
//
|
|
// KBChatLimitPopView.m
|
|
// keyBoard
|
|
//
|
|
// Created by Codex on 2026/1/27.
|
|
//
|
|
|
|
#import "KBChatLimitPopView.h"
|
|
#import <Masonry/Masonry.h>
|
|
|
|
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;
|
|
|
|
@interface KBChatLimitPopView ()
|
|
@property (nonatomic, strong) UIImageView *iconImageView;
|
|
@property (nonatomic, strong) UILabel *messageLabel;
|
|
@property (nonatomic, strong) UIButton *gotoButton;
|
|
@property (nonatomic, strong) UIButton *closeButton;
|
|
@end
|
|
|
|
@implementation KBChatLimitPopView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
[self setupUI];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - UI
|
|
|
|
- (void)setupUI {
|
|
[self addSubview:self.iconImageView];
|
|
[self.iconImageView addSubview:self.messageLabel];
|
|
[self addSubview:self.gotoButton];
|
|
[self addSubview:self.closeButton];
|
|
|
|
[self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self);
|
|
make.centerX.equalTo(self);
|
|
make.width.height.mas_equalTo(kKBChatLimitIconSize);
|
|
}];
|
|
|
|
// 让文案落在图中留白区域(大致居中偏下)
|
|
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
// 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);
|
|
}];
|
|
|
|
[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);
|
|
}];
|
|
|
|
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.gotoButton.mas_bottom).offset(kKBChatLimitSpacing2);
|
|
make.centerX.equalTo(self);
|
|
make.width.height.mas_equalTo(kKBChatLimitCloseSize);
|
|
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
|
|
|
|
- (UIImageView *)iconImageView {
|
|
if (!_iconImageView) {
|
|
_iconImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ai_limit_icon"]];
|
|
_iconImageView.contentMode = UIViewContentModeScaleAspectFit;
|
|
_iconImageView.userInteractionEnabled = YES;
|
|
}
|
|
return _iconImageView;
|
|
}
|
|
|
|
- (UILabel *)messageLabel {
|
|
if (!_messageLabel) {
|
|
_messageLabel = [[UILabel alloc] init];
|
|
_messageLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
|
|
_messageLabel.textColor = [UIColor colorWithWhite:0.18 alpha:1.0];
|
|
_messageLabel.textAlignment = NSTextAlignmentCenter;
|
|
_messageLabel.numberOfLines = 0;
|
|
}
|
|
return _messageLabel;
|
|
}
|
|
|
|
- (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];
|
|
}
|
|
return _gotoButton;
|
|
}
|
|
|
|
- (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];
|
|
}
|
|
return _closeButton;
|
|
}
|
|
|
|
@end
|
|
|