verdnatura-chat/app/presentation/Loading.js

80 lines
1.3 KiB
JavaScript
Raw Normal View History

import React, { Component } from 'react';
import { View, StyleSheet, Animated, Dimensions } from 'react-native';
const logo = require('../images/logo.png');
const styles = StyleSheet.create({
container: {
flex: 1,
width: '100%',
alignItems: 'center',
justifyContent: 'center'
},
background: {
width: Dimensions.get('window').width,
height: Dimensions.get('window').height,
alignItems: 'center',
justifyContent: 'center'
},
logo: {
width: Dimensions.get('window').width - 100,
height: Dimensions.get('window').width - 100,
resizeMode: 'contain'
}
});
export default class Loading extends Component {
constructor(props) {
super(props);
this.scale = new Animated.Value(1.0);
}
componentDidMount() {
requestAnimationFrame(() => {
this.animate();
});
}
animate = () => {
Animated.sequence([
Animated.timing(
this.scale,
{
toValue: 0.8,
duration: 1000,
useNativeDriver: true
2017-11-13 12:49:19 +00:00
}
),
Animated.timing(
this.scale,
{
toValue: 1,
duration: 1000,
useNativeDriver: true
2017-11-13 12:49:19 +00:00
}
)
]).start(() => {
this.animate();
});
}
render() {
return (
<View style={styles.container}>
<Animated.Image
style={[
styles.logo,
{
transform: [
{ scale: this.scale }
]
}]}
source={logo}
/>
</View>
);
}
}