Skip to content

Commit

Permalink
Improve iOS 18 tab bar controller transition support
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoNatan committed Sep 3, 2024
1 parent fb65937 commit 9e8c499
Showing 1 changed file with 40 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,8 @@ - (void)hBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio
self._ln_bottomBarExtension_nocreate.hidden = NO;
self._ln_bottomBarExtension_nocreate.alpha = 1.0;

[self._ln_bottomBarExtension layoutIfNeeded];

__ln_alreadyInHideShowBar = YES;
if(@available(iOS 18.0, *))
{
Expand All @@ -1299,8 +1301,20 @@ - (void)hBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio
}
__ln_alreadyInHideShowBar = NO;

if(transition != 1 && isExplicit == NO)
{
return;
}

NSString* effectGroupingIdentifier = self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier;
self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier = nil;
if(transition == 1)
{
self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier = nil;
}
else
{
self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 0.0;
}

self._ln_popupController_nocreate.popupBar.wantsBackgroundCutout = NO;
if(transition == 1 && isFloating)
Expand Down Expand Up @@ -1328,14 +1342,19 @@ - (void)hBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio
}

self._ln_bottomBarExtension_nocreate.frame = CGRectMake(0, self.view.bounds.size.height - bottomSafeArea, self.view.bounds.size.width, self._ln_bottomBarExtension_nocreate.frame.size.height);
self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 0.0;

if(transition == 1)
{
self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 0.0;
}

[self __repositionPopupBarToClosed_hack];

if(isFloating)
{
[self._ln_popupController_nocreate.popupBar layoutIfNeeded];
self._ln_popupController_nocreate.popupBar.backgroundView.alpha = 1.0;

if(transition == 1)
{
self._ln_popupController_nocreate.popupBar.backgroundView.frame = CGRectOffset(backgroundViewFrame, (isRTL ? 1 : -1) * CGRectGetWidth(backgroundViewFrame), -CGRectGetHeight(frame) + bottomSafeArea);
Expand Down Expand Up @@ -1445,34 +1464,34 @@ - (void)sBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio

self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 0.0;

if(wasHidden == YES)
{
self._ln_popupController_nocreate.popupBar.wantsBackgroundCutout = NO;
}
self._ln_popupController_nocreate.popupBar.wantsBackgroundCutout = NO;

CGRect backgroundViewFrame = self._ln_popupController_nocreate.popupBar.backgroundView.frame;
__block CGRect frame = self.tabBar.frame;

__block CGRect backgroundViewFrame = self._ln_popupController_nocreate.popupBar.backgroundView.frame;
CGFloat bottomSafeArea = self.view.superview.safeAreaInsets.bottom;
if(transition == 2 && isFloating)
{
self._ln_popupController_nocreate.popupBar.backgroundView.alpha = 1.0;
self._ln_popupController_nocreate.popupBar.backgroundView.transitionShadingView.alpha = 1.0;
self._ln_popupController_nocreate.popupBar.backgroundView.transitionShadingView.hidden = NO;

if(wasHidden == YES)
{
self._ln_popupController_nocreate.popupBar.backgroundView.frame = CGRectOffset(backgroundViewFrame, (isRTL ? 1 : -1) * CGRectGetWidth(backgroundViewFrame), -CGRectGetHeight(self.tabBar.frame) + bottomSafeArea);
}
} else if(isFloating)
CGRect initial = CGRectOffset(backgroundViewFrame, (isRTL ? 1 : -1) * CGRectGetWidth(backgroundViewFrame), -CGRectGetHeight(frame) + bottomSafeArea);

self._ln_popupController_nocreate.popupBar.backgroundView.frame = initial;
}
else if(isFloating)
{
self._ln_popupController_nocreate.popupBar.backgroundView.frame = CGRectOffset(backgroundViewFrame, 0, bottomSafeArea);
}

__block CGRect frame = self.tabBar.frame;

[self _setIgnoringLayoutDuringTransition:YES];

NSString* effectGroupingIdentifier = self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier;
self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier = nil;
if(transition == 2)
{
self._ln_popupController_nocreate.popupBar.effectGroupingIdentifier = nil;
}

void (^animations)(id<UIViewControllerTransitionCoordinatorContext>) = ^ (id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
if(transition != 2)
Expand All @@ -1491,8 +1510,11 @@ - (void)sBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio
}
self._ln_bottomBarExtension.frame = frame;

self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 1.0;
if(isFloating && wasHidden == YES)
if(transition == 2)
{
self._ln_popupController_nocreate.popupBar.bottomShadowView.alpha = 1.0;
}
if(isFloating)
{
self._ln_popupController_nocreate.popupBar.backgroundView.frame = backgroundViewFrame;
self._ln_popupController_nocreate.popupBar.backgroundView.alpha = 1.0;
Expand All @@ -1510,10 +1532,7 @@ - (void)sBWT:(NSInteger)transition iE:(BOOL)isExplicit d:(NSTimeInterval)duratio
void (^completion)(id<UIViewControllerTransitionCoordinatorContext>) = ^ (id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) {
[self _setPrepareTabBarIgnored:NO];

if(wasHidden == YES)
{
[self._ln_popupController_nocreate.popupBar setWantsBackgroundCutout:YES allowImplicitAnimations:YES];
}
[self._ln_popupController_nocreate.popupBar setWantsBackgroundCutout:YES allowImplicitAnimations:YES];

if(transition == 2 && isFloating)
{
Expand Down

0 comments on commit 9e8c499

Please sign in to comment.