This commit is contained in:
2025-10-30 20:23:34 +08:00
parent 9af91cc4bc
commit 247a87891e
8 changed files with 302 additions and 17 deletions

View File

@@ -24,6 +24,9 @@ static CGFloat KEYBOARDHEIGHT = 256 + 20;
@implementation KeyboardViewController
{
BOOL _kb_didTriggerLoginDeepLinkOnce;
}
- (void)viewDidLoad {
[super viewDidLoad];
@@ -72,16 +75,16 @@ static CGFloat KEYBOARDHEIGHT = 256 + 20;
/// / keyBoardMainView /
- (void)showSettingView:(BOOL)show {
if (show) {
// if (!self.settingView) {
self.settingView = [[KBSettingView alloc] init];
self.settingView.hidden = YES;
[self.view addSubview:self.settingView];
[self.settingView mas_makeConstraints:^(MASConstraintMaker *make) {
//
make.edges.equalTo(self.keyBoardMainView);
}];
[self.settingView.backButton addTarget:self action:@selector(onTapSettingsBack) forControlEvents:UIControlEventTouchUpInside];
// }
// if (!self.settingView) {
self.settingView = [[KBSettingView alloc] init];
self.settingView.hidden = YES;
[self.view addSubview:self.settingView];
[self.settingView mas_makeConstraints:^(MASConstraintMaker *make) {
//
make.edges.equalTo(self.keyBoardMainView);
}];
[self.settingView.backButton addTarget:self action:@selector(onTapSettingsBack) forControlEvents:UIControlEventTouchUpInside];
// }
[self.view bringSubviewToFront:self.settingView];
// keyBoardMainView self.view
[self.view layoutIfNeeded];
@@ -183,4 +186,23 @@ static CGFloat KEYBOARDHEIGHT = 256 + 20;
[self showSettingView:NO];
}
// App App
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (!_kb_didTriggerLoginDeepLinkOnce) {
_kb_didTriggerLoginDeepLinkOnce = YES;
[self kb_tryOpenContainerForLoginIfNeeded];
}
}
- (void)kb_tryOpenContainerForLoginIfNeeded {
NSURL *url = [NSURL URLWithString:@"kbkeyboard://login?src=keyboard"];
if (!url) return;
__weak typeof(self) weakSelf = self;
[self.extensionContext openURL:url completionHandler:^(__unused BOOL success) {
// 使
__unused typeof(weakSelf) selfStrong = weakSelf;
}];
}
@end

View File

@@ -10,6 +10,7 @@
#import "KBFunctionPasteView.h"
#import "KBFunctionTagCell.h"
#import "Masonry.h"
#import <MBProgressHUD.h>
static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
@@ -160,6 +161,26 @@ static NSString * const kKBFunctionTagCellId = @"KBFunctionTagCellId";
return 12.0;
}
// App App
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
UIInputViewController *ivc = [self findInputViewController];
if (!ivc) return;
NSString *title = (indexPath.item < self.itemsInternal.count) ? self.itemsInternal[indexPath.item] : @"";
NSString *encodedTitle = [title stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]] ?: @"";
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"kbkeyboard://login?src=functionView&index=%ld&title=%@", (long)indexPath.item, encodedTitle]];
if (!url) return;
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.05 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[ivc.extensionContext openURL:url completionHandler:^(BOOL success) {
if (!success) {
NSLog(@"[KB] openURL failed. Likely Full Access is OFF. 请到 设置>通用>键盘>键盘>你的键盘 开启“允许完全访问”。");
}
}];
});
}
#pragma mark - Button Actions
- (void)onTapPaste {