Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 | import React, { createContext } from 'react';
import { usePauseMenu } from '@lib/components/PauseMenu';
import { useIsForWebviewContext } from '@lib/providers/IsForWebview';
import { ExitModal } from '@lib/components/ExitModal';
const PauseMenuContext = createContext<{
openPauseMenu: () => unknown;
}>({
openPauseMenu: async () => {
// pass
}
});
export const usePauseMenuContext = () => React.useContext(PauseMenuContext);
export function PauseMenuProvider({
children,
title
}: {
children: React.ReactNode;
title?: string;
}) {
const { isWebview } = useIsForWebviewContext();
const { props: pauseMenuProps, openPauseMenuWithAwait } = usePauseMenu();
const openPauseMenuForWebview = () => {
window.flutter_inappwebview.callHandler('openPause');
};
const openPauseMenu = React.useMemo(
() => (isWebview ? openPauseMenuForWebview : openPauseMenuWithAwait),
[isWebview, openPauseMenuWithAwait]
);
const value = React.useMemo(() => ({ openPauseMenu }), [openPauseMenu]);
return (
<PauseMenuContext.Provider value={value}>
{children}
<ExitModal
isOpen={pauseMenuProps.isOpen}
onClose={pauseMenuProps.onClose}
title={title || ''}
content={`게임을 종료할까요?\n지금 게임을 나가도 진행 내용은 저장돼요.`}
/>
</PauseMenuContext.Provider>
);
}
|