React Navigation modal height
Here's an example of how to achieve this in react-navigation
v3.x:
App Container
const TestRootStack = createStackNavigator(
{
TestRoot: TestRootScreen,
TestModal: {
screen: TestModalScreen,
navigationOptions: {
/**
* Distance from top to register swipe to dismiss modal gesture. Default (135)
* https://reactnavigation.org/docs/en/stack-navigator.html#gestureresponsedistance
*/
gestureResponseDistance: { vertical: 1000 }, // default is 135 },
},
},
},
{
headerMode: 'none',
mode: 'modal',
transparentCard: true,
},
);
const AppContainer = createAppContainer(TestRootStack);
Root Screen
class TestRootScreen extends React.Component {
render() {
return (
<SafeAreaView style={styles.container}>
<Button title="Show Modal" onPress={() => this.props.navigation.navigate('TestModal')} />
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'blue',
alignItems: 'center',
justifyContent: 'center',
},
});
Modal Screen
class TestModalScreen extends React.Component {
render() {
return (
<SafeAreaView style={styles.container}>
<View style={styles.innerContainer} />
</SafeAreaView>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'transparent',
justifyContent: 'flex-end',
},
innerContainer: {
position: 'absolute',
bottom: 0,
left: 0,
right: 0,
top: 100,
backgroundColor: 'red',
},
});
In your stacknavigator you can set these options:
mode: 'modal',
headerMode: 'none',
cardStyle:{
backgroundColor:"transparent",
opacity:0.99
}
And in your modal screen:
class ModalScreen extends React.Component {
render() {
return (
<View style={{ flex: 1 ,flexDirection: 'column', justifyContent: 'flex-end'}}>
<View style={{ height: "50%" ,width: '100%', backgroundColor:"#fff", justifyContent:"center"}}>
<Text>Testing a modal with transparent background</Text>
</View>
</View>
);
}
}
Also you can refer to this expo snack https://snack.expo.io/@yannerio/modal that I've created to show how it works, or you could use React Native Modal