import { FC } from "react";
import { TouchableOpacity, View, Text, Linking } from "react-native";
import { useCurrentTrain } from "@/stateBox/useCurrentTrain";
import AntDesign from "react-native-vector-icons/AntDesign";
type Props = {
  stationNumber: string;
  onExit: () => void;
  navigate?: (screen: string, params: { screen: string }) => void;
};
export const StationTrainPositionButton: FC<Props> = (props) => {
  const { stationNumber, onExit, navigate } = props;
  const { setInjectData } = useCurrentTrain();
  return (
    <TouchableOpacity
      style={{
        height: 50,
        backgroundColor: "#0099CC",
        flexDirection: "row",
        alignContent: "center",
        alignItems: "center",
        margin: 2,
        flex: 1,
      }}
      onLongPress={() => {
        navigate("positions", { screen: "Apps" });
        setInjectData({ type: "station", value:stationNumber, fixed: true });
        onExit();
      }}
      onPress={() => {
        navigate("positions", { screen: "Apps" });
        setInjectData({ type: "station", value: stationNumber, fixed: false });
        onExit();
      }}
    >
      <View style={{ flex: 1 }} />
      <AntDesign
        name={"barchart"}
        size={20}
        color={"white"}
        style={{ marginHorizontal: 5, marginVertical: 5 }}
      />
      <Text
        style={{
          color: "white",
          textAlign: "center",
          textAlignVertical: "center",
        }}
      >
        走行位置に移動
      </Text>
      <View style={{ flex: 1 }} />
    </TouchableOpacity>
  );
};
