import React, {FC, PropsWithChildren} from "react";
import {useNavigationActions} from "./tree/hooks";
import {PopupWindowProps, ScreenNavigation} from "./PopupWindow";

export type PopupWindowContentProps = {
    height: number,
    content: (args: {
        height: number,
        width?: number,
        screenNavigation: ReturnType<typeof useNavigationActions>,
        close: PopupWindowProps['onClose']
    }) => React.ReactNode,
    width?: number,
    onClose: PopupWindowProps['onClose']
} & ScreenNavigation

export const PopupWindowContent: FC<PopupWindowContentProps> = ({
                                                                    height,
                                                                    width,
                                                                    content,
                                                                    screenId,
                                                                    setCurrentScreenId,
                                                                    onClose
                                                                }) => {
    const screenNavigation = useNavigationActions(screenId, setCurrentScreenId)
    return <>{content({height, width, screenNavigation, close: onClose})}</>
}
