Skip to content

Commit f3f5723

Browse files
committed
Layout improvements
1 parent 392dc55 commit f3f5723

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

LNPopupController/LNPopupController/Private/LNPopupController.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,8 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple
15921592
_LNCallDelegateObjectBool(_containerController, @selector(popupPresentationControllerWillDismissPopupBar:animated:), animated);
15931593
[self.popupBar.customBarViewController _userFacing_viewWillDisappear:animated];
15941594

1595+
[_bottomBar _ln_triggerBarAppearanceRefreshIfNeededTriggeringLayout:YES];
1596+
15951597
CGRect barFrame = self.popupBar.frame;
15961598
barFrame.size.height = 0;
15971599
self.popupBar.frame = barFrame;
@@ -1601,8 +1603,6 @@ - (void)_dismissPopupBarAnimated:(BOOL)animated completion:(void(^)(void))comple
16011603
self.popupBar.shadowView.alpha = 0.0;
16021604
_LNPopupSupportSetPopupInsetsForViewController(_containerController, YES, UIEdgeInsetsZero);
16031605

1604-
[_bottomBar _ln_triggerBarAppearanceRefreshIfNeededTriggeringLayout:YES];
1605-
16061606
CGFloat currentBarAlpha = self.popupBarStorage.alpha;
16071607
[UIView animateWithDuration:0.5 delay:0.0 usingSpringWithDamping:500 initialSpringVelocity:0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
16081608
if(_containerController.shouldFadePopupBarOnDismiss)

LNPopupController/LNPopupController/Private/UIViewController+LNPopupSupportPrivate.mm

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,33 +1756,47 @@ - (CGRect)defaultFrameForBottomDockingView
17561756
{
17571757
CGRect toolbarBarFrame = self.toolbar.frame;
17581758

1759-
CGFloat bottomSafeAreaHeight = self.view.safeAreaInsets.bottom;
1760-
if([NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"] == NO)
1759+
CGFloat bottomSafeAreaHeight = 0.0;
1760+
if(unavailable(iOS 18.0, *))
17611761
{
1762-
bottomSafeAreaHeight -= self.view.window.safeAreaInsets.bottom;
1762+
bottomSafeAreaHeight = self.view.safeAreaInsets.bottom;
1763+
if([NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"] == NO)
1764+
{
1765+
bottomSafeAreaHeight -= self.view.window.safeAreaInsets.bottom;
1766+
}
17631767
}
1764-
17651768
toolbarBarFrame.origin = CGPointMake(toolbarBarFrame.origin.x, self.view.bounds.size.height - (self.isToolbarHidden ? 0.0 : toolbarBarFrame.size.height) - bottomSafeAreaHeight);
17661769

17671770
return toolbarBarFrame;
17681771
}
17691772

17701773
- (UIEdgeInsets)insetsForBottomDockingView
17711774
{
1772-
if(self.presentingViewController != nil && [NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"])
1775+
if(@available(iOS 18.0, *))
17731776
{
1774-
return UIEdgeInsetsZero;
1777+
CGFloat offset = 0;
1778+
1779+
if(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
1780+
{
1781+
static auto key = LNPopupHiddenString("_backgroundView.bounds");
1782+
if([[self.toolbar valueForKeyPath:key] CGRectValue].size.height < (self.toolbar.bounds.size.height + self.view.safeAreaInsets.bottom))
1783+
{
1784+
//Something in UIKit reports safe area insets incorrectly on iPadOS. This is a workaround for this issue.
1785+
offset -= 5;
1786+
}
1787+
}
1788+
1789+
return UIEdgeInsetsMake(0, 0, self.view.safeAreaInsets.bottom + offset, 0);
17751790
}
1776-
1777-
CGFloat offset = 0;
1778-
1779-
if(UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad && self.view.superview.safeAreaInsets.bottom > 0 && ([self _ln_isObjectFromSwiftUI] || self.splitViewController != nil))
1791+
else
17801792
{
1781-
//Something in SwiftUI reports safe area insets incorrectly on iPadOS. This is a workaround for this issue.
1782-
offset -= 5;
1793+
if(self.presentingViewController != nil && [NSStringFromClass(self.nonMemoryLeakingPresentationController.class) containsString:@"Preview"])
1794+
{
1795+
return UIEdgeInsetsZero;
1796+
}
1797+
1798+
return UIEdgeInsetsMake(0, 0, MAX(self.view.superview.safeAreaInsets.bottom, self.view.window.safeAreaInsets.bottom), 0);
17831799
}
1784-
1785-
return UIEdgeInsetsMake(0, 0, MAX(self.view.superview.safeAreaInsets.bottom, self.view.window.safeAreaInsets.bottom) + offset, 0);
17861800
}
17871801

17881802
+ (void)load

LNPopupControllerExample/LNPopupControllerExample/TestingScene/DemoViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ - (UIViewController*)_targetVCForPopup
385385
if([self.splitViewController isKindOfClass:LNSplitViewControllerPrimaryPopup.class] && self.navigationController != [self.splitViewController viewControllerForColumn:UISplitViewControllerColumnPrimary])
386386
{
387387
self.view.backgroundColor = UIColor.systemBackgroundColor;
388-
block(NSLocalizedString(@"Primary", @""));
388+
block(NSLocalizedString(@"Secondary", @""));
389389
return nil;
390390
}
391391

LNPopupControllerExample/LNPopupControllerExample/TestingScene/LNPopupControllerExampleSupport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withT
108108

109109
- (void)updateTabsForTraitCollection:(UITraitCollection*)collection API_AVAILABLE(ios(18.0))
110110
{
111-
if(collection.userInterfaceIdiom == UIUserInterfaceIdiomPad && collection.horizontalSizeClass == UIUserInterfaceSizeClassRegular && _sidebarTabs.count > 0)
111+
if(collection.userInterfaceIdiom == UIUserInterfaceIdiomPad && collection.horizontalSizeClass == UIUserInterfaceSizeClassRegular && _sidebarTabs.count > 0 && self.splitViewController == nil)
112112
{
113113
self.tabs = [_tabs arrayByAddingObjectsFromArray:_sidebarTabs];
114114
self.compactTabIdentifiers = [_tabs valueForKey:@"identifier"];

0 commit comments

Comments
 (0)