Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native Modal with transparent using Navigator without using Modal

Tags:

react-native

React Native documentation says RN apps should rather use Navigator to create Modals (https://facebook.github.io/react-native/docs/modal.html#content).

How can I create a transparent modal using Navigator, without using Modal? I'd like the user to see the current page in the background. Thank you.

like image 936
skleest Avatar asked Nov 30 '15 21:11

skleest


1 Answers

To answer the updated question, all you need to do is change your configureScene to something like this:

configureScene(route, routeStack){
  if(route.type == 'Modal') {
    return Navigator.SceneConfigs.FloatFromBottom
  }
  return Navigator.SceneConfigs.PushFromRight 
}

Then, pass the type of 'Modal' when wanting a modal:

_navigate(name, type='Normal') {
  this.props.navigator.push({
    component: Home,
    passProps: {
      name: name
    },
    type: type
  })
}

There is an example set up here.

https://rnplay.org/apps/ALL-Sw

like image 191
Nader Dabit Avatar answered Oct 26 '22 22:10

Nader Dabit