種別表示機能を追加
This commit is contained in:
@@ -1,7 +1,10 @@
|
|||||||
import lineColorList from "@/assets/originData/lineColorList";
|
import lineColorList from "@/assets/originData/lineColorList";
|
||||||
|
import { customTrainDataDetector } from "@/components/custom-train-data";
|
||||||
import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker";
|
import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker";
|
||||||
import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData";
|
||||||
|
import { typeID } from "@/lib/getStringConfig";
|
||||||
import { getTrainDelayStatus } from "@/lib/getTrainDelayStatus";
|
import { getTrainDelayStatus } from "@/lib/getTrainDelayStatus";
|
||||||
|
import { getTrainType } from "@/lib/getTrainType";
|
||||||
import { objectIsEmpty } from "@/lib/objectIsEmpty";
|
import { objectIsEmpty } from "@/lib/objectIsEmpty";
|
||||||
import { trainPosition } from "@/lib/trainPositionTextArray";
|
import { trainPosition } from "@/lib/trainPositionTextArray";
|
||||||
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
||||||
@@ -221,6 +224,7 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
margin: 0,
|
margin: 0,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
color:"white"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{station[0]?.Station_JP}
|
{station[0]?.Station_JP}
|
||||||
@@ -265,7 +269,7 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
<FixedStationBoxEachTrain
|
<FixedStationBoxEachTrain
|
||||||
d={d}
|
d={d}
|
||||||
station={station[0]}
|
station={station[0]}
|
||||||
key={d.train}
|
key={d.train + "-fixedStationBox"}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
) : (
|
) : (
|
||||||
@@ -283,6 +287,7 @@ export const FixedStation = ({ stationID }) => {
|
|||||||
const FixedStationBoxEachTrain = ({ d, station }) => {
|
const FixedStationBoxEachTrain = ({ d, station }) => {
|
||||||
const { currentTrain } = useCurrentTrain();
|
const { currentTrain } = useCurrentTrain();
|
||||||
const { stationList } = useStationList();
|
const { stationList } = useStationList();
|
||||||
|
const { allCustomTrainData } = useAllTrainDiagram();
|
||||||
const currentTrainData = checkDuplicateTrainData(
|
const currentTrainData = checkDuplicateTrainData(
|
||||||
currentTrain.filter((a) => a.num == d.train),
|
currentTrain.filter((a) => a.num == d.train),
|
||||||
stationList
|
stationList
|
||||||
@@ -292,16 +297,55 @@ const FixedStationBoxEachTrain = ({ d, station }) => {
|
|||||||
currentTrainData,
|
currentTrainData,
|
||||||
station.Station_JP
|
station.Station_JP
|
||||||
)}`;
|
)}`;
|
||||||
|
const getTrainDataFromCurrentTrain = (trainNum: string) => {
|
||||||
|
const customTrainData = customTrainDataDetector(
|
||||||
|
d.train,
|
||||||
|
allCustomTrainData
|
||||||
|
);
|
||||||
|
switch (customTrainData.type) {
|
||||||
|
case "Normal":
|
||||||
|
case "OneMan":
|
||||||
|
const currentTrainData = currentTrain.filter((a) => a.num == trainNum);
|
||||||
|
if (currentTrainData.length == 0) return customTrainData;
|
||||||
|
else if (currentTrainData[0].Type.includes("rapid:")) {
|
||||||
|
const typeText = currentTrainData[0].Type.split(":");
|
||||||
|
const returnData = {
|
||||||
|
type: "Rapid",
|
||||||
|
trainName: typeText[1].replace("\r", ""),
|
||||||
|
trainIcon: null,
|
||||||
|
trainNumDistance: null,
|
||||||
|
info: "",
|
||||||
|
};
|
||||||
|
return returnData;
|
||||||
|
}
|
||||||
|
return customTrainData;
|
||||||
|
default:
|
||||||
|
return customTrainData;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const [train, setTrain] = useState<{
|
||||||
|
ToData: string;
|
||||||
|
TrainNumber: string;
|
||||||
|
id: string;
|
||||||
|
img: string;
|
||||||
|
isWanman: boolean;
|
||||||
|
trainName: string;
|
||||||
|
trainNumDistance: number;
|
||||||
|
type: typeID;
|
||||||
|
viaData: string;
|
||||||
|
info?: string;
|
||||||
|
uwasa?: string;
|
||||||
|
}>(getTrainDataFromCurrentTrain(d.train));
|
||||||
|
useEffect(() => {
|
||||||
|
setTrain(getTrainDataFromCurrentTrain(d.train));
|
||||||
|
}, [currentTrain, d.train]);
|
||||||
|
const { name, color } = getTrainType(train.type);
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={{ backgroundColor: "white", flexDirection: "row" }}>
|
||||||
style={{ backgroundColor: "white", flexDirection: "row" }}
|
<Text style={{ fontSize: 20, flex: 2 }}>{d.time}</Text>
|
||||||
key={d.train + "-fixedStationBox"}
|
<Text style={{ fontSize: 20, flex: 2 }}>{name}</Text>
|
||||||
>
|
<Text style={{ fontSize: 20, flex: 3 }}>{d.lastStation}</Text>
|
||||||
<Text style={{ fontSize: 20, flex: 1 }}>{d.time}</Text>
|
<Text style={{ fontSize: 20, flex: 3 }}>{trainDelayStatus}</Text>
|
||||||
<Text style={{ fontSize: 20, flex: 1 }}>{d.train}</Text>
|
|
||||||
<Text style={{ fontSize: 20, flex: 1 }}>{d.lastStation}</Text>
|
|
||||||
<Text style={{ fontSize: 20 }}>{trainDelayStatus}</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user