Last active
November 5, 2020 15:44
-
-
Save brunopk/36e8d7241ce03df92b45ee8377714f58 to your computer and use it in GitHub Desktop.
A modal component using styled components https://styled-components.com/ and react-native-modal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import Modal from 'react-native-modal'; | |
import styled from 'styled-components/native'; | |
import {View, StyleSheet} from 'react-native'; | |
const styles = StyleSheet.create({ | |
primaryContainer: { | |
height: '30%', | |
justifyContent: 'center', | |
alignItems: 'center', | |
}, | |
secondContainer: { | |
height: '100%', | |
}, | |
}); | |
const Body = styled.View` | |
background-color: white; | |
`; | |
const Buttons = styled(Body)` | |
flex-direction: row; | |
justify-content: flex-end; | |
padding: 10px; | |
`; | |
function CustomModal({ | |
visible, | |
setVisible, | |
children, | |
positiveBtn, | |
negativeBtn, | |
}) { | |
return ( | |
<Modal isVisible={visible} onBackButtonPress={() => setVisible(false)}> | |
<View style={styles.primaryContainer}> | |
<View style={styles.secondContainer}> | |
<Body>{children}</Body> | |
<Buttons> | |
{negativeBtn} | |
{positiveBtn} | |
</Buttons> | |
</View> | |
</View> | |
</Modal> | |
); | |
} | |
export {CustomModal as Modal}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment