import React, { useState } from "react"; import { View, TextInput, StyleSheet, Platform, StyleProp, ViewStyle } from "react-native"; import { Ionicons } from "@expo/vector-icons"; interface SearchBarProps { onSearch?: (text: string) => void; style?: StyleProp; } export default function SearchBar({ onSearch, style }: SearchBarProps) { const [searchText, setSearchText] = useState(""); const handleChangeText = (text: string) => { setSearchText(text); onSearch?.(text); }; return ( {searchText.length > 0 && ( handleChangeText("")} /> )} ); } const styles = StyleSheet.create({ container: { flexDirection: "row", alignItems: "center", backgroundColor: "#F9FAFB", borderRadius: 12, paddingHorizontal: 16, paddingVertical: 12, borderWidth: 1, borderColor: "#E5E7EB", }, icon: { marginRight: 8, }, input: { flex: 1, fontSize: 16, color: "#111827", fontFamily: Platform.select({ ios: "System", android: "Roboto", default: "System", }), }, clearIcon: { marginLeft: 8, }, });