11import React , { useCallback , useMemo } from 'react' ;
2- import { FlatList , StyleSheet , View } from 'react-native' ;
2+ import { FlatList , StyleSheet } from 'react-native' ;
3+
4+ import Animated , { LinearTransition , ZoomIn , ZoomOut } from 'react-native-reanimated' ;
35
46import { SearchSourceState , TextComposerState , TextComposerSuggestion } from 'stream-chat' ;
57
@@ -12,7 +14,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
1214import { useStableCallback } from '../../hooks' ;
1315import { useStateStore } from '../../hooks/useStateStore' ;
1416
15- export const DEFAULT_LIST_HEIGHT = 200 ;
17+ export const DEFAULT_LIST_HEIGHT = 208 ;
1618
1719export type AutoCompleteSuggestionListProps = Partial <
1820 Pick < MessageInputContextValue , 'AutoCompleteSuggestionHeader' | 'AutoCompleteSuggestionItem' >
@@ -63,10 +65,10 @@ export const AutoCompleteSuggestionList = ({
6365 colors : { black, white } ,
6466 messageInput : {
6567 container : { maxHeight } ,
66- suggestionsListContainer : { flatlist } ,
6768 } ,
6869 } ,
6970 } = useTheme ( ) ;
71+ const styles = useStyles ( ) ;
7072
7173 const renderItem = useCallback (
7274 ( { item } : { item : TextComposerSuggestion } ) => {
@@ -90,7 +92,12 @@ export const AutoCompleteSuggestionList = ({
9092 }
9193
9294 return (
93- < View style = { [ styles . container ] } >
95+ < Animated . View
96+ entering = { ZoomIn . duration ( 200 ) }
97+ exiting = { ZoomOut . duration ( 200 ) }
98+ layout = { LinearTransition . duration ( 200 ) }
99+ style = { styles . container }
100+ >
94101 < FlatList
95102 data = { items }
96103 keyboardShouldPersistTaps = 'always'
@@ -99,33 +106,47 @@ export const AutoCompleteSuggestionList = ({
99106 onEndReached = { loadMore }
100107 onEndReachedThreshold = { 0.1 }
101108 renderItem = { renderItem }
102- style = { [
103- styles . flatlist ,
104- flatlist ,
105- { backgroundColor : white , maxHeight, shadowColor : black } ,
106- ] }
109+ style = { [ styles . flatlist , { backgroundColor : white , maxHeight, shadowColor : black } ] }
107110 testID = { 'auto-complete-suggestion-list' }
108111 />
109- </ View >
112+ </ Animated . View >
110113 ) ;
111114} ;
112115
113- const styles = StyleSheet . create ( {
114- container : {
115- maxHeight : DEFAULT_LIST_HEIGHT ,
116- } ,
117- flatlist : {
118- borderRadius : 8 ,
119- elevation : 3 ,
120- marginHorizontal : 8 ,
121- shadowOffset : {
122- height : 1 ,
123- width : 0 ,
116+ const useStyles = ( ) => {
117+ const {
118+ theme : {
119+ semantics,
120+ messageInput : {
121+ suggestionsListContainer : { flatlist } ,
122+ } ,
124123 } ,
125- shadowOpacity : 0.22 ,
126- shadowRadius : 2.22 ,
127- } ,
128- } ) ;
124+ } = useTheme ( ) ;
125+ return useMemo (
126+ ( ) =>
127+ StyleSheet . create ( {
128+ container : {
129+ maxHeight : DEFAULT_LIST_HEIGHT ,
130+ backgroundColor : semantics . composerBg ,
131+ borderTopWidth : 1 ,
132+ borderColor : semantics . borderCoreDefault ,
133+ } ,
134+ flatlist : {
135+ borderRadius : 8 ,
136+ elevation : 3 ,
137+ marginHorizontal : 8 ,
138+ shadowOffset : {
139+ height : 1 ,
140+ width : 0 ,
141+ } ,
142+ shadowOpacity : 0.22 ,
143+ shadowRadius : 2.22 ,
144+ ...flatlist ,
145+ } ,
146+ } ) ,
147+ [ semantics , flatlist ] ,
148+ ) ;
149+ } ;
129150
130151AutoCompleteSuggestionList . displayName =
131152 'AutoCompleteSuggestionList{messageInput{suggestions{List}}}' ;
0 commit comments