Files
jrshikoku/components/発車時刻表/LED_inside_Component/TrainName.tsx
2025-08-24 11:18:36 +00:00

35 lines
1011 B
TypeScript

import React, { FC } from "react";
import { Text, View } from "react-native";
import { getTrainType } from "../../../lib/getTrainType";
type Props = {
trainName: string;
trainNumDistance?: number;
trainIDSwitch: boolean;
trainID: string;
type: string;
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>
);
};