import React from "react";
import { View, Text, TouchableOpacity, StyleSheet, StatusBar, Image } from "react-native";
import { NativeStackScreenProps,NativeStackNavigationProp } from "@react-navigation/native-stack";
import { RootStackParamList } from "../App";
import MyStatusbar from "./component/MyStatusbar";
import MyHeader from "./component/MyHeader";
import pxToDp from "./helper/pxToDp";
import DeviceInfo from "react-native-device-info";
import { useTranslation } from 'react-i18next';

type Props = NativeStackScreenProps<RootStackParamList>;

export default function HomeScreen({ navigation }: Props) {
  const { t } = useTranslation();
  return (
    <View style={styles.container}>
      {/* 设置状态栏颜色 */}
      <MyStatusbar backgroundColor="#E7141E" dark={false}></MyStatusbar>
      <MyHeader title={t('home.title')} textColor="#fff" backgroundColor="#E7141E" hideBack navigation={navigation}
      rightView={<TouchableOpacity style={{width:pxToDp(56),height:pxToDp(56),alignItems:'center',justifyContent:'center'}}
        onPress={() => navigation.navigate("Setting")}>
        <Image source={require('./img/Settings.png')} style={{width:pxToDp(48),height:pxToDp(44)}}></Image>
      </TouchableOpacity>}></MyHeader>
      {/* 中间按钮 */}
      <View style={styles.centerBox}>
        <Image source={require("./img/Search.png")} style={{width:pxToDp(568),height:pxToDp(344),marginBottom:pxToDp(100)}}></Image>
        <TouchableOpacity
          style={styles.button}
          onPress={() => navigation.navigate("Scan")}
        >
          <Text style={styles.buttonText}>{t('home.scan')}</Text>
        </TouchableOpacity>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#fff",
  },
  centerBox: {
    flex: 1,
    // justifyContent: "center",
    alignItems: "center",
    backgroundColor:'#fff',
    paddingTop:pxToDp(250)
  },
  button: {
    backgroundColor: "#E7141E",
    borderRadius: pxToDp(24),
    width:pxToDp(300),
    height:pxToDp(96),
    alignItems:'center',
    justifyContent:'center'
  },
  buttonText: {
    color: "#fff",
    fontSize: pxToDp(32),
    fontWeight: "bold",
  },
  bottomBox: {
    alignItems: "center",
    marginBottom: 20,
  },
  privacyText: {
    fontSize: 16,
    color: "#E7141E", // 红色字体
    marginBottom: 8,
  },
  version: {
    fontSize: 14,
    color: "#999",
  },
});
