diff --git a/apps/mobile/app/components/toast/index.tsx b/apps/mobile/app/components/toast/index.tsx index a5cad43ac..06a8f56a9 100644 --- a/apps/mobile/app/components/toast/index.tsx +++ b/apps/mobile/app/components/toast/index.tsx @@ -19,17 +19,17 @@ along with this program. If not, see . import { useThemeColors } from "@notesnook/theme"; import React, { useCallback, useEffect, useRef, useState } from "react"; -import { TouchableOpacity, useWindowDimensions, View } from "react-native"; +import { TouchableOpacity, View } from "react-native"; import Icon from "react-native-vector-icons/MaterialCommunityIcons"; import { notesnook } from "../../../e2e/test.ids"; import useGlobalSafeAreaInsets from "../../hooks/use-global-safe-area-insets"; -import useKeyboard from "../../hooks/use-keyboard"; import { DDS } from "../../services/device-detection"; import { eSubscribeEvent, eUnSubscribeEvent, ToastOptions } from "../../services/event-manager"; +import { useSettingStore } from "../../stores/use-setting-store"; import { getElevationStyle } from "../../utils/elevation"; import { eHideToast, eShowToast } from "../../utils/events"; import { SIZE } from "../../utils/size"; @@ -41,12 +41,10 @@ export const Toast = ({ context = "global" }) => { const { colors, isDark } = useThemeColors(); const [toastOptions, setToastOptions] = useState(); const hideTimeout = useRef(); - const keyboard = useKeyboard(); const insets = useGlobalSafeAreaInsets(); const [visible, setVisible] = useState(false); const toastMessages = useRef([]); - const dimensions = useWindowDimensions(); - + const dimensions = useSettingStore((state) => state.dimensions); const hideToast = useCallback(() => { const nextToastMessage = toastMessages.current.shift(); if (nextToastMessage) { @@ -113,9 +111,7 @@ export const Toast = ({ context = "global" }) => { width: DDS.isTab ? dimensions.width / 2 : "100%", alignItems: "center", alignSelf: "center", - top: keyboard.keyboardShown - ? insets.top + 15 - : dimensions.height - Math.max(insets.bottom, 70), + top: dimensions.height - Math.max(insets.bottom, 70), position: "absolute", zIndex: 999, elevation: 15 diff --git a/apps/mobile/app/services/event-manager.ts b/apps/mobile/app/services/event-manager.ts index b17ea81f4..46cfced41 100644 --- a/apps/mobile/app/services/event-manager.ts +++ b/apps/mobile/app/services/event-manager.ts @@ -139,6 +139,7 @@ export type ToastOptions = { duration?: number; func?: () => void; actionText?: string; + icon?: string; }; export const ToastManager = {