一部ロジックの短縮化
This commit is contained in:
parent
5115656050
commit
b2ee75205b
@ -403,12 +403,12 @@ const EachData = ({
|
||||
|
||||
const TrainName = ({ train, trainIDSwitch, d, getTrainType }) => {
|
||||
const { trainName, trainNumDistance } = train;
|
||||
let TrainNumber = "";
|
||||
if (trainNumDistance != undefined) {
|
||||
const timeInfo =
|
||||
parseInt(d.train.replace("M", "").replace("D", "")) - trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
let TrainNumber =
|
||||
trainNumDistance != undefined
|
||||
? `${
|
||||
parseInt(d.train.replace("M", "").replace("D", "")) - trainNumDistance
|
||||
}号`
|
||||
: "";
|
||||
return (
|
||||
<View style={{ flex: 9 }}>
|
||||
<Text
|
||||
@ -426,23 +426,22 @@ const TrainName = ({ train, trainIDSwitch, d, getTrainType }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const LastStation = ({ d }) => {
|
||||
const LastStation = ({ d: { lastStation } }) => {
|
||||
return (
|
||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize:
|
||||
d.lastStation.length > 4 ? parseInt("13%") : parseInt("18%"),
|
||||
fontSize: lastStation.length > 4 ? parseInt("13%") : parseInt("18%"),
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.lastStation}
|
||||
{lastStation}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
const DependTime = ({ d }) => {
|
||||
const DependTime = ({ d: { time } }) => {
|
||||
return (
|
||||
<View style={{ flex: 3 }}>
|
||||
<Text
|
||||
@ -452,7 +451,7 @@ const DependTime = ({ d }) => {
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.time}
|
||||
{time}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
@ -464,34 +463,28 @@ const checkDuplicateTrainData = (currentTrainArray) => {
|
||||
if (notNyujoData.length == 0) return currentTrainArray[0];
|
||||
else return notNyujoData[0];
|
||||
};
|
||||
|
||||
const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => {
|
||||
const [status, setStatus] = useState("");
|
||||
useEffect(() => {
|
||||
const array = currentTrain.filter((a) => a.num == d.train);
|
||||
const current = checkDuplicateTrainData(array);
|
||||
// 土讃線複数存在対策
|
||||
// 土讃線複数存在対策
|
||||
const getTrainDelayStatus = (current) => {
|
||||
if (!current) return () => {};
|
||||
const delay = current.delay;
|
||||
switch (true) {
|
||||
case delay === "入線":
|
||||
if (current.Pos === station.Station_JP) {
|
||||
setStatus("当駅始発");
|
||||
break;
|
||||
return "当駅始発";
|
||||
} else {
|
||||
setStatus("発車前");
|
||||
break;
|
||||
return "発車前";
|
||||
}
|
||||
case isNaN(delay):
|
||||
setStatus(delay);
|
||||
break;
|
||||
return delay;
|
||||
case delay === 0:
|
||||
setStatus("定刻通り");
|
||||
break;
|
||||
return "定刻通り";
|
||||
default:
|
||||
setStatus(delay + "分遅れ");
|
||||
break;
|
||||
return delay + "分遅れ";
|
||||
}
|
||||
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
@ -502,11 +495,14 @@ const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => {
|
||||
paddingLeft: 1,
|
||||
}}
|
||||
>
|
||||
{status}
|
||||
{getTrainDelayStatus(
|
||||
checkDuplicateTrainData(currentTrain.filter((a) => a.num == d.train))
|
||||
)}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const Description = ({ train }) => {
|
||||
return (
|
||||
<View
|
||||
|
Loading…
Reference in New Issue
Block a user