@@ -4,18 +4,19 @@ import React, { Component } from 'react';
4
4
import PropTypes from 'prop-types' ;
5
5
import { StyleSheet , TextInput } from 'react-native' ;
6
6
import color from 'color' ;
7
-
8
7
import withTheme from '../core/withTheme' ;
9
8
import Icon from './Icon' ;
10
9
import TouchableRipple from './TouchableRipple' ;
11
10
import Paper from './Paper' ;
11
+ import { white } from '../styles/colors' ;
12
12
import type { Theme } from '../types/Theme' ;
13
13
14
14
type Props = {
15
15
placeholder ?: string ,
16
16
value : string ,
17
17
onChangeText : ( query : string ) => void ,
18
18
theme : Theme ,
19
+ style ?: any ,
19
20
} ;
20
21
21
22
/**
@@ -36,38 +37,49 @@ class SearchBar extends Component<void, Props, void> {
36
37
*/
37
38
onChangeText : PropTypes . func . isRequired ,
38
39
theme : PropTypes . object . isRequired ,
40
+ style : Paper . propTypes . style ,
39
41
} ;
40
42
41
43
_handleClearPress = ( ) = > {
42
44
this . props . onChangeText ( '' ) ;
43
45
} ;
44
46
45
47
render ( ) {
46
- const { placeholder, value, theme } = this . props ;
48
+ const { placeholder, value, theme, style, ...rest } = this . props ;
49
+ const { colors , roundness } = theme ;
50
+ const textColor = colors . text ;
51
+ const iconColor = color ( textColor ) . alpha ( 0.54 ) . rgbaString ( ) ;
52
+ const rippleColor = color ( textColor ) . alpha ( 0.32 ) . rgbaString ( ) ;
47
53
48
54
return (
49
- < Paper elevation = { 4 } style = { styles . container } >
55
+ < Paper
56
+ elevation = { 4 }
57
+ style = { [ { borderRadius : roundness } , styles . container , style ] }
58
+ >
50
59
< Icon
51
- style = { [ styles . iconWrapper , styles . icon ] }
60
+ style = { [ styles . icon , { color : iconColor } ] }
52
61
name = "search"
53
62
size = { 24 }
54
63
/>
55
64
< TextInput
56
- style = { styles . input }
65
+ style = { [ styles . input , { color : textColor } ] }
57
66
placeholder = { placeholder || '' }
58
- value = { value }
59
- placeholderTextColor = { theme . colors . placeholder }
67
+ placeholderTextColor = { colors . placeholder }
60
68
underlineColorAndroid = "transparent"
61
- onChangeText = { this . props . onChangeText }
62
69
returnKeyType = "search"
70
+ { ...rest }
63
71
/>
64
72
{ value
65
73
? < TouchableRipple
66
74
borderless
75
+ rippleColor = { rippleColor }
67
76
onPress = { this . _handleClearPress }
68
- style = { styles . iconWrapper }
69
77
>
70
- < Icon style = { styles . icon } name = "close" size = { 24 } />
78
+ < Icon
79
+ style = { [ styles . icon , { color : iconColor } ] }
80
+ name = "close"
81
+ size = { 24 }
82
+ />
71
83
</ TouchableRipple >
72
84
: null }
73
85
</ Paper >
@@ -78,19 +90,16 @@ class SearchBar extends Component<void, Props, void> {
78
90
const styles = StyleSheet . create ( {
79
91
container : {
80
92
flexDirection : 'row' ,
81
- justifyContent : 'center' ,
82
93
alignItems : 'center' ,
83
- margin : 8 ,
94
+ backgroundColor : white ,
95
+ margin : 4 ,
84
96
} ,
85
97
input : {
86
98
flex : 1 ,
87
99
fontSize : 18 ,
88
100
} ,
89
- iconWrapper : {
90
- padding : 16 ,
91
- } ,
92
101
icon : {
93
- color : color ( 'black' ) . alpha ( 0.54 ) . rgbaString ( ) ,
102
+ margin : 12 ,
94
103
} ,
95
104
} ) ;
96
105
0 commit comments