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
93
|
import React from 'react';
import {
Keyboard,
NativeSyntheticEvent,
StyleSheet,
Text,
TextInput,
TextInputProps,
TextInputSubmitEditingEventData,
TouchableOpacity,
View,
} from 'react-native';
import {normalize} from 'react-native-elements';
import Animated from 'react-native-reanimated';
interface SearchBarProps extends TextInputProps {
onCancel: () => void;
searching: boolean;
placeholder: string;
}
const ChatSearchBar: React.FC<SearchBarProps> = ({
onFocus,
onBlur,
onChangeText,
value,
onCancel,
onLayout,
placeholder,
}) => {
const handleSubmit = (
e: NativeSyntheticEvent<TextInputSubmitEditingEventData>,
) => {
e.preventDefault();
Keyboard.dismiss();
};
return (
<View style={styles.container} onLayout={onLayout}>
<Animated.View style={styles.inputContainer}>
<Animated.View style={styles.searchTextContainer}>
<Text style={styles.searchTextStyes}>To:</Text>
</Animated.View>
<TextInput
style={styles.input}
placeholderTextColor={'#828282'}
onSubmitEditing={handleSubmit}
clearButtonMode="always"
autoCapitalize="none"
autoCorrect={false}
{...{placeholder, value, onChangeText, onFocus, onBlur}}
/>
</Animated.View>
<TouchableOpacity style={styles.cancelButton} onPress={onCancel}>
<Text style={styles.cancelText}>Cancel</Text>
</TouchableOpacity>
</View>
);
};
const styles = StyleSheet.create({
container: {
height: 40,
paddingHorizontal: 20,
flexDirection: 'row',
zIndex: 2,
},
searchTextContainer: {marginHorizontal: 12},
searchTextStyes: {fontWeight: 'bold', fontSize: 14, lineHeight: 17},
inputContainer: {
flexGrow: 1,
flexDirection: 'row',
alignItems: 'center',
paddingHorizontal: 8,
borderRadius: 20,
backgroundColor: '#F0F0F0',
},
input: {
flex: 1,
fontSize: 16,
color: '#000',
letterSpacing: normalize(0.5),
},
cancelButton: {
justifyContent: 'center',
paddingLeft: 10,
},
cancelText: {
color: '#818181',
fontWeight: '500',
},
});
export default ChatSearchBar;
|