|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | 3 | var React = require('react-native'); |
4 | | -var {View, Text, StyleSheet} = React; |
| 4 | +var {View, Text, StyleSheet, Animated, Dimensions} = React; |
5 | 5 | var Button = require('react-native-button'); |
6 | 6 | var Actions = require('react-native-router-flux').Actions; |
7 | 7 |
|
| 8 | +var { |
| 9 | + height: deviceHeight |
| 10 | +} = Dimensions.get('window'); |
| 11 | + |
| 12 | + |
8 | 13 | class Error extends React.Component { |
| 14 | + constructor(props){ |
| 15 | + super (props) |
| 16 | + |
| 17 | + this.state = { |
| 18 | + offset: new Animated.Value(-deviceHeight) |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | + componentDidMount() { |
| 23 | + Animated.timing(this.state.offset, { |
| 24 | + duration: 150, |
| 25 | + toValue: 0 |
| 26 | + }).start(); |
| 27 | + } |
| 28 | + |
| 29 | + closeModal() { |
| 30 | + Animated.timing(this.state.offset, { |
| 31 | + duration: 150, |
| 32 | + toValue: -deviceHeight |
| 33 | + }).start(Actions.dismiss); |
| 34 | + } |
| 35 | + |
9 | 36 | render(){ |
10 | 37 | return ( |
11 | | - <View style={[styles.container,{backgroundColor:'rgba(52,52,52,0.5)'}]}> |
12 | | - <View style={{width:250,height:250,justifyContent: 'center', |
13 | | - alignItems: 'center',backgroundColor:'white'}}> |
14 | | - <Text>{this.props.data}</Text> |
15 | | - <Button onPress={Actions.dismiss}>Close</Button> |
16 | | - </View> |
| 38 | + <Animated.View style={[styles.container, {backgroundColor:'rgba(52,52,52,0.5)'}, |
| 39 | + {transform: [{translateY: this.state.offset}]}]}> |
| 40 | + <View style={{ width:250, |
| 41 | + height:250, |
| 42 | + justifyContent: 'center', |
| 43 | + alignItems: 'center', |
| 44 | + backgroundColor:'white' }}> |
| 45 | + <Text>{this.props.data}</Text> |
| 46 | + <Button onPress={this.closeModal.bind(this)}>Close</Button> |
17 | 47 | </View> |
| 48 | + </Animated.View> |
18 | 49 | ); |
19 | 50 | } |
20 | 51 | } |
|
0 commit comments