From ddf1eebfe7ae7ce763a7951cf064724192ac0e51 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 22 Oct 2024 12:19:20 +0300 Subject: [PATCH] animate search --- src/view/screens/Search/Search.tsx | 104 ++++++++++++++++++----------- 1 file changed, 64 insertions(+), 40 deletions(-) diff --git a/src/view/screens/Search/Search.tsx b/src/view/screens/Search/Search.tsx index 652d4ec38e..f535992a34 100644 --- a/src/view/screens/Search/Search.tsx +++ b/src/view/screens/Search/Search.tsx @@ -12,6 +12,14 @@ import { } from 'react-native' import {ScrollView as RNGHScrollView} from 'react-native-gesture-handler' import RNPickerSelect from 'react-native-picker-select' +import Animated, { + LayoutAnimationConfig, + LinearTransition, + SlideInLeft, + SlideInRight, + SlideOutLeft, + SlideOutRight, +} from 'react-native-reanimated' import {AppBskyActorDefs, AppBskyFeedDefs, moderateProfile} from '@atproto/api' import { FontAwesomeIcon, @@ -63,6 +71,7 @@ import {atoms as a, useBreakpoints, useTheme as useThemeNew, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as FeedCard from '#/components/FeedCard' import {SearchInput} from '#/components/forms/SearchInput' +import {useInteractionState} from '#/components/hooks/useInteractionState' import {ChevronBottom_Stroke2_Corner0_Rounded as ChevronDown} from '#/components/icons/Chevron' import {Menu_Stroke2_Corner0_Rounded as Menu} from '#/components/icons/Menu' import * as Layout from '#/components/Layout' @@ -844,7 +853,10 @@ export function SearchScreen( [selectedProfiles], ) + const {state: isFocused, onIn: onFocus, onOut: onBlur} = useInteractionState() + const onSearchInputFocus = React.useCallback(() => { + onFocus() if (isWeb) { // Prevent a jump on iPad by ensuring that // the initial focused render has no result list. @@ -854,7 +866,7 @@ export function SearchScreen( } else { setShowAutocomplete(true) } - }, [setShowAutocomplete]) + }, [setShowAutocomplete, onFocus]) return ( @@ -872,46 +884,58 @@ export function SearchScreen( }), ]} sideBorders={gtMobile}> - - {!gtMobile && ( - - )} - - + + + {!gtMobile && !isFocused && ( + + + + )} + + + + {showAutocomplete && ( + + + + )} - {showAutocomplete && ( - - )} - + {showFilters && (