diff --git a/packages/core-mobile/app/new/routes/index.tsx b/packages/core-mobile/app/new/routes/index.tsx index 5dcb9f1f24..fa1ce74158 100644 --- a/packages/core-mobile/app/new/routes/index.tsx +++ b/packages/core-mobile/app/new/routes/index.tsx @@ -1,7 +1,7 @@ import { useRouter } from 'expo-router' import { View, Button } from '@avalabs/k2-alpine' import React from 'react' -import { showToast } from 'new/utils/toast' +import { showNotificationAlert, showSnackbar } from 'new/utils/toast' export default function Index(): JSX.Element { const { navigate } = useRouter() @@ -9,24 +9,16 @@ export default function Index(): JSX.Element { const handleSignIn = (): void => { navigate('/portfolio/') - showToast({ - toastType: 'snackbar', - content: { - message: 'Welcome back!' - } - }) + showSnackbar('Welcome back!') } const handleSignUp = (): void => { navigate('/signup/') - showToast({ - toastType: 'notificationAlert', - content: { - type: 'success', - title: 'Sign up', - message: 'Sign up button pressed' - } + showNotificationAlert({ + type: 'success', + title: 'Sign up', + message: 'Sign up button pressed' }) } diff --git a/packages/core-mobile/app/new/utils/toast.tsx b/packages/core-mobile/app/new/utils/toast.tsx index bd75d67c0b..0f1cf8ee8e 100644 --- a/packages/core-mobile/app/new/utils/toast.tsx +++ b/packages/core-mobile/app/new/utils/toast.tsx @@ -65,7 +65,7 @@ type NotificationAlertToast = { content: { type: NotificationAlertType; title: string; message?: string } } -export function showToast(props: SnackbarToast | NotificationAlertToast): void { +function showToast(props: SnackbarToast | NotificationAlertToast): void { global.toast?.hideAll() const _toastId = props.toastId ?? uuid() @@ -78,6 +78,28 @@ export function showToast(props: SnackbarToast | NotificationAlertToast): void { }) } -export function dismissToast(toastId: string): void { +function dismissToast(toastId: string): void { global?.toast?.hide(toastId) } + +export function showSnackbar(message: string): void { + showToast({ + toastType: 'snackbar', + content: { message } + }) +} + +export function showNotificationAlert({ + type, + title, + message +}: { + type: NotificationAlertType + title: string + message?: string +}): void { + showToast({ + toastType: 'notificationAlert', + content: { type, title, message } + }) +} diff --git a/yarn.lock b/yarn.lock index c84bf18d89..e2933ee42b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -26640,7 +26640,7 @@ react-native-webview@ava-labs/react-native-webview: peerDependencies: react: "*" react-native: "*" - checksum: 6e268fad7aa8b8e56fd28cc95f94f35a33fdac4cec0085ae71a766d092760e3f9af35218706113ff7ae99a74baabc5112d32005dce9e66bdf4fda676fad9aa4e + checksum: a187edd718e1ea3a6b1e5da167744e6ee324bc3c3e492bcb0a9d028ab68a82907f053f37c23aa4229d6a9091541cee3c73549c3c850056e4cf5eb5b3cb2c9ffc languageName: node linkType: hard