158 lines
5.2 KiB
Objective-C
158 lines
5.2 KiB
Objective-C
//
|
|
// KBChatLimitPopView.m
|
|
// keyBoard
|
|
//
|
|
// Created by Codex on 2026/1/27.
|
|
//
|
|
|
|
#import "KBChatLimitPopView.h"
|
|
#import <Masonry/Masonry.h>
|
|
|
|
@interface KBChatLimitPopView ()
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
@property (nonatomic, strong) UILabel *messageLabel;
|
|
@property (nonatomic, strong) UIButton *cancelButton;
|
|
@property (nonatomic, strong) UIButton *rechargeButton;
|
|
@property (nonatomic, strong) UIView *buttonDivider;
|
|
@end
|
|
|
|
@implementation KBChatLimitPopView
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
if (self = [super initWithFrame:frame]) {
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
self.layer.cornerRadius = 16.0;
|
|
self.layer.masksToBounds = YES;
|
|
[self setupUI];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
#pragma mark - UI
|
|
|
|
- (void)setupUI {
|
|
[self addSubview:self.titleLabel];
|
|
[self addSubview:self.messageLabel];
|
|
[self addSubview:self.buttonDivider];
|
|
[self addSubview:self.cancelButton];
|
|
[self addSubview:self.rechargeButton];
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self).offset(20);
|
|
make.left.equalTo(self).offset(20);
|
|
make.right.equalTo(self).offset(-20);
|
|
}];
|
|
|
|
[self.messageLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.equalTo(self.titleLabel.mas_bottom).offset(8);
|
|
make.left.equalTo(self).offset(20);
|
|
make.right.equalTo(self).offset(-20);
|
|
}];
|
|
|
|
[self.buttonDivider mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.right.equalTo(self);
|
|
make.height.mas_equalTo(1);
|
|
make.top.greaterThanOrEqualTo(self.messageLabel.mas_bottom).offset(16);
|
|
make.bottom.equalTo(self).offset(-48);
|
|
}];
|
|
|
|
[self.cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.left.bottom.equalTo(self);
|
|
make.top.equalTo(self.buttonDivider.mas_bottom);
|
|
make.right.equalTo(self.mas_centerX);
|
|
}];
|
|
|
|
[self.rechargeButton mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.right.bottom.equalTo(self);
|
|
make.top.equalTo(self.buttonDivider.mas_bottom);
|
|
make.left.equalTo(self.mas_centerX);
|
|
}];
|
|
|
|
UIView *verticalLine = [[UIView alloc] init];
|
|
verticalLine.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
|
|
[self addSubview:verticalLine];
|
|
[verticalLine mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.centerX.equalTo(self);
|
|
make.top.equalTo(self.buttonDivider.mas_bottom);
|
|
make.bottom.equalTo(self);
|
|
make.width.mas_equalTo(1);
|
|
}];
|
|
}
|
|
|
|
#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
|
|
|
|
- (UILabel *)titleLabel {
|
|
if (!_titleLabel) {
|
|
_titleLabel = [[UILabel alloc] init];
|
|
_titleLabel.text = KBLocalized(@"提示");
|
|
_titleLabel.font = [UIFont boldSystemFontOfSize:18];
|
|
_titleLabel.textColor = [UIColor blackColor];
|
|
_titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
}
|
|
return _titleLabel;
|
|
}
|
|
|
|
- (UILabel *)messageLabel {
|
|
if (!_messageLabel) {
|
|
_messageLabel = [[UILabel alloc] init];
|
|
_messageLabel.font = [UIFont systemFontOfSize:14];
|
|
_messageLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
|
|
_messageLabel.textAlignment = NSTextAlignmentCenter;
|
|
_messageLabel.numberOfLines = 0;
|
|
}
|
|
return _messageLabel;
|
|
}
|
|
|
|
- (UIButton *)cancelButton {
|
|
if (!_cancelButton) {
|
|
_cancelButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
[_cancelButton setTitle:KBLocalized(@"取消") forState:UIControlStateNormal];
|
|
_cancelButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
[_cancelButton setTitleColor:[UIColor colorWithWhite:0.2 alpha:1.0] forState:UIControlStateNormal];
|
|
[_cancelButton addTarget:self action:@selector(onTapCancel) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _cancelButton;
|
|
}
|
|
|
|
- (UIButton *)rechargeButton {
|
|
if (!_rechargeButton) {
|
|
_rechargeButton = [UIButton buttonWithType:UIButtonTypeSystem];
|
|
[_rechargeButton setTitle:KBLocalized(@"去充值") forState:UIControlStateNormal];
|
|
_rechargeButton.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
|
[_rechargeButton setTitleColor:[UIColor colorWithRed:0.28 green:0.45 blue:0.94 alpha:1.0] forState:UIControlStateNormal];
|
|
[_rechargeButton addTarget:self action:@selector(onTapRecharge) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _rechargeButton;
|
|
}
|
|
|
|
- (UIView *)buttonDivider {
|
|
if (!_buttonDivider) {
|
|
_buttonDivider = [[UIView alloc] init];
|
|
_buttonDivider.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1.0];
|
|
}
|
|
return _buttonDivider;
|
|
}
|
|
|
|
@end
|