Skip to content

Commit

Permalink
refactor(iOS): simplify UINavigationControllerDelegate methods implem…
Browse files Browse the repository at this point in the history
…entation (#2562)

## Description

Noticed a low-hanging opportunity to simplify this method while doing
something different.
We already had this loop implemented in helper function so we could use
it.

## Test code and steps to reproduce

CI should be enough

## Checklist

- [ ] Ensured that CI passes
  • Loading branch information
kkafar authored Dec 10, 2024
1 parent d9dfe1a commit afd5e72
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ios/RNSScreenStack.mm
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,16 @@ - (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
UIView *view = viewController.view;
#ifdef RCT_NEW_ARCH_ENABLED
if (![view isKindOfClass:[RNSScreenView class]]) {
if (![viewController.view isKindOfClass:[RNSScreenView class]]) {
// if the current view is a snapshot, config was already removed so we don't trigger the method
return;
}
#endif
RNSScreenStackHeaderConfig *config = nil;
for (UIView *subview in view.reactSubviews) {
if ([subview isKindOfClass:[RNSScreenStackHeaderConfig class]]) {
config = (RNSScreenStackHeaderConfig *)subview;
break;
}
}
[RNSScreenStackHeaderConfig willShowViewController:viewController animated:animated withConfig:config];
auto *screenView = static_cast<RNSScreenView *>(viewController.view);
[RNSScreenStackHeaderConfig willShowViewController:viewController
animated:animated
withConfig:screenView.findHeaderConfig];
}

- (void)presentationControllerDidDismiss:(UIPresentationController *)presentationController
Expand Down

0 comments on commit afd5e72

Please sign in to comment.