fix(mobile): disable navigation gesture for swipe-dialog (#8993)

This commit is contained in:
CatsJuice
2024-12-12 06:55:15 +00:00
parent 01b6e43c1f
commit 84df2a1d16
6 changed files with 71 additions and 50 deletions

View File

@@ -6,22 +6,19 @@ import { type PropsWithChildren, useCallback } from 'react';
export const ModalConfigProvider = ({ children }: PropsWithChildren) => {
const navigationGesture = useService(NavigationGestureService);
const onOpenChange = useCallback(
(open: boolean) => {
const prev = navigationGesture.enabled$.value;
if (open && !prev) {
navigationGesture.setEnabled(false);
return () => {
navigationGesture.setEnabled(prev);
};
}
return;
},
[navigationGesture]
);
const onOpen = useCallback(() => {
const prev = navigationGesture.enabled$.value;
if (prev) {
navigationGesture.setEnabled(false);
return () => {
navigationGesture.setEnabled(prev);
};
}
return;
}, [navigationGesture]);
return (
<ModalConfigContext.Provider value={{ onOpenChange }}>
<ModalConfigContext.Provider value={{ onOpen }}>
{children}
</ModalConfigContext.Provider>
);