import React, { FC } from "react";
import { Text, View } from "react-native";
import { getTrainType } from "../../../lib/getTrainType";
import { trainTypeID } from "@/lib/CommonTypes";
type Props = {
  trainName: string;
  trainNumDistance?: number;
  trainIDSwitch: boolean;
  trainID: string;
  type: trainTypeID;
  isThrew: boolean;
};
export const TrainName: FC<Props> = (props) => {
  const { trainName, trainNumDistance, trainIDSwitch, trainID, type, isThrew } = props;
  const { name, color } = getTrainType({ type });
  const TrainNumber =
    trainNumDistance != undefined
      ? `${
          parseInt(trainID.replace("M", "").replace("D", "")) - trainNumDistance
        }号`
      : "";
  return (
    <View style={{ flex: 9 }}>
      <Text
        style={{
          fontSize: trainName.length > 6 ? parseInt("12%") : parseInt("16%"),
          color: color,
          fontWeight: "bold",
        }}
      >
        {trainIDSwitch ? trainID : `${isThrew ? `★通過列車★` : `${name} ${trainName}${TrainNumber}`} `}
      </Text>
    </View>
  );
};
