Skip to content

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
bokuweb committed Jan 22, 2016
1 parent f6d8184 commit 6599d9e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions index.android.js
Expand Up @@ -28,7 +28,7 @@ class Example extends Component {
const modalStyles = {
modal : {
width: 240,
height: 180,
height: 160,
backgroundColor: '#FFF'
},
overlay : {
Expand Down Expand Up @@ -82,7 +82,7 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'center',
alignItems: 'center',
paddingTop: 80
paddingTop: 70
},
button: {
paddingTop: 20,
Expand Down
44 changes: 27 additions & 17 deletions index.js
Expand Up @@ -37,28 +37,38 @@ export default class Modal extends Component {

render() {
if (!this.state.isOpen) return null;
const style = {
position: 'absolute',
top: (deviceHeight - this.props.styles.modal.height) / 2,
left: (deviceWidth - this.props.styles.modal.width) / 2
};
const styles = StyleSheet.create({
overlay: {
backgroundColor: 'rgba(0,0,0,0.8)',
position: 'absolute',
top: 0,
left: 0,
width: deviceWidth,
height: deviceHeight
},
modal: {
position: 'absolute',
top: (deviceHeight - this.props.styles.modal.height) / 2,
left: (deviceWidth - this.props.styles.modal.width) / 2
}
});

return (
<Animated.View style={[styles.overlay, styles.flexCenter, this.props.styles.overlay, {transform: [{translateY: this.state.offset}]}]}>
<View style={[this.props.styles.modal, style]}>
<Animated.View style={[
styles.overlay,
styles.flexCenter,
this.props.styles.overlay,
{transform: [{translateY: this.state.offset}]}
]}>
<View style={[
this.props.styles.modal,
styles.modal
]}>
{this.props.children}
</View>
</Animated.View>
);
}
}

const styles = StyleSheet.create({
overlay: {
backgroundColor: 'rgba(0,0,0,0.8)',
position: 'absolute',
top: 0,
left: 0,
width: deviceWidth,
height: deviceHeight
}
});

0 comments on commit 6599d9e

Please sign in to comment.