34 lines
943 B
TypeScript
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>
|
|
);
|
|
};
|