调整逻辑

This commit is contained in:
2025-11-03 18:45:06 +08:00
parent 915b329805
commit edf88721da
10 changed files with 82 additions and 28 deletions

View File

@@ -27,6 +27,8 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
@property (nonatomic, strong) UITapGestureRecognizer *bgTap;//
@property (nonatomic, strong) NSMutableArray<NSDictionary *> *items; // [{type, text}]
///
@property (nonatomic, strong, nullable) KBPermissionViewController *permVC;
@end
@@ -80,6 +82,9 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
// /
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(kb_checkKeyboardPermission) name:UIApplicationDidBecomeActiveNotification object:nil];
//
[self kb_preparePermissionOverlayIfNeeded];
}
- (void)dealloc {
@@ -101,23 +106,26 @@ typedef NS_ENUM(NSInteger, KBGuideItemType) {
KBFARecord fa = [mgr lastKnownFullAccess];
BOOL needGuide = (!enabled) || (enabled && fa == KBFARecordDenied);
UIViewController *top = [UIViewController kb_topMostViewController];
if (needGuide) {
if (![top isKindOfClass:[KBPermissionViewController class]]) {
KBPermissionViewController *guide = [KBPermissionViewController new];
guide.modalPresentationStyle = UIModalPresentationFullScreen;
__weak typeof(self) weakSelf = self;
guide.onBack = ^{
// 退
[weakSelf.navigationController popViewControllerAnimated:YES];
};
[top presentViewController:guide animated:YES completion:nil];
}
} else {
if ([top isKindOfClass:[KBPermissionViewController class]]) {
[top dismissViewControllerAnimated:YES completion:nil];
}
}
[self kb_preparePermissionOverlayIfNeeded];
BOOL show = needGuide;
[UIView performWithoutAnimation:^{
self.permVC.view.hidden = !show;
}];
}
///
- (void)kb_preparePermissionOverlayIfNeeded {
if (self.permVC) return;
KBPermissionViewController *guide = [KBPermissionViewController new];
guide.modalPresentationStyle = UIModalPresentationFullScreen; // present
KBWeakSelf;
guide.backHandler = ^{ [weakSelf.navigationController popViewControllerAnimated:YES]; };
self.permVC = guide;
[self addChildViewController:guide];
[self.view addSubview:guide.view];
[guide.view mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.view); }];
[guide didMoveToParentViewController:self];
guide.view.hidden = YES; //
}
- (void)kb_didTapBackground {