Skip to content
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

Adjust modal size and native-stack onDismissed #583

Closed
kockok opened this issue Jul 31, 2020 · 9 comments
Closed

Adjust modal size and native-stack onDismissed #583

kockok opened this issue Jul 31, 2020 · 9 comments

Comments

@kockok
Copy link

kockok commented Jul 31, 2020

I use this package with react-navigation V5.

I suggest to add an option to customize the height of the modal screen.

Besides, I currently use this code to popToTop:

    const unsubscribe = navigation.addListener('dismiss', () => {
      navigation.popToTop();
    });

    return unsubscribe;
  }, [navigation]);

When I swipe down to dismiss the modal, it won't directly popToTop.

I know that this package has a onDismissed prop and I want it to execute navigation.popToTop();.

However, I can't find a way to implement this with createNativeStackNavigator() and errors occur.

Screenshot 2020-08-01 at 1 18 49 AM

@WoLewicki
Copy link
Member

As for the height of modal, you can look at #530, and for the events, in 2.10.1, the navigation events were added to native-stack, in #499. Does it solve your issue?

@kockok
Copy link
Author

kockok commented Aug 7, 2020

As for the height of modal, you can look at #530, and for the events, in 2.10.1, the navigation events were added to native-stack, in #499. Does it solve your issue?

No, I only want onDismissed to work.

@WoLewicki
Copy link
Member

https://github.com/software-mansion/react-native-screens/tree/master/native-stack#dismiss probably this is the name of the event you are looking for.

@kockok
Copy link
Author

kockok commented Aug 7, 2020

Yeah I know that...
However, what I want to know is that why native-stack won't accept the onDismissed prop?
What I want is: A(screen)->B(screen)->C(Modal) then swipe down to navigate C(Modal)->A(screen)
But using listeners would like:A(screen)->B(screen)->C(Modal) then C(Modal)->B(screen)->A(Screen).

@WoLewicki
Copy link
Member

Because the native-stack does not have such prop. It is a property of a Screen component and is used by native-stack to trigger navigation actions of dismissing a screen and emitting navigation event 'dismiss'. https://github.com/software-mansion/react-native-screens/blob/master/src/native-stack/views/NativeStackView.tsx#L96 you can see that it calls 'pop' action. If you want your own action there, you could overwrite this behavior for e.g. stackPresentation: 'modal'.

@kockok
Copy link
Author

kockok commented Aug 7, 2020

@WoLewicki
How to override this function?

            onDismissed={() => {
              navigation.emit({
                type: 'dismiss',
                target: route.key,
              });

              navigation.dispatch({
                ...StackActions.pop(),
                source: route.key,
                target: key,
              });
            }}>

I hope that the maintainers can add an option to customise the ...StackActions.pop() to ...StackActions.popToTop()

@WoLewicki
Copy link
Member

Just apply a patch to this file in your node_modules. You can use patch-package.

@kockok
Copy link
Author

kockok commented Aug 7, 2020

OK, let me know if ...StackActions could be customized officially.

@kockok kockok closed this as completed Aug 7, 2020
@WoLewicki
Copy link
Member

This behavior won't be changed to what you would want because it would result in every dismiss to pop the whole stack, which does not make sense in most cases.

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

2 participants