AI键移除 放在顶部KBToolBar
This commit is contained in:
@@ -277,10 +277,6 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
title:@"123"
|
||||
output:@""
|
||||
type:KBKeyTypeModeChange];
|
||||
KBKey *customAI = [KBKey keyWithIdentifier:@"ai"
|
||||
title:@"AI"
|
||||
output:@""
|
||||
type:KBKeyTypeCustom];
|
||||
KBKey *emoji = [KBKey keyWithIdentifier:KBKeyIdentifierEmojiPanel
|
||||
title:@"😊"
|
||||
output:@""
|
||||
@@ -293,7 +289,7 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
title:KBLocalized(@"Send")
|
||||
output:@"\n"
|
||||
type:KBKeyTypeReturn];
|
||||
return @[ mode123, customAI, emoji, space, ret ];
|
||||
return @[ mode123, emoji, space, ret ];
|
||||
}
|
||||
|
||||
// 底部控制行(数字布局)
|
||||
@@ -302,10 +298,6 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
title:@"abc"
|
||||
output:@""
|
||||
type:KBKeyTypeModeChange];
|
||||
KBKey *customAI = [KBKey keyWithIdentifier:@"ai"
|
||||
title:@"AI"
|
||||
output:@""
|
||||
type:KBKeyTypeCustom];
|
||||
KBKey *emoji = [KBKey keyWithIdentifier:KBKeyIdentifierEmojiPanel
|
||||
title:@"😊"
|
||||
output:@""
|
||||
@@ -318,7 +310,7 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
title:KBLocalized(@"Send")
|
||||
output:@"\n"
|
||||
type:KBKeyTypeReturn];
|
||||
return @[ modeABC, customAI, emoji, space, ret ];
|
||||
return @[ modeABC, emoji, space, ret ];
|
||||
}
|
||||
|
||||
#pragma mark - Row Building
|
||||
@@ -332,7 +324,7 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier {
|
||||
|
||||
// 第 4 行(底部控制行)使用单独的布局规则:
|
||||
// 123/ABC、AI、Send 给定尺寸,Space 自动吃掉剩余宽度。
|
||||
// 123/ABC、Emoji、Send 给定尺寸,Space 自动吃掉剩余宽度。
|
||||
BOOL isBottomControlRow = [self kb_isBottomControlRowWithKeys:keys];
|
||||
|
||||
CGFloat spacing = 0; // 键与键之间的间距
|
||||
@@ -419,7 +411,7 @@ edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier {
|
||||
}];
|
||||
}
|
||||
|
||||
// 底部控制行:在第一轮已完成左右约束的前提下,仅给 123/ABC、AI、Send 指定宽度,
|
||||
// 底部控制行:在第一轮已完成左右约束的前提下,仅给 123/ABC、Emoji、Send 指定宽度,
|
||||
// Space 不加宽度约束,让其自动填充剩余空间。
|
||||
if (isBottomControlRow) {
|
||||
[self kb_applyBottomControlRowWidthInRow:row];
|
||||
@@ -448,7 +440,7 @@ edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier {
|
||||
}
|
||||
}
|
||||
if (firstChar) {
|
||||
// 如果该行本身没有字符键(如底部控制行),且基准按钮是 123/ABC/AI/#+= 等,
|
||||
// 如果该行本身没有字符键(如底部控制行),且基准按钮是 123/ABC/#+= 等,
|
||||
// 也将其约束为 1:1,避免 123/ABC 不是正方形。
|
||||
if (!hasCharacterInRow &&
|
||||
(firstChar.key.type == KBKeyTypeModeChange ||
|
||||
@@ -540,7 +532,7 @@ edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier {
|
||||
}
|
||||
|
||||
// 为底部控制行设置宽度:
|
||||
// - 123/ABC、AI:正方形(宽 = 行高 * multiplier)
|
||||
// - 123/ABC、Emoji:正方形(宽 = 行高 * multiplier)
|
||||
// - Send:宽 = 模式键宽度的 2 倍
|
||||
// - Space:不加宽度约束,依靠左右约束自动填充剩余空间。
|
||||
- (void)kb_applyBottomControlRowWidthInRow:(UIView *)row {
|
||||
|
||||
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol KBToolBarDelegate <NSObject>
|
||||
@optional
|
||||
/// 左侧 4 个功能按钮点击(index: 0~3)
|
||||
/// 左侧功能按钮点击(index 从 0 开始)
|
||||
- (void)toolBar:(KBToolBar *)toolBar didTapActionAtIndex:(NSInteger)index;
|
||||
/// 右侧设置按钮点击
|
||||
- (void)toolBarDidTapSettings:(KBToolBar *)toolBar;
|
||||
@@ -21,12 +21,12 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (void)toolBarDidTapUndo:(KBToolBar *)toolBar;
|
||||
@end
|
||||
|
||||
/// 顶部工具栏:左侧 4 个按钮,右侧 1 个设置按钮。
|
||||
/// 顶部工具栏:左侧按钮数量可变,右侧为设置/撤销等功能区。
|
||||
@interface KBToolBar : UIView
|
||||
|
||||
@property (nonatomic, weak, nullable) id<KBToolBarDelegate> delegate;
|
||||
|
||||
/// 左侧 4 个按钮的标题。默认值:@[@"Item1", @"Item2", @"Item3", @"Item4"]。
|
||||
/// 左侧按钮的标题(数量由数组决定)。默认值:@[@"Recharge Now", @"AI"]。
|
||||
@property (nonatomic, copy) NSArray<NSString *> *leftButtonTitles;
|
||||
|
||||
/// 暴露按钮以便外部定制(只读;首次访问时懒加载创建)
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
- (instancetype)initWithFrame:(CGRect)frame{
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
self.backgroundColor = [UIColor clearColor];
|
||||
_leftButtonTitles = @[KBLocalized(@"Recharge Now")]; // 默认标题
|
||||
_leftButtonTitles = @[KBLocalized(@"Recharge Now"), @"AI"]; // 默认标题
|
||||
[self setupUI];
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(kb_undoStateChanged)
|
||||
|
||||
Reference in New Issue
Block a user