diff --git a/app/(tabs)/index.tsx b/app/(tabs)/index.tsx index b782fc5..3566738 100644 --- a/app/(tabs)/index.tsx +++ b/app/(tabs)/index.tsx @@ -1,4 +1,7 @@ +import Toast from "react-native-toast-message" + import { EditScreenInfo } from "@/components/edit-screen-info" +import { Pressable } from "@/components/pressable" import { Text } from "@/components/text" import { View } from "@/components/view" @@ -8,6 +11,18 @@ export default function TabOneScreen() { Tab One + + { + Toast.show({ + type: "success", + text1: "Scucess", + text2: "This is a success toast 👋" + }) + }} + > + Launch a toast + ) } diff --git a/app/(tabs)/two.tsx b/app/(tabs)/two.tsx index 16f1f1d..2fa596e 100644 --- a/app/(tabs)/two.tsx +++ b/app/(tabs)/two.tsx @@ -1,4 +1,7 @@ +import Toast from "react-native-toast-message" + import { EditScreenInfo } from "@/components/edit-screen-info" +import { Pressable } from "@/components/pressable" import { Text } from "@/components/text" import { View } from "@/components/view" @@ -8,6 +11,17 @@ export default function TabTwoScreen() { Tab Two + { + Toast.show({ + type: "error", + text1: "Uh oh!", + text2: "This is an error toast 😱" + }) + }} + > + Launch an Error toast + ) } diff --git a/app/_layout.tsx b/app/_layout.tsx index 596f2c5..972e99b 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -11,6 +11,8 @@ import { SplashScreen, Stack } from "expo-router" import { useColorScheme } from "nativewind" import { useEffect } from "react" +import { ToastContainer } from "@/components/toast-container" + export { // Catch any errors thrown by the Layout component. ErrorBoundary @@ -57,6 +59,9 @@ function RootLayoutNav() { + + {/* Toast should be the last item */} + ) } diff --git a/assets/globals.css b/assets/globals.css index 1c19f75..cf6033b 100644 --- a/assets/globals.css +++ b/assets/globals.css @@ -9,6 +9,9 @@ --primary: 346.8 77.2% 49.8%; /* #CF364C */ --primary-foreground: 355.7 100% 97.3%; /* #fff1f2 */ + + --destructive: 0 84.2% 60.2%; /* #ef4444 */ + --destructive-foreground: 0 0% 98%; /* #fafafa */ } .dark:root { @@ -17,5 +20,8 @@ --primary: 346.8 77.2% 49.8%; /* #CF364C */ --primary-foreground: 355.7 100% 97.3%; /* #fff1f2 */ + + --destructive: 0 62.8% 30.6%; /* #7f1d1d */ + --destructive-foreground: 0 85.7% 97.3%; /* #fef2f2 */ } } diff --git a/bun.lockb b/bun.lockb index 8f457c3..8d1e8ab 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/toast-container.tsx b/components/toast-container.tsx new file mode 100644 index 0000000..d08732a --- /dev/null +++ b/components/toast-container.tsx @@ -0,0 +1,64 @@ +import { useSafeAreaInsets } from "react-native-safe-area-context" +import OriginalToast, { + type ToastConfig, + type ToastConfigParams, + type ToastProps +} from "react-native-toast-message" + +import { cls } from "@/lib/utils/cls" + +import { Pressable, type PressableProps } from "./pressable" +import { Text } from "./text" + +function BaseToast({ + text1, + text2, + type, + hide, + props, + ..._rest +}: ToastConfigParams) { + return ( + { + hide() + }} + {...props} + > + + {text1} + + {text2 ? ( + + {text2} + + ) : null} + + ) +} + +const toastConfig: ToastConfig = { + success: (props) => , + error: (props) => , + info: (props) => +} + +export function ToastContainer(props: ToastProps) { + const { top } = useSafeAreaInsets() + + return +} diff --git a/package.json b/package.json index 1dea25a..aecdb78 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,7 @@ "react-native-reanimated": "~3.6.0", "react-native-safe-area-context": "4.7.4", "react-native-screens": "~3.27.0", + "react-native-toast-message": "^2.2.0", "react-native-web": "~0.19.9", "tailwind-merge": "^2.2.0", "zod": "^3.22.4" diff --git a/tailwind.config.js b/tailwind.config.js index 3c579dd..abc5450 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -12,6 +12,11 @@ module.exports = { primary: { DEFAULT: "hsl(var(--primary))", foreground: "hsl(var(--primary-foreground))" + }, + + destructive: { + DEFAULT: "hsl(var(--destructive))", + foreground: "hsl(var(--destructive-foreground))" } }, fontFamily: {