import React, { useEffect } from "react";
import { View, Image, StyleSheet } from "react-native";
import { NativeStackScreenProps } from "@react-navigation/native-stack";
import { RootStackParamList } from "../App";
import MyStatusbar from "./component/MyStatusbar";

type Props = NativeStackScreenProps<RootStackParamList>;

export default function SplashScreen({ navigation }: Props) {
  useEffect(() => {
    const timer = setTimeout(() => {
      navigation.replace("Home"); // ✅ 1.5秒后自动进入Home
    }, 1500);

    return () => clearTimeout(timer);
  }, [navigation]);

  return (
    <View style={styles.container}>
      <MyStatusbar backgroundColor="#E7141E" dark={false}></MyStatusbar>
      <Image
        source={require("../assets/logo.png")} // ✅ 替换为你自己的图片
        style={styles.logo}
        resizeMode="contain"
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#E7141E", // ✅ 红色底
    justifyContent: "center",
    alignItems: "center",
  },
  logo: {
    width: 190, // ✅ 正方形图片
    height: 190,
  },
});
