@@ -25,7 +25,37 @@ type State = {
25
25
26
26
class MaterialSearchBar extends React . Component < Props , State > {
27
27
_textInput : TextInput
28
- static defaultProps = { }
28
+
29
+ static defaultProps = {
30
+ containerStyle : {
31
+ flexDirection : 'row' ,
32
+ alignItems : 'center' ,
33
+ backgroundColor : 'white' ,
34
+ elevation : 8 ,
35
+ paddingHorizontal : 12
36
+ } ,
37
+ styleInput : {
38
+ flex : 1 ,
39
+ height : 56 ,
40
+ color : 'black' ,
41
+ fontSize : 20 ,
42
+ fontFamily : 'Roboto'
43
+ } ,
44
+ placeholderTextColor : 'grey'
45
+ }
46
+
47
+ static propTypes = {
48
+ /** Override the inline-styles of the root element */
49
+ containerStyle : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . object ] ) ,
50
+ /** Override the inline-styles of the style input */
51
+ styleInput : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . object ] ) ,
52
+ /** The displayed search icon on the right of the input text */
53
+ searchIcon : PropTypes . element ,
54
+ /** The displayed close icon on the right of the input text */
55
+ closeIcon : PropTypes . element ,
56
+ /** A function to execute when field's value is changed */
57
+ onChangeText : PropTypes . func . isRequired
58
+ }
29
59
30
60
constructor ( props : Props ) {
31
61
super ( props )
@@ -42,7 +72,10 @@ class MaterialSearchBar extends React.Component<Props, State> {
42
72
} )
43
73
}
44
74
45
- doAnimation = ( ) = > {
75
+ /**
76
+ * Starts a sequenced animation on close/search button
77
+ */
78
+ startAnimation = ( ) => {
46
79
Animated . sequence ( [
47
80
Animated . timing ( this . state . scale , {
48
81
toValue : 1.2 ,
@@ -66,13 +99,13 @@ class MaterialSearchBar extends React.Component<Props, State> {
66
99
}
67
100
68
101
if ( this . state . value . length === 0 ) {
69
- this . doAnimation ( )
102
+ this . startAnimation ( )
70
103
}
71
104
}
72
105
73
106
componentWillUpdate ( nextProps : Props , nextState : State ) {
74
107
if ( nextState . value . length === 0 ) {
75
- this . doAnimation ( )
108
+ this . startAnimation ( )
76
109
}
77
110
}
78
111
@@ -118,31 +151,4 @@ class MaterialSearchBar extends React.Component<Props, State> {
118
151
}
119
152
}
120
153
121
- MaterialSearchBar . defaultProps = {
122
- containerStyle : {
123
- flexDirection : 'row' ,
124
- alignItems : 'center' ,
125
- backgroundColor : 'white' ,
126
- elevation : 8 ,
127
- paddingHorizontal : 12
128
- } ,
129
- styleInput : {
130
- flex : 1 ,
131
- height : 56 ,
132
- color : 'black' ,
133
- fontSize : 20 ,
134
- fontFamily : 'Roboto'
135
- } ,
136
- placeholderTextColor : 'grey'
137
- }
138
-
139
- MaterialSearchBar . propTypes = {
140
- /** Override the inline-styles of the root element. */
141
- containerStyle : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . object ] ) ,
142
- styleInput : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . object ] ) ,
143
- searchIcon : PropTypes . element ,
144
- closeIcon : PropTypes . element ,
145
- onChangeText : PropTypes . func . isRequired
146
- }
147
-
148
154
export default MaterialSearchBar
0 commit comments