diff --git a/components/ActionSheetComponents/EachTrainInfo/DataConnectedButton.tsx b/components/ActionSheetComponents/EachTrainInfo/DataConnectedButton.tsx new file mode 100644 index 0000000..f8035dd --- /dev/null +++ b/components/ActionSheetComponents/EachTrainInfo/DataConnectedButton.tsx @@ -0,0 +1,64 @@ +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 ( + { + // timeの文字列が列番として有効かを検証する + if (!isValidTrainNumber(time)) { + Alert.alert( + "列番が見つかりません", + `列番「${time}」は時刻表に存在しません。`, + [{ text: "OK" }] + ); + return; + } + + openTrainInfo(time); + }} + key={station + time} + > + + + + + {se === "連" ? "⬐" : "↳"} + + {time} + + + {se === "連" ? "連結" : "解結"} + + + + + ); +}; diff --git a/components/ActionSheetComponents/EachTrainInfo/DataFromButton.tsx b/components/ActionSheetComponents/EachTrainInfo/DataFromButton.tsx deleted file mode 100644 index 155a48a..0000000 --- a/components/ActionSheetComponents/EachTrainInfo/DataFromButton.tsx +++ /dev/null @@ -1,36 +0,0 @@ -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 ( - Linking.openURL(time)} - key={station} - > - - - {station} - - - 提供元 - - - - - - ); -}; diff --git a/components/ActionSheetComponents/EachTrainInfo/EachStopList.tsx b/components/ActionSheetComponents/EachTrainInfo/EachStopList.tsx index 5a15267..20ced97 100644 --- a/components/ActionSheetComponents/EachTrainInfo/EachStopList.tsx +++ b/components/ActionSheetComponents/EachTrainInfo/EachStopList.tsx @@ -4,11 +4,11 @@ import dayjs from "dayjs"; import lineColorList from "../../../assets/originData/lineColorList"; import { trainDataType } from "@/lib/trainPositionTextArray"; import { getStopListColors } from "./colorScheme"; -import { - isCanceledSe, - isThroughSe, +import { + isCanceledSe, + isThroughSe, isCommunitySe, - parseSeString + parseSeString, } from "@/utils/seUtils"; import type { SeTypes } from "@/types"; @@ -96,9 +96,9 @@ export const EachStopList: FC = ({ "StationNumber": "B01", }, ] */ - const StationNumbers = Stations - .filter((d) => d.StationNumber != null) - .map((d) => d.StationNumber as string); + const StationNumbers = Stations.filter((d) => d.StationNumber != null).map( + (d) => d.StationNumber as string + ); // SE文字列を表示用に変換 const [seString, seType] = parseSeString(se); @@ -106,26 +106,51 @@ export const EachStopList: FC = ({ const isThrough = isThroughSe(se); const isCanceled = isCanceledSe(se); const isCommunity = isCommunitySe(se); - const isDelayed = currentTrainData?.delay !== undefined && - currentTrainData?.delay !== "入線" && - currentTrainData?.delay > 0; - - const colors = getStopListColors(isThrough, isCommunity, isCanceled, isDelayed, isNotService); + const isDelayed = + currentTrainData?.delay !== undefined && + currentTrainData?.delay !== "入線" && + currentTrainData?.delay > 0; + + const colors = getStopListColors( + isThrough, + isCommunity, + isCanceled, + isDelayed, + isNotService + ); // 打ち消し線用の通常色(遅延していない時の色) - const normalColors = getStopListColors(isThrough, isCommunity, isCanceled, false, isNotService); + const normalColors = getStopListColors( + isThrough, + isCommunity, + isCanceled, + false, + isNotService + ); // beforeSameStationData用の色設定 // 通過系と編(コミュニティ)はbeforeのseから判定、休(運休)は現在のseから判定 let beforeTimeTextColor = colors.timeText; let beforeNormalTimeTextColor = normalColors.timeText; - + if (beforeSameStationData) { const beforeSe = beforeSameStationData[1]; const beforeIsThrough = isThroughSe(beforeSe); const beforeIsCommunity = isCommunitySe(beforeSe); // 運休判定は現在のseを使用(本体と同じ背景色なので) - const beforeColors = getStopListColors(beforeIsThrough, beforeIsCommunity, isCanceled, isDelayed, isNotService); - const beforeNormalColors = getStopListColors(beforeIsThrough, beforeIsCommunity, isCanceled, false, isNotService); + const beforeColors = getStopListColors( + beforeIsThrough, + beforeIsCommunity, + isCanceled, + isDelayed, + isNotService + ); + const beforeNormalColors = getStopListColors( + beforeIsThrough, + beforeIsCommunity, + isCanceled, + false, + isNotService + ); beforeTimeTextColor = beforeColors.timeText; beforeNormalTimeTextColor = beforeNormalColors.timeText; } @@ -136,7 +161,7 @@ export const EachStopList: FC = ({ openStationACFromEachTrainInfo && openStationACFromEachTrainInfo(station) } - key={station+se+time} + key={station + se + time} > = ({ - + {points && ( 🚊 )} - + {beforeSameStationData && ( = ({ currentTrainData={currentTrainData} se={beforeSameStationData[1]} time={beforeSameStationData[2]} - key={"before"+beforeSameStationData[2]} + key={"before" + beforeSameStationData[2]} textColor={beforeTimeTextColor} normalTextColor={beforeNormalTimeTextColor} /> @@ -209,7 +234,7 @@ export const EachStopList: FC = ({ currentTrainData={currentTrainData} se={se} time={time} - key={se+time} + key={se + time} textColor={colors.timeText} normalTextColor={normalColors.timeText} /> @@ -228,9 +253,17 @@ const TimeText: FC<{ time: string; textColor: string; normalTextColor: string; -}> = ({ isDouble, currentTrainData, se, time, isBefore=false, textColor, normalTextColor }) => { +}> = ({ + isDouble, + currentTrainData, + se, + time, + isBefore = false, + textColor, + normalTextColor, +}) => { const [seString, seType] = parseSeString(se); - + return ( {!!currentTrainData?.delay && @@ -243,7 +276,7 @@ const TimeText: FC<{ color: normalTextColor, width: 60, position: "absolute", - right: isBefore ? 125:120, + right: isBefore ? 125 : 120, textAlign: "right", textDecorationLine: "line-through", fontStyle: seType == "community" ? "italic" : "normal", @@ -325,7 +358,7 @@ const StationTimeBox: FC = (props) => { .set("hour", parseInt(time.split(":")[0])) .set("minute", parseInt(time.split(":")[1])) .add(delay == "入線" || delay == undefined ? 0 : delay, "minute"); - + return ( )} {trainDataWithThrough.map((item, index, array) => - item.split(",")[1] === "提" ? ( - + item.split(",")[1] === "連" || item.split(",")[1] === "解" ? ( + + ) : item.split(",")[1].includes(".") ? ( + <> ) : ( = ({ size={20} color="white" 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( - `[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n使用車両情報:\n${todayOperation - ?.map((op) => op.unit_ids) - .join("+")}\n投稿者メモ:\n${uwasa || "なし"}` - ) - } + `[このアイコン、列車データはコミュニティによってリアルタイム追加されています。]\n使用車両情報:\n${displayOps + .map((op) => op.unit_ids) + .join("+")}\n${directionText}\n投稿者メモ:\n${uwasa || "なし"}` + ); + }} /> )} diff --git a/components/Settings/SettingTopPage.tsx b/components/Settings/SettingTopPage.tsx index a046373..9341906 100644 --- a/components/Settings/SettingTopPage.tsx +++ b/components/Settings/SettingTopPage.tsx @@ -17,7 +17,7 @@ import { SwitchArea } from "../atom/SwitchArea"; import { useNotification } from "../../stateBox/useNotifications"; import { SheetHeaderItem } from "@/components/atom/SheetHeaderItem"; -const versionCode = "6.1.9.3"; // Update this version code as needed +const versionCode = "6.1.9.4"; // Update this version code as needed export const SettingTopPage = ({ testNFC,