Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9aed4e04e1 | ||
|
|
ae403f66f3 | ||
|
|
827591ba6c | ||
|
|
47170f8f5d | ||
|
|
e5da54da85 |
@@ -1,64 +0,0 @@
|
|||||||
import React, { FC } from "react";
|
|
||||||
import { View, Text, TouchableWithoutFeedback, Alert } from "react-native";
|
|
||||||
import { useAllTrainDiagram } from "@/stateBox/useAllTrainDiagram";
|
|
||||||
|
|
||||||
export const DataConnectedButton: FC<{
|
|
||||||
i: string;
|
|
||||||
openTrainInfo: (trainNum: string) => void;
|
|
||||||
}> = ({ i, openTrainInfo }) => {
|
|
||||||
const [station, se, time] = i.split(",");
|
|
||||||
const { keyList } = useAllTrainDiagram();
|
|
||||||
// 列番が有効かどうかをチェックする関数
|
|
||||||
const isValidTrainNumber = (trainNum: string): boolean => {
|
|
||||||
return keyList.includes(trainNum);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<TouchableWithoutFeedback
|
|
||||||
onPress={() => {
|
|
||||||
// timeの文字列が列番として有効かを検証する
|
|
||||||
if (!isValidTrainNumber(time)) {
|
|
||||||
Alert.alert(
|
|
||||||
"列番が見つかりません",
|
|
||||||
`列番「${time}」は時刻表に存在しません。`,
|
|
||||||
[{ text: "OK" }]
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
openTrainInfo(time);
|
|
||||||
}}
|
|
||||||
key={station + time}
|
|
||||||
>
|
|
||||||
<View style={{ flexDirection: "row", backgroundColor: "#f5f5f5" }}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 8,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: "#f0f0f0",
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
width: 35,
|
|
||||||
position: "relative",
|
|
||||||
marginHorizontal: 15,
|
|
||||||
flexDirection: "row",
|
|
||||||
height: "10%",
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Text style={{ fontSize:16, fontFamily: "DiaPro" }}>
|
|
||||||
{se === "連" ? "⬐" : "↳"}
|
|
||||||
</Text>
|
|
||||||
<Text style={{ fontSize: 20, color: "#0000EE" }}>{time}</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text style={{ fontSize: 18, width: 50 }}>
|
|
||||||
{se === "連" ? "連結" : "解結"}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
</TouchableWithoutFeedback>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import React, { FC } from "react";
|
||||||
|
import { View, Text, TouchableWithoutFeedback } from "react-native";
|
||||||
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
import { Linking } from "react-native";
|
||||||
|
export const DataFromButton: FC<{ i: string }> = ({ i }) => {
|
||||||
|
const [station, se, time] = i.split(",");
|
||||||
|
return (
|
||||||
|
<TouchableWithoutFeedback
|
||||||
|
onPress={() => Linking.openURL(time)}
|
||||||
|
key={station}
|
||||||
|
>
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}>{station}</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ fontSize: 18 }}>
|
||||||
|
提供元
|
||||||
|
<MaterialCommunityIcons
|
||||||
|
name={"open-in-new"}
|
||||||
|
color="black"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</TouchableWithoutFeedback>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -4,11 +4,11 @@ import dayjs from "dayjs";
|
|||||||
import lineColorList from "../../../assets/originData/lineColorList";
|
import lineColorList from "../../../assets/originData/lineColorList";
|
||||||
import { trainDataType } from "@/lib/trainPositionTextArray";
|
import { trainDataType } from "@/lib/trainPositionTextArray";
|
||||||
import { getStopListColors } from "./colorScheme";
|
import { getStopListColors } from "./colorScheme";
|
||||||
import {
|
import {
|
||||||
isCanceledSe,
|
isCanceledSe,
|
||||||
isThroughSe,
|
isThroughSe,
|
||||||
isCommunitySe,
|
isCommunitySe,
|
||||||
parseSeString,
|
parseSeString
|
||||||
} from "@/utils/seUtils";
|
} from "@/utils/seUtils";
|
||||||
import type { SeTypes } from "@/types";
|
import type { SeTypes } from "@/types";
|
||||||
|
|
||||||
@@ -96,9 +96,9 @@ export const EachStopList: FC<props> = ({
|
|||||||
"StationNumber": "B01",
|
"StationNumber": "B01",
|
||||||
},
|
},
|
||||||
] */
|
] */
|
||||||
const StationNumbers = Stations.filter((d) => d.StationNumber != null).map(
|
const StationNumbers = Stations
|
||||||
(d) => d.StationNumber as string
|
.filter((d) => d.StationNumber != null)
|
||||||
);
|
.map((d) => d.StationNumber as string);
|
||||||
// SE文字列を表示用に変換
|
// SE文字列を表示用に変換
|
||||||
const [seString, seType] = parseSeString(se);
|
const [seString, seType] = parseSeString(se);
|
||||||
|
|
||||||
@@ -106,51 +106,26 @@ export const EachStopList: FC<props> = ({
|
|||||||
const isThrough = isThroughSe(se);
|
const isThrough = isThroughSe(se);
|
||||||
const isCanceled = isCanceledSe(se);
|
const isCanceled = isCanceledSe(se);
|
||||||
const isCommunity = isCommunitySe(se);
|
const isCommunity = isCommunitySe(se);
|
||||||
const isDelayed =
|
const isDelayed = currentTrainData?.delay !== undefined &&
|
||||||
currentTrainData?.delay !== undefined &&
|
currentTrainData?.delay !== "入線" &&
|
||||||
currentTrainData?.delay !== "入線" &&
|
currentTrainData?.delay > 0;
|
||||||
currentTrainData?.delay > 0;
|
|
||||||
|
const colors = getStopListColors(isThrough, isCommunity, isCanceled, isDelayed, isNotService);
|
||||||
const colors = getStopListColors(
|
|
||||||
isThrough,
|
|
||||||
isCommunity,
|
|
||||||
isCanceled,
|
|
||||||
isDelayed,
|
|
||||||
isNotService
|
|
||||||
);
|
|
||||||
// 打ち消し線用の通常色(遅延していない時の色)
|
// 打ち消し線用の通常色(遅延していない時の色)
|
||||||
const normalColors = getStopListColors(
|
const normalColors = getStopListColors(isThrough, isCommunity, isCanceled, false, isNotService);
|
||||||
isThrough,
|
|
||||||
isCommunity,
|
|
||||||
isCanceled,
|
|
||||||
false,
|
|
||||||
isNotService
|
|
||||||
);
|
|
||||||
|
|
||||||
// beforeSameStationData用の色設定
|
// beforeSameStationData用の色設定
|
||||||
// 通過系と編(コミュニティ)はbeforeのseから判定、休(運休)は現在のseから判定
|
// 通過系と編(コミュニティ)はbeforeのseから判定、休(運休)は現在のseから判定
|
||||||
let beforeTimeTextColor = colors.timeText;
|
let beforeTimeTextColor = colors.timeText;
|
||||||
let beforeNormalTimeTextColor = normalColors.timeText;
|
let beforeNormalTimeTextColor = normalColors.timeText;
|
||||||
|
|
||||||
if (beforeSameStationData) {
|
if (beforeSameStationData) {
|
||||||
const beforeSe = beforeSameStationData[1];
|
const beforeSe = beforeSameStationData[1];
|
||||||
const beforeIsThrough = isThroughSe(beforeSe);
|
const beforeIsThrough = isThroughSe(beforeSe);
|
||||||
const beforeIsCommunity = isCommunitySe(beforeSe);
|
const beforeIsCommunity = isCommunitySe(beforeSe);
|
||||||
// 運休判定は現在のseを使用(本体と同じ背景色なので)
|
// 運休判定は現在のseを使用(本体と同じ背景色なので)
|
||||||
const beforeColors = getStopListColors(
|
const beforeColors = getStopListColors(beforeIsThrough, beforeIsCommunity, isCanceled, isDelayed, isNotService);
|
||||||
beforeIsThrough,
|
const beforeNormalColors = getStopListColors(beforeIsThrough, beforeIsCommunity, isCanceled, false, isNotService);
|
||||||
beforeIsCommunity,
|
|
||||||
isCanceled,
|
|
||||||
isDelayed,
|
|
||||||
isNotService
|
|
||||||
);
|
|
||||||
const beforeNormalColors = getStopListColors(
|
|
||||||
beforeIsThrough,
|
|
||||||
beforeIsCommunity,
|
|
||||||
isCanceled,
|
|
||||||
false,
|
|
||||||
isNotService
|
|
||||||
);
|
|
||||||
beforeTimeTextColor = beforeColors.timeText;
|
beforeTimeTextColor = beforeColors.timeText;
|
||||||
beforeNormalTimeTextColor = beforeNormalColors.timeText;
|
beforeNormalTimeTextColor = beforeNormalColors.timeText;
|
||||||
}
|
}
|
||||||
@@ -161,7 +136,7 @@ export const EachStopList: FC<props> = ({
|
|||||||
openStationACFromEachTrainInfo &&
|
openStationACFromEachTrainInfo &&
|
||||||
openStationACFromEachTrainInfo(station)
|
openStationACFromEachTrainInfo(station)
|
||||||
}
|
}
|
||||||
key={station + se + time}
|
key={station+se+time}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -207,16 +182,16 @@ export const EachStopList: FC<props> = ({
|
|||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<View
|
<View style={{ position: "relative", width: 0, alignItems: "flex-end" }}>
|
||||||
style={{ position: "relative", width: 0, alignItems: "flex-end" }}
|
|
||||||
>
|
|
||||||
{points && (
|
{points && (
|
||||||
<Text style={{ fontSize: 20, position: "absolute", left: -70 }}>
|
<Text style={{ fontSize: 20, position: "absolute", left: -70 }}>
|
||||||
🚊
|
🚊
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "column", alignItems: "flex-end" }}>
|
<View
|
||||||
|
style={{ flexDirection: "column", alignItems: "flex-end" }}
|
||||||
|
>
|
||||||
{beforeSameStationData && (
|
{beforeSameStationData && (
|
||||||
<TimeText
|
<TimeText
|
||||||
isDouble={!!beforeSameStationData || !!afterSameStationData}
|
isDouble={!!beforeSameStationData || !!afterSameStationData}
|
||||||
@@ -224,7 +199,7 @@ export const EachStopList: FC<props> = ({
|
|||||||
currentTrainData={currentTrainData}
|
currentTrainData={currentTrainData}
|
||||||
se={beforeSameStationData[1]}
|
se={beforeSameStationData[1]}
|
||||||
time={beforeSameStationData[2]}
|
time={beforeSameStationData[2]}
|
||||||
key={"before" + beforeSameStationData[2]}
|
key={"before"+beforeSameStationData[2]}
|
||||||
textColor={beforeTimeTextColor}
|
textColor={beforeTimeTextColor}
|
||||||
normalTextColor={beforeNormalTimeTextColor}
|
normalTextColor={beforeNormalTimeTextColor}
|
||||||
/>
|
/>
|
||||||
@@ -234,7 +209,7 @@ export const EachStopList: FC<props> = ({
|
|||||||
currentTrainData={currentTrainData}
|
currentTrainData={currentTrainData}
|
||||||
se={se}
|
se={se}
|
||||||
time={time}
|
time={time}
|
||||||
key={se + time}
|
key={se+time}
|
||||||
textColor={colors.timeText}
|
textColor={colors.timeText}
|
||||||
normalTextColor={normalColors.timeText}
|
normalTextColor={normalColors.timeText}
|
||||||
/>
|
/>
|
||||||
@@ -253,17 +228,9 @@ const TimeText: FC<{
|
|||||||
time: string;
|
time: string;
|
||||||
textColor: string;
|
textColor: string;
|
||||||
normalTextColor: string;
|
normalTextColor: string;
|
||||||
}> = ({
|
}> = ({ isDouble, currentTrainData, se, time, isBefore=false, textColor, normalTextColor }) => {
|
||||||
isDouble,
|
|
||||||
currentTrainData,
|
|
||||||
se,
|
|
||||||
time,
|
|
||||||
isBefore = false,
|
|
||||||
textColor,
|
|
||||||
normalTextColor,
|
|
||||||
}) => {
|
|
||||||
const [seString, seType] = parseSeString(se);
|
const [seString, seType] = parseSeString(se);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
<View style={{ flexDirection: "row", alignItems: "center" }}>
|
||||||
{!!currentTrainData?.delay &&
|
{!!currentTrainData?.delay &&
|
||||||
@@ -276,7 +243,7 @@ const TimeText: FC<{
|
|||||||
color: normalTextColor,
|
color: normalTextColor,
|
||||||
width: 60,
|
width: 60,
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
right: isBefore ? 125 : 120,
|
right: isBefore ? 125:120,
|
||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
textDecorationLine: "line-through",
|
textDecorationLine: "line-through",
|
||||||
fontStyle: seType == "community" ? "italic" : "normal",
|
fontStyle: seType == "community" ? "italic" : "normal",
|
||||||
@@ -358,7 +325,7 @@ const StationTimeBox: FC<StationTimeBoxType> = (props) => {
|
|||||||
.set("hour", parseInt(time.split(":")[0]))
|
.set("hour", parseInt(time.split(":")[0]))
|
||||||
.set("minute", parseInt(time.split(":")[1]))
|
.set("minute", parseInt(time.split(":")[1]))
|
||||||
.add(delay == "入線" || delay == undefined ? 0 : delay, "minute");
|
.add(delay == "入線" || delay == undefined ? 0 : delay, "minute");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { getTrainType } from "../../lib/getTrainType";
|
|||||||
import { customTrainDataDetector } from "../custom-train-data";
|
import { customTrainDataDetector } from "../custom-train-data";
|
||||||
import { useDeviceOrientationChange } from "../../stateBox/useDeviceOrientationChange";
|
import { useDeviceOrientationChange } from "../../stateBox/useDeviceOrientationChange";
|
||||||
import { EachStopList } from "./EachTrainInfo/EachStopList";
|
import { EachStopList } from "./EachTrainInfo/EachStopList";
|
||||||
import { DataConnectedButton } from "./EachTrainInfo/DataConnectedButton";
|
import { DataFromButton } from "./EachTrainInfo/DataFromButton";
|
||||||
import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView";
|
import { DynamicHeaderScrollView } from "../DynamicHeaderScrollView";
|
||||||
import { LongHeader } from "./EachTrainInfo/LongHeader";
|
import { LongHeader } from "./EachTrainInfo/LongHeader";
|
||||||
import { ShortHeader } from "./EachTrainInfo/ShortHeader";
|
import { ShortHeader } from "./EachTrainInfo/ShortHeader";
|
||||||
@@ -47,8 +47,8 @@ export const EachTrainInfoCore = ({
|
|||||||
const { isLandscape } = useDeviceOrientationChange();
|
const { isLandscape } = useDeviceOrientationChange();
|
||||||
|
|
||||||
const scrollHandlers = actionSheetRef
|
const scrollHandlers = actionSheetRef
|
||||||
? //@ts-ignore
|
//@ts-ignore
|
||||||
useScrollHandlers("scrollview-1", actionSheetRef)
|
? useScrollHandlers("scrollview-1", actionSheetRef)
|
||||||
: null;
|
: null;
|
||||||
// Custom hooks for data management
|
// Custom hooks for data management
|
||||||
const { trainData, setTrainData, trueTrainID } = useTrainDiagramData(
|
const { trainData, setTrainData, trueTrainID } = useTrainDiagramData(
|
||||||
@@ -244,14 +244,8 @@ export const EachTrainInfoCore = ({
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
{trainDataWithThrough.map((item, index, array) =>
|
{trainDataWithThrough.map((item, index, array) =>
|
||||||
item.split(",")[1] === "連" || item.split(",")[1] === "解" ? (
|
item.split(",")[1] === "提" ? (
|
||||||
<DataConnectedButton
|
<DataFromButton i={item} key={`${item}-data`} />
|
||||||
i={item}
|
|
||||||
key={`${item}-data`}
|
|
||||||
openTrainInfo={openTrainInfo}
|
|
||||||
/>
|
|
||||||
) : item.split(",")[1].includes(".") ? (
|
|
||||||
<></>
|
|
||||||
) : (
|
) : (
|
||||||
<EachStopList
|
<EachStopList
|
||||||
i={item}
|
i={item}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ export const HeaderText: FC<Props> = ({
|
|||||||
}
|
}
|
||||||
}, [trainData]);
|
}, [trainData]);
|
||||||
|
|
||||||
const todayOperation = getTodayOperationByTrainId(trainNum).filter(d=> d.state !== 100);
|
const todayOperation = getTodayOperationByTrainId(trainNum);
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
||||||
@@ -216,20 +216,13 @@ export const HeaderText: FC<Props> = ({
|
|||||||
size={20}
|
size={20}
|
||||||
color="white"
|
color="white"
|
||||||
style={{ marginLeft: 5 }}
|
style={{ marginLeft: 5 }}
|
||||||
onPress={() => {
|
onPress={() =>
|
||||||
// 列番が奇数か偶数かで表示順を逆転
|
|
||||||
const trainNumInt = parseInt(trainNum, 10);
|
|
||||||
const ops = todayOperation ? [...todayOperation] : [];
|
|
||||||
const displayOps = trainNumInt % 2 === 0 ? ops : ops.reverse();
|
|
||||||
const directionText = trainNumInt % 2 === 0
|
|
||||||
? '←進行方向'
|
|
||||||
: '進行方向→';
|
|
||||||
alert(
|
alert(
|
||||||
`[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n使用車両情報:\n${displayOps
|
`[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n使用車両情報:\n${todayOperation
|
||||||
.map((op) => op.unit_ids)
|
?.map((op) => op.unit_ids)
|
||||||
.join("+")}\n${directionText}\n投稿者メモ:\n${uwasa || "なし"}`
|
.join("+")}\n投稿者メモ:\n${uwasa || "なし"}`
|
||||||
);
|
)
|
||||||
}}
|
}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -34,54 +34,12 @@ export const TrainIconStatus: FC<Props> = (props) => {
|
|||||||
const { train_info_img: vehicle_info_img, vehicle_info_url } =
|
const { train_info_img: vehicle_info_img, vehicle_info_url } =
|
||||||
customTrainDataDetector(data.trainNum, allCustomTrainData);
|
customTrainDataDetector(data.trainNum, allCustomTrainData);
|
||||||
if (todayOperation.length !== 0) {
|
if (todayOperation.length !== 0) {
|
||||||
const returnData =
|
const data =
|
||||||
todayOperation
|
todayOperation.map((op) => ({
|
||||||
.sort((a, b) => {
|
vehicle_info_img: op.vehicle_img,
|
||||||
// trainIdからカンマ以降の数字を抽出する関数
|
vehicle_info_url: op.vehicle_info_url,
|
||||||
const extractOrderNumber = (trainId: string): number => {
|
})) || [];
|
||||||
const parts = trainId.split(',');
|
setTrainIcon(data);
|
||||||
if (parts.length > 1) {
|
|
||||||
const num = parseInt(parts[1].trim(), 10);
|
|
||||||
return isNaN(num) ? Infinity : num;
|
|
||||||
}
|
|
||||||
return Infinity; // カンマなし = 末尾に移動
|
|
||||||
};
|
|
||||||
|
|
||||||
// data.trainNumと一致するtrainIdを探す関数
|
|
||||||
const findMatchingTrainId = (operation: OperationLogs): string | null => {
|
|
||||||
const allTrainIds = [
|
|
||||||
...(operation.train_ids || []),
|
|
||||||
...(operation.related_train_ids || []),
|
|
||||||
];
|
|
||||||
|
|
||||||
// data.trainNumの接頭辞と一致するものを探す
|
|
||||||
for (const trainId of allTrainIds) {
|
|
||||||
const prefix = trainId.split(',')[0]; // カンマ前の部分
|
|
||||||
if (prefix === data.trainNum) {
|
|
||||||
return trainId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const aTrainId = findMatchingTrainId(a);
|
|
||||||
const bTrainId = findMatchingTrainId(b);
|
|
||||||
|
|
||||||
// マッチしたものがない場合は元の順序を保持
|
|
||||||
if (!aTrainId || !bTrainId) {
|
|
||||||
return aTrainId ? -1 : bTrainId ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const aOrder = extractOrderNumber(aTrainId);
|
|
||||||
const bOrder = extractOrderNumber(bTrainId);
|
|
||||||
|
|
||||||
return aOrder - bOrder;
|
|
||||||
})
|
|
||||||
.map((op) => ({
|
|
||||||
vehicle_info_img: op.vehicle_img || vehicle_info_img,
|
|
||||||
vehicle_info_url: op.vehicle_info_url,
|
|
||||||
})) || [];
|
|
||||||
setTrainIcon(returnData);
|
|
||||||
} else if (vehicle_info_img) {
|
} else if (vehicle_info_img) {
|
||||||
setTrainIcon([{ vehicle_info_img, vehicle_info_url }]);
|
setTrainIcon([{ vehicle_info_img, vehicle_info_url }]);
|
||||||
}
|
}
|
||||||
@@ -166,12 +124,10 @@ export const TrainIconStatus: FC<Props> = (props) => {
|
|||||||
<Image
|
<Image
|
||||||
source={{ uri: trainIcon }}
|
source={{ uri: trainIcon }}
|
||||||
style={{
|
style={{
|
||||||
height: index > 0 ? 15 : 30,
|
height: 30,
|
||||||
width: index > 0 ? 12 : 24,
|
width: 24,
|
||||||
marginRight: 5,
|
marginRight: 5,
|
||||||
marginLeft: index > 0 ? -10 : 0,
|
display: index == 0 ? "flex" : "none", //暫定対応:複数アイコンがある場合は最初のアイコンのみ表示
|
||||||
marginTop: index > 0 ? 10 : 0,
|
|
||||||
//display: index == 0 ? "flex" : "none", //暫定対応:複数アイコンがある場合は最初のアイコンのみ表示
|
|
||||||
}}
|
}}
|
||||||
resizeMethod="resize"
|
resizeMethod="resize"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export const AllTrainDiagramView: FC = () => {
|
|||||||
const Item: FC<ItemProps> = ({ id, openTrainInfo }) => {
|
const Item: FC<ItemProps> = ({ id, openTrainInfo }) => {
|
||||||
const { train_info_img, train_name, type, train_num_distance, to_data } =
|
const { train_info_img, train_name, type, train_num_distance, to_data } =
|
||||||
customTrainDataDetector(id, allCustomTrainData);
|
customTrainDataDetector(id, allCustomTrainData);
|
||||||
const todayOperation = getTodayOperationByTrainId(id).filter(d=> d.state !== 100);
|
const todayOperation = getTodayOperationByTrainId(id);
|
||||||
|
|
||||||
const [typeString, fontAvailable, isOneMan] = getStringConfig(type, id);
|
const [typeString, fontAvailable, isOneMan] = getStringConfig(type, id);
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ export const AllTrainDiagramView: FC = () => {
|
|||||||
? todayOperation.map((operation, index) => (
|
? todayOperation.map((operation, index) => (
|
||||||
<Image
|
<Image
|
||||||
key={index}
|
key={index}
|
||||||
source={{ uri: operation.vehicle_img || train_info_img }}
|
source={{ uri: operation.vehicle_img }}
|
||||||
style={{
|
style={{
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 22,
|
height: 22,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { SwitchArea } from "../atom/SwitchArea";
|
|||||||
import { useNotification } from "../../stateBox/useNotifications";
|
import { useNotification } from "../../stateBox/useNotifications";
|
||||||
import { SheetHeaderItem } from "@/components/atom/SheetHeaderItem";
|
import { SheetHeaderItem } from "@/components/atom/SheetHeaderItem";
|
||||||
|
|
||||||
const versionCode = "6.1.9.4"; // Update this version code as needed
|
const versionCode = "6.1.9.2"; // Update this version code as needed
|
||||||
|
|
||||||
export const SettingTopPage = ({
|
export const SettingTopPage = ({
|
||||||
testNFC,
|
testNFC,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const INTERVALS = {
|
|||||||
STORAGE_CHECK: 10000,
|
STORAGE_CHECK: 10000,
|
||||||
|
|
||||||
/** 遅延情報更新間隔(ミリ秒) */
|
/** 遅延情報更新間隔(ミリ秒) */
|
||||||
DELAY_UPDATE: 30000,
|
DELAY_UPDATE: 60000,
|
||||||
|
|
||||||
/** 列車位置更新間隔(ミリ秒) */
|
/** 列車位置更新間隔(ミリ秒) */
|
||||||
TRAIN_POSITION_UPDATE: 5000,
|
TRAIN_POSITION_UPDATE: 5000,
|
||||||
|
|||||||
@@ -91,5 +91,4 @@ export type OperationLogs = {
|
|||||||
vehicle_img: string;
|
vehicle_img: string;
|
||||||
vehicle_info_url: string;
|
vehicle_info_url: string;
|
||||||
related_train_ids?: string[];
|
related_train_ids?: string[];
|
||||||
state: number | null;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ export const injectJavascriptData: InjectJavascriptData = (
|
|||||||
if (data === null) {
|
if (data === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(!_.isEqual(data.filter(d=> d.state !== 100), operationList)) {
|
else if(!_.isEqual(data, operationList)) {
|
||||||
operationList = data.filter(d=> d.state !== 100);
|
operationList = data;
|
||||||
setReload();
|
setReload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -83,47 +83,7 @@ export const injectJavascriptData: InjectJavascriptData = (
|
|||||||
setTimeout(operationListUpdate, ${INTERVALS.DELAY_UPDATE});
|
setTimeout(operationListUpdate, ${INTERVALS.DELAY_UPDATE});
|
||||||
}
|
}
|
||||||
operationListUpdate();
|
operationListUpdate();
|
||||||
const sortOperationalList = (a, b,targetTrainID) => {
|
|
||||||
// trainIdからカンマ以降の数字を抽出する関数
|
|
||||||
const extractOrderNumber = (trainId) => {
|
|
||||||
const parts = trainId.split(',');
|
|
||||||
if (parts.length > 1) {
|
|
||||||
const num = parseInt(parts[1].trim(), 10);
|
|
||||||
return isNaN(num) ? Infinity : num;
|
|
||||||
}
|
|
||||||
return Infinity; // カンマなし = 末尾に移動
|
|
||||||
};
|
|
||||||
|
|
||||||
// data.trainNumと一致するtrainIdを探す関数
|
|
||||||
const findMatchingTrainId = (operation)=> {
|
|
||||||
const allTrainIds = [
|
|
||||||
...(operation.train_ids || []),
|
|
||||||
...(operation.related_train_ids || []),
|
|
||||||
];
|
|
||||||
|
|
||||||
// data.trainNumの接頭辞と一致するものを探す
|
|
||||||
for (const trainId of allTrainIds) {
|
|
||||||
const prefix = trainId.split(',')[0]; // カンマ前の部分
|
|
||||||
if (prefix === targetTrainID) {
|
|
||||||
return trainId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const aTrainId = findMatchingTrainId(a);
|
|
||||||
const bTrainId = findMatchingTrainId(b);
|
|
||||||
|
|
||||||
// マッチしたものがない場合は元の順序を保持
|
|
||||||
if (!aTrainId || !bTrainId) {
|
|
||||||
return aTrainId ? -1 : bTrainId ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const aOrder = extractOrderNumber(aTrainId);
|
|
||||||
const bOrder = extractOrderNumber(bTrainId);
|
|
||||||
|
|
||||||
return aOrder - bOrder;
|
|
||||||
};
|
|
||||||
|
|
||||||
let trainDiagramData2 = {};
|
let trainDiagramData2 = {};
|
||||||
const TrainDiagramData2Update = () =>{
|
const TrainDiagramData2Update = () =>{
|
||||||
@@ -173,18 +133,11 @@ export const injectJavascriptData: InjectJavascriptData = (
|
|||||||
`;
|
`;
|
||||||
// 左か右かを判定してアイコンを設置する
|
// 左か右かを判定してアイコンを設置する
|
||||||
const trainIcon = `
|
const trainIcon = `
|
||||||
const setStationIcon = (setIconElem,img,hasProblem,backCount = 100) =>{
|
const setStationIcon = (setIconElem,img,hasProblem) =>{
|
||||||
const position = setIconElem.getAttribute("style").includes("left");
|
const position = setIconElem.getAttribute("style").includes("left");
|
||||||
let marginData = ${uiSetting === "tokyo" ? `"5px"`: `"2px"`};
|
const marginData = ${uiSetting === "tokyo" ? `"5px"`: `"2px"`}
|
||||||
let backgroundColor = "transparent";
|
setIconElem.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:"+(position ? 'left' : 'right')+";height:22px;margin: "+marginData+";'>");
|
||||||
let heightData = "22px";
|
setIconElem.remove();
|
||||||
if(backCount == 0){
|
|
||||||
marginData = position ? ${uiSetting === "tokyo" ? `"0px 0px -10px 0px" : "-10px 0px 0px 0px"`: `"0px 2px 0px 0px" : "0px 2px 0px 0px"`};
|
|
||||||
heightData = "16px";
|
|
||||||
}
|
|
||||||
|
|
||||||
setIconElem.insertAdjacentHTML('beforebegin', "<img src="+img+" style='float:"+(position ? 'left' : 'right')+";height:"+heightData+";margin: "+marginData+";background-color: "+backgroundColor+";'>");
|
|
||||||
if (backCount == 0 || backCount == 100) setIconElem.remove();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const setTrainIcon = (列番データ) => {
|
const setTrainIcon = (列番データ) => {
|
||||||
@@ -941,25 +894,18 @@ export const injectJavascriptData: InjectJavascriptData = (
|
|||||||
}
|
}
|
||||||
isEdit = data.priority == 400;
|
isEdit = data.priority == 400;
|
||||||
isSeason = data.priority == 300;
|
isSeason = data.priority == 300;
|
||||||
operationList
|
operationList.forEach(e => {
|
||||||
.sort((a,b)=>sortOperationalList(a,b,data.train_id))
|
if(e.train_ids){
|
||||||
.forEach(e => {
|
if(e.train_ids.includes(data.train_id)){
|
||||||
if (e.train_ids?.length > 0) {
|
isEdit = true;
|
||||||
const trainIds = e.train_ids.map((x) => x.split(",")[0]);
|
}
|
||||||
if (trainIds.includes(data.train_id.toString())) {
|
|
||||||
//returnData.push(e);
|
|
||||||
isEdit = true;
|
|
||||||
}
|
}
|
||||||
} else if (e.related_train_ids?.length > 0) {
|
else if(e.related_train_ids){
|
||||||
const trainIds = e.related_train_ids.map(
|
if(e.related_train_ids.includes(data.train_id)){
|
||||||
(x) => x.split(",")[0]
|
isEdit = true;
|
||||||
);
|
}
|
||||||
if (trainIds.includes(data.train_id.toString())) {
|
|
||||||
//returnData.push(e);
|
|
||||||
isEdit = true;
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
if(data.train_name != ""){
|
if(data.train_name != ""){
|
||||||
trainName = data.train_name;
|
trainName = data.train_name;
|
||||||
if(data.train_num_distance != ""){
|
if(data.train_num_distance != ""){
|
||||||
@@ -1269,51 +1215,33 @@ const setStrings = () =>{
|
|||||||
setTrainMenuDialog(element)
|
setTrainMenuDialog(element)
|
||||||
|
|
||||||
${iconSetting == "true" ? `
|
${iconSetting == "true" ? `
|
||||||
let trainIconUrl = [];
|
let trainIconUrl = null;
|
||||||
operationList
|
operationList.forEach(e => {
|
||||||
.sort((a,b)=>sortOperationalList(a,b,列番データ.toString()))
|
if(e.train_ids){
|
||||||
.reverse()
|
if(e.train_ids.includes(列番データ)){
|
||||||
.forEach(e => {
|
if(e.vehicle_img) trainIconUrl = e.vehicle_img;
|
||||||
if (e.train_ids?.length > 0) {
|
|
||||||
const trainIds = e.train_ids.map((x) => x.split(",")[0]);
|
|
||||||
if (trainIds.includes(列番データ.toString())) {
|
|
||||||
if(e.vehicle_img) trainIconUrl.push(e.vehicle_img);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else if (e.related_train_ids?.length > 0) {
|
}
|
||||||
const trainIds = e.related_train_ids.map(
|
else if(e.related_train_ids){
|
||||||
(x) => x.split(",")[0]
|
if(e.related_train_ids.includes(列番データ)){
|
||||||
);
|
if(e.vehicle_img) trainIconUrl = e.vehicle_img;
|
||||||
if (trainIds.includes(列番データ.toString())) {
|
|
||||||
if(e.vehicle_img) trainIconUrl.push(e.vehicle_img);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(trainIconUrl.length > 0){
|
if(trainIconUrl != null){
|
||||||
[trainIconUrl[0], trainIconUrl[trainIconUrl.length - 1]].forEach((url,index,array) => {
|
setStationIcon(element.querySelector("img"),trainIconUrl,hasProblem);
|
||||||
|
|
||||||
if(url && url != ""){
|
|
||||||
setStationIcon(element.querySelector("img"),url,hasProblem,trainIconUrl.length == 1 ? 100 : index);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(trainDataList.find(e => e.train_id === 列番データ) !== undefined){
|
if(trainDataList.find(e => e.train_id === 列番データ) !== undefined){
|
||||||
const trainIconUrl = [trainDataList.find(e => e.train_id === 列番データ).train_info_img];
|
const trainIconUrl = trainDataList.find(e => e.train_id === 列番データ).train_info_img;
|
||||||
if(trainIconUrl.length > 0){
|
if(!!trainIconUrl){
|
||||||
trainIconUrl.forEach((url,index,array) => {
|
setStationIcon(element.querySelector("img"),trainIconUrl,hasProblem);
|
||||||
if(url && url != ""){
|
|
||||||
setStationIcon(element.querySelector("img"),url,hasProblem);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
const trainIconUrl = [setTrainIcon(列番データ)];
|
const trainIconUrl = setTrainIcon(列番データ);
|
||||||
if(trainIconUrl.length > 0){
|
if(!!trainIconUrl){
|
||||||
if(trainIconUrl[0] && trainIconUrl[0] != ""){
|
setStationIcon(element.querySelector("img"),trainIconUrl,hasProblem);
|
||||||
setStationIcon(element.querySelector("img"),trainIconUrl[0],hasProblem);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,7 @@ import trainList from "@/assets/originData/trainList";
|
|||||||
import { CustomTrainData, OperationLogs } from "@/lib/CommonTypes";
|
import { CustomTrainData, OperationLogs } from "@/lib/CommonTypes";
|
||||||
import useInterval from "@/lib/useInterval";
|
import useInterval from "@/lib/useInterval";
|
||||||
import { AS } from "@/storageControl";
|
import { AS } from "@/storageControl";
|
||||||
import React, {
|
import React, { createContext, FC, useContext, useEffect, useState } from "react";
|
||||||
createContext,
|
|
||||||
FC,
|
|
||||||
useContext,
|
|
||||||
useEffect,
|
|
||||||
useState,
|
|
||||||
} from "react";
|
|
||||||
import { API_ENDPOINTS, STORAGE_KEYS } from "@/constants";
|
import { API_ENDPOINTS, STORAGE_KEYS } from "@/constants";
|
||||||
const initialState = {
|
const initialState = {
|
||||||
allTrainDiagram: {},
|
allTrainDiagram: {},
|
||||||
@@ -33,13 +27,9 @@ export const useAllTrainDiagram = () => useContext(AllTrainDiagramContext);
|
|||||||
type Props = {
|
type Props = {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
};
|
};
|
||||||
export const AllTrainDiagramProvider: FC<Props> = ({ children }) => {
|
export const AllTrainDiagramProvider:FC<Props> = ({ children }) => {
|
||||||
const [allTrainDiagram, setAllTrainDiagram] = useState<{
|
const [allTrainDiagram, setAllTrainDiagram] = useState<{ [key: string]: string }>(trainList);
|
||||||
[key: string]: string;
|
const [allCustomTrainData, setAllCustomTrainData] = useState<CustomTrainData[]>([]); // カスタム列車データ
|
||||||
}>(trainList);
|
|
||||||
const [allCustomTrainData, setAllCustomTrainData] = useState<
|
|
||||||
CustomTrainData[]
|
|
||||||
>([]); // カスタム列車データ
|
|
||||||
const [keyList, setKeyList] = useState<string[]>([]); // 第二要素
|
const [keyList, setKeyList] = useState<string[]>([]); // 第二要素
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (allTrainDiagram && Object.keys(allTrainDiagram).length > 0)
|
if (allTrainDiagram && Object.keys(allTrainDiagram).length > 0)
|
||||||
@@ -57,11 +47,7 @@ export const AllTrainDiagramProvider: FC<Props> = ({ children }) => {
|
|||||||
});
|
});
|
||||||
//dataのkeyで並び替え
|
//dataのkeyで並び替え
|
||||||
const sortedData = Object.keys(data)
|
const sortedData = Object.keys(data)
|
||||||
.sort(
|
.sort((a, b) => parseInt(a.replace(/[D,M]/, "")) - parseInt(b.replace(/[D,M]/, "")))
|
||||||
(a, b) =>
|
|
||||||
parseInt(a.replace(/[D,M]/, "")) -
|
|
||||||
parseInt(b.replace(/[D,M]/, ""))
|
|
||||||
)
|
|
||||||
.reduce((acc, key) => {
|
.reduce((acc, key) => {
|
||||||
acc[key] = data[key];
|
acc[key] = data[key];
|
||||||
return acc;
|
return acc;
|
||||||
@@ -101,7 +87,7 @@ export const AllTrainDiagramProvider: FC<Props> = ({ children }) => {
|
|||||||
getCustomTrainData();
|
getCustomTrainData();
|
||||||
}, []);
|
}, []);
|
||||||
useInterval(getCustomTrainData, 30000); // 30秒毎にカスタム列車データ取得
|
useInterval(getCustomTrainData, 30000); // 30秒毎にカスタム列車データ取得
|
||||||
|
|
||||||
const [todayOperation, setTodayOperation] = useState<OperationLogs[]>([]); // 本日の運行情報
|
const [todayOperation, setTodayOperation] = useState<OperationLogs[]>([]); // 本日の運行情報
|
||||||
const getTodayOperation = () => {
|
const getTodayOperation = () => {
|
||||||
fetch(API_ENDPOINTS.OPERATION_LOGS)
|
fetch(API_ENDPOINTS.OPERATION_LOGS)
|
||||||
@@ -123,22 +109,15 @@ export const AllTrainDiagramProvider: FC<Props> = ({ children }) => {
|
|||||||
getTodayOperation();
|
getTodayOperation();
|
||||||
}, []);
|
}, []);
|
||||||
useInterval(getTodayOperation, 30000); // 30秒毎にカスタム列車データ取得
|
useInterval(getTodayOperation, 30000); // 30秒毎にカスタム列車データ取得
|
||||||
|
|
||||||
const getTodayOperationByTrainId = (train_id: string) => {
|
const getTodayOperationByTrainId = (train_id: string) => {
|
||||||
const returnData: OperationLogs[] = [];
|
const returnData: OperationLogs[] = [];
|
||||||
todayOperation.forEach((operation) => {
|
todayOperation.forEach((operation) => {
|
||||||
if (operation.train_ids?.length > 0) {
|
if (operation.train_ids?.includes(train_id.toString())) {
|
||||||
const trainIds = operation.train_ids.map((x) => x.split(",")[0]);
|
returnData.push(operation);
|
||||||
if (trainIds.includes(train_id.toString())) {
|
}
|
||||||
returnData.push(operation);
|
else if (operation.related_train_ids?.includes(train_id.toString())) {
|
||||||
}
|
returnData.push(operation);
|
||||||
} else if (operation.related_train_ids?.length > 0) {
|
|
||||||
const trainIds = operation.related_train_ids.map(
|
|
||||||
(x) => x.split(",")[0]
|
|
||||||
);
|
|
||||||
if (trainIds.includes(train_id.toString())) {
|
|
||||||
returnData.push(operation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return returnData.length > 0 ? returnData : [];
|
return returnData.length > 0 ? returnData : [];
|
||||||
@@ -152,7 +131,7 @@ export const AllTrainDiagramProvider: FC<Props> = ({ children }) => {
|
|||||||
allCustomTrainData,
|
allCustomTrainData,
|
||||||
keyList,
|
keyList,
|
||||||
todayOperation,
|
todayOperation,
|
||||||
getTodayOperationByTrainId,
|
getTodayOperationByTrainId
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
Reference in New Issue
Block a user