react-native-simple-toast icon indicating copy to clipboard operation
react-native-simple-toast copied to clipboard

Toast displayed behind a modal

Open Crash-- opened this issue 9 years ago • 6 comments

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 ?

Crash-- avatar Nov 16 '16 10:11 Crash--

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?

Crash-- avatar Nov 17 '16 13:11 Crash--

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.

himelnagrana avatar Nov 25 '16 11:11 himelnagrana

Same issue.

messense avatar Dec 22 '16 05:12 messense

Any update on this? Would love to see this fixed.

ryanvanbelkum avatar Feb 22 '17 17:02 ryanvanbelkum

@luoruidong , Can you please build a new release with this fix?

Thanks.

ithieund avatar Mar 29 '17 08:03 ithieund

@Crash-- thank you so much but could you please make a PR for this fix? i couldn't get it work in my project

mahdieh-dev avatar Mar 07 '19 12:03 mahdieh-dev