From 54f7b680522723af6c20a2dcda78e6d85d4d6ec9 Mon Sep 17 00:00:00 2001 From: adids1221 Date: Tue, 25 Feb 2025 19:09:20 +0200 Subject: [PATCH 1/9] add SearchInput component and related types --- demo/src/screens/MenuStructure.js | 17 +- .../componentScreens/SearchInputScreen.tsx | 118 +++++++ demo/src/screens/componentScreens/index.js | 4 +- src/components/index.js | 3 + .../searchInput/__tests__/searchInput.spec.ts | 18 ++ src/components/searchInput/index.tsx | 306 ++++++++++++++++++ .../searchInput/searchInput.api.json | 60 ++++ src/components/searchInput/types.ts | 72 +++++ src/index.ts | 1 + 9 files changed, 593 insertions(+), 6 deletions(-) create mode 100644 demo/src/screens/componentScreens/SearchInputScreen.tsx create mode 100644 src/components/searchInput/__tests__/searchInput.spec.ts create mode 100644 src/components/searchInput/index.tsx create mode 100644 src/components/searchInput/searchInput.api.json create mode 100644 src/components/searchInput/types.ts diff --git a/demo/src/screens/MenuStructure.js b/demo/src/screens/MenuStructure.js index c755c44436..c63e9edf65 100644 --- a/demo/src/screens/MenuStructure.js +++ b/demo/src/screens/MenuStructure.js @@ -38,6 +38,7 @@ export const navigationData = { {title: 'Page Control', tags: 'page', screen: 'unicorn.components.PageControlScreen'}, {title: 'ProgressBar', tags: 'progress bar animated', screen: 'unicorn.animations.ProgressBarScreen'}, {title: 'ScrollBar', tags: 'scroll bar gradient', screen: 'unicorn.components.ScrollBarScreen'}, + {title: 'SearchInputScreen', tags: 'search input', screen: 'unicorn.components.SearchInputScreen'}, { title: 'Shared Transition', tags: 'shared transition element', @@ -99,16 +100,18 @@ export const navigationData = { {title: 'Conversation List', tags: 'list conversation', screen: 'unicorn.lists.ConversationListScreen'}, {title: 'Drawer', tags: 'drawer', screen: 'unicorn.components.DrawerScreen'}, {title: 'SortableList', tags: 'sortable list drag', screen: 'unicorn.components.SortableListScreen'}, - {title: 'HorizontalSortableList', tags: 'sortable horizontal list drag', screen: 'unicorn.components.HorizontalSortableListScreen'}, + { + title: 'HorizontalSortableList', + tags: 'sortable horizontal list drag', + screen: 'unicorn.components.HorizontalSortableListScreen' + }, {title: 'GridList', tags: 'grid list', screen: 'unicorn.components.GridListScreen'}, {title: 'SortableGridList', tags: 'sort grid list drag', screen: 'unicorn.components.SortableGridListScreen'} ] }, Charts: { title: 'Charts', - screens: [ - {title: 'PieChart', tags: 'pie chart data', screen: 'unicorn.components.PieChartScreen'} - ] + screens: [{title: 'PieChart', tags: 'pie chart data', screen: 'unicorn.components.PieChartScreen'}] }, LayoutsAndTemplates: { title: 'Layouts & Templates', @@ -120,7 +123,11 @@ export const navigationData = { {title: 'Modal', tags: 'modal topbar screen', screen: 'unicorn.screens.ModalScreen'}, {title: 'StateScreen', tags: 'empty state screen', screen: 'unicorn.screens.EmptyStateScreen'}, {title: 'TabController', tags: 'tabbar controller native', screen: 'unicorn.components.TabControllerScreen'}, - {title: 'TabControllerWithStickyHeader', tags: 'tabbar controller native sticky header', screen: 'unicorn.components.TabControllerWithStickyHeaderScreen'}, + { + title: 'TabControllerWithStickyHeader', + tags: 'tabbar controller native sticky header', + screen: 'unicorn.components.TabControllerWithStickyHeaderScreen' + }, {title: 'Timeline', tags: 'timeline', screen: 'unicorn.components.TimelineScreen'}, { title: 'withScrollEnabler', diff --git a/demo/src/screens/componentScreens/SearchInputScreen.tsx b/demo/src/screens/componentScreens/SearchInputScreen.tsx new file mode 100644 index 0000000000..75101051d2 --- /dev/null +++ b/demo/src/screens/componentScreens/SearchInputScreen.tsx @@ -0,0 +1,118 @@ +import React, {useCallback, useRef, useState} from 'react'; +import {Alert, ScrollView} from 'react-native'; +import {Colors, View, Text, Switch, SearchInput, SearchInputRef, SearchInputPresets, Button} from 'react-native-ui-lib'; + +const SearchInputScreen = () => { + const [showCancelBtn, setShowCancelBtn] = useState(false); + const [showLoader, setShowLoader] = useState(false); + const searchInput = useRef(); + + const onChangeText = (text: string) => { + console.log('UILIB text: ', text); + }; + + const onDismiss = useCallback(() => { + Alert.alert('Cancel was pressed'); + }, []); + + return ( + + + SearchInput + + + + + + + + + + + + + Search Input Presets: + + + + Default: + + + + + Prominent: + + + + + + Settings: + + setShowCancelBtn(value)} + onColor={Colors.$iconSuccessLight} + /> + Toggle cancel button + + + setShowLoader(value)} onColor={Colors.$iconSuccessLight}/> + Toggle loader + + + Actions: on the first example + +