diff --git a/LNPopupController/LNPopupController/Private/LNPopupController.mm b/LNPopupController/LNPopupController/Private/LNPopupController.mm index a519256..b575059 100644 --- a/LNPopupController/LNPopupController/Private/LNPopupController.mm +++ b/LNPopupController/LNPopupController/Private/LNPopupController.mm @@ -1592,6 +1592,8 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple _LNCallDelegateObjectBool(_containerController, @selector(popupPresentationControllerWillDismissPopupBar:animated:), animated); [self.popupBar.customBarViewController _userFacing_viewWillDisappear:animated]; + [_bottomBar _ln_triggerBarAppearanceRefreshIfNeededTriggeringLayout:YES]; + CGRect barFrame = self.popupBar.frame; barFrame.size.height = 0; self.popupBar.frame = barFrame; @@ -1601,8 +1603,6 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple self.popupBar.shadowView.alpha = 0.0; _LNPopupSupportSetPopupInsetsForViewController(_containerController, YES, UIEdgeInsetsZero); - [_bottomBar _ln_triggerBarAppearanceRefreshIfNeededTriggeringLayout:YES]; - CGFloat currentBarAlpha = self.popupBarStorage.alpha; [UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:500 initialSpringVelocity:0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{ if(_containerController.shouldFadePopupBarOnDismiss) diff --git a/LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.mm b/LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.mm index dc38bd5..42ff03a 100644 --- a/LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.mm +++ b/LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.mm @@ -1756,12 +1756,15 @@ - (CGRect)defaultFrameForBottomDockingView { CGRect toolbarBarFrame = self.toolbar.frame; - CGFloat bottomSafeAreaHeight = self.view.safeAreaInsets.bottom; - if([NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"] == NO) + CGFloat bottomSafeAreaHeight = 0.0; + if(unavailable(iOS 18.0, *)) { - bottomSafeAreaHeight -= self.view.window.safeAreaInsets.bottom; + bottomSafeAreaHeight = self.view.safeAreaInsets.bottom; + if([NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"] == NO) + { + bottomSafeAreaHeight -= self.view.window.safeAreaInsets.bottom; + } } - toolbarBarFrame.origin = CGPointMake(toolbarBarFrame.origin.x, self.view.bounds.size.height - (self.isToolbarHidden ? 0.0 : toolbarBarFrame.size.height) - bottomSafeAreaHeight); return toolbarBarFrame; @@ -1769,20 +1772,31 @@ - (CGRect)defaultFrameForBottomDockingView - (UIEdgeInsets)insetsForBottomDockingView { - if(self.presentingViewController != nil && [NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"]) + if(@available(iOS 18.0, *)) { - return UIEdgeInsetsZero; + CGFloat offset = 0; + + if(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) + { + static auto key = LNPopupHiddenString("_backgroundView.bounds"); + if([[self.toolbar valueForKeyPath:key] CGRectValue].size.height < (self.toolbar.bounds.size.height + self.view.safeAreaInsets.bottom)) + { + //Something in UIKit reports safe area insets incorrectly on iPadOS. This is a workaround for this issue. + offset -= 5; + } + } + + return UIEdgeInsetsMake(0, 0, self.view.safeAreaInsets.bottom + offset, 0); } - - CGFloat offset = 0; - - if(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad && self.view.superview.safeAreaInsets.bottom > 0 && ([self _ln_isObjectFromSwiftUI] || self.splitViewController != nil)) + else { - //Something in SwiftUI reports safe area insets incorrectly on iPadOS. This is a workaround for this issue. - offset -= 5; + if(self.presentingViewController != nil && [NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"]) + { + return UIEdgeInsetsZero; + } + + return UIEdgeInsetsMake(0, 0, MAX(self.view.superview.safeAreaInsets.bottom, self.view.window.safeAreaInsets.bottom), 0); } - - return UIEdgeInsetsMake(0, 0, MAX(self.view.superview.safeAreaInsets.bottom, self.view.window.safeAreaInsets.bottom) + offset, 0); } + (void)load diff --git a/LNPopupControllerExample/LNPopupControllerExample/TestingScene/DemoViewController.m b/LNPopupControllerExample/LNPopupControllerExample/TestingScene/DemoViewController.m index dc96348..746e529 100644 --- a/LNPopupControllerExample/LNPopupControllerExample/TestingScene/DemoViewController.m +++ b/LNPopupControllerExample/LNPopupControllerExample/TestingScene/DemoViewController.m @@ -385,7 +385,7 @@ - (UIViewController*)_targetVCForPopup if([self.splitViewController isKindOfClass:LNSplitViewControllerPrimaryPopup.class] && self.navigationController != [self.splitViewController viewControllerForColumn:UISplitViewControllerColumnPrimary]) { self.view.backgroundColor = UIColor.systemBackgroundColor; - block(NSLocalizedString(@"Primary", @"")); + block(NSLocalizedString(@"Secondary", @"")); return nil; } diff --git a/LNPopupControllerExample/LNPopupControllerExample/TestingScene/LNPopupControllerExampleSupport.m b/LNPopupControllerExample/LNPopupControllerExample/TestingScene/LNPopupControllerExampleSupport.m index 7805694..dd7b257 100644 --- a/LNPopupControllerExample/LNPopupControllerExample/TestingScene/LNPopupControllerExampleSupport.m +++ b/LNPopupControllerExample/LNPopupControllerExample/TestingScene/LNPopupControllerExampleSupport.m @@ -108,7 +108,7 @@ - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withT - (void)updateTabsForTraitCollection:(UITraitCollection*)collection API_AVAILABLE(ios(18.0)) { - if(collection.userInterfaceIdiom == UIUserInterfaceIdiomPad && collection.horizontalSizeClass == UIUserInterfaceSizeClassRegular && _sidebarTabs.count > 0) + if(collection.userInterfaceIdiom == UIUserInterfaceIdiomPad && collection.horizontalSizeClass == UIUserInterfaceSizeClassRegular && _sidebarTabs.count > 0 && self.splitViewController == nil) { self.tabs = [_tabs arrayByAddingObjectsFromArray:_sidebarTabs]; self.compactTabIdentifiers = [_tabs valueForKey:@"identifier"];