import React, { forwardRef } from 'react'; import { View, ViewStyle } from 'react-native'; import tw from '../lib/tailwind'; import { theme } from '../theme'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import MyTextInput from './textinput'; import MyTouchableOpacity from './touchable-opacity'; interface SearchBarProps { value: string; onChangeText: (text: string) => void; placeholder?: string; editable?: boolean; onSubmitEditing?: () => void; returnKeyType?: 'search' | 'done' | 'go' | 'next' | 'send'; containerStyle?: ViewStyle; onPress?: () => void; activeOpacity?: number; } const SearchBar = forwardRef(({ value, onChangeText, placeholder = 'Search fresh meat...', editable = true, onSubmitEditing, returnKeyType = 'search', containerStyle, onPress, activeOpacity = 0.8, }, ref) => { const Wrapper = onPress ? MyTouchableOpacity : View; const wrapperProps = onPress ? { style: [tw`flex-row items-center bg-white rounded-2xl px-4 h-12 mb-6 shadow-md`, { overflow: 'visible' }, containerStyle], onPress, activeOpacity, } : { style: [tw`flex-row items-center bg-white rounded-2xl px-4 h-12 mb-6 shadow-md`, { overflow: 'visible' }, containerStyle], }; return ( ); }); SearchBar.displayName = 'SearchBar'; export default SearchBar;