From c01a1885c2ebf9443ffb505fc762f84b5928c4c6 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Wed, 27 Aug 2025 11:39:46 +0800 Subject: [PATCH] fix : toast Deskripsi: - bisa custom posisi toast alert No Issues --- app/index.tsx | 1 - components/auth/viewLogin.tsx | 5 ++--- components/auth/viewVerification.tsx | 4 ++-- components/toastCustom.tsx | 4 ++-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/index.tsx b/app/index.tsx index c9db8e4..a936882 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -1,7 +1,6 @@ import ViewLogin from "@/components/auth/viewLogin"; import ViewVerification from "@/components/auth/viewVerification"; import Text from '@/components/Text'; -import ToastCustom from "@/components/toastCustom"; import { requestPermission } from "@/lib/useNotification"; import { useAuthSession } from "@/providers/AuthProvider"; import { Redirect } from "expo-router"; diff --git a/components/auth/viewLogin.tsx b/components/auth/viewLogin.tsx index 0098854..6f1ab07 100644 --- a/components/auth/viewLogin.tsx +++ b/components/auth/viewLogin.tsx @@ -28,14 +28,13 @@ export default function ViewLogin({ onValidate }: Props) { const otp = Math.floor(1000 + Math.random() * 9000) const responseOtp = await apiSendOtp({ phone: `62${phone}`, otp }) if (responseOtp == 200) { - // localStorage.setItem('user', response.id) await AsyncStorage.setItem('user', response.id); return onValidate({ phone: `62${phone}`, otp }) } } - return Toast.show({ type: 'small', text1: response.message, }) + return Toast.show({ type: 'small', text1: response.message, position: 'top' }) } catch (error) { - return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' }) } finally { setLoadingLogin(false) } diff --git a/components/auth/viewVerification.tsx b/components/auth/viewVerification.tsx index 31ffaf7..9b05956 100644 --- a/components/auth/viewVerification.tsx +++ b/components/auth/viewVerification.tsx @@ -27,7 +27,7 @@ export default function ViewVerification({ phone, otp }: Props) { const encrypted = await encryptToken(valueUser); signIn(encrypted); } else { - return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', }) + return Toast.show({ type: 'small', text1: 'Terjadi kesalahan', position: 'top' }) } } @@ -35,7 +35,7 @@ export default function ViewVerification({ phone, otp }: Props) { if (value === otpFix.toString()) { login() } else { - return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai' }); + return Toast.show({ type: 'small', text1: 'Kode OTP tidak sesuai', position: 'top' }); } } diff --git a/components/toastCustom.tsx b/components/toastCustom.tsx index 9fd1595..efadded 100644 --- a/components/toastCustom.tsx +++ b/components/toastCustom.tsx @@ -3,9 +3,9 @@ import { View } from "react-native"; import Toast from "react-native-toast-message"; import Text from "./Text"; -export default function ToastCustom() { +export default function ToastCustom({ position }: { position?: 'top' | 'bottom' }) { return ( - Toast.hide()} visibilityTime={1500} position="bottom" config={{ + Toast.hide()} visibilityTime={1500} position={position || 'bottom'} config={{ small: ({ text1 }) => ( {text1}