Skip to content

Commit

Permalink
Layout improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Nov 8, 2024
1 parent 392dc55 commit f3f5723
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1756,33 +1756,47 @@ - (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;
}

- (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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down

0 comments on commit f3f5723

Please sign in to comment.