Skip to content

Commit 3bf6562

Browse files
authored
Merge pull request httnn#11 from charliesbox/customization
Added more customisation to container and the overlay
2 parents 2ed0b3c + 4eae725 commit 3bf6562

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ import Modal from 'react-native-simple-modal';
1616
<Modal
1717
open={false}
1818
offset={0}
19-
overlayOpacity={0.75}
19+
overlayBackground={'rgba(0, 0, 0, 0.75)'}
2020
animationDuration={200}
2121
animationTension={40}
2222
modalDidOpen={() => undefined}
2323
modalDidClose={() => undefined}
2424
closeOnTouchOutside={true}
25-
style={{
25+
containerStyle={{
26+
justifyContent: 'center'
27+
}}
28+
modalStyle={{
2629
borderRadius: 2,
2730
margin: 20,
2831
padding: 10,

index.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ class Modal extends Component {
7979
}
8080
render() {
8181
const {opacity, open, scale, offset, children} = this.state;
82-
const {overlayOpacity} = this.props;
83-
let containerStyles = [styles.absolute, styles.container];
82+
let containerStyles = [styles.absolute, styles.container, this.props.containerStyle];
8483

8584
if (!this.state.open) {
8685
containerStyles.push(styles.hidden);
@@ -95,12 +94,12 @@ class Modal extends Component {
9594
disabled={!this.props.closeOnTouchOutside}
9695
onPress={this.close.bind(this)}
9796
activeOpacity={0.75}>
98-
<Animated.View style={{flex: 1, opacity, backgroundColor: 'rgba(0, 0, 0, ' + overlayOpacity + ')'}} />
97+
<Animated.View style={{flex: 1, opacity, backgroundColor: this.props.overlayBackground}} />
9998
</TouchableOpacity>
10099
<Animated.View
101100
style={[
102101
styles.defaultModalStyle,
103-
this.props.style,
102+
this.props.modalStyle,
104103
{opacity, transform: [{scale}, {translateY: offset}]}
105104
]}>
106105
{children}
@@ -126,7 +125,6 @@ class Modal extends Component {
126125
Modal.propTypes = {
127126
open: PropTypes.bool,
128127
offset: PropTypes.number,
129-
overlayOpacity: PropTypes.number,
130128
animationDuration: PropTypes.number,
131129
animationTension: PropTypes.number,
132130
modalDidOpen: PropTypes.func,
@@ -137,7 +135,7 @@ Modal.propTypes = {
137135
Modal.defaultProps = {
138136
open: false,
139137
offset: 0,
140-
overlayOpacity: 0.75,
138+
overlayBackground: 'rgba(0, 0, 0, 0.75)',
141139
animationDuration: 200,
142140
animationTension: 40,
143141
modalDidOpen: () => undefined,

0 commit comments

Comments
 (0)