diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/Contents.json b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/Contents.json new file mode 100644 index 0000000..d4b1584 --- /dev/null +++ b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "kb_del_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "kb_del_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@2x.png b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@2x.png new file mode 100644 index 0000000..3f36532 Binary files /dev/null and b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@2x.png differ diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@3x.png b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@3x.png new file mode 100644 index 0000000..5cc16ee Binary files /dev/null and b/CustomKeyboard/KeyboardAssets.xcassets/kb_del_icon.imageset/kb_del_icon@3x.png differ diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/Contents.json b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/Contents.json new file mode 100644 index 0000000..7e0aba3 --- /dev/null +++ b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/Contents.json @@ -0,0 +1,22 @@ +{ + "images" : [ + { + "idiom" : "universal", + "scale" : "1x" + }, + { + "filename" : "kb_zt_icon@2x.png", + "idiom" : "universal", + "scale" : "2x" + }, + { + "filename" : "kb_zt_icon@3x.png", + "idiom" : "universal", + "scale" : "3x" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@2x.png b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@2x.png new file mode 100644 index 0000000..4e71878 Binary files /dev/null and b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@2x.png differ diff --git a/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@3x.png b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@3x.png new file mode 100644 index 0000000..4307360 Binary files /dev/null and b/CustomKeyboard/KeyboardAssets.xcassets/kb_zt_icon.imageset/kb_zt_icon@3x.png differ diff --git a/CustomKeyboard/KeyboardViewController.m b/CustomKeyboard/KeyboardViewController.m index 8a98d9e..db717ed 100644 --- a/CustomKeyboard/KeyboardViewController.m +++ b/CustomKeyboard/KeyboardViewController.m @@ -246,6 +246,21 @@ static void KBSkinInstallNotificationCallback(CFNotificationCenterRef center, [self showFunctionPanel:NO]; } } +- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index{ + NSString *schemeStr = [NSString stringWithFormat:@"%@://recharge?src=keyboard", KB_APP_SCHEME]; + NSURL *scheme = [NSURL URLWithString:schemeStr]; +// +// if (!ul && !scheme) { return; } +// + // 从当前视图作为起点,通过响应链找到 UIApplication 再调起主 App + BOOL ok = [KBHostAppLauncher openHostAppURL:scheme fromResponder:self.view]; + + if (!ok) { + // 失败兜底:给个文案提示 + // 比如:请回到桌面手动打开 XXX App 进行设置/充值 + [KBHUD showInfo:@"请回到桌面手动打开App进行充值"]; + } +} #pragma mark - lazy - (KBKeyBoardMainView *)keyBoardMainView{ diff --git a/CustomKeyboard/View/Function/KBFunctionTagListView.m b/CustomKeyboard/View/Function/KBFunctionTagListView.m index f5e5364..aba890c 100644 --- a/CustomKeyboard/View/Function/KBFunctionTagListView.m +++ b/CustomKeyboard/View/Function/KBFunctionTagListView.m @@ -6,6 +6,7 @@ #import "KBFunctionTagCell.h" static NSString * const kKBFunctionTagCellId2 = @"KBFunctionTagCellId2"; +static CGFloat const kKBItemSpace = 4; @interface KBFunctionTagListView () @property (nonatomic, strong) UICollectionView *collectionViewInternal; @@ -54,13 +55,13 @@ static NSString * const kKBFunctionTagCellId2 = @"KBFunctionTagCellId2"; } - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath { - CGFloat totalW = collectionView.bounds.size.width; CGFloat space = 10.0; NSInteger columns = 3; + CGFloat totalW = collectionView.bounds.size.width; CGFloat space = kKBItemSpace; NSInteger columns = 3; CGFloat width = floor((totalW - space * (columns - 1)) / columns); - return CGSizeMake(width, 48); + return CGSizeMake(width, 41); } -- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return 10.0; } -- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return 12.0; } +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section { return kKBItemSpace; } +- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section { return kKBItemSpace; } - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath { if ([self.delegate respondsToSelector:@selector(tagListView:didSelectIndex:title:)]) { diff --git a/CustomKeyboard/View/KBFunctionBarView.h b/CustomKeyboard/View/KBFunctionBarView.h index e422613..cf3a12a 100644 --- a/CustomKeyboard/View/KBFunctionBarView.h +++ b/CustomKeyboard/View/KBFunctionBarView.h @@ -9,7 +9,9 @@ NS_ASSUME_NONNULL_BEGIN -/// 功能区顶部的Bar:左侧4个按钮,右侧3个按钮 +/// 功能区顶部的 Bar: +/// 左侧:App 图标按钮(点击可回到主 App 或打开更多功能) +/// 右侧:升级 VIP 按钮 @class KBFunctionBarView; @protocol KBFunctionBarViewDelegate @@ -24,15 +26,15 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak, nullable) id delegate; -/// 左侧4个按钮(懒加载创建,等宽水平排布) +/// 左侧按钮(当前只有一个:App 图标) @property (nonatomic, strong, readonly) NSArray *leftButtons; -/// 右侧3个按钮(懒加载创建,等宽水平排布,靠右) +/// 右侧按钮(当前只有一个:升级 VIP) @property (nonatomic, strong, readonly) NSArray *rightButtons; -/// 配置按钮标题(可选) -@property (nonatomic, copy) NSArray *leftTitles; // 默认 @[@"帮回", @"会说", @"话术", @"更多"] -@property (nonatomic, copy) NSArray *rightTitles; // 默认 @[@"❤", @"收藏", @"宫格"] +/// 预留的标题配置(目前按钮主要以图片为主,可选) +@property (nonatomic, copy) NSArray *leftTitles; +@property (nonatomic, copy) NSArray *rightTitles; @end diff --git a/CustomKeyboard/View/KBFunctionBarView.m b/CustomKeyboard/View/KBFunctionBarView.m index 1121e45..27ba738 100644 --- a/CustomKeyboard/View/KBFunctionBarView.m +++ b/CustomKeyboard/View/KBFunctionBarView.m @@ -22,8 +22,9 @@ - (instancetype)initWithFrame:(CGRect)frame{ if (self = [super initWithFrame:frame]) { self.backgroundColor = [UIColor clearColor]; - _leftTitles = @[@"ABC"]; - _rightTitles = @[@"Upgrade VIP"]; + // 标题字段暂时不用,预留给后续可能的文案按钮 + _leftTitles = @[]; + _rightTitles = @[]; [self buildUI]; } return self; @@ -38,91 +39,60 @@ #pragma mark - UI - (void)buildUI { - // 左右两个容器,方便分别布局 - [self addSubview:self.leftContainer]; + // 左右容器 + 可选地球键 [self addSubview:self.globeButtonInternal]; + [self addSubview:self.leftContainer]; [self addSubview:self.rightContainer]; + // 右侧:升级 VIP 按钮(使用资源图 upgrad_vip_icon,设计尺寸 115x35) [self.rightContainer mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.equalTo(self.mas_right).offset(-12); + make.right.equalTo(self.mas_right).offset(-6); make.centerY.equalTo(self.mas_centerY); - make.height.mas_equalTo(36); + make.width.mas_equalTo(115); + make.height.mas_equalTo(35); }]; - // 左侧地球键(按需显示) + UIButton *vipButton = [UIButton buttonWithType:UIButtonTypeCustom]; + vipButton.tag = 200; // 右侧 index = 0 + UIImage *vipImage = [UIImage imageNamed:@"upgrad_vip_icon"]; + [vipButton setImage:vipImage forState:UIControlStateNormal]; + vipButton.imageView.contentMode = UIViewContentModeScaleAspectFit; + vipButton.adjustsImageWhenHighlighted = YES; + [vipButton addTarget:self action:@selector(onRightTap:) forControlEvents:UIControlEventTouchUpInside]; + [self.rightContainer addSubview:vipButton]; + [vipButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self.rightContainer); + }]; + self.rightButtonsInternal = @[vipButton]; + + // 左侧地球键(按需显示,由 kb_refreshGlobeVisibility 控制是否展示) [self.globeButtonInternal mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.mas_left).offset(12); make.centerY.equalTo(self.mas_centerY); make.width.height.mas_equalTo(32); }]; + // 左侧:App 图标按钮(使用资源图 App_icon,图标 34x34,按钮容器 36x36) [self.leftContainer mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.globeButtonInternal.mas_right).offset(8); - make.right.equalTo(self.rightContainer.mas_left).offset(-12); make.centerY.equalTo(self.mas_centerY); + make.width.mas_equalTo(36); make.height.mas_equalTo(36); + make.left.equalTo(self.mas_left).offset(12); // 具体偏移在 kb_refreshGlobeVisibility 中会根据地球键重新设置 }]; - // 左侧4个等宽按钮 - NSMutableArray *leftBtns = [NSMutableArray arrayWithCapacity:4]; - UIView *prev = nil; - for (NSInteger i = 0; i < self.leftTitles.count; i++) { - UIButton *btn = [self buildButtonWithTitle:(i < self.leftTitles.count ? self.leftTitles[i] : [NSString stringWithFormat:@"L%ld", (long)i])]; - btn.tag = 100 + i; - [btn addTarget:self action:@selector(onLeftTap:) forControlEvents:UIControlEventTouchUpInside]; - [self.leftContainer addSubview:btn]; - [btn mas_makeConstraints:^(MASConstraintMaker *make) { - if (prev) { - make.left.equalTo(prev.mas_right).offset(8); - make.width.equalTo(prev); - } else { - make.left.equalTo(self.leftContainer.mas_left); - } - make.top.bottom.equalTo(self.leftContainer); - }]; - prev = btn; - [leftBtns addObject:btn]; - } - [prev mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.equalTo(self.leftContainer.mas_right); + UIButton *appButton = [UIButton buttonWithType:UIButtonTypeCustom]; + appButton.tag = 100; // 左侧 index = 0 + UIImage *appImage = [UIImage imageNamed:@"App_icon"]; + [appButton setImage:appImage forState:UIControlStateNormal]; + appButton.imageView.contentMode = UIViewContentModeScaleAspectFit; + appButton.adjustsImageWhenHighlighted = YES; + [appButton addTarget:self action:@selector(onLeftTap:) forControlEvents:UIControlEventTouchUpInside]; + [self.leftContainer addSubview:appButton]; + [appButton mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.equalTo(self.leftContainer); + make.width.height.mas_equalTo(34); // 设计图尺寸 }]; - self.leftButtonsInternal = leftBtns.copy; - - // 右侧N个按钮(靠右、两两等宽) - NSMutableArray *rightBtns = [NSMutableArray arrayWithCapacity:3]; - for (NSInteger i = 0; i < self.rightTitles.count; i++) { - UIButton *btn = [self buildButtonWithTitle:(i < self.rightTitles.count ? self.rightTitles[i] : [NSString stringWithFormat:@"R%ld", (long)i])]; - btn.tag = 200 + i; - [self.rightContainer addSubview:btn]; - [btn addTarget:self action:@selector(onRightTap:) forControlEvents:UIControlEventTouchUpInside]; - [rightBtns addObject:btn]; - } - - // 从右往左链式布局,保证整体靠右;支持 1/2/3... 任意数量 - UIView *prevRight = nil; // 指向右侧已布局的按钮 - for (NSInteger i = rightBtns.count - 1; i >= 0; i--) { - UIButton *btn = rightBtns[i]; - [btn mas_makeConstraints:^(MASConstraintMaker *make) { - if (!prevRight) { - // 最右侧按钮贴右 - make.right.equalTo(self.rightContainer.mas_right); - } else { - // 其余按钮紧挨左侧兄弟,且与其等宽 - make.right.equalTo(prevRight.mas_left).offset(-8); - make.width.equalTo(prevRight); - } - make.top.bottom.equalTo(self.rightContainer); - }]; - prevRight = btn; - } - // 最左侧一个不超出容器左边(允许根据内容自然宽度收缩) - if (prevRight) { - [prevRight mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.greaterThanOrEqualTo(self.rightContainer.mas_left); - }]; - } - - self.rightButtonsInternal = rightBtns.copy; + self.leftButtonsInternal = @[appButton]; // 初始刷新地球键可见性与事件绑定 [self kb_refreshGlobeVisibility]; @@ -144,17 +114,6 @@ } } -- (UIButton *)buildButtonWithTitle:(NSString *)title { - UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; - btn.layer.cornerRadius = 18; - btn.layer.masksToBounds = YES; - btn.backgroundColor = [UIColor colorWithWhite:1 alpha:0.9]; - btn.titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium]; - [btn setTitle:title forState:UIControlStateNormal]; - [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; - return btn; -} - #pragma mark - Lazy - (UIView *)leftContainer { @@ -201,8 +160,8 @@ } else { make.left.equalTo(self.mas_left).offset(12); } - make.right.equalTo(self.rightContainer.mas_left).offset(-12); make.centerY.equalTo(self.mas_centerY); + make.width.mas_equalTo(36); make.height.mas_equalTo(36); }]; diff --git a/CustomKeyboard/View/KBFunctionPasteView.m b/CustomKeyboard/View/KBFunctionPasteView.m index 93b8f8c..ebdcf73 100644 --- a/CustomKeyboard/View/KBFunctionPasteView.m +++ b/CustomKeyboard/View/KBFunctionPasteView.m @@ -7,10 +7,13 @@ #import "KBFunctionPasteView.h" #import "Masonry.h" +#import "KBFont.h" @interface KBFunctionPasteView () @property (nonatomic, strong) UIImageView *iconViewInternal; @property (nonatomic, strong) UILabel *placeholderLabelInternal; +@property (nonatomic, strong) UIButton *pasBtn; + @end @implementation KBFunctionPasteView @@ -22,19 +25,24 @@ self.layer.cornerRadius = 12.0; self.layer.masksToBounds = YES; - [self addSubview:self.iconViewInternal]; - [self addSubview:self.placeholderLabelInternal]; +// [self addSubview:self.iconViewInternal]; +// [self addSubview:self.placeholderLabelInternal]; + [self addSubview:self.pasBtn]; + [self.pasBtn mas_makeConstraints:^(MASConstraintMaker *make) { + make.edges.equalTo(self); + }]; - [self.iconViewInternal mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.mas_left).offset(12); - make.centerY.equalTo(self.mas_centerY); - make.width.height.mas_equalTo(20); - }]; - [self.placeholderLabelInternal mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.iconViewInternal.mas_right).offset(8); - make.right.equalTo(self.mas_right).offset(-12); - make.centerY.equalTo(self.mas_centerY); - }]; +// [self.iconViewInternal mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.equalTo(self.mas_left).offset(12); +// make.centerY.equalTo(self.mas_centerY); +// make.width.height.mas_equalTo(20); +// }]; +// [self.placeholderLabelInternal mas_makeConstraints:^(MASConstraintMaker *make) { +// make.left.equalTo(self.iconViewInternal.mas_right).offset(8); +// make.right.equalTo(self.mas_right).offset(-12); +// make.centerY.equalTo(self.mas_centerY); +// }]; + } return self; } @@ -44,15 +52,7 @@ - (UIImageView *)iconViewInternal { if (!_iconViewInternal) { _iconViewInternal = [[UIImageView alloc] init]; - // 用简单的系统表情代替资源图(项目可替换成实际图片) - UILabel *emoji = [[UILabel alloc] init]; - emoji.text = @"📋"; // 粘贴/剪贴板含义 - emoji.font = [UIFont systemFontOfSize:18]; - emoji.textAlignment = NSTextAlignmentCenter; - [_iconViewInternal addSubview:emoji]; - [emoji mas_makeConstraints:^(MASConstraintMaker *make) { - make.edges.equalTo(_iconViewInternal); - }]; + _iconViewInternal.image = [UIImage imageNamed:@"kb_zt_icon"]; } return _iconViewInternal; } @@ -60,13 +60,26 @@ - (UILabel *)placeholderLabelInternal { if (!_placeholderLabelInternal) { _placeholderLabelInternal = [[UILabel alloc] init]; - _placeholderLabelInternal.text = KBLocalized(@"Tap to paste their message"); + // 文案改为更贴近设计稿 + _placeholderLabelInternal.text = KBLocalized(@"Paste Ta's Words"); _placeholderLabelInternal.textColor = [UIColor colorWithRed:0.20 green:0.64 blue:0.54 alpha:1.0]; _placeholderLabelInternal.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; } return _placeholderLabelInternal; } +- (UIButton *)pasBtn{ + if (!_pasBtn) { + _pasBtn = [UIButton buttonWithType:UIButtonTypeCustom]; + [_pasBtn setImage:[UIImage imageNamed:@"kb_zt_icon"] forState:UIControlStateNormal]; + [_pasBtn setTitle:KBLocalized(@" Paste Ta's Words") forState:UIControlStateNormal]; + [_pasBtn setTitleColor:[UIColor colorWithHex:0x02BEAC] forState:UIControlStateNormal]; + _pasBtn.titleLabel.font = [KBFont medium:13]; + _pasBtn.backgroundColor = [UIColor whiteColor]; + } + return _pasBtn; +} + #pragma mark - Expose - (UIImageView *)iconView { return self.iconViewInternal; } diff --git a/CustomKeyboard/View/KBFunctionTagCell.m b/CustomKeyboard/View/KBFunctionTagCell.m index d848f63..976a488 100644 --- a/CustomKeyboard/View/KBFunctionTagCell.m +++ b/CustomKeyboard/View/KBFunctionTagCell.m @@ -22,26 +22,38 @@ self.contentView.layer.cornerRadius = 12; self.contentView.layer.masksToBounds = YES; - [self.contentView addSubview:self.iconViewInternal]; - [self.contentView addSubview:self.titleLabelInternal]; + // 小菊花:默认隐藏,放在整体内容右侧偏内的位置 + [self.contentView addSubview:self.loadingView]; + [self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) { + make.center.equalTo(self.contentView); + make.width.height.mas_equalTo(16); + }]; + + // 中心容器:将 icon + title 组合整体水平居中 + UIView *centerContainer = [[UIView alloc] init]; + centerContainer.backgroundColor = [UIColor clearColor]; + [self.contentView addSubview:centerContainer]; + [centerContainer mas_makeConstraints:^(MASConstraintMaker *make) { + make.centerX.equalTo(self.contentView.mas_centerX); + make.centerY.equalTo(self.contentView.mas_centerY); + make.left.greaterThanOrEqualTo(self.contentView.mas_left).offset(6); + make.right.lessThanOrEqualTo(self.contentView).offset(-6); + }]; + + [centerContainer addSubview:self.iconViewInternal]; + [centerContainer addSubview:self.titleLabelInternal]; [self.iconViewInternal mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.contentView.mas_left).offset(10); - make.centerY.equalTo(self.contentView.mas_centerY); + make.left.equalTo(centerContainer.mas_left); + make.centerY.equalTo(centerContainer.mas_centerY); + // 留出一点余量,避免 emoji 字形在右侧被裁剪 make.width.height.mas_equalTo(24); }]; [self.titleLabelInternal mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.iconViewInternal.mas_right).offset(6); - make.right.equalTo(self.contentView.mas_right).offset(-10); - make.centerY.equalTo(self.contentView.mas_centerY); - }]; - - // 小菊花:默认隐藏,放在标题右侧 - [self.contentView addSubview:self.loadingView]; - [self.loadingView mas_makeConstraints:^(MASConstraintMaker *make) { - make.centerY.equalTo(self.contentView); - make.right.equalTo(self.contentView.mas_right).offset(-10); - make.width.height.mas_equalTo(16); + make.left.equalTo(self.iconViewInternal.mas_right).offset(3); + make.top.equalTo(centerContainer.mas_top); + make.bottom.equalTo(centerContainer.mas_bottom); + make.right.equalTo(centerContainer.mas_right); }]; } return self; @@ -56,6 +68,8 @@ emoji.text = @"🙂"; // 占位图标 emoji.textAlignment = NSTextAlignmentCenter; emoji.font = [UIFont systemFontOfSize:20]; + emoji.adjustsFontSizeToFitWidth = YES; + emoji.minimumScaleFactor = 0.8; [_iconViewInternal addSubview:emoji]; [emoji mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(_iconViewInternal); @@ -67,8 +81,11 @@ - (UILabel *)titleLabelInternal { if (!_titleLabelInternal) { _titleLabelInternal = [[UILabel alloc] init]; - _titleLabelInternal.font = [UIFont systemFontOfSize:15 weight:UIFontWeightSemibold]; - _titleLabelInternal.textColor = [UIColor blackColor]; + _titleLabelInternal.font = [KBFont medium:10]; + _titleLabelInternal.textColor = [UIColor colorWithHex:0x1B1F1A]; + // 最多两行,文本过长时末尾截断 + _titleLabelInternal.numberOfLines = 2; + _titleLabelInternal.lineBreakMode = NSLineBreakByTruncatingTail; } return _titleLabelInternal; } diff --git a/CustomKeyboard/View/KBFunctionView.h b/CustomKeyboard/View/KBFunctionView.h index 958461a..6266c07 100644 --- a/CustomKeyboard/View/KBFunctionView.h +++ b/CustomKeyboard/View/KBFunctionView.h @@ -11,6 +11,8 @@ @protocol KBFunctionViewDelegate @optional - (void)functionView:(KBFunctionView *_Nullable)functionView didTapToolActionAtIndex:(NSInteger)index; +- (void)functionView:(KBFunctionView *_Nullable)functionView didRightTapToolActionAtIndex:(NSInteger)index; + @end NS_ASSUME_NONNULL_BEGIN diff --git a/CustomKeyboard/View/KBFunctionView.m b/CustomKeyboard/View/KBFunctionView.m index 2f78e9b..b4a99c7 100644 --- a/CustomKeyboard/View/KBFunctionView.m +++ b/CustomKeyboard/View/KBFunctionView.m @@ -106,16 +106,16 @@ [self.barViewInternal mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self); make.top.equalTo(self.mas_top).offset(6); - make.height.mas_equalTo(48); + make.height.mas_equalTo(52); }]; // 右侧竖排按钮容器 [self addSubview:self.rightButtonContainer]; [self.rightButtonContainer mas_makeConstraints:^(MASConstraintMaker *make) { - make.right.equalTo(self.mas_right).offset(-6); - make.top.equalTo(self.barViewInternal.mas_bottom).offset(8); + make.right.equalTo(self.mas_right).offset(-4); + make.top.equalTo(self.barViewInternal.mas_bottom).offset(0); make.bottom.equalTo(self.mas_bottom).offset(-10); - make.width.mas_equalTo(72); + make.width.mas_equalTo(60); }]; // 右侧四个按钮 @@ -125,10 +125,10 @@ [self.rightButtonContainer addSubview:self.sendButtonInternal]; // 竖向排布:粘贴、删除、清空为等高;发送优先更高,但允许在空间不足时压缩 - CGFloat smallH = 44; + CGFloat smallH = 41; CGFloat bigH = 56; // 原 10 在键盘总高度 276 下容易超出容器,改为 8 以避免 AutoLayout 冲突 - CGFloat vSpace = 8; + CGFloat vSpace = 4; [self.pasteButtonInternal mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.rightButtonContainer.mas_top); make.left.right.equalTo(self.rightButtonContainer); @@ -156,18 +156,18 @@ // 2. 粘贴区(位于右侧按钮左侧) [self addSubview:self.pasteViewInternal]; [self.pasteViewInternal mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.mas_left).offset(12); - make.right.equalTo(self.rightButtonContainer.mas_left).offset(-12); - make.top.equalTo(self.barViewInternal.mas_bottom).offset(8); - make.height.mas_equalTo(48); + make.left.equalTo(self.mas_left).offset(vSpace); + make.right.equalTo(self.rightButtonContainer.mas_left).offset(-vSpace); + make.top.equalTo(self.barViewInternal.mas_bottom).offset(0); + make.height.mas_equalTo(smallH); }]; // 3. Tag List View [self addSubview:self.tagListView]; [self.tagListView mas_makeConstraints:^(MASConstraintMaker *make) { - make.left.equalTo(self.mas_left).offset(12); - make.right.equalTo(self.rightButtonContainer.mas_left).offset(-12); - make.top.equalTo(self.pasteViewInternal.mas_bottom).offset(10); + make.left.equalTo(self.pasteViewInternal); + make.right.equalTo(self.rightButtonContainer.mas_left).offset(-vSpace); + make.top.equalTo(self.pasteViewInternal.mas_bottom).offset(vSpace); make.bottom.equalTo(self.mas_bottom).offset(-10); }]; } @@ -176,13 +176,13 @@ - (void)reloadDemoData { // 演示数据(可由外部替换) - self.itemsInternal = @[KBLocalized(@"高情商"), - KBLocalized(@"暖味拉扯"), - KBLocalized(@"风趣幽默"), - KBLocalized(@"撩女生"), - KBLocalized(@"社交惬匿"), - KBLocalized(@"情场高手"), - KBLocalized(@"一枚暖男"), + self.itemsInternal = @[KBLocalized(@"Warm hearted man"), + KBLocalized(@"Warm2 hearted man"), + KBLocalized(@"Warm3 hearted man"), + KBLocalized(@"撩女生啊u发顺丰大师傅"), + KBLocalized(@"Warm = man"), + KBLocalized(@"Warm hearted man"), + KBLocalized(@"一枚暖男发放"), KBLocalized(@"聊天搭子"), KBLocalized(@"表达爱意"), KBLocalized(@"更多话术")]; @@ -537,6 +537,9 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C - (void)functionBarView:(KBFunctionBarView *)bar didTapRightAtIndex:(NSInteger)index { // 右侧按钮点击,如收藏/宫格等,按需继续向外抛出(这里暂不定义单独协议方法,可在此内部处理或扩展) + if ([self.delegate respondsToSelector:@selector(functionView:didRightTapToolActionAtIndex:)]) { + [self.delegate functionView:self didRightTapToolActionAtIndex:index]; + } } - (KBFunctionPasteView *)pasteViewInternal { @@ -563,11 +566,11 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C } - (UIButton *)buildRightButtonWithTitle:(NSString *)title color:(UIColor *)color { - UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem]; + UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; btn.backgroundColor = color; - btn.layer.cornerRadius = 12.0; + btn.layer.cornerRadius = 8.0; btn.layer.masksToBounds = YES; - btn.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; + btn.titleLabel.font = [KBFont medium:13]; [btn setTitle:title forState:UIControlStateNormal]; [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; return btn; @@ -583,14 +586,12 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C - (UIButton *)deleteButtonInternal { if (!_deleteButtonInternal) { - // 浅灰底深色文字,更接近截图里“删除”样式 - _deleteButtonInternal = [UIButton buttonWithType:UIButtonTypeSystem]; - _deleteButtonInternal.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0]; - _deleteButtonInternal.layer.cornerRadius = 12.0; + _deleteButtonInternal = [UIButton buttonWithType:UIButtonTypeCustom]; + _deleteButtonInternal.backgroundColor = [UIColor colorWithHex:0xB9BDC8]; + _deleteButtonInternal.layer.cornerRadius = 8.0; _deleteButtonInternal.layer.masksToBounds = YES; - _deleteButtonInternal.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; - [_deleteButtonInternal setTitle:KBLocalized(@"Delete") forState:UIControlStateNormal]; - [_deleteButtonInternal setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; + [_deleteButtonInternal setImage:[UIImage imageNamed:@"kb_del_icon"] forState:UIControlStateNormal]; + [_deleteButtonInternal addTarget:self action:@selector(onTapDelete) forControlEvents:UIControlEventTouchUpInside]; } return _deleteButtonInternal; @@ -598,11 +599,11 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C - (UIButton *)clearButtonInternal { if (!_clearButtonInternal) { - _clearButtonInternal = [UIButton buttonWithType:UIButtonTypeSystem]; - _clearButtonInternal.backgroundColor = [UIColor colorWithWhite:0.92 alpha:1.0]; - _clearButtonInternal.layer.cornerRadius = 12.0; + _clearButtonInternal = [UIButton buttonWithType:UIButtonTypeCustom]; + _clearButtonInternal.backgroundColor = [UIColor colorWithHex:0xB9BDC8]; + _clearButtonInternal.layer.cornerRadius = 8.0; _clearButtonInternal.layer.masksToBounds = YES; - _clearButtonInternal.titleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightSemibold]; + _clearButtonInternal.titleLabel.font = [KBFont medium:13]; [_clearButtonInternal setTitle:KBLocalized(@"Clear") forState:UIControlStateNormal]; [_clearButtonInternal setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [_clearButtonInternal addTarget:self action:@selector(onTapClear) forControlEvents:UIControlEventTouchUpInside]; @@ -610,9 +611,9 @@ static void KBULDarwinCallback(CFNotificationCenterRef center, void *observer, C return _clearButtonInternal; } - - (UIButton *)sendButtonInternal { +- (UIButton *)sendButtonInternal { if (!_sendButtonInternal) { - _sendButtonInternal = [self buildRightButtonWithTitle:KBLocalized(@"Send") color:[UIColor colorWithRed:0.13 green:0.73 blue:0.60 alpha:1.0]]; + _sendButtonInternal = [self buildRightButtonWithTitle:KBLocalized(@"Send") color:[UIColor colorWithHex:0x02BEAC]]; [_sendButtonInternal addTarget:self action:@selector(onTapSend) forControlEvents:UIControlEventTouchUpInside]; } return _sendButtonInternal; diff --git a/Shared/Localization/en.lproj/Localizable.strings b/Shared/Localization/en.lproj/Localizable.strings index 078ec6b..b74895d 100644 --- a/Shared/Localization/en.lproj/Localizable.strings +++ b/Shared/Localization/en.lproj/Localizable.strings @@ -110,6 +110,8 @@ "Gender" = "Gender"; "User ID" = "User ID"; +" Paste Ta's Words" = " Paste Ta's Words"; + // Search & history "Clear history" = "Clear history"; diff --git a/Shared/Localization/zh-Hans.lproj/Localizable.strings b/Shared/Localization/zh-Hans.lproj/Localizable.strings index 96b32af..8e09c28 100644 --- a/Shared/Localization/zh-Hans.lproj/Localizable.strings +++ b/Shared/Localization/zh-Hans.lproj/Localizable.strings @@ -111,6 +111,8 @@ "Gender" = "性别"; "User ID" = "用户ID"; +" Paste Ta's Words" = " 粘贴TA的话"; + // 搜索与历史(英文 key) "Clear history" = "清空历史"; "Delete all history?" = "是否删除所有历史记录?"; diff --git a/keyBoard/AppDelegate.m b/keyBoard/AppDelegate.m index e7340ef..565e703 100644 --- a/keyBoard/AppDelegate.m +++ b/keyBoard/AppDelegate.m @@ -23,6 +23,7 @@ #import "FGIAPManager.h" #import "KBSexSelVC.h" #import "KBKeyboardPermissionManager.h" +#import "KBVipPay.h" // 注意:用于判断系统已启用本输入法扩展的 bundle id 需与扩展 target 的 // PRODUCT_BUNDLE_IDENTIFIER 完全一致。 @@ -140,7 +141,8 @@ NULL, NULL, true); if ([entry isEqualToString:@"recharge"]) { // 充值入口:拉起主 App 后进入充值相关页面(目前先做占位提示) - [KBHUD showInfo:@"去充值"]; +// [KBHUD showInfo:@"去充值"]; + } else { // 默认逻辑:登录 [self kb_presentLoginSheetIfNeeded]; @@ -171,7 +173,9 @@ return YES; }else if ([host isEqualToString:@"recharge"]) { // kbkeyboard://settings // [self kb_openAppSettings]; - [KBHUD showInfo:@"去充值"]; +// [KBHUD showInfo:@"去充值"]; + KBVipPay *vc = [[KBVipPay alloc] init]; + [KB_CURRENT_NAV pushViewController:vc animated:true]; return YES; } return NO;