@@ -5,7 +5,6 @@ import * as React from 'react';
5
5
import { View , StyleSheet } from 'react-native' ;
6
6
import Icon from './Icon' ;
7
7
import TouchableRipple from './TouchableRipple' ;
8
- import { grey300 , grey700 } from '../styles/colors' ;
9
8
import withTheme from '../core/withTheme' ;
10
9
import Text from './Typography/Text' ;
11
10
import type { Theme } from '../types' ;
@@ -28,10 +27,7 @@ type Props = {
28
27
* Function to execute on press.
29
28
*/
30
29
onPress ?: ( ) => mixed ,
31
- /**
32
- * Custom color for the drawer text and icon.
33
- */
34
- color ?: string ,
30
+ style ?: any ,
35
31
/**
36
32
* @optional
37
33
*/
@@ -53,61 +49,72 @@ type Props = {
53
49
*/
54
50
class DrawerItem extends React . Component < Props > {
55
51
render ( ) {
56
- const {
57
- color : activeColor ,
58
- icon,
59
- label,
60
- active,
61
- theme,
62
- ...props
63
- } = this . props ;
64
- const { colors, dark } = theme ;
65
- const backgroundColor = active ? ( dark ? grey700 : grey300 ) : 'transparent' ;
66
- const labelColor = active
67
- ? activeColor || colors . text
68
- : color ( colors . text )
69
- . alpha ( 0.54 )
52
+ const { icon, label, active, theme, style, onPress, ...rest } = this . props ;
53
+ const { colors, roundness } = theme ;
54
+ const backgroundColor = active
55
+ ? color ( colors . primary )
56
+ . alpha ( 0.12 )
70
57
. rgb ( )
71
- . string ( ) ;
72
- const iconColor = active
73
- ? activeColor || colors . text
58
+ . string ( )
59
+ : 'transparent' ;
60
+ const contentColor = active
61
+ ? colors . primary
74
62
: color ( colors . text )
75
- . alpha ( 0.54 )
63
+ . alpha ( 0.68 )
76
64
. rgb ( )
77
65
. string ( ) ;
78
66
const fontFamily = theme . fonts . medium ;
79
67
const labelMargin = icon ? 32 : 0 ;
80
68
81
69
return (
82
- < TouchableRipple { ...props } >
83
- < View style = { [ styles . wrapper , { backgroundColor } ] } >
84
- { icon && < Icon source = { icon } size = { 24 } color = { iconColor } /> }
85
- < Text
86
- numberOfLines = { 1 }
87
- style = { [
88
- {
89
- color : labelColor ,
90
- fontFamily,
91
- marginLeft : labelMargin ,
92
- } ,
93
- styles . label ,
94
- ] }
95
- >
96
- { label }
97
- </ Text >
98
- </ View >
99
- </ TouchableRipple >
70
+ < View
71
+ { ...rest }
72
+ style = { [
73
+ styles . container ,
74
+ { backgroundColor, borderRadius : roundness } ,
75
+ style ,
76
+ ] }
77
+ >
78
+ < TouchableRipple
79
+ borderless
80
+ delayPressIn = { 0 }
81
+ onPress = { onPress }
82
+ style = { { borderRadius : roundness } }
83
+ >
84
+ < View style = { styles . wrapper } >
85
+ { icon ? (
86
+ < Icon source = { icon } size = { 24 } color = { contentColor } />
87
+ ) : null }
88
+ < Text
89
+ numberOfLines = { 1 }
90
+ style = { [
91
+ styles . label ,
92
+ {
93
+ color : contentColor ,
94
+ fontFamily,
95
+ marginLeft : labelMargin ,
96
+ } ,
97
+ ] }
98
+ >
99
+ { label }
100
+ </ Text >
101
+ </ View >
102
+ </ TouchableRipple >
103
+ </ View >
100
104
) ;
101
105
}
102
106
}
103
107
104
108
const styles = StyleSheet . create ( {
109
+ container : {
110
+ marginHorizontal : 10 ,
111
+ marginVertical : 4 ,
112
+ } ,
105
113
wrapper : {
106
114
flexDirection : 'row' ,
107
115
alignItems : 'center' ,
108
- paddingHorizontal : 16 ,
109
- paddingVertical : 12 ,
110
- height : 48 ,
116
+ padding : 8 ,
117
+ height : 40 ,
111
118
} ,
112
119
label : {
113
120
marginRight : 32 ,
0 commit comments