mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-24 18:02:47 +08:00
feat(mobile): disable swipe back gesture when there is no back in header (#8876)
close AF-1663, AF-1756 - new global `ModalConfigContext` - new logic to judge whether inside modal - render `✕` for PageHeader back if inside modal - only enable `NavigationGesture` when there is `<` in PageHeader
This commit is contained in:
28
packages/frontend/apps/ios/src/modal-config.tsx
Normal file
28
packages/frontend/apps/ios/src/modal-config.tsx
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ModalConfigContext } from '@affine/component';
|
||||
import { NavigationGestureService } from '@affine/core/mobile/modules/navigation-gesture';
|
||||
import { useService } from '@toeverything/infra';
|
||||
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]
|
||||
);
|
||||
|
||||
return (
|
||||
<ModalConfigContext.Provider value={{ onOpenChange }}>
|
||||
{children}
|
||||
</ModalConfigContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user