getTrainTypeの仕様変更に追従
This commit is contained in:
@@ -260,7 +260,10 @@ export const EachTrainInfoCore = ({
|
||||
})
|
||||
.catch(() => AS.setItem("trainPositionSwitch", "true"));
|
||||
}, []);
|
||||
|
||||
const customTrainType = getTrainType({
|
||||
type: customTrainDataDetector(data.trainNum, allCustomTrainData).type,
|
||||
});
|
||||
|
||||
const openTrainInfo = (d) => {
|
||||
const train = customTrainDataDetector(d, allCustomTrainData);
|
||||
let TrainNumber = "";
|
||||
@@ -269,12 +272,11 @@ export const EachTrainInfoCore = ({
|
||||
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const limitedData = getTrainType({ type: train.type });
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
limited: `${limitedData.data}:${train.trainName}${TrainNumber}`,
|
||||
},
|
||||
navigate,
|
||||
from: from == "LED" ? "LED2" : "NearTrainDiagramView",
|
||||
@@ -332,9 +334,7 @@ export const EachTrainInfoCore = ({
|
||||
style: {
|
||||
maxHeight: isLandscape ? height - 94 : (height / 100) * 70,
|
||||
backgroundColor:
|
||||
getTrainType(
|
||||
customTrainDataDetector(data.trainNum, allCustomTrainData).type
|
||||
).data === "notService"
|
||||
customTrainType.data === "notService"
|
||||
? "#777777ff"
|
||||
: "white",
|
||||
},
|
||||
@@ -367,9 +367,7 @@ export const EachTrainInfoCore = ({
|
||||
/>
|
||||
}
|
||||
>
|
||||
{getTrainType(
|
||||
customTrainDataDetector(data.trainNum, allCustomTrainData).type
|
||||
).data === "notService" && (
|
||||
{customTrainType.data === "notService" && (
|
||||
<Text style={{ backgroundColor: "#ffffffc2", fontWeight: "bold" }}>
|
||||
この列車には乗車できません。
|
||||
</Text>
|
||||
|
@@ -64,7 +64,7 @@ export default function AllTrainDiagramView() {
|
||||
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const type = getTrainType(train.type).data;
|
||||
const type = getTrainType({type:train.type}).data;
|
||||
const limited = `${type}:${train.trainName}${TrainNumber}`;
|
||||
const payload = {
|
||||
data: { trainNum: d, limited },
|
||||
|
@@ -2,7 +2,7 @@ import lineColorList from "@/assets/originData/lineColorList";
|
||||
import { customTrainDataDetector } from "@/components/custom-train-data";
|
||||
import { StationNumberMaker } from "@/components/駅名表/StationNumberMaker";
|
||||
import { checkDuplicateTrainData } from "@/lib/checkDuplicateTrainData";
|
||||
import { typeID } from "@/lib/getStringConfig";
|
||||
import { CustomTrainData, trainTypeID } from "@/lib/CommonTypes";
|
||||
import { getTrainDelayStatus } from "@/lib/getTrainDelayStatus";
|
||||
import { getTrainType } from "@/lib/getTrainType";
|
||||
import { objectIsEmpty } from "@/lib/objectIsEmpty";
|
||||
@@ -182,8 +182,9 @@ export const FixedStation = ({ stationID }) => {
|
||||
if (!currentTrain) return () => {};
|
||||
const data = trainTimeAndNumber
|
||||
.filter((d) => currentTrain.map((m) => m.num).includes(d.train)) //現在の列車に絞る[ToDo]
|
||||
.filter(timeFiltering).filter(d=>!d.isThrough)
|
||||
.filter((d) => d.lastStation != station[0].Station_JP) //最終列車表示設定
|
||||
.filter(timeFiltering)
|
||||
.filter((d) => !d.isThrough)
|
||||
.filter((d) => d.lastStation != station[0].Station_JP); //最終列車表示設定
|
||||
setSelectedTrain(data);
|
||||
}, [trainTimeAndNumber, currentTrain /*finalSwitch*/]);
|
||||
|
||||
@@ -226,7 +227,7 @@ export const FixedStation = ({ stationID }) => {
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
flex: 1,
|
||||
color:"white"
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
{station[0]?.Station_JP}
|
||||
@@ -313,7 +314,7 @@ const FixedStationBoxEachTrain = ({ d, station }) => {
|
||||
else if (currentTrainData[0].Type.includes("rapid:")) {
|
||||
const typeText = currentTrainData[0].Type.split(":");
|
||||
const returnData = {
|
||||
type: "Rapid",
|
||||
type: "Rapid" as trainTypeID,
|
||||
trainName: typeText[1].replace("\r", ""),
|
||||
trainIcon: null,
|
||||
trainNumDistance: null,
|
||||
@@ -326,25 +327,20 @@ const FixedStationBoxEachTrain = ({ d, station }) => {
|
||||
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));
|
||||
const [train, setTrain] = useState<CustomTrainData>(getTrainDataFromCurrentTrain(d.train));
|
||||
useEffect(() => {
|
||||
setTrain(getTrainDataFromCurrentTrain(d.train));
|
||||
}, [currentTrain, d.train]);
|
||||
const { name, color } = getTrainType(train.type, true);
|
||||
const { name, color } = getTrainType({ type: train.type, whiteMode: true });
|
||||
return (
|
||||
<View style={{ backgroundColor: "white", flexDirection: "row",height:"33%",overflow:"visible" }}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "white",
|
||||
flexDirection: "row",
|
||||
height: "33%",
|
||||
overflow: "visible",
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 14, flex: 3 }}>{d.time}</Text>
|
||||
<Text style={{ fontSize: 14, flex: 4, color }}>{name}</Text>
|
||||
<Text style={{ fontSize: 14, flex: 4 }}>{d.lastStation}行</Text>
|
||||
|
@@ -5,12 +5,13 @@ import { useStationList, StationProps } from "@/stateBox/useStationList";
|
||||
import { FC, useEffect, useState } from "react";
|
||||
import { Text, TouchableOpacity, View, Image } from "react-native";
|
||||
import { customTrainDataDetector } from "../../custom-train-data";
|
||||
import { getStringConfig, typeID } from "@/lib/getStringConfig";
|
||||
import { getStringConfig } from "@/lib/getStringConfig";
|
||||
import { getTrainType } from "@/lib/getTrainType";
|
||||
import { trainPosition } from "@/lib/trainPositionTextArray";
|
||||
import { StationNumberMaker } from "../../駅名表/StationNumberMaker";
|
||||
import { lineListPair, stationIDPair } from "@/lib/getStationList";
|
||||
import { findReversalPoints } from "@/lib/eachTrainInfoCoreLib/findReversalPoints";
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
type props = {
|
||||
trainID: string;
|
||||
@@ -70,7 +71,7 @@ export const FixedTrain: FC<props> = ({ trainID }) => {
|
||||
isWanman: boolean;
|
||||
trainName: string;
|
||||
trainNumDistance: number;
|
||||
type: typeID;
|
||||
type: trainTypeID;
|
||||
viaData: string;
|
||||
info?: string;
|
||||
uwasa?: string;
|
||||
@@ -235,6 +236,7 @@ export const FixedTrain: FC<props> = ({ trainID }) => {
|
||||
station.length > 0
|
||||
? lineColorList[station[0]?.StationNumber.slice(0, 1)]
|
||||
: "black";
|
||||
const customTrainType = getTrainType({ type: customData.type, whiteMode: true });
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{ flex: 1, flexDirection: "row", backgroundColor: "black" }}
|
||||
@@ -248,7 +250,7 @@ export const FixedTrain: FC<props> = ({ trainID }) => {
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: getTrainType(customData.type, true).color,
|
||||
backgroundColor: customTrainType.color,
|
||||
flexDirection: "row",
|
||||
alignContent: "center",
|
||||
alignSelf: "center",
|
||||
@@ -296,9 +298,9 @@ export const FixedTrain: FC<props> = ({ trainID }) => {
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: getTrainType(customData.type, true).color,
|
||||
backgroundColor: customTrainType.color,
|
||||
width: 10,
|
||||
borderLeftColor: getTrainType(customData.type, true).color,
|
||||
borderLeftColor: customTrainType.color,
|
||||
borderTopColor: lineColor,
|
||||
borderBottomColor: lineColor,
|
||||
borderTopWidth: 14,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { migrateTrainName } from "@/lib/eachTrainInfoCoreLib/migrateTrainName";
|
||||
import { getStringConfig, typeID } from "@/lib/getStringConfig";
|
||||
import { getStringConfig } from "@/lib/getStringConfig";
|
||||
import { getTrainType } from "@/lib/getTrainType";
|
||||
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
||||
import { FC, useEffect, useLayoutEffect, useMemo, useState } from "react";
|
||||
@@ -18,6 +18,7 @@ import { useStationList } from "@/stateBox/useStationList";
|
||||
import { SharedValue, useAnimatedStyle } from "react-native-reanimated";
|
||||
import Animated from "react-native-reanimated";
|
||||
import lineColorList from "@/assets/originData/lineColorList";
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
export const ExGridViewItem: FC<{
|
||||
d: {
|
||||
@@ -52,7 +53,7 @@ export const ExGridViewItem: FC<{
|
||||
isSeason: boolean;
|
||||
trainName: string;
|
||||
trainNumDistance?: number;
|
||||
type: typeID;
|
||||
type: trainTypeID;
|
||||
viaData?: string;
|
||||
uwasa?: string;
|
||||
}>();
|
||||
@@ -65,7 +66,7 @@ export const ExGridViewItem: FC<{
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const { color, name, data } = getTrainType(trainData?.type, true);
|
||||
const { color, name, data } = getTrainType({ type: trainData?.type, whiteMode: true });
|
||||
// 列車名、種別、フォントの取得
|
||||
const [
|
||||
typeString,
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { migrateTrainName } from "@/lib/eachTrainInfoCoreLib/migrateTrainName";
|
||||
import { getStringConfig, typeID } from "@/lib/getStringConfig";
|
||||
import { getStringConfig } from "@/lib/getStringConfig";
|
||||
import { getTrainType } from "@/lib/getTrainType";
|
||||
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
||||
import { FC, useEffect, useMemo, useState } from "react";
|
||||
@@ -10,6 +10,7 @@ import { SheetManager } from "react-native-actions-sheet";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import { lineList } from "@/lib/getStationList";
|
||||
import { useStationList } from "@/stateBox/useStationList";
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
export const ListViewItem: FC<{
|
||||
d: {
|
||||
@@ -34,7 +35,7 @@ export const ListViewItem: FC<{
|
||||
isSeason: boolean;
|
||||
trainName: string;
|
||||
trainNumDistance?: number;
|
||||
type: typeID;
|
||||
type: trainTypeID;
|
||||
viaData?: string;
|
||||
uwasa?: string;
|
||||
}>();
|
||||
@@ -47,8 +48,8 @@ export const ListViewItem: FC<{
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
const { color, name, data } = getTrainType(trainData?.type, true);
|
||||
const { originalStationList } = useStationList();
|
||||
const { color, name, data } = getTrainType({ type: trainData?.type, whiteMode: true });
|
||||
const { originalStationList } = useStationList();
|
||||
// 列車名、種別、フォントの取得
|
||||
const [
|
||||
typeString,
|
||||
|
@@ -18,8 +18,8 @@ import dayjs from "dayjs";
|
||||
import { ExGridView } from "./ExGridView";
|
||||
import { Switch } from "react-native-elements";
|
||||
import { customTrainDataDetector } from "../custom-train-data";
|
||||
import { typeID } from "@/lib/getStringConfig";
|
||||
import { colorString } from "@/lib/getTrainType";
|
||||
import { getTrainType } from "@/lib/getTrainType";
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
type props = {
|
||||
route: {
|
||||
@@ -55,7 +55,7 @@ export const StationDiagramView: FC<props> = ({ route }) => {
|
||||
const { navigate, addListener, goBack, canGoBack } = useNavigation();
|
||||
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
|
||||
const [input, setInput] = useState("");
|
||||
const [selectedTypeList, setSelectedTypeList] = useState<typeID[]>([
|
||||
const [selectedTypeList, setSelectedTypeList] = useState<trainTypeID[]>([
|
||||
"Normal",
|
||||
"OneMan",
|
||||
"Rapid",
|
||||
@@ -262,48 +262,36 @@ export const StationDiagramView: FC<props> = ({ route }) => {
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="普通"
|
||||
typeID="Normal"
|
||||
color="black"
|
||||
relativeID={["OneMan"]}
|
||||
/>
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="快速"
|
||||
typeID="Rapid"
|
||||
color="#00b8d8cc"
|
||||
relativeID={["OneManRapid"]}
|
||||
/>
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="特急"
|
||||
typeID="LTDEXP"
|
||||
color="red"
|
||||
relativeID={["NightLTDEXP"]}
|
||||
/>
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="臨時"
|
||||
typeID="SPCL"
|
||||
color="#297bff"
|
||||
relativeID={["SPCL_Normal", "SPCL_Rapid", "SPCL_EXP", "Party"]}
|
||||
/>
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="貨物"
|
||||
typeID="Freight"
|
||||
color="#00869ecc"
|
||||
/>
|
||||
<TypeSelectorBox
|
||||
selectedTypeList={selectedTypeList}
|
||||
setSelectedTypeList={setSelectedTypeList}
|
||||
typeName="回送"
|
||||
typeID="Forwarding"
|
||||
color="#727272cc"
|
||||
relativeID={["FreightForwarding"]}
|
||||
/>
|
||||
<TouchableOpacity
|
||||
@@ -395,23 +383,15 @@ export const StationDiagramView: FC<props> = ({ route }) => {
|
||||
};
|
||||
|
||||
export const TypeSelectorBox: FC<{
|
||||
selectedTypeList: typeID[];
|
||||
setSelectedTypeList: (list: typeID[]) => void;
|
||||
typeName: string;
|
||||
typeID: typeID;
|
||||
color: colorString;
|
||||
relativeID?: typeID[];
|
||||
selectedTypeList: trainTypeID[];
|
||||
setSelectedTypeList: (list: trainTypeID[]) => void;
|
||||
typeID: trainTypeID;
|
||||
relativeID?: trainTypeID[];
|
||||
}> = (props) => {
|
||||
const {
|
||||
selectedTypeList,
|
||||
setSelectedTypeList,
|
||||
typeName,
|
||||
typeID,
|
||||
relativeID,
|
||||
color,
|
||||
} = props;
|
||||
const { selectedTypeList, setSelectedTypeList, typeID, relativeID } = props;
|
||||
const isSelected =
|
||||
selectedTypeList.findIndex((item) => item === typeID) !== -1;
|
||||
const { color, shortName } = getTrainType({ type: typeID, whiteMode: true });
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
@@ -447,7 +427,7 @@ export const TypeSelectorBox: FC<{
|
||||
margin: 5,
|
||||
}}
|
||||
>
|
||||
{typeName}
|
||||
{shortName}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import { CustomTrainData } from "@/lib/CommonTypes";
|
||||
import dayjs from "dayjs";
|
||||
export const customTrainDataDetector = (
|
||||
type CustomTrainDataDetector = (
|
||||
TrainNumber: string,
|
||||
allCustomTrainData?: any[]
|
||||
) => CustomTrainData;
|
||||
export const customTrainDataDetector: CustomTrainDataDetector = (
|
||||
TrainNumber,
|
||||
allCustomTrainData
|
||||
) => {
|
||||
if (allCustomTrainData && allCustomTrainData.length > 0) {
|
||||
const customTrain = allCustomTrainData.find(
|
||||
|
@@ -18,6 +18,7 @@ import { useStationList } from "../../stateBox/useStationList";
|
||||
import useInterval from "@/lib/useInterval";
|
||||
import dayjs from "dayjs";
|
||||
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
||||
import { CustomTrainData, trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
type Props = {
|
||||
d: {
|
||||
@@ -62,7 +63,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d.train,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
limited: `${getTrainType({type:train.type}).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
},
|
||||
@@ -75,7 +76,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getTrainDataFromCurrentTrain = (trainNum: string) => {
|
||||
const getTrainDataFromCurrentTrain:(t:string)=>CustomTrainData = (trainNum: string) => {
|
||||
const customTrainData = customTrainDataDetector(
|
||||
d.train,
|
||||
allCustomTrainData
|
||||
@@ -88,7 +89,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
else if (currentTrainData[0].Type.includes("rapid:")) {
|
||||
const typeText = currentTrainData[0].Type.split(":");
|
||||
const returnData = {
|
||||
type: "Rapid",
|
||||
type: "Rapid" as trainTypeID,
|
||||
trainName: typeText[1].replace("\r", ""),
|
||||
trainIcon: null,
|
||||
trainNumDistance: null,
|
||||
@@ -101,19 +102,7 @@ export const EachData: FC<Props> = (props) => {
|
||||
return customTrainData;
|
||||
}
|
||||
};
|
||||
const [train, setTrain] = useState<{
|
||||
ToData: string;
|
||||
TrainNumber: string;
|
||||
id: string;
|
||||
img: string;
|
||||
isWanman: boolean;
|
||||
trainName: string;
|
||||
trainNumDistance: number;
|
||||
type:string;
|
||||
viaData:string;
|
||||
info?:string;
|
||||
uwasa?:string;
|
||||
}>(getTrainDataFromCurrentTrain(d.train));
|
||||
const [train, setTrain] = useState<CustomTrainData>(getTrainDataFromCurrentTrain(d.train));
|
||||
useEffect(() => {
|
||||
setTrain(getTrainDataFromCurrentTrain(d.train));
|
||||
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||
|
@@ -1,17 +1,18 @@
|
||||
import React, { FC } from "react";
|
||||
import { Text, View } from "react-native";
|
||||
import { getTrainType } from "../../../lib/getTrainType";
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
type Props = {
|
||||
trainName: string;
|
||||
trainNumDistance?: number;
|
||||
trainIDSwitch: boolean;
|
||||
trainID: string;
|
||||
type: string;
|
||||
type: trainTypeID;
|
||||
isThrew: boolean;
|
||||
};
|
||||
export const TrainName: FC<Props> = (props) => {
|
||||
const { trainName, trainNumDistance, trainIDSwitch, trainID, type, isThrew } = props;
|
||||
const { name, color } = getTrainType(type);
|
||||
const { name, color } = getTrainType({ type });
|
||||
const TrainNumber =
|
||||
trainNumDistance != undefined
|
||||
? `${
|
||||
|
36
lib/CommonTypes.ts
Normal file
36
lib/CommonTypes.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
|
||||
export type trainTypeID =
|
||||
| "Normal"
|
||||
| "OneMan"
|
||||
| "Rapid"
|
||||
| "OneManRapid"
|
||||
| "LTDEXP"
|
||||
| "NightLTDEXP"
|
||||
| "SPCL"
|
||||
| "SPCL_Normal"
|
||||
| "SPCL_Rapid"
|
||||
| "SPCL_EXP"
|
||||
| "Party"
|
||||
| "Freight"
|
||||
| "Forwarding"
|
||||
| "FreightForwarding"
|
||||
| "Other";
|
||||
|
||||
export type CustomTrainData = {
|
||||
ToData?: string;
|
||||
TrainNumber?: string;
|
||||
id?: string;
|
||||
img?: string;
|
||||
isWanman?: boolean;
|
||||
trainName?: string;
|
||||
trainNumDistance?: number;
|
||||
type?: trainTypeID;
|
||||
viaData?: string;
|
||||
info?: string;
|
||||
infogram?: string;
|
||||
uwasa?: string;
|
||||
isEdit?: boolean;
|
||||
isSeason?: boolean;
|
||||
vehicleFormation?: string;
|
||||
trainInfoUrl?: string;
|
||||
};
|
@@ -1,20 +1,6 @@
|
||||
export type typeID =
|
||||
| "Normal"
|
||||
| "OneMan"
|
||||
| "Rapid"
|
||||
| "OneManRapid"
|
||||
| "LTDEXP"
|
||||
| "NightLTDEXP"
|
||||
| "SPCL"
|
||||
| "SPCL_Normal"
|
||||
| "SPCL_Rapid"
|
||||
| "SPCL_EXP"
|
||||
| "Party"
|
||||
| "Freight"
|
||||
| "Forwarding"
|
||||
| "FreightForwarding"
|
||||
| "Other";
|
||||
type types = (types: typeID, id: string) => [string, boolean, boolean];
|
||||
import { trainTypeID } from "@/lib/CommonTypes";
|
||||
|
||||
type types = (types: trainTypeID, id: string) => [string, boolean, boolean];
|
||||
export const getStringConfig: types = (type, id) => {
|
||||
switch (type) {
|
||||
case "Normal":
|
||||
|
@@ -1,17 +1,18 @@
|
||||
import { typeID } from "./getStringConfig";
|
||||
import { trainTypeID } from "./CommonTypes";
|
||||
|
||||
export type colorString =
|
||||
| "aqua"
|
||||
| "#00a0bdff"
|
||||
| "#007488ff"
|
||||
| "red"
|
||||
| "#297bff"
|
||||
| "#ff7300ff"
|
||||
| "#00869ecc"
|
||||
| "#727272cc"
|
||||
| "#00b8d8cc"
|
||||
| "#5f5f5fff"
|
||||
| "#e000b0ff"
|
||||
| "white"
|
||||
| "black"
|
||||
| "pink";
|
||||
|
||||
type trainTypeString =
|
||||
| "快速"
|
||||
| "特急"
|
||||
@@ -25,56 +26,182 @@ type trainTypeString =
|
||||
| "貨物"
|
||||
| "回送"
|
||||
| "単機回送"
|
||||
| "試運転"
|
||||
| "その他";
|
||||
type trainTypeDataString = "rapid" | "express" | "normal" | "notService";
|
||||
type getTrainType = (
|
||||
d: typeID,
|
||||
isWhiteMode?: boolean
|
||||
) => {
|
||||
type getTrainType = (e: {
|
||||
type: trainTypeID;
|
||||
id?: string;
|
||||
whiteMode?: boolean;
|
||||
}) => {
|
||||
color: colorString;
|
||||
name: trainTypeString;
|
||||
shortName?: string;
|
||||
fontAvailable: boolean;
|
||||
isOneMan: boolean;
|
||||
data: trainTypeDataString;
|
||||
};
|
||||
export const getTrainType: getTrainType = (nameString, whiteMode) => {
|
||||
switch (nameString) {
|
||||
export const getTrainType: getTrainType = ({ type, id, whiteMode }) => {
|
||||
switch (type) {
|
||||
case "Normal":
|
||||
return {
|
||||
color: whiteMode ? "black" : "white",
|
||||
name: "普通列車",
|
||||
shortName: "普通",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
case "OneMan":
|
||||
return {
|
||||
color: whiteMode ? "black" : "white",
|
||||
name: "普通列車(ワンマン)",
|
||||
shortName: "普通",
|
||||
fontAvailable: true,
|
||||
isOneMan: true,
|
||||
data: "normal",
|
||||
};
|
||||
case "Rapid":
|
||||
return {
|
||||
color: whiteMode ? "#00a0bdff" : "aqua",
|
||||
name: "快速",
|
||||
shortName: "快速",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "rapid",
|
||||
};
|
||||
case "OneManRapid":
|
||||
return { color: whiteMode ? "#00a0bdff" : "aqua", name: "快速", data: "rapid" };
|
||||
return {
|
||||
color: whiteMode ? "#00a0bdff" : "aqua",
|
||||
name: "快速",
|
||||
shortName: "快速",
|
||||
fontAvailable: true,
|
||||
isOneMan: true,
|
||||
data: "rapid",
|
||||
};
|
||||
case "LTDEXP":
|
||||
return { color: "red", name: "特急", data: "express" };
|
||||
return {
|
||||
color: "red",
|
||||
name: "特急",
|
||||
shortName: "特急",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "express",
|
||||
};
|
||||
case "NightLTDEXP":
|
||||
return { color: whiteMode ? "#e000b0ff":"pink", name: "寝台特急", data: "express" };
|
||||
return {
|
||||
color: whiteMode ? "#e000b0ff" : "pink",
|
||||
name: "寝台特急",
|
||||
shortName: "特急",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "express",
|
||||
};
|
||||
case "SPCL":
|
||||
case "SPCL_Normal":
|
||||
return { color: "#297bff", name: "臨時", data: "normal" };
|
||||
return {
|
||||
color: "#297bff",
|
||||
name: "臨時",
|
||||
shortName: "臨時",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
case "SPCL_Rapid":
|
||||
return { color: "#297bff", name: "臨時快速", data: "normal" };
|
||||
return {
|
||||
color: "#297bff",
|
||||
name: "臨時快速",
|
||||
shortName: "臨時快速",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
case "SPCL_EXP":
|
||||
return { color: "#297bff", name: "臨時特急", data: "normal" };
|
||||
return {
|
||||
color: "#297bff",
|
||||
name: "臨時特急",
|
||||
shortName: "臨時特急",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
case "Party":
|
||||
return { color: "#ff7300ff", name: "団体臨時", data: "normal" };
|
||||
return {
|
||||
color: "#ff7300ff",
|
||||
name: "団体臨時",
|
||||
shortName: "団体臨時",
|
||||
fontAvailable: true,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
case "Freight":
|
||||
return { color: "#007488ff", name: "貨物", data: "notService" };
|
||||
return {
|
||||
color: "#007488ff",
|
||||
name: "貨物",
|
||||
shortName: "貨物",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
case "Forwarding":
|
||||
return { color: "#727272cc", name: "回送", data: "notService" };
|
||||
return {
|
||||
color: "#5f5f5fff",
|
||||
name: "回送",
|
||||
shortName: "回送",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
case "FreightForwarding":
|
||||
return { color: "#727272cc", name: "単機回送", data: "notService" };
|
||||
return {
|
||||
color: "#5f5f5fff",
|
||||
name: "単機回送",
|
||||
shortName: "単機回送",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
case "Other":
|
||||
default:
|
||||
switch (true) {
|
||||
case !!id.includes("T"):
|
||||
return {
|
||||
color: "#5f5f5fff",
|
||||
name: "単機回送",
|
||||
shortName: "単機回送",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
case !!id.includes("R"):
|
||||
case !!id.includes("E"):
|
||||
case !!id.includes("L"):
|
||||
case !!id.includes("A"):
|
||||
case !!id.includes("B"):
|
||||
return {
|
||||
color: "#5f5f5fff",
|
||||
name: "回送",
|
||||
shortName: "回送",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
case !!id.includes("H"):
|
||||
return {
|
||||
color: "#5f5f5fff",
|
||||
name: "試運転",
|
||||
shortName: "試運転",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "notService",
|
||||
};
|
||||
}
|
||||
return {
|
||||
color: whiteMode ? "black" : "white",
|
||||
name: "その他",
|
||||
shortName: "その他",
|
||||
fontAvailable: false,
|
||||
isOneMan: false,
|
||||
data: "normal",
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user