import * as React from "react";
import TTNavStack from "@/components/TTNavStack";
import * as ScreenOrientation from "expo-screen-orientation";
import { NavigationContainer } from "@react-navigation/native";
import { migrateDb } from "./lib/db";
import { Text } from "react-native";

export default function Layout() {
  const [loaded, setLoaded] = React.useState<boolean>(true);
  React.useEffect(() => {
    (async function () {
      await migrateDb();
      await ScreenOrientation.unlockAsync();
      await ScreenOrientation.lockAsync(
        ScreenOrientation.OrientationLock.LANDSCAPE_LEFT
      );
      setLoaded(true);
    })();
  });
  return loaded ? <TTNavStack /> : <Text>Loading...</Text>;
}
