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
|
// @flow
import React from 'react';
import { View, Text, Component } from 'reactxp';
import { Button } from './Button';
import Img from '../Img';
import { colors } from '../../config';
import { createViewStyles, createTextStyles } from '../../lib/styles';
const styles = {
...createViewStyles({
cell:{
backgroundColor: colors.blue80,
paddingTop: 7,
paddingLeft: 12,
paddingRight: 12,
paddingBottom: 9,
borderRadius: 4,
flex: 1,
flexDirection: 'row',
alignItems: 'center',
alignContent: 'center',
justifyContent: 'space-between',
},
hover:{
backgroundColor: colors.blue60,
},
icon:{
marginLeft: 8,
width: 0,
height: 0,
flexGrow: 0,
flexShrink: 0,
flexBasis: 'auto',
alignItems: 'flex-end',
color: colors.white80,
},
}),
...createTextStyles({
label:{
alignItems: 'center',
alignContent: 'center',
fontFamily: 'DINPro',
fontSize: 20,
fontWeight: '900',
lineHeight: 26,
color: colors.white80,
},
labelHover: {
color: colors.white,
},
})
};
export default class AppButton extends Component {
props: {
icon?: string,
iconStyle?: string,
hoverStyle?: string,
text: string,
textHoverStyle?: string,
tintColor?: string,
onPress?: () => void,
style?: string,
disabled?: boolean,
};
state = { hovered: false };
render() {
const { style, tintColor, hoverStyle, text, textHoverStyle, icon, iconStyle, onPress, disabled, ...otherProps } = this.props;
return (
<Button style={[ styles.cell, style, this.state.hovered ? [styles.hover, hoverStyle] : null ]}
onPress={ onPress }
onHoverStart={() => !disabled ? this.setState({ hovered: true }) : null }
onHoverEnd={() => !disabled ? this.setState({ hovered: false }) : null }
disabled={ disabled }
{...otherProps}>
<View style={[ styles.icon, iconStyle ]}/>
<Text style={[ styles.label, this.state.hovered ? [styles.labelHover, textHoverStyle] : null ]}>{ text }</Text>
{icon ? <Img style={[ styles.icon, iconStyle ]}
source={ icon }
tintColor={ tintColor }/> : <View style={[ styles.icon, iconStyle ]}/> }
</Button>
);
}
}
|