From 2129f69fa0fdf85645fabe77f0803beb6d93f819 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 1 Oct 2024 00:53:11 +0300 Subject: ALF text input for generic search input (#5511) * alf text input for generic search input * clearer ref naming * Adjust props and definition * Migrate props * Migrate props * Migrate props * Replace on search screen * rm old props --------- Co-authored-by: Eric Bailey --- src/components/forms/SearchInput.tsx | 75 ++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/components/forms/SearchInput.tsx (limited to 'src/components/forms/SearchInput.tsx') diff --git a/src/components/forms/SearchInput.tsx b/src/components/forms/SearchInput.tsx new file mode 100644 index 000000000..30791d005 --- /dev/null +++ b/src/components/forms/SearchInput.tsx @@ -0,0 +1,75 @@ +import React from 'react' +import {TextInput, View} from 'react-native' +import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {HITSLOP_10} from '#/lib/constants' +import {isNative} from '#/platform/detection' +import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonIcon} from '#/components/Button' +import * as TextField from '#/components/forms/TextField' +import {MagnifyingGlass2_Stroke2_Corner0_Rounded as MagnifyingGlassIcon} from '#/components/icons/MagnifyingGlass2' +import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' + +type SearchInputProps = Omit & { + label?: TextField.InputProps['label'] + /** + * Called when the user presses the (X) button + */ + onClearText?: () => void +} + +export const SearchInput = React.forwardRef( + function SearchInput({value, label, onClearText, ...rest}, ref) { + const t = useTheme() + const {_} = useLingui() + + return ( + + + + + + + {value && value.length > 0 && ( + + + + )} + + ) + }, +) -- cgit 1.4.1