jrshikoku/components/発車時刻表/LED_inside_Component/TrainName.tsx
harukin-expo-dev-env 06ba5fe1de LEDの処理大整理
2024-09-09 13:50:20 +00:00

34 lines
943 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;
};
export const TrainName: FC<Props> = (props) => {
const { trainName, trainNumDistance, trainIDSwitch, trainID, type } = 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 : `${name} ${trainName}${TrainNumber}`}
</Text>
</View>
);
};