This commit is contained in:
2025-12-15 16:41:53 +08:00
parent 06dee39566
commit a7574cd286
5 changed files with 153 additions and 82 deletions

View File

@@ -25,13 +25,12 @@ static __weak UIView *sContainerView = nil; // 缺省承载视图(
if (NSThread.isMainThread) { blk(); } else { dispatch_async(dispatch_get_main_queue(), blk); }
}
+ (MBProgressHUD *)ensureHUDWithMask:(KBHUDMaskType)mask tap:(BOOL)tap {
// 使
/// HUD 宿
+ (UIView *)kb_resolvedHostView {
UIView *hostView = sContainerView;
#ifndef KB_APP_EXTENSION
// App 退 KeyWindow
if (!hostView) {
// KB_KeyWindow App PrefixHeader
UIWindow *win = nil;
// 访 UIApplication App Extension
Class uiAppClass = NSClassFromString(@"UIApplication");
@@ -51,7 +50,11 @@ static __weak UIView *sContainerView = nil; // 缺省承载视图(
hostView = win;
}
#endif
return hostView;
}
+ (MBProgressHUD *)ensureHUDWithMask:(KBHUDMaskType)mask tap:(BOOL)tap {
UIView *hostView = [self kb_resolvedHostView];
if (!hostView) { return nil; }
MBProgressHUD *hud = sHUD;
@@ -119,8 +122,27 @@ static __weak UIView *sContainerView = nil; // 缺省承载视图(
+ (void)_showText:(NSString *)text icon:(nullable UIImage *)icon {
[self onMain:^{
MBProgressHUD *hud = [self ensureHUDWithMask:sMaskType tap:sDefaultTapToDismiss];
if (!hud) { return; }
MBProgressHUD *loadingHUD = sHUD;
if (loadingHUD) {
[loadingHUD hideAnimated:YES];
}
sHUD = nil;
UIView *hostView = [self kb_resolvedHostView];
if (!hostView) { return; }
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:hostView animated:YES];
hud.removeFromSuperViewOnHide = YES;
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
hud.bezelView.layer.cornerRadius = 12.0;
hud.bezelView.color = [UIColor colorWithWhite:0 alpha:0.8];
hud.contentColor = UIColor.whiteColor;
hud.margin = 16;
hud.label.numberOfLines = 0;
hud.detailsLabel.numberOfLines = 0;
[self applyMaskType:sMaskType hud:hud];
[self applyTapToDismiss:sDefaultTapToDismiss hud:hud];
hud.mode = icon ? MBProgressHUDModeCustomView : MBProgressHUDModeText;
hud.label.text = text ?: @"";
hud.detailsLabel.text = nil;

View File

@@ -14,17 +14,17 @@
// /
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *descLabel;
@property (nonatomic, strong) UIView *line1;
@property (nonatomic, strong) UILabel *q1Label;
@property (nonatomic, strong) UIView *line2;
@property (nonatomic, strong) UILabel *q2Label;
@property (nonatomic, strong) UIStackView *buttonStack;
@property (nonatomic, strong) UIButton *q1Button;
@property (nonatomic, strong) UIButton *q2Button;
@end
@implementation KBGuideTopCell
- (void)setupUI {
self.contentView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
self.backgroundColor = [UIColor clearColor];
self.contentView.backgroundColor = [UIColor clearColor];
//
[self.contentView addSubview:self.avatarView];
@@ -55,33 +55,23 @@
make.left.right.equalTo(self.titleLabel);
}];
//
[self.cardView addSubview:self.line1];
[self.cardView addSubview:self.q1Label];
[self.cardView addSubview:self.line2];
[self.cardView addSubview:self.q2Label];
[self.line1 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.descLabel.mas_bottom).offset(10);
make.left.right.equalTo(self.cardView);
make.height.mas_equalTo(KB_ONE_PIXEL);
//
[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);
}];
[self.q1Label mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.line1.mas_bottom).offset(10);
make.left.right.equalTo(self.titleLabel);
}];
[self.buttonStack addArrangedSubview:self.q1Button];
[self.buttonStack addArrangedSubview:self.q2Button];
[self.line2 mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.q1Label.mas_bottom).offset(10);
make.left.right.equalTo(self.cardView);
make.height.mas_equalTo(KB_ONE_PIXEL);
[self.q1Button mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
[self.q2Label mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.line2.mas_bottom).offset(10);
make.left.right.equalTo(self.titleLabel);
make.bottom.equalTo(self.cardView).offset(-14);
[self.q2Button mas_makeConstraints:^(MASConstraintMaker *make) {
make.height.mas_equalTo(46);
}];
}
@@ -101,8 +91,12 @@
if (!_cardView) {
_cardView = [UIView new];
_cardView.backgroundColor = [UIColor whiteColor];
_cardView.layer.cornerRadius = 18;
_cardView.layer.masksToBounds = YES;
_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;
}
return _cardView;
}
@@ -111,9 +105,9 @@
if (!_titleLabel) {
_titleLabel = [UILabel new];
_titleLabel.numberOfLines = 0;
_titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_titleLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
_titleLabel.text = KBLocalized(@"👋 Welcome to Key of Love Keyboard");
_titleLabel.font = [KBFont regular:10];
_titleLabel.textColor = [UIColor colorWithHex:0x929292];
_titleLabel.text = KBLocalized(@"Welcome To Use The [key Of Love] Keyboard");
}
return _titleLabel;
}
@@ -122,42 +116,60 @@
if (!_descLabel) {
_descLabel = [UILabel new];
_descLabel.numberOfLines = 0;
_descLabel.font = [UIFont systemFontOfSize:14];
_descLabel.textColor = [UIColor colorWithWhite:0.2 alpha:1.0];
_descLabel.text = KBLocalized(@"Tap any conversation to paste, then try any reply style~");
_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
}];
}
return _descLabel;
}
- (UIView *)line1 { if (!_line1) { _line1 = [UIView new]; _line1.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0]; } return _line1; }
- (UIView *)line2 { if (!_line2) { _line2 = [UIView new]; _line2.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0]; } return _line2; }
- (UILabel *)q1Label {
if (!_q1Label) {
_q1Label = [UILabel new];
_q1Label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_q1Label.textColor = [UIColor blackColor];
_q1Label.text = KBLocalized(@"What are you doing?");
//
_q1Label.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(kb_onTapQ1)];
[_q1Label addGestureRecognizer:tap];
- (UIStackView *)buttonStack {
if (!_buttonStack) {
_buttonStack = [[UIStackView alloc] init];
_buttonStack.axis = UILayoutConstraintAxisVertical;
_buttonStack.distribution = UIStackViewDistributionFill;
_buttonStack.spacing = 10;
}
return _q1Label;
return _buttonStack;
}
- (UILabel *)q2Label {
if (!_q2Label) {
_q2Label = [UILabel new];
_q2Label.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold];
_q2Label.textColor = [UIColor blackColor];
_q2Label.text = KBLocalized(@"I'm going to take a shower.");
//
_q2Label.userInteractionEnabled = YES;
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(kb_onTapQ2)];
[_q2Label addGestureRecognizer:tap];
- (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];
}
return _q2Label;
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;
}
///
@@ -169,12 +181,12 @@
///
- (void)kb_onTapQ1 {
[self kb_copyTextToPasteboard:self.q1Label.text];
[self kb_copyTextToPasteboard:[self.q1Button titleForState:UIControlStateNormal]];
}
///
- (void)kb_onTapQ2 {
[self kb_copyTextToPasteboard:self.q2Label.text];
[self kb_copyTextToPasteboard:[self.q2Button titleForState:UIControlStateNormal]];
}
@end

View File

@@ -38,6 +38,7 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
/// GIF
@property (nonatomic, assign) CGFloat kb_currentKeyboardHeight;
@property (nonatomic, strong) UIImageView *bgImageView; //
@end
@@ -45,7 +46,15 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
// self.view.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
self.view.backgroundColor = UIColor.clearColor;
self.kb_navView.backgroundColor = [UIColor clearColor];
self.bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"my_bg_icon"]];
self.bgImageView.contentMode = UIViewContentModeScaleAspectFill;
[self.view insertSubview:self.bgImageView belowSubview:self.kb_navView];
[self.bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
[self.view addSubview:self.tableView];
[self.view addSubview:self.inputBar];
@@ -421,7 +430,7 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 线
_tableView.backgroundColor = [UIColor colorWithWhite:0.96 alpha:1.0];
_tableView.backgroundColor = [UIColor clearColor];
_tableView.rowHeight = UITableViewAutomaticDimension;
_tableView.estimatedRowHeight = 120; //
_tableView.contentInset = UIEdgeInsetsMake(0, 0, 52 + KB_SafeAreaBottom(), 0);