1
This commit is contained in:
@@ -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