import React from 'react' import { StyleSheet, View, TouchableOpacity, ImageStore, Platform, TextInput, Pressable } from 'react-native' import { OInput, OButton } from '../shared' import { useLanguage } from 'ordering-components/native' import { useTheme } from 'styled-components/native'; import Icon from 'react-native-vector-icons/Feather' export const SearchBar = (props: any) => { const { searchValue, placeholder, onSearch, onCancel, lazyLoad, isCancelButtonShow, isCancelXButtonShow, noBorderShow, borderStyle, height, inputStyle, onPress, isDisabled, iconCustomRight, onSubmitEditing, blurOnSubmit, inputContainerStyles, containerStyles, hideIcon, autoFocus } = props const theme = useTheme(); const styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', padding: 1, maxHeight: 44, height: 44, borderColor: theme.colors.clear }, borderStyle: { borderColor: theme.colors.primary, borderWidth: 1, borderRadius: 7.6, }, inputStyle: { height: '100%', borderRadius: 7.6, paddingHorizontal: 10, backgroundColor: theme.colors.backgroundGray100, }, buttonStyle: { maxHeight: 40, paddingRight: 5, backgroundColor: 'red' } }) const [, t] = useLanguage() const handleClear = () => { onSearch('') } let timeout: null | any = null const onChangeSearch = (e: any) => { if (!lazyLoad) { onSearch(e) } else { clearTimeout(timeout) timeout = setTimeout(function () { onSearch(e) }, 750) } } return ( onPress && onPress()} iconCustomRight={iconCustomRight} onSubmitEditing={() => onSubmitEditing && onSubmitEditing()} /> {isCancelButtonShow && ( )} {isCancelXButtonShow && ( )} ) }