1
This commit is contained in:
@@ -45,6 +45,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/// 更新联想候选
|
||||
- (void)kb_setSuggestions:(NSArray<NSString *> *)suggestions;
|
||||
|
||||
/// 根据 profileId 重新加载键盘布局
|
||||
- (void)reloadLayoutWithProfileId:(NSString *)profileId;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@@ -305,4 +305,13 @@
|
||||
self.suggestionBar.alpha = shouldShow ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
- (void)reloadLayoutWithProfileId:(NSString *)profileId {
|
||||
if (profileId.length == 0) {
|
||||
NSLog(@"[KBKeyBoardMainView] reloadLayoutWithProfileId: empty profileId");
|
||||
return;
|
||||
}
|
||||
NSLog(@"[KBKeyBoardMainView] Reloading layout with profileId: %@", profileId);
|
||||
[self.keyboardView reloadLayoutWithProfileId:profileId];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -27,7 +27,9 @@ typedef NS_ENUM(NSInteger, KBKeyboardLayoutStyle) {
|
||||
@property (nonatomic, assign, getter=isShiftOn) BOOL shiftOn; // 大小写状态
|
||||
// 在数字布局中,是否显示“更多符号”(#+=)页
|
||||
@property (nonatomic, assign) BOOL symbolsMoreOn;
|
||||
@property (nonatomic, copy) NSString *currentLayoutJsonId; // 当前使用的布局 JSON ID
|
||||
|
||||
- (void)reloadKeys; // 当布局样式/大小写变化时调用
|
||||
- (void)reloadLayoutWithProfileId:(NSString *)profileId; // 根据 profileId 重新加载布局
|
||||
|
||||
@end
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#import "KBKeyPreviewView.h"
|
||||
#import "KBBackspaceLongPressHandler.h"
|
||||
#import "KBKeyboardLayoutConfig.h"
|
||||
#import "KBKeyboardLayoutResolver.h"
|
||||
|
||||
// UI 常量统一管理,方便后续调试样式(以 375 宽设计稿为基准,通过 KBFit 做等比缩放)
|
||||
#define kKBRowVerticalSpacing KBFit(8.0f)
|
||||
@@ -46,6 +47,17 @@ static const CGFloat kKBLettersRow2EdgeSpacerMultiplier = 0.5;
|
||||
// 默认小写:与需求一致,初始不开启 Shift
|
||||
_shiftOn = NO;
|
||||
_symbolsMoreOn = NO; // 数字面板默认第一页(123)
|
||||
|
||||
// 从 App Group 读取当前 profileId 并设置布局
|
||||
NSString *profileId = [[KBKeyboardLayoutResolver sharedResolver] currentProfileId];
|
||||
if (profileId.length > 0) {
|
||||
_currentLayoutJsonId = [[KBKeyboardLayoutResolver sharedResolver] layoutJsonIdForProfileId:profileId];
|
||||
NSLog(@"[KBKeyboardView] Loaded profileId: %@, layoutJsonId: %@", profileId, _currentLayoutJsonId);
|
||||
} else {
|
||||
_currentLayoutJsonId = @"letters";
|
||||
NSLog(@"[KBKeyboardView] No profileId found, using default 'letters'");
|
||||
}
|
||||
|
||||
self.layoutConfig = [KBKeyboardLayoutConfig sharedConfig];
|
||||
self.backspaceHandler = [[KBBackspaceLongPressHandler alloc] initWithContainerView:self];
|
||||
[self buildBase];
|
||||
@@ -866,7 +878,28 @@ edgeSpacerMultiplier:(CGFloat)edgeSpacerMultiplier {
|
||||
if (self.layoutStyle == KBKeyboardLayoutStyleNumbers) {
|
||||
return [self kb_layoutForName:(self.symbolsMoreOn ? @"symbolsMore" : @"numbers")];
|
||||
}
|
||||
return [self kb_layoutForName:@"letters"];
|
||||
// 使用当前设置的 layoutJsonId,如果为空则回退到 "letters"
|
||||
NSString *layoutName = self.currentLayoutJsonId.length > 0 ? self.currentLayoutJsonId : @"letters";
|
||||
return [self kb_layoutForName:layoutName];
|
||||
}
|
||||
|
||||
- (void)reloadLayoutWithProfileId:(NSString *)profileId {
|
||||
if (profileId.length == 0) {
|
||||
NSLog(@"[KBKeyboardView] reloadLayoutWithProfileId: empty profileId, ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *newLayoutJsonId = [[KBKeyboardLayoutResolver sharedResolver] layoutJsonIdForProfileId:profileId];
|
||||
if ([newLayoutJsonId isEqualToString:self.currentLayoutJsonId]) {
|
||||
NSLog(@"[KBKeyboardView] Layout already loaded: %@", newLayoutJsonId);
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"[KBKeyboardView] Switching layout from %@ to %@", self.currentLayoutJsonId, newLayoutJsonId);
|
||||
self.currentLayoutJsonId = newLayoutJsonId;
|
||||
|
||||
// 重新加载键盘布局
|
||||
[self reloadKeys];
|
||||
}
|
||||
|
||||
- (void)kb_buildLegacyLayout {
|
||||
|
||||
Reference in New Issue
Block a user