From 36c2519fa060f28954488c95228892b5f2e5cceb Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Mon, 4 May 2026 17:55:49 +0800 Subject: [PATCH] upd: search --- components/inputSearch.tsx | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/components/inputSearch.tsx b/components/inputSearch.tsx index 3a930d8..39e5fe7 100644 --- a/components/inputSearch.tsx +++ b/components/inputSearch.tsx @@ -1,19 +1,42 @@ import { useTheme } from "@/providers/ThemeProvider"; import { Feather } from "@expo/vector-icons"; +import { useState } from "react"; +import { TouchableOpacity } from "react-native"; import { InputForm } from "./inputForm"; export default function InputSearch({ onChange, width, value, bg }: { onChange?: (val: string) => void, width?: number, value?: string, bg?: string }) { const { colors } = useTheme(); + const [internalValue, setInternalValue] = useState(value ?? ""); + + const displayValue = value !== undefined ? value : internalValue; + + const handleChange = (val: string) => { + setInternalValue(val); + onChange?.(val); + }; + + const handleClear = () => { + setInternalValue(""); + onChange?.(""); + }; + return ( } - onChange={onChange} + itemRight={ + displayValue ? ( + + + + ) : undefined + } + onChange={handleChange} width={width} bg={bg} - value={value} + value={displayValue} mb={false} /> ) -- 2.49.1