react-native-simple-toast
react-native-simple-toast copied to clipboard
Toast displayed behind a modal
This module works great with "simple" view on iOS. But as soon as I open a modal (I use this module for my navigation stack https://github.com/wix/react-native-navigation), the toast is displayed behind and I can't see it.
Is it something we can manage inside react-native-simple-toast ?
Just created :
- (UIViewController *)visibleViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil)
{
return rootViewController;
}
if ([rootViewController.presentedViewController isKindOfClass:[UINavigationController class]])
{
UINavigationController *navigationController = (UINavigationController *)rootViewController.presentedViewController;
UIViewController *lastViewController = [[navigationController viewControllers] lastObject];
return [self visibleViewController:lastViewController];
}
if ([rootViewController.presentedViewController isKindOfClass:[UITabBarController class]])
{
UITabBarController *tabBarController = (UITabBarController *)rootViewController.presentedViewController;
UIViewController *selectedViewController = tabBarController.selectedViewController;
return [self visibleViewController:selectedViewController];
}
UIViewController *presentedViewController = (UIViewController *)rootViewController.presentedViewController;
return [self visibleViewController:presentedViewController];
}
and edited
dispatch_async(dispatch_get_main_queue(), ^{
//UIView *root = [[[[[UIApplication sharedApplication] delegate] window] rootViewController] view];
UIViewController *ctrl = [self visibleViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
UIView *root = [ctrl view];
And I got it working. Do you want a PR for that?
Well I created a patch of your changes on my project and included that on installation step. So even without merged pull and new version - your changes worked. Thanks a lot.
Same issue.
Any update on this? Would love to see this fixed.
@luoruidong , Can you please build a new release with this fix?
Thanks.
@Crash-- thank you so much but could you please make a PR for this fix? i couldn't get it work in my project