diff --git a/components/ActionSheetComponents/EachTrainInfoCore.js b/components/ActionSheetComponents/EachTrainInfoCore.js
index db31578..ca5565c 100644
--- a/components/ActionSheetComponents/EachTrainInfoCore.js
+++ b/components/ActionSheetComponents/EachTrainInfoCore.js
@@ -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" && (
この列車には乗車できません。
diff --git a/components/AllTrainDiagramView.js b/components/AllTrainDiagramView.js
index a92ca21..e290c15 100644
--- a/components/AllTrainDiagramView.js
+++ b/components/AllTrainDiagramView.js
@@ -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 },
diff --git a/components/Apps/FixedPositionBox/FixedStationBox.tsx b/components/Apps/FixedPositionBox/FixedStationBox.tsx
index 5febbf0..e409ca3 100644
--- a/components/Apps/FixedPositionBox/FixedStationBox.tsx
+++ b/components/Apps/FixedPositionBox/FixedStationBox.tsx
@@ -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(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 (
-
+
{d.time}
{name}
{d.lastStation}行
diff --git a/components/Apps/FixedPositionBox/FixedTrainBox.tsx b/components/Apps/FixedPositionBox/FixedTrainBox.tsx
index d66c650..9c1eb92 100644
--- a/components/Apps/FixedPositionBox/FixedTrainBox.tsx
+++ b/components/Apps/FixedPositionBox/FixedTrainBox.tsx
@@ -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 = ({ 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 = ({ trainID }) => {
station.length > 0
? lineColorList[station[0]?.StationNumber.slice(0, 1)]
: "black";
+ const customTrainType = getTrainType({ type: customData.type, whiteMode: true });
return (
= ({ trainID }) => {
= ({ trainID }) => {
();
@@ -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,
diff --git a/components/StationDiagram/ListViewItem.tsx b/components/StationDiagram/ListViewItem.tsx
index 7e1e50e..543ba84 100644
--- a/components/StationDiagram/ListViewItem.tsx
+++ b/components/StationDiagram/ListViewItem.tsx
@@ -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,
diff --git a/components/StationDiagram/StationDiagramView.tsx b/components/StationDiagram/StationDiagramView.tsx
index 3ce86ca..6f7ed1c 100644
--- a/components/StationDiagram/StationDiagramView.tsx
+++ b/components/StationDiagram/StationDiagramView.tsx
@@ -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 = ({ route }) => {
const { navigate, addListener, goBack, canGoBack } = useNavigation();
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
const [input, setInput] = useState("");
- const [selectedTypeList, setSelectedTypeList] = useState([
+ const [selectedTypeList, setSelectedTypeList] = useState([
"Normal",
"OneMan",
"Rapid",
@@ -262,48 +262,36 @@ export const StationDiagramView: FC = ({ route }) => {
= ({ 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 (
- {typeName}
+ {shortName}
);
diff --git a/components/custom-train-data.ts b/components/custom-train-data.ts
index 9fcc0d7..313b2af 100644
--- a/components/custom-train-data.ts
+++ b/components/custom-train-data.ts
@@ -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(
diff --git a/components/発車時刻表/EachData.tsx b/components/発車時刻表/EachData.tsx
index c83f0b2..985ec6e 100644
--- a/components/発車時刻表/EachData.tsx
+++ b/components/発車時刻表/EachData.tsx
@@ -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) => {
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) => {
});
};
- 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) => {
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) => {
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(getTrainDataFromCurrentTrain(d.train));
useEffect(() => {
setTrain(getTrainDataFromCurrentTrain(d.train));
}, [currentTrain, d.train, trainDescriptionSwitch]);
diff --git a/components/発車時刻表/LED_inside_Component/TrainName.tsx b/components/発車時刻表/LED_inside_Component/TrainName.tsx
index 118c5a9..eaab5a8 100644
--- a/components/発車時刻表/LED_inside_Component/TrainName.tsx
+++ b/components/発車時刻表/LED_inside_Component/TrainName.tsx
@@ -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) => {
const { trainName, trainNumDistance, trainIDSwitch, trainID, type, isThrew } = props;
- const { name, color } = getTrainType(type);
+ const { name, color } = getTrainType({ type });
const TrainNumber =
trainNumDistance != undefined
? `${
diff --git a/lib/CommonTypes.ts b/lib/CommonTypes.ts
new file mode 100644
index 0000000..46a05eb
--- /dev/null
+++ b/lib/CommonTypes.ts
@@ -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;
+};
\ No newline at end of file
diff --git a/lib/getStringConfig.ts b/lib/getStringConfig.ts
index 54f84a9..b1a4ace 100644
--- a/lib/getStringConfig.ts
+++ b/lib/getStringConfig.ts
@@ -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":
diff --git a/lib/getTrainType.ts b/lib/getTrainType.ts
index cdc53e3..51a887a 100644
--- a/lib/getTrainType.ts
+++ b/lib/getTrainType.ts
@@ -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",
};
}