Skip to content

Commit

Permalink
chore: add safeArea for handling inset top and bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
seyedmostafahasani committed Dec 6, 2023
1 parent ce571f7 commit 0bce335
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
},
"peerDependencies": {
"react": "*",
"react-native": "*"
"react-native": "*",
"react-native-safe-area-context": "^4.7.4"
},
"importSort": {
".js, .jsx, .ts, .tsx": {
Expand Down
5 changes: 3 additions & 2 deletions src/useToast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -16,8 +17,8 @@ export const DEFAULT_OPTIONS: Required<ToastOptions> = {
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,
Expand Down

0 comments on commit 0bce335

Please sign in to comment.