-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
74 lines (65 loc) · 1.57 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import React, { Component } from "react";
import { Button, View, Text, StyleSheet } from "react-native";
import { AnimatedGradient } from "./AnimatedGradient";
const colors1 = ["#240080", "transparent"];
const colors2 = ["transparent", "transparent"];
const colors3 = ["blue", "red"];
export class ColorExample extends Component {
constructor(props) {
super(props);
this.state = {
colors: colors1
};
}
render() {
const { colors } = this.state;
return (
<View style={styles.component}>
<Text style={styles.header}>Animating Color Gradients</Text>
<View style={{ flexDirection: "row", justifyContent: "space-around" }}>
<Button
onPress={() => {
this.setState({
colors: colors1
});
}}
title="gradient 1"
/>
<Button
onPress={() => {
this.setState({
colors: colors2
});
}}
title="gradient 2"
/>
<Button
onPress={() => {
this.setState({
colors: colors3
});
}}
title="gradient 3"
/>
</View>
<AnimatedGradient
style={{ flex: 1 }}
colors={colors}
start={{ x: 1, y: 0 }}
end={{ x: 0, y: 1 }}
/>
</View>
);
}
}
const styles = StyleSheet.create({
component: {
flex: 1
},
header: {
fontSize: 20,
marginTop: 50,
marginBottom: 20,
alignSelf: "center"
}
});