import { IMenuContext } from './types'; /** * MenuContext provides a context for managing the state and behavior of a menu component. * * This context allows components to access the current visibility state of the menu, * as well as methods to open and close the menu. It can be used in conjunction with * the IMenuContext interface to ensure type safety and clarity in the context's structure. * * The context is initialized with a default value of null, indicating that it should * be provided by a higher-level component (such as a MenuProvider) that manages the * actual state and logic for the menu. * * @constant MenuContext * @type {React.Context} * * @example * // Example of providing the MenuContext in a parent component * const MenuProvider: React.FC = ({ children }) => { * const [visible, setVisible] = useState(false); * * const openMenu = (event?: GestureResponderEvent, callback?: Function) => { * setVisible(true); * if (callback) callback(); * }; * * const closeMenu = (event?: GestureResponderEvent, callback?: Function) => { * setVisible(false); * if (callback) callback(); * }; * * const isOpen = () => visible; * * const value: IMenuContext = { * visible, * isOpen, * openMenu, * closeMenu, * }; * * return ( * * {children} * * ); * }; * * // Example of using the MenuContext in a child component * const MyMenuComponent: React.FC = () => { * const menuContext = useContext(MenuContext); * * const handleOpen = () => { * menuContext?.openMenu(); * }; * * const handleClose = () => { * menuContext?.closeMenu(); * }; * * return ( * *