This commit is contained in:
2026-03-02 09:19:06 +08:00
parent da4649101e
commit 781e557e80
34 changed files with 3926 additions and 87 deletions

View File

@@ -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 {