aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/components/ui/Toast.tsx
blob: 722c93ab47fc2e503ae760dd0139f0af7500410c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { toast as sonnerToast } from "sonner-native";

const toastVariants = {
  default: "bg-foreground",
  destructive: "bg-destructive",
  success: "bg-green-500",
  info: "bg-blue-500",
};

type ToastVariant = keyof typeof toastVariants;

// Compatibility wrapper for sonner-native
function useToast() {
  return {
    toast: ({
      message,
      variant = "default",
      duration = 3000,
    }: {
      message: string;
      variant?: ToastVariant;
      duration?: number;
      position?: "top" | "bottom";
      showProgress?: boolean;
    }) => {
      // Map variants to sonner-native methods
      switch (variant) {
        case "success":
          sonnerToast.success(message, { duration });
          break;
        case "destructive":
          sonnerToast.error(message, { duration });
          break;
        case "info":
          sonnerToast.info(message, { duration });
          break;
        default:
          sonnerToast(message, { duration });
      }
    },
    removeToast: () => {
      // sonner-native handles dismissal automatically
    },
  };
}

export { ToastVariant, toastVariants, useToast };