From b7d3dccd95d43266481821fc6e3a1fbe3ceb2962 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Thu, 4 Sep 2025 20:52:18 +0000 Subject: [PATCH] =?UTF-8?q?=E6=99=82=E5=88=BB=E8=A1=A8=E3=83=95=E3=82=A3?= =?UTF-8?q?=E3=83=AB=E3=82=BF=E3=83=AA=E3=83=B3=E3=82=B0=E6=A9=9F=E8=83=BD?= =?UTF-8?q?=E4=B8=80=E9=80=9A=E3=82=8A=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StationDiagram/StationDiagramView.tsx | 234 +++++++++++++++--- lib/getTrainType.ts | 2 +- 2 files changed, 205 insertions(+), 31 deletions(-) diff --git a/components/StationDiagram/StationDiagramView.tsx b/components/StationDiagram/StationDiagramView.tsx index 4df556a..6b5d95c 100644 --- a/components/StationDiagram/StationDiagramView.tsx +++ b/components/StationDiagram/StationDiagramView.tsx @@ -8,6 +8,7 @@ import { KeyboardAvoidingView, Platform, TouchableOpacity, + LayoutAnimation, } from "react-native"; import { useNavigation } from "@react-navigation/native"; import { BigButton } from "../atom/BigButton"; @@ -18,6 +19,7 @@ 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"; type props = { route: { @@ -53,7 +55,14 @@ 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", + "OneManRapid", + "LTDEXP", + "NightLTDEXP", + ]); type hoge = { trainNumber: string; array: string; @@ -61,10 +70,9 @@ export const StationDiagramView: FC = ({ route }) => { timeType: string; time: string; }[]; + const [showTypeFiltering, setShowTypeFiltering] = useState(false); const [showLastStop, setShowLastStop] = useState(false); - const [isSpecial, setIsSpecial] = useState(false); const [threw, setIsThrew] = useState(false); - const [isOutOfService, setIsOutOfService] = useState(false); const [currentStationDiagram, setCurrentStationDiagram] = useState([]); useEffect(() => { if (allTrainDiagram && currentStation.length > 0) { @@ -108,15 +116,29 @@ export const StationDiagramView: FC = ({ route }) => { time, }; // //条件によってフィルタリング + if (!threw && timeType && timeType.includes("通")) return; + if (!showLastStop && timeType && timeType.includes("着")) return; if ( selectedTypeList.length > 0 && - selectedTypeList.findIndex((item) => item === type) !== -1 - ) - return; - if (!threw && timeType && timeType.includes("通")) return; - if (!isOutOfService && !!d.match(/[A,B,R,H,E,T,L]/)) return; - if (!isSpecial && !!d.match(/9\d\d\d[D,M,S]/)) return; - if (!showLastStop && timeType && timeType.includes("着")) return; + selectedTypeList.findIndex((item) => item === type) === -1 + ) { + if ( + selectedTypeList.findIndex( + (item) => item === "Forwarding" + ) !== -1 + ) { + console.log("回送"); + console.log(d); + console.log(!d.match(/[A,B,R,H,E,T,L]/)); + if (!d.match(/[A,B,R,H,E,T,L]/)) return; + } + else if ( + selectedTypeList.findIndex((item) => item === "SPCL") !== -1 + ) { + if (!d.match(/9\d\d\d[D,M,S]/)) return; + } + else{ return; } + } returnDataArray.push(arrayData); }); }); @@ -137,7 +159,7 @@ export const StationDiagramView: FC = ({ route }) => { }) ); } - }, [currentStation, showLastStop, isSpecial, isOutOfService, threw, input]); + }, [currentStation, showLastStop, threw, input, selectedTypeList]); useEffect(() => { const showSubscription = Keyboard.addListener("keyboardDidShow", () => { @@ -230,24 +252,113 @@ export const StationDiagramView: FC = ({ route }) => { 当駅止 - - - 臨時 - - - - 回送 - + + {showTypeFiltering ? ( + <> + + + + + + + { + LayoutAnimation.configureNext( + LayoutAnimation.Presets.easeInEaseOut + ); + setShowTypeFiltering(false); + }} + > + + < + + + + ) : ( + { + LayoutAnimation.configureNext( + LayoutAnimation.Presets.easeInEaseOut + ); + setShowTypeFiltering(true); + }} + > + + > + + + )} = ({ route }) => { }} > setKeyBoardVisible(true)} onEndEditing={() => {}} onChange={(ret) => setInput(ret.nativeEvent.text)} @@ -278,3 +389,66 @@ export const StationDiagramView: FC = ({ route }) => { ); }; + +export const TypeSelectorBox: FC<{ + selectedTypeList: typeID[]; + setSelectedTypeList: (list: typeID[]) => void; + typeName: string; + typeID: typeID; + color: colorString; + relativeID?: typeID[]; +}> = (props) => { + const { + selectedTypeList, + setSelectedTypeList, + typeName, + typeID, + relativeID, + color + } = props; + return ( + item === typeID) !== -1 ? 1 : 0.8, + backgroundColor: + selectedTypeList.findIndex((item) => item === typeID) !== -1 + ? "white" + : color, + alignSelf: "center", + borderColor: color, + borderWidth: 1, + borderRadius: 100, + }} + onPress={() => { + if (selectedTypeList.findIndex((item) => item === typeID) === -1) { + setSelectedTypeList([ + ...selectedTypeList, + typeID, + ...(relativeID ?? []), + ]); + } else { + setSelectedTypeList( + selectedTypeList.filter( + (item) => item !== typeID && !relativeID?.includes(item) + ) + ); + } + }} + > + item === typeID) !== -1 + ? color + : "white", + fontSize: 14, + margin: 5, + }} + > + {typeName} + + + ); +}; diff --git a/lib/getTrainType.ts b/lib/getTrainType.ts index 4f3f951..99450f9 100644 --- a/lib/getTrainType.ts +++ b/lib/getTrainType.ts @@ -1,6 +1,6 @@ import { typeID } from "./getStringConfig"; -type colorString = +export type colorString = | "aqua" | "red" | "#297bff"