import { PortalHost } from "@rn-primitives/portal";
import { Stack } from "expo-router";
import { StatusBar } from "expo-status-bar";
import "../../global.css";
import { useEffect } from "react";
import Toast from "react-native-toast-message";
import useDeviceLock from "../hooks/useDeviceCheck";
import { connectSocket } from "../lib/socket.io";
import { zebraScanner } from "../lib/ZebraScanner";

export default function RootLayout() {
	useDeviceLock();

	useEffect(() => {
		zebraScanner.ensureProfile();
		connectSocket();
	}, []);

	return (
		<>
			<StatusBar style="dark" />
			<Stack screenOptions={{ headerShown: false }}>
				<Stack.Screen name="index" />
				<Stack.Screen name="login" />
				<Stack.Screen name="setup" />
				<Stack.Screen name="updateScreen" />
				<Stack.Screen name="(tabs)" />
			</Stack>
			<PortalHost />
			<Toast />
		</>
	);
}
