-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHongUI.js
106 lines (105 loc) · 2.93 KB
/
HongUI.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import React, {Component} from 'react';
import {Text, View, StyleSheet, Animated, TouchableHighlight} from 'react-native';
import FontAwesome from 'react-native-vector-icons/FontAwesome';
import LinearGradient from 'react-native-linear-gradient';
export class HButton extends Component {
static defaultProps = {
LinearGradientColor: ['#00FA9A','#0f0'],
LinearGradientStart: [0, 0],
LinearGradientEnd: [0, 1],
FontAwesomeName: 'bars',
FontAwesomeSize: 25,
FontAwesomeColor: '#fff',
Text: '传入Text属性',
onPress:()=>{}
};
state = {
scaleSize: new Animated.Value(1),
};
render() {
return (
<View>
<Animated.View style={{opacity: this.state.scaleSize}}>
<TouchableHighlight style={{borderRadius:10}} onPress={()=>this.props.onPress()}>
<LinearGradient
colors={[
this.props.LinearGradientColor[0],
this.props.LinearGradientColor[1],
]}
start={{
x: this.props.LinearGradientStart[0],
y: this.props.LinearGradientStart[1],
}}
end={{
x: this.props.LinearGradientEnd[0],
y: this.props.LinearGradientEnd[1],
}}
locations={[0.2, 1]}
style={[
styles.linearGradient,
this.props.LinearGradientStyle
]}>
<View style={styles.smallCard}>
<FontAwesome
name={this.props.FontAwesomeName}
size={this.props.FontAwesomeSize}
color={this.props.FontAwesomeColor}
/>
<Text
onPress={this.Press}
style={[styles.scrollViewText, this.props.TextStyle]}>
{this.props.Text}
</Text>
</View>
</LinearGradient>
</TouchableHighlight>
</Animated.View>
</View>
);
}
Press = () => {
Animated.timing(this.state.scaleSize,{
toValue: 0.85,
duration: 200,
useNativeDriver:false
}).start()
setTimeout(()=>{
Animated.timing(this.state.scaleSize,{
toValue: 1,
duration: 200,
useNativeDriver:false
}).start()
},200)
};
}
const styles = StyleSheet.create({
linearGradient: {
borderRadius: 10,
elevation: 10,
shadowColor: '#ccc',
shadowOffset: {h: 10, w: 10},
shadowRadius: 5,
shadowOpacity: 0.3,
width: 200,
},
scrollViewText: {
fontSize: 20,
color: '#fff',
fontWeight: 'bold',
position: 'relative',
left: -10,
},
smallCard: {
height: 60,
width: 200,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-evenly',
},
scrollInnerBox: {
display: 'flex',
alignItems: 'flex-end',
// position: 'relative',
// backgroundColor: '#fff'
},
});