1
- import type { PropsWithChildren } from 'react' ;
1
+ import type { ReactNode } from 'react' ;
2
2
import React , { useState } from 'react' ;
3
3
import { View } from 'react-native' ;
4
4
import DragAndDropProvider from '@components/DragAndDrop/Provider' ;
5
5
import HeaderWithBackButton from '@components/HeaderWithBackButton' ;
6
6
import ScreenWrapper from '@components/ScreenWrapper' ;
7
7
import useThemeStyles from '@hooks/useThemeStyles' ;
8
8
import * as DeviceCapabilities from '@libs/DeviceCapabilities' ;
9
+ import callOrReturn from '@src/types/utils/callOrReturn' ;
9
10
10
11
type StepScreenDragAndDropWrapperProps = {
11
12
/** The title to show in the header (should be translated already) */
@@ -22,15 +23,18 @@ type StepScreenDragAndDropWrapperProps = {
22
23
23
24
/** An ID used for unit testing */
24
25
testID : string ;
26
+
27
+ /** The children to render */
28
+ children : ( ( isDraggingOver : boolean ) => ReactNode ) | ReactNode ;
25
29
} ;
26
30
27
- function StepScreenDragAndDropWrapper ( { testID, headerTitle, onBackButtonPress, onEntryTransitionEnd, children, shouldShowWrapper} : PropsWithChildren < StepScreenDragAndDropWrapperProps > ) {
31
+ function StepScreenDragAndDropWrapper ( { testID, headerTitle, onBackButtonPress, onEntryTransitionEnd, children, shouldShowWrapper} : StepScreenDragAndDropWrapperProps ) {
28
32
const styles = useThemeStyles ( ) ;
29
33
30
34
const [ isDraggingOver , setIsDraggingOver ] = useState ( false ) ;
31
35
32
36
if ( ! shouldShowWrapper ) {
33
- return children ;
37
+ return callOrReturn ( children , false ) ;
34
38
}
35
39
36
40
return (
@@ -49,7 +53,7 @@ function StepScreenDragAndDropWrapper({testID, headerTitle, onBackButtonPress, o
49
53
title = { headerTitle }
50
54
onBackButtonPress = { onBackButtonPress }
51
55
/>
52
- { children }
56
+ { callOrReturn ( children , isDraggingOver ) }
53
57
</ View >
54
58
</ DragAndDropProvider >
55
59
) }
0 commit comments