Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/components/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ import {

import type { ExtraInsets, Toast as ToastType } from '../core/types';
import { resolveValue, Toast as T, ToastPosition } from '../core/types';
import {
colors,
ConstructShadow,
useKeyboard,
useVisibilityChange,
} from '../utils';
import { colors, ConstructShadow, useVisibilityChange } from '../utils';
import { toast as toasting } from '../headless';

const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
Expand All @@ -48,6 +43,8 @@ type Props = {
onToastHide?: (toast: T) => void;
onToastPress?: (toast: T) => void;
extraInsets?: ExtraInsets;
keyboardVisible?: boolean;
keyboardHeight: number;
defaultStyle?: {
pressable?: ViewStyle;
view?: ViewStyle;
Expand All @@ -68,10 +65,11 @@ export const Toast: FC<Props> = ({
onToastShow,
extraInsets,
defaultStyle,
keyboardVisible,
keyboardHeight,
}) => {
const insets = useSafeAreaInsets();
const { width, height } = useWindowDimensions();
const { keyboardShown: keyboardVisible, keyboardHeight } = useKeyboard();

useVisibilityChange(
() => {
Expand Down
4 changes: 4 additions & 0 deletions src/components/Toasts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Toast } from './Toast';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { ExtraInsets } from '../core/types';
import { useScreenReader } from 'src/core/utils';
import { useKeyboard } from 'src/utils';

type Props = {
overrideDarkMode?: boolean;
Expand Down Expand Up @@ -37,6 +38,7 @@ export const Toasts: FunctionComponent<Props> = ({
const { startPause, endPause } = handlers;
const insets = useSafeAreaInsets();
const isScreenReaderEnabled = useScreenReader();
const { keyboardShown: keyboardVisible, keyboardHeight } = useKeyboard();

if (isScreenReaderEnabled && !preventScreenReaderFromHiding) {
return null;
Expand Down Expand Up @@ -69,6 +71,8 @@ export const Toasts: FunctionComponent<Props> = ({
onToastShow={onToastShow}
extraInsets={extraInsets}
defaultStyle={defaultStyle}
keyboardVisible={keyboardVisible}
keyboardHeight={keyboardHeight}
/>
))}
</View>
Expand Down