2025-10-29 16:26:57 +08:00
|
|
|
|
//
|
|
|
|
|
|
// KBGuideTopCell.m
|
|
|
|
|
|
// keyBoard
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#import "KBGuideTopCell.h"
|
|
|
|
|
|
|
|
|
|
|
|
@interface KBGuideTopCell ()
|
|
|
|
|
|
|
2025-12-15 17:56:06 +08:00
|
|
|
|
// 左侧头像(使用 App_icon 素材)
|
|
|
|
|
|
@property (nonatomic, strong) UIImageView *avatarImageView;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
// 白色卡片容器
|
|
|
|
|
|
@property (nonatomic, strong) UIView *cardView;
|
|
|
|
|
|
// 卡片标题/正文
|
|
|
|
|
|
@property (nonatomic, strong) UILabel *titleLabel;
|
|
|
|
|
|
@property (nonatomic, strong) UILabel *descLabel;
|
2025-12-15 16:41:53 +08:00
|
|
|
|
@property (nonatomic, strong) UIStackView *buttonStack;
|
|
|
|
|
|
@property (nonatomic, strong) UIButton *q1Button;
|
|
|
|
|
|
@property (nonatomic, strong) UIButton *q2Button;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@implementation KBGuideTopCell
|
|
|
|
|
|
|
|
|
|
|
|
- (void)setupUI {
|
2025-12-15 16:41:53 +08:00
|
|
|
|
self.backgroundColor = [UIColor clearColor];
|
|
|
|
|
|
self.contentView.backgroundColor = [UIColor clearColor];
|
2025-10-29 16:26:57 +08:00
|
|
|
|
|
|
|
|
|
|
// 头像
|
2025-12-15 17:56:06 +08:00
|
|
|
|
[self.contentView addSubview:self.avatarImageView];
|
|
|
|
|
|
[self.avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2025-10-29 16:26:57 +08:00
|
|
|
|
make.left.equalTo(self.contentView).offset(16);
|
|
|
|
|
|
make.top.equalTo(self.contentView).offset(12);
|
|
|
|
|
|
make.width.height.mas_equalTo(36);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
// 卡片
|
|
|
|
|
|
[self.contentView addSubview:self.cardView];
|
|
|
|
|
|
[self.cardView mas_makeConstraints:^(MASConstraintMaker *make) {
|
2025-12-15 17:56:06 +08:00
|
|
|
|
make.left.equalTo(self.avatarImageView.mas_right).offset(8);
|
2025-10-29 16:26:57 +08:00
|
|
|
|
make.right.lessThanOrEqualTo(self.contentView).offset(-32);
|
|
|
|
|
|
make.top.equalTo(self.contentView).offset(8);
|
|
|
|
|
|
make.bottom.equalTo(self.contentView).offset(-8);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
[self.cardView addSubview:self.titleLabel];
|
|
|
|
|
|
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.top.left.equalTo(self.cardView).offset(12);
|
|
|
|
|
|
make.right.equalTo(self.cardView).offset(-12);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
[self.cardView addSubview:self.descLabel];
|
|
|
|
|
|
[self.descLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.top.equalTo(self.titleLabel.mas_bottom).offset(6);
|
|
|
|
|
|
make.left.right.equalTo(self.titleLabel);
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
2025-12-15 16:41:53 +08:00
|
|
|
|
// 示例按钮区域
|
|
|
|
|
|
[self.cardView addSubview:self.buttonStack];
|
|
|
|
|
|
[self.buttonStack mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.top.equalTo(self.descLabel.mas_bottom).offset(20);
|
|
|
|
|
|
make.left.equalTo(self.cardView).offset(12);
|
|
|
|
|
|
make.right.equalTo(self.cardView).offset(-12);
|
|
|
|
|
|
make.bottom.equalTo(self.cardView).offset(-16);
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}];
|
|
|
|
|
|
|
2025-12-15 16:41:53 +08:00
|
|
|
|
[self.buttonStack addArrangedSubview:self.q1Button];
|
|
|
|
|
|
[self.buttonStack addArrangedSubview:self.q2Button];
|
2025-10-29 16:26:57 +08:00
|
|
|
|
|
2025-12-15 16:41:53 +08:00
|
|
|
|
[self.q1Button mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.height.mas_equalTo(46);
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}];
|
2025-12-15 16:41:53 +08:00
|
|
|
|
[self.q2Button mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
|
|
make.height.mas_equalTo(46);
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#pragma mark - Lazy
|
|
|
|
|
|
|
2025-12-15 17:56:06 +08:00
|
|
|
|
- (UIImageView *)avatarImageView {
|
|
|
|
|
|
if (!_avatarImageView) {
|
|
|
|
|
|
_avatarImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"App_icon"]];
|
|
|
|
|
|
_avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
|
|
|
|
|
|
_avatarImageView.layer.cornerRadius = 18;
|
|
|
|
|
|
_avatarImageView.layer.masksToBounds = YES;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
2025-12-15 17:56:06 +08:00
|
|
|
|
return _avatarImageView;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIView *)cardView {
|
|
|
|
|
|
if (!_cardView) {
|
|
|
|
|
|
_cardView = [UIView new];
|
|
|
|
|
|
_cardView.backgroundColor = [UIColor whiteColor];
|
2025-12-15 16:41:53 +08:00
|
|
|
|
_cardView.layer.cornerRadius = 20;
|
|
|
|
|
|
_cardView.layer.masksToBounds = NO;
|
|
|
|
|
|
_cardView.layer.shadowColor = [UIColor colorWithRed:0.42 green:0.54 blue:0.83 alpha:0.35].CGColor;
|
|
|
|
|
|
_cardView.layer.shadowOpacity = 0.5;
|
|
|
|
|
|
_cardView.layer.shadowOffset = CGSizeMake(0, 6);
|
|
|
|
|
|
_cardView.layer.shadowRadius = 14;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
return _cardView;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UILabel *)titleLabel {
|
|
|
|
|
|
if (!_titleLabel) {
|
|
|
|
|
|
_titleLabel = [UILabel new];
|
|
|
|
|
|
_titleLabel.numberOfLines = 0;
|
2025-12-15 16:41:53 +08:00
|
|
|
|
_titleLabel.font = [KBFont regular:10];
|
|
|
|
|
|
_titleLabel.textColor = [UIColor colorWithHex:0x929292];
|
|
|
|
|
|
_titleLabel.text = KBLocalized(@"Welcome To Use The [key Of Love] Keyboard");
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
return _titleLabel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UILabel *)descLabel {
|
|
|
|
|
|
if (!_descLabel) {
|
|
|
|
|
|
_descLabel = [UILabel new];
|
|
|
|
|
|
_descLabel.numberOfLines = 0;
|
2025-12-15 16:41:53 +08:00
|
|
|
|
_descLabel.font = [KBFont regular:10];
|
|
|
|
|
|
_descLabel.textColor = [UIColor colorWithHex:0x929292];
|
|
|
|
|
|
NSString *desc = KBLocalized(@"Click \"copy Any Conversation\", \"paste\"\nAnd Try Replying Using The Keyboard\n[persona] Method");
|
|
|
|
|
|
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
|
|
|
|
|
|
style.lineSpacing = 4;
|
|
|
|
|
|
_descLabel.attributedText = [[NSAttributedString alloc] initWithString:desc attributes:@{
|
|
|
|
|
|
NSParagraphStyleAttributeName : style
|
|
|
|
|
|
}];
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
return _descLabel;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-15 16:41:53 +08:00
|
|
|
|
- (UIStackView *)buttonStack {
|
|
|
|
|
|
if (!_buttonStack) {
|
|
|
|
|
|
_buttonStack = [[UIStackView alloc] init];
|
|
|
|
|
|
_buttonStack.axis = UILayoutConstraintAxisVertical;
|
|
|
|
|
|
_buttonStack.distribution = UIStackViewDistributionFill;
|
|
|
|
|
|
_buttonStack.spacing = 10;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
2025-12-15 16:41:53 +08:00
|
|
|
|
return _buttonStack;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-15 16:41:53 +08:00
|
|
|
|
- (UIButton *)q1Button {
|
|
|
|
|
|
if (!_q1Button) {
|
|
|
|
|
|
_q1Button = [self kb_makeActionButton];
|
|
|
|
|
|
[_q1Button setTitle:KBLocalized(@"I Miss You") forState:UIControlStateNormal];
|
|
|
|
|
|
[_q1Button addTarget:self action:@selector(kb_onTapQ1) forControlEvents:UIControlEventTouchUpInside];
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
2025-12-15 16:41:53 +08:00
|
|
|
|
return _q1Button;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIButton *)q2Button {
|
|
|
|
|
|
if (!_q2Button) {
|
|
|
|
|
|
_q2Button = [self kb_makeActionButton];
|
|
|
|
|
|
[_q2Button setTitle:KBLocalized(@"I'm Going To Take A Bath") forState:UIControlStateNormal];
|
|
|
|
|
|
[_q2Button addTarget:self action:@selector(kb_onTapQ2) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
}
|
|
|
|
|
|
return _q2Button;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (UIButton *)kb_makeActionButton {
|
|
|
|
|
|
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
|
|
|
|
|
|
btn.backgroundColor = [UIColor whiteColor];
|
|
|
|
|
|
btn.layer.cornerRadius = 4;
|
|
|
|
|
|
btn.backgroundColor = [UIColor colorWithHex:0xF3F3F3];
|
|
|
|
|
|
// btn.layer.borderWidth = 1;
|
|
|
|
|
|
// btn.layer.borderColor = [UIColor colorWithRed:0.82 green:0.86 blue:0.99 alpha:1].CGColor;
|
|
|
|
|
|
btn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
|
|
|
|
|
|
[btn setTitleColor:[UIColor colorWithHex:0x1B1F1A] forState:UIControlStateNormal];
|
|
|
|
|
|
btn.titleLabel.numberOfLines = 0;
|
|
|
|
|
|
btn.titleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
|
btn.contentEdgeInsets = UIEdgeInsetsMake(10, 16, 10, 16);
|
|
|
|
|
|
btn.adjustsImageWhenHighlighted = NO;
|
|
|
|
|
|
return btn;
|
2025-10-29 16:26:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-24 19:58:19 +08:00
|
|
|
|
/// 复制统一处理
|
|
|
|
|
|
- (void)kb_copyTextToPasteboard:(NSString *)text {
|
|
|
|
|
|
if (text.length == 0) { return; }
|
|
|
|
|
|
UIPasteboard.generalPasteboard.string = text;
|
|
|
|
|
|
[KBHUD showInfo:KBLocalized(@"Copy Success")];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 点击第一条示例文案
|
|
|
|
|
|
- (void)kb_onTapQ1 {
|
2025-12-15 16:41:53 +08:00
|
|
|
|
[self kb_copyTextToPasteboard:[self.q1Button titleForState:UIControlStateNormal]];
|
2025-11-24 19:58:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 点击第二条示例文案
|
|
|
|
|
|
- (void)kb_onTapQ2 {
|
2025-12-15 16:41:53 +08:00
|
|
|
|
[self kb_copyTextToPasteboard:[self.q2Button titleForState:UIControlStateNormal]];
|
2025-11-24 19:58:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-29 16:26:57 +08:00
|
|
|
|
@end
|