import { Button, ButtonSize, Colors, KeyboardAwareScrollView, LoaderScreen, Text, TextField, TextFieldRef, View, } from "react-native-ui-lib"; import React, { useEffect, useRef, useState } from "react"; import { useSignIn } from "@/hooks/firebase/useSignIn"; import { Dimensions, KeyboardAvoidingView, Platform, StyleSheet, } from "react-native"; import Toast from "react-native-toast-message"; import KeyboardManager from "react-native-keyboard-manager"; import { SafeAreaView } from "react-native-safe-area-context"; import { useRouter } from "expo-router"; import * as Device from "expo-device"; import { DeviceType } from "expo-device"; if (Platform.OS === "ios") KeyboardManager.setEnableAutoToolbar(true); const SignInPage = () => { const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const passwordRef = useRef(null); const isTablet: boolean = Device.deviceType === DeviceType.TABLET; const [isPortrait, setIsPortrait] = useState(() => { const dim = Dimensions.get("screen"); return dim.height >= dim.width; }); useEffect(() => { const subscription = Dimensions.addEventListener("change", ({ screen }) => { setIsPortrait(screen.height >= screen.width); }); return () => subscription.remove(); }, []); const getTopPadding = () => { if (Device.deviceType === DeviceType.TABLET) { return isPortrait ? "50%" : "15%"; } return "20%"; // non-tablet case, regardless of orientation }; const { mutateAsync: signIn, error, isError, isLoading } = useSignIn(); const router = useRouter(); const handleSignIn = async () => { await signIn({ email, password }); if (!isError) { Toast.show({ type: "success", text1: "Login successful!", }); } else { Toast.show({ type: "error", text1: "Error logging in", text2: `${error}`, }); } }; return ( Jump back into Cally Please enter your details. { // Move focus to the description field passwordRef.current?.focus(); }} /> {isTablet ? : }