BottomModal.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import React from 'react';
  2. import { StyleSheet, View } from 'react-native';
  3. import Modal from 'react-native-modal';
  4. export const ModalProps = {
  5. avoidKeyboard: true,
  6. animationIn: "fadeIn",
  7. animationOut: "fadeOut",
  8. propagateSwipe: true,
  9. useNativeDriver: !isIOS,
  10. statusBarTranslucent: true,
  11. deviceHeight: $height + statusHeight,
  12. hideModalContentWhileAnimating: true
  13. }
  14. export default BottomModal = ({
  15. visible=false,
  16. onHide,
  17. children,
  18. backdropOpacity=0.7,
  19. style=styles.bottomModalView,
  20. contentStyle=styles.bottomModalContent}) => {
  21. return (
  22. <Modal
  23. isVisible={visible}
  24. onBackButtonPress={onHide}
  25. onBackdropPress={onHide}
  26. useNativeDriver={!isIOS}
  27. statusBarTranslucent={true}
  28. backdropOpacity={backdropOpacity}
  29. style={style}>
  30. <View style={contentStyle}>
  31. {children}
  32. </View>
  33. </Modal>
  34. );
  35. }
  36. const styles = StyleSheet.create({
  37. bottomModalView: {
  38. margin: 0,
  39. justifyContent: 'flex-end'
  40. },
  41. bottomModalContent: {
  42. maxHeight: $vht(isIOS ? 92 : 96),
  43. backgroundColor: pageBackground,
  44. ...$borderRadius(20, 20, 0, 0)
  45. },
  46. })