mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 08:50:50 +08:00
@@ -1,5 +1,6 @@
|
|||||||
import { ModalConfigContext } from '@affine/component';
|
import { ModalConfigContext } from '@affine/component';
|
||||||
import { NavigationGestureService } from '@affine/core/mobile/modules/navigation-gesture';
|
import { NavigationGestureService } from '@affine/core/mobile/modules/navigation-gesture';
|
||||||
|
import { globalVars } from '@affine/core/mobile/styles/variables.css';
|
||||||
import { useService } from '@toeverything/infra';
|
import { useService } from '@toeverything/infra';
|
||||||
import { type PropsWithChildren, useCallback } from 'react';
|
import { type PropsWithChildren, useCallback } from 'react';
|
||||||
|
|
||||||
@@ -18,7 +19,9 @@ export const ModalConfigProvider = ({ children }: PropsWithChildren) => {
|
|||||||
}, [navigationGesture]);
|
}, [navigationGesture]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalConfigContext.Provider value={{ onOpen }}>
|
<ModalConfigContext.Provider
|
||||||
|
value={{ onOpen, dynamicKeyboardHeight: globalVars.appKeyboardHeight }}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</ModalConfigContext.Provider>
|
</ModalConfigContext.Provider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ export interface ModalConfig {
|
|||||||
* return a function to handle close/unmount callback
|
* return a function to handle close/unmount callback
|
||||||
*/
|
*/
|
||||||
onOpen?: () => OnClose;
|
onOpen?: () => OnClose;
|
||||||
|
/**
|
||||||
|
* For mobile
|
||||||
|
*/
|
||||||
|
dynamicKeyboardHeight?: string | number;
|
||||||
}
|
}
|
||||||
export const ModalConfigContext = createContext<ModalConfig>({});
|
export const ModalConfigContext = createContext<ModalConfig>({});
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ function createContainer() {
|
|||||||
|
|
||||||
export const ModalInner = forwardRef<HTMLDivElement, ModalProps>(
|
export const ModalInner = forwardRef<HTMLDivElement, ModalProps>(
|
||||||
(props, ref) => {
|
(props, ref) => {
|
||||||
const { onOpen: modalConfigOnOpen } = useContext(ModalConfigContext);
|
const { onOpen: modalConfigOnOpen, dynamicKeyboardHeight } =
|
||||||
|
useContext(ModalConfigContext);
|
||||||
const {
|
const {
|
||||||
modal,
|
modal,
|
||||||
portalOptions,
|
portalOptions,
|
||||||
@@ -243,7 +244,7 @@ export const ModalInner = forwardRef<HTMLDivElement, ModalProps>(
|
|||||||
>
|
>
|
||||||
<SafeArea
|
<SafeArea
|
||||||
bottom={BUILD_CONFIG.isMobileEdition}
|
bottom={BUILD_CONFIG.isMobileEdition}
|
||||||
bottomOffset={12}
|
bottomOffset={dynamicKeyboardHeight ?? 12}
|
||||||
data-full-screen={fullScreen}
|
data-full-screen={fullScreen}
|
||||||
data-modal={modal}
|
data-modal={modal}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
|||||||
Reference in New Issue
Block a user