mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
29 lines
926 B
TypeScript
29 lines
926 B
TypeScript
import { ModalConfigContext } from '@affine/component';
|
|
import { NavigationGestureService } from '@affine/core/mobile/modules/navigation-gesture';
|
|
import { globalVars } from '@affine/core/mobile/styles/variables.css';
|
|
import { useService } from '@toeverything/infra';
|
|
import { type PropsWithChildren, useCallback } from 'react';
|
|
|
|
export const ModalConfigProvider = ({ children }: PropsWithChildren) => {
|
|
const navigationGesture = useService(NavigationGestureService);
|
|
|
|
const onOpen = useCallback(() => {
|
|
const prev = navigationGesture.enabled$.value;
|
|
if (prev) {
|
|
navigationGesture.setEnabled(false);
|
|
return () => {
|
|
navigationGesture.setEnabled(prev);
|
|
};
|
|
}
|
|
return;
|
|
}, [navigationGesture]);
|
|
|
|
return (
|
|
<ModalConfigContext.Provider
|
|
value={{ onOpen, dynamicKeyboardHeight: globalVars.appKeyboardHeight }}
|
|
>
|
|
{children}
|
|
</ModalConfigContext.Provider>
|
|
);
|
|
};
|