This commit is contained in:
2025-11-12 21:23:31 +08:00
parent 0aead49816
commit bc261661ae
7 changed files with 317 additions and 24 deletions

View File

@@ -16,6 +16,9 @@
#import "KBLoginSheetViewController.h"
#import "AppleSignInManager.h"
#import <objc/message.h>
#import "KBULBridge.h" // Darwin UL
#import "LSTPopView.h"
#import "KBLoginPopView.h"
// bundle id target
// PRODUCT_BUNDLE_IDENTIFIER
@@ -69,7 +72,14 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
if ([host hasSuffix:@"app.tknb.net"]) {
NSString *path = url.path.lowercaseString ?: @"";
if ([path hasPrefix:@"/ul/settings"]) { [self kb_openAppSettings]; return YES; }
if ([path hasPrefix:@"/ul/login"]) { [self kb_presentLoginSheetIfNeeded]; return YES; }
if ([path hasPrefix:@"/ul/login"]) {
// UL App 退 Scheme
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(),
(__bridge CFStringRef)KBDarwinULHandled,
NULL, NULL, true);
[self kb_presentLoginSheetIfNeeded];
return YES;
}
}
}
return NO;
@@ -83,6 +93,10 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
NSString *urlHost = url.host ?: @"";
NSString *host = [urlHost lowercaseString];
if ([host isEqualToString:@"login"]) { // kbkeyboard://login
// Scheme
CFNotificationCenterPostNotification(CFNotificationCenterGetDarwinNotifyCenter(),
(__bridge CFStringRef)KBDarwinULHandled,
NULL, NULL, true);
[self kb_presentLoginSheetIfNeeded];
return YES;
} else if ([host isEqualToString:@"settings"]) { // kbkeyboard://settings
@@ -100,7 +114,37 @@ static NSString * const kKBKeyboardExtensionBundleId = @"com.loveKey.nyx.CustomK
if (loggedIn) return;
UIViewController *top = [UIViewController kb_topMostViewController];
if (!top) return;
[KBLoginSheetViewController presentIfNeededFrom:top];
// [KBLoginSheetViewController presentIfNeededFrom:top];
[self goLogin];
}
- (void)goLogin{
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
KBLoginPopView *view = [[KBLoginPopView alloc] initWithFrame:CGRectMake(0, 0, KB_SCREEN_WIDTH, KB_SCREEN_WIDTH)];
//
LSTPopView *pop = [LSTPopView initWithCustomView:view
parentView:nil
popStyle:LSTPopStyleSmoothFromBottom
dismissStyle:LSTDismissStyleSmoothToBottom];
pop.hemStyle = LSTHemStyleBottom;
pop.bgColor = [[UIColor blackColor] colorWithAlphaComponent:0.4];
pop.isClickBgDismiss = YES; //
pop.cornerRadius = 0; // view
__weak typeof(pop) weakPop = pop;
view.appleLoginHandler = ^{
[weakPop dismiss];
[[AppleSignInManager shared] signInFromViewController:KB_CURRENT_NAV completion:^(ASAuthorizationAppleIDCredential * _Nullable credential, NSError * _Nullable error) {
NSLog(@"=====");
}];
};
view.closeHandler = ^{ [weakPop dismiss]; };
[pop pop];
});
}
- (void)kb_openAppSettings {