1- import React , { useCallback , useMemo } from 'react' ;
1+ import React , { useCallback , useEffect , useMemo } from 'react' ;
22import { StyleSheet , Text , TextInput , View } from 'react-native' ;
33import { Gesture , GestureDetector } from 'react-native-gesture-handler' ;
44import Animated , {
@@ -11,6 +11,7 @@ import Animated, {
1111 useSharedValue ,
1212 withDelay ,
1313 withSpring ,
14+ withTiming ,
1415} from 'react-native-reanimated' ;
1516
1617import { PollComposerOption , PollComposerState } from 'stream-chat' ;
@@ -295,6 +296,19 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
295296 // this will hold id for item which user started dragging
296297 const draggedItemId = useSharedValue < string | null > ( null ) ;
297298
299+ // holds the animated height of the option container
300+ const animatedOptionsContainerHeight = useSharedValue ( createPollOptionHeight * options . length ) ;
301+
302+ useEffect ( ( ) => {
303+ animatedOptionsContainerHeight . value = withTiming ( createPollOptionHeight * options . length , {
304+ duration : 200 ,
305+ } ) ;
306+ } , [ animatedOptionsContainerHeight , createPollOptionHeight , options . length ] ) ;
307+
308+ const animatedOptionsContainerStyle = useAnimatedStyle ( ( ) => ( {
309+ height : animatedOptionsContainerHeight . value ,
310+ } ) ) ;
311+
298312 const boundaries = useMemo (
299313 ( ) => ( { maxBound : ( options . length - 1 ) * createPollOptionHeight , minBound : 0 } ) ,
300314 [ createPollOptionHeight , options . length ] ,
@@ -332,7 +346,7 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
332346 return (
333347 < View style = { [ styles . container , container ] } >
334348 < Text style = { [ styles . text , { color : black } , title ] } > { t < string > ( 'Options' ) } </ Text >
335- < View style = { { height : createPollOptionHeight * options . length } } >
349+ < Animated . View style = { animatedOptionsContainerStyle } >
336350 { options . map ( ( option , index ) => (
337351 < MemoizedCreatePollOption
338352 boundaries = { boundaries }
@@ -348,7 +362,7 @@ export const CreatePollOptions = ({ currentOptionPositions }: CreatePollOptionsP
348362 option = { option }
349363 />
350364 ) ) }
351- </ View >
365+ </ Animated . View >
352366 </ View >
353367 ) ;
354368} ;
0 commit comments