Created
November 27, 2017 23:36
-
-
Save norbajunior/8a4364d3f7ee5cd72e3450fcbf283abd to your computer and use it in GitHub Desktop.
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 { Animated } from 'react-native' | |
class Notification extends Component { | |
constructor(props) { | |
super(props) | |
this.offset = new Animated.Value(props.offset) | |
} | |
componentDidMount() { | |
Animated.sequence([ | |
Animated.delay(this.props.delay), | |
Animated.spring(this.offset, { | |
tension: -5, | |
toValue: 0 | |
}), | |
Animated.timing(this.offset, { | |
duration: 1000, | |
toValue: -80 | |
}) | |
]).start(() => this.props.removeNotification(this.props.id)) | |
} | |
render() { | |
const { message, avatar } = this.props | |
return ( | |
<Animated.View | |
style={[styles.messageContainerStyle, { | |
transform: [{ | |
translateY: this.state.offset | |
}] | |
}]} | |
> | |
<Image source={this.props.avatar} /> | |
<Text>Nova Mensagem</Text> | |
<Text>{this.props.message}</Text> | |
</Animated.View> | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment