diff --git a/components/common/SearchBar.tsx b/components/common/SearchBar.tsx index 372d052..714a3d6 100644 --- a/components/common/SearchBar.tsx +++ b/components/common/SearchBar.tsx @@ -1,14 +1,18 @@ import { AntDesign } from '@expo/vector-icons'; -import React from 'react'; +import React, { useState } from 'react'; import { StyleSheet, TextInput, TouchableOpacity, View, ViewProps } from 'react-native'; import { SIZES } from '../../constants/theme'; import { useTheme } from '../../app/contexts/ThemeContext'; -type SearchBarProps = {placeholder: string} & ViewProps +interface SearchBarProps extends ViewProps { + placeholder? : string; + onChangeText? : (text: string) => void | undefined +} export default function SearchBar(props: SearchBarProps) { const [isActive, setIsactive] = React.useState(false); const { colors } = useTheme(); + const [text, setText] = useState(""); const textColor = colors const backgroundColor = colors.elementDefaultColor; @@ -23,6 +27,10 @@ export default function SearchBar(props: SearchBarProps) { setIsactive(false) } } + if(props.onChangeText){ + props.onChangeText(text) + } + setText(text) } // cant apply the background color otherwise @@ -35,10 +43,10 @@ export default function SearchBar(props: SearchBarProps) { // changed styles.container to containerStyle return ( - + {isActive && - + {handleChange("")}}> }