Skip to content

Toast displayed behind a modal #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Crash-- opened this issue Nov 16, 2016 · 6 comments
Open

Toast displayed behind a modal #3

Crash-- opened this issue Nov 16, 2016 · 6 comments

Comments

@Crash--
Copy link

Crash-- commented Nov 16, 2016

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--
Copy link
Author

Crash-- commented Nov 17, 2016

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?

@himelnagrana
Copy link

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.

@messense
Copy link

Same issue.

@ryanvanbelkum
Copy link

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

@ithieund
Copy link

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

Thanks.

@mahdieh-dev
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants