|
| 1 | +import {height} from 'dom-helpers'; |
1 | 2 | import React from 'react'; |
2 | 3 | import {Text, View, TextInput} from 'react-native'; |
3 | 4 |
|
@@ -33,45 +34,57 @@ const Input = ({ |
33 | 34 | const getBorderColor = () => { |
34 | 35 | if (error) { |
35 | 36 | return props.borderColor || '#DC2626'; |
| 37 | + } else if (focused) { |
| 38 | + return props.focusBorderColor || props.borderColor; |
36 | 39 | } |
37 | | - |
38 | | - if (focused) { |
39 | | - return props.focusColor || '#52525B'; |
40 | | - } |
| 40 | + return props.borderColor; |
41 | 41 | }; |
42 | 42 |
|
43 | 43 | return ( |
44 | 44 | <> |
45 | 45 | <View style={{...props.labelStyles}}> |
46 | | - {label && <Text>{label}</Text>} |
| 46 | + {label && ( |
| 47 | + <Text style={{color: props.labelTextColor || '#000'}}>{label}</Text> |
| 48 | + )} |
47 | 49 | </View> |
48 | 50 | <View |
49 | 51 | style={{ |
50 | 52 | ...(props.wrapperStyles || { |
51 | | - height: 42, |
52 | | - borderWidth: 1, |
53 | | - borderRadius: 4, |
54 | | - paddingHorizontal: 5, |
55 | | - marginTop: 5, |
56 | | - alignItems: icon ? 'center' : 'baseline', |
| 53 | + height: props.height || 42, |
| 54 | + borderWidth: props.borderWidth || 1, |
| 55 | + borderRadius: props.borderRadius || 4, |
| 56 | + paddingHorizontal: props.paddingHorizontal || 5, |
| 57 | + marginTop: props.marginTop || 5, |
| 58 | + alignItems: 'center', |
57 | 59 | borderColor: getBorderColor(), |
58 | | - flexDirection: getFlexDirection(), |
| 60 | + flexDirection: getFlexDirection() || 'row', |
59 | 61 | }), |
60 | 62 | }}> |
61 | | - <View>{icon && icon}</View> |
62 | | - <TextInput |
63 | | - placeholder={placeholder} |
64 | | - style={textInputStyles} |
65 | | - onChangeText={onChangeText} |
66 | | - value={value} |
67 | | - onFocus={() => { |
68 | | - setFocused(true); |
69 | | - }} |
70 | | - onBlur={() => { |
71 | | - setFocused(false); |
72 | | - }} |
73 | | - {...props} |
74 | | - /> |
| 63 | + <View |
| 64 | + style={{ |
| 65 | + alignItems: 'center', |
| 66 | + }}> |
| 67 | + {icon && icon} |
| 68 | + </View> |
| 69 | + <View |
| 70 | + style={{ |
| 71 | + height: props.height || 42, |
| 72 | + }}> |
| 73 | + <TextInput |
| 74 | + placeholder={placeholder} |
| 75 | + style={textInputStyles} |
| 76 | + color={props.color || '#000'} |
| 77 | + onChangeText={onChangeText} |
| 78 | + value={value} |
| 79 | + onFocus={() => { |
| 80 | + setFocused(true); |
| 81 | + }} |
| 82 | + onBlur={() => { |
| 83 | + setFocused(false); |
| 84 | + }} |
| 85 | + {...props} |
| 86 | + /> |
| 87 | + </View> |
75 | 88 | </View> |
76 | 89 | <View> |
77 | 90 | {error && ( |
|
0 commit comments