@@ -4,17 +4,14 @@ import {
44 findNodeHandle ,
55 GestureResponderEvent ,
66 Keyboard ,
7- LayoutAnimation ,
87 Pressable ,
98 StyleProp ,
10- StyleSheet ,
11- TouchableWithoutFeedback ,
129 UIManager ,
1310 View ,
1411 ViewStyle ,
1512} from 'react-native' ;
1613
17- import Animated , { Easing , FadeIn , FadeOut , useSharedValue } from 'react-native-reanimated' ;
14+ import { useSharedValue } from 'react-native-reanimated' ;
1815import { Portal } from 'react-native-teleport' ;
1916
2017import type { Attachment , LocalMessage , UserResponse } from 'stream-chat' ;
@@ -25,7 +22,6 @@ import { useMessageActions } from './hooks/useMessageActions';
2522import { useMessageDeliveredData } from './hooks/useMessageDeliveryData' ;
2623import { useMessageReadData } from './hooks/useMessageReadData' ;
2724import { useProcessReactions } from './hooks/useProcessReactions' ;
28- import { MessageOverlayBundle } from './MessageOverlayBundle' ;
2925import { messageActions as defaultMessageActions } from './utils/messageActions' ;
3026
3127import { closeOverlay , openOverlay , useOverlayController } from '../../contexts' ;
@@ -84,7 +80,7 @@ function measureInWindow(node: any): Promise<{ x: number; y: number; w: number;
8480 const handle = findNodeHandle ( node ) ;
8581 if ( ! handle ) return reject ( new Error ( 'No native handle' ) ) ;
8682
87- UIManager . measureInWindow ( handle , ( x , y , w , h ) => resolve ( { x , y , w , h } ) ) ;
83+ UIManager . measureInWindow ( handle , ( x , y , w , h ) => resolve ( { h , w , x , y } ) ) ;
8884 } ) ;
8985}
9086
@@ -326,7 +322,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
326322 const { client } = chatContext ;
327323 const {
328324 theme : {
329- colors : { targetedMessageBackground, bg_gradient_start, overlay } ,
325+ colors : { targetedMessageBackground, bg_gradient_start } ,
330326 messageSimple : { targetedMessageContainer, unreadUnderlayColor = bg_gradient_start , wrapper } ,
331327 screenPadding,
332328 } ,
@@ -335,15 +331,16 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
335331 const topH = useSharedValue < { w : number ; h : number ; x : number ; y : number } | undefined > (
336332 undefined ,
337333 ) ;
338- const bottomH = useSharedValue ( { w : 0 , h : 0 , x : 0 , y : 0 } ) ;
334+ const bottomH = useSharedValue < { w : number ; h : number ; x : number ; y : number } | undefined > (
335+ undefined ,
336+ ) ;
339337
340338 const showMessageOverlay = async ( showMessageReactions = false , selectedReaction ?: string ) => {
341339 await dismissKeyboard ( ) ;
342340 try {
343341 const layout = await measureInWindow ( messageWrapperRef . current ) ;
344342 setShowMessageReactions ( showMessageReactions ) ;
345- // LayoutAnimation.configureNext(LayoutAnimation.Presets.spring);
346- openOverlay ( message . id , { state : { isMyMessage, rect : layout } , topH, bottomH } ) ;
343+ openOverlay ( message . id , { bottomH, state : { isMyMessage, rect : layout } , topH } ) ;
347344 setSelectedReaction ( selectedReaction ) ;
348345 } catch ( e ) {
349346 console . error ( e ) ;
@@ -820,11 +817,11 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
820817 ] }
821818 testID = 'message-wrapper'
822819 >
823- { active ? (
820+ { active && state ? (
824821 < View
825822 style = { {
826- width : state . rect . w ,
827823 height : state . rect . h ,
824+ width : state . rect . w ,
828825 } }
829826 />
830827 ) : null }
@@ -833,8 +830,7 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
833830 < Pressable
834831 onLayout = { ( e ) => {
835832 const { x, y, width : w , height : h } = e . nativeEvent . layout ;
836- console . log ( 'BLA' , x , y , w , h ) ;
837- topH . value = { x, y, w, h } ;
833+ topH . value = { h, w, x, y } ;
838834 } }
839835 onPress = { ( ) => Alert . alert ( 'HIT TOP' ) }
840836 >
@@ -844,47 +840,26 @@ const MessageWithContext = (props: MessagePropsWithContext) => {
844840 </ Portal >
845841 < Portal
846842 hostName = { active ? 'message-overlay' : undefined }
847- style = { active ? { width : state . rect . w } : null }
843+ style = { active && state ? { width : state . rect . w } : undefined }
848844 >
849- { /* The message itself: NOT animated; it just rides along as a child */ }
850845 < MessageSimple ref = { messageWrapperRef } />
851-
852- { /* Actions below; height measured */ }
846+ </ Portal >
847+ < Portal hostName = { active && ! closing ? 'bottom-item' : undefined } >
853848 { active && ! closing ? (
854- < Animated . View
855- entering = { FadeIn . duration ( ANIMATED_DURATION ) . easing ( Easing . in ( Easing . cubic ) ) }
856- exiting = { FadeOut . duration ( ANIMATED_DURATION ) . easing ( Easing . out ( Easing . cubic ) ) }
849+ < Pressable
857850 onLayout = { ( e ) => {
858851 const { x, y, width : w , height : h } = e . nativeEvent . layout ;
859- // eslint-disable-next-line sort-keys
860- bottomH . value = { x, y, w, h } ;
861- } }
862- style = { {
863- position : 'absolute' ,
864- top : state . rect . h ,
865- ...( isMyMessage ? { right : state . rect . x } : { left : state . rect . x } ) ,
852+ bottomH . value = { h, w, x, y } ;
866853 } }
854+ onPress = { ( ) => Alert . alert ( 'HIT BOTTOM' ) }
867855 >
868- < Pressable onPress = { ( ) => Alert . alert ( 'HIT BOTTOM' ) } >
869- < MessageActions />
870- </ Pressable >
871- </ Animated . View >
856+ < MessageActions />
857+ </ Pressable >
872858 ) : null }
873859 </ Portal >
874860 { isBounceDialogOpen ? (
875861 < MessageBounce setIsBounceDialogOpen = { setIsBounceDialogOpen } />
876862 ) : null }
877- { /*{messageOverlayVisible ? (*/ }
878- { /*<MessageMenu*/ }
879- { /* dismissOverlay={dismissOverlay}*/ }
880- { /* handleReaction={ownCapabilities.sendReaction ? handleReaction : undefined}*/ }
881- { /* layout={messageOverlayVisible}*/ }
882- { /* messageActions={messageActions}*/ }
883- { /* selectedReaction={selectedReaction}*/ }
884- { /* showMessageReactions={showMessageReactions}*/ }
885- { /* visible={!!messageOverlayVisible}*/ }
886- { /*/>*/ }
887- { /*) : null}*/ }
888863 </ View >
889864 </ View >
890865 </ MessageProvider >
@@ -1110,9 +1085,7 @@ export const Message = (props: MessageProps) => {
11101085 ) ;
11111086} ;
11121087
1113- const ReactionList = ( ) => < View style = { { backgroundColor : 'blue' , width : 150 , height : 30 } } /> ;
1088+ const ReactionList = ( ) => < View style = { { backgroundColor : 'blue' , height : 30 , width : 150 } } /> ;
11141089const MessageActions = ( ) => (
1115- < View style = { { backgroundColor : 'purple' , width : 150 , height : 200 } } />
1090+ < View style = { { backgroundColor : 'purple' , height : 200 , width : 150 } } />
11161091) ;
1117-
1118- const ANIMATED_DURATION = 250 ;
0 commit comments