Skip to content

Commit 3d22dbe

Browse files
committed
update dependecies
1 parent 51d0d1e commit 3d22dbe

File tree

3 files changed

+43
-43
lines changed

3 files changed

+43
-43
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ var ChildComponent = React.createClass({
5656
<TouchableOpacity style={{ backgroundColor: "#ddd",padding:10 }} onPress={() => { this.setState({ isOpen: true }) }}>
5757
<Text style={{fontSize:18,textAlign:"center"}}>Show Modal</Text>
5858
</TouchableOpacity>
59-
<ResponsiveModal sizeMatching="content"
59+
<ResponsiveAppModal sizeMatching="content"
6060
isOpen={this.state.isOpen} onClosed={() => { this.setState({ isOpen: false }) }} >
6161
<View style={{ height: 200, backgroundColor: "red" }}>
6262
</View>
63-
</ResponsiveModal>
63+
</ResponsiveAppModal>
6464
</View>
6565
);
6666
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
22
"name": "react-native-responsive-app-modal",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Create responsive modals easily by auto injecting it to the app root.",
55
"main": "src/index.js",
66
"scripts": {
77
"test": "test"
88
},
99
"dependencies": {
10-
"react-native-modalbox": "1.3.8",
11-
"react-native-root-siblings":"1.2.1"
10+
"react-native-modalbox": "^1.4.2",
11+
"react-native-root-siblings": "^2.2.0",
12+
"prop-types": "^15.6.0"
1213
},
1314
"peerDependencies": {
1415
"react-native": "*"

src/index.js

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,55 +2,38 @@ import React, { Component } from 'react';
22
import {
33
View,
44
Platform,
5-
I18nManager
5+
I18nManager,
6+
Dimensions
67
} from 'react-native';
78
import Modalbox from 'react-native-modalbox';
89
import RootSiblings from 'react-native-root-siblings';
9-
import Dimensions from 'Dimensions';
10+
import PropTypes from 'prop-types';
1011

11-
var ResponsiveAppModal = React.createClass({
12-
propTypes: {
13-
...Modalbox.propTypes,
14-
screenHeight: React.PropTypes.number,
15-
screenWidth: React.PropTypes.number,
16-
verticalMargin: React.PropTypes.number,
17-
horizontalMargin: React.PropTypes.number,
18-
sizeMatching: React.PropTypes.oneOf(['content', 'screen']).isRequired
19-
},
20-
getInitialState: function () {
12+
export default class ResponsiveAppModal extends Component<{}> {
13+
constructor(props) {
14+
super(props);
2115
const { width, height } = Dimensions.get('window');
22-
return {
16+
this.state = {
2317
width: width,
2418
height: height,
2519
};
26-
},
27-
getDefaultProps() {
28-
return {
29-
swipeToClose: false,
30-
backButtonClose: true,
31-
isOpen: false,
32-
style: {
33-
height: null,
34-
width: null
35-
}
36-
};
37-
},
20+
}
3821
componentWillMount() {
3922
this.modal = new RootSiblings(this.renderModal(this.props, this.state));
4023
if (typeof Dimensions.addEventListener === 'function')
4124
Dimensions.addEventListener('change', this._dimensionsChanged);
42-
},
25+
}
4326
componentWillUpdate(nextProps, nextState) {
4427
this.modal.update(this.renderModal(nextProps, nextState));
45-
},
28+
}
4629
componentWillUnmount() {
4730
this.modal.destroy();
4831
this.modal = null;
4932

5033
if (typeof Dimensions.addEventListener === 'function')
5134
Dimensions.removeEventListener('change', this._dimensionsChanged);
52-
},
53-
_dimensionsChanged(Dimensions) {
35+
}
36+
_dimensionsChanged = (Dimensions) => {
5437
const { width, height } = Dimensions.window;
5538

5639
let newDimensions = {
@@ -60,8 +43,8 @@ var ResponsiveAppModal = React.createClass({
6043
if (newDimensions.width != this.state.width || newDimensions.height != this.state.height) {
6144
this.setState(newDimensions);
6245
}
63-
},
64-
_renderAndroid(props, state) {
46+
}
47+
_renderAndroid = (props, state) => {
6548
let { screenHeight, screenWidth, verticalMargin, horizontalMargin, sizeMatching, style } = this.props;
6649
if (!screenHeight >= 0 || !screenHeight >= 0) {
6750
let { width, height } = state;
@@ -85,8 +68,8 @@ var ResponsiveAppModal = React.createClass({
8568
</View>
8669
</Modalbox>
8770
);
88-
},
89-
_renderIOS(props, state) {
71+
}
72+
_renderIOS = (props, state) => {
9073
let { screenHeight, screenWidth, verticalMargin, horizontalMargin, sizeMatching, style } = props;
9174
if (!screenHeight >= 0 || !screenHeight >= 0) {
9275
let { width, height } = state;
@@ -107,17 +90,33 @@ var ResponsiveAppModal = React.createClass({
10790
{props.children}
10891
</Modalbox>
10992
);
110-
},
111-
renderModal(props, state) {
93+
}
94+
renderModal = (props, state) => {
11295
return Platform.select({
11396
ios: this._renderIOS(props, state),
11497
android: this._renderAndroid(props, state),
11598
})
116-
},
99+
}
117100
render() {
118101
//the render function is not used, instead
119102
return (<View></View>);
120103
}
121-
});
104+
}
122105

123-
module.exports = ResponsiveAppModal;
106+
ResponsiveAppModal.propTypes = {
107+
...Modalbox.propTypes,
108+
screenHeight: PropTypes.number,
109+
screenWidth: PropTypes.number,
110+
verticalMargin: PropTypes.number,
111+
horizontalMargin: PropTypes.number,
112+
sizeMatching: PropTypes.oneOf(['content', 'screen']).isRequired
113+
}
114+
ResponsiveAppModal.defaultProps = {
115+
swipeToClose: false,
116+
backButtonClose: true,
117+
isOpen: false,
118+
style: {
119+
height: null,
120+
width: null
121+
}
122+
}

0 commit comments

Comments
 (0)