diff --git a/package.json b/package.json index 81135fe6..c70bf65a 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,8 @@ }, "peerDependencies": { "react": "*", - "react-native": "*" + "react-native": "*", + "react-native-safe-area-context": "^4.7.4" }, "importSort": { ".js, .jsx, .ts, .tsx": { diff --git a/src/useToast.ts b/src/useToast.ts index ae494db0..c9ec1337 100644 --- a/src/useToast.ts +++ b/src/useToast.ts @@ -5,6 +5,7 @@ import { useTimeout } from './hooks'; import { ToastData, ToastOptions, ToastProps, ToastShowParams } from './types'; import { noop } from './utils/func'; import { mergeIfDefined } from './utils/obj'; +import {initialWindowMetrics} from 'react-native-safe-area-context'; export const DEFAULT_DATA: ToastData = { text1: undefined, @@ -16,8 +17,8 @@ export const DEFAULT_OPTIONS: Required = { position: 'top', autoHide: true, visibilityTime: 4000, - topOffset: 40, - bottomOffset: 40, + topOffset: initialWindowMetrics?.insets.top ?? 40, + bottomOffset: initialWindowMetrics?.insets.bottom ?? 40, keyboardOffset: 10, onShow: noop, onHide: noop,