diff --git a/components/ActionSheetComponents/StationDeteilView.js b/components/ActionSheetComponents/StationDeteilView.js index 7acc01f..f9f93ab 100644 --- a/components/ActionSheetComponents/StationDeteilView.js +++ b/components/ActionSheetComponents/StationDeteilView.js @@ -135,11 +135,11 @@ export const StationDeteilView = (props) => { onExit={onExit} /> )} - {updatePermission &&} + {!currentStation[0].StationTimeTable || ( void; + currentStationDiagram: hoge; +}> = ({ input, setInput, currentStationDiagram }) => { + const { getStationDataFromName } = useStationList(); + const [stationList, setStationList] = useState< + { + stationName: string; + number: string[]; + }[] + >([]); + const [listFiltered, setListFiltered] = useState(""); + const [filteredStationLine, setFilteredStationLine] = useState([]); + useEffect(() => { + const x: { stationName: string; number: string[] }[] = []; + currentStationDiagram.forEach((d) => { + d.array.split("#").forEach((s) => { + if (s == "") return; + const [stationName, type, time] = s.split(","); + if (!x.find((item) => item.stationName === stationName)) { + if (!type?.includes("通")) { + const stationData = getStationDataFromName(stationName); + if (listFiltered === "その他") { + if (stationData.length === 0) { + x.push({ + stationName, + number: stationData.map((item) => item.StationNumber), + }); + return; + } + } + const filter = stationData.filter((s) => { + if (listFiltered === "") return true; + if (listFiltered === "その他") { + return !( + s.StationNumber ? s.StationNumber.slice(0, 1) : "" + ).match(/[A-Z]/); + } + return ( + s.StationNumber ? s.StationNumber.slice(0, 1) : "" + ).includes(listFiltered); + }); + if (filter.length === 0) return; + x.push({ + stationName, + number: stationData.map((item) => item.StationNumber), + }); + } + } + }); + }); + setStationList(x); + }, [currentStationDiagram, listFiltered]); + useEffect(() => { + const filtered = stationList + .map((s) => s.number?.map((r) => (r ? r.slice(0, 1) : ""))) + .flat(); + const arrayB = Array.from(new Set(filtered)); + setFilteredStationLine(arrayB.map((r) => (r !== "" ? r : "その他"))); + }, [stationList]); + return ( + + {input} + + + {stationList.map(({ stationName, number }) => ( + setInput(stationName)} + > + {stationName} + + ))} + + + + { + LayoutAnimation.configureNext({ + duration: 400, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setListFiltered(""); + }} + > + 全て + + {filteredStationLine.map((line) => ( + { + LayoutAnimation.configureNext({ + duration: 400, + update: { type: "easeInEaseOut", springDamping: 0.6 }, + }); + setListFiltered(line); + }} + > + + {line} + + + ))} + + + ); +}; diff --git a/components/StationDiagram/StationDiagramView.tsx b/components/StationDiagram/StationDiagramView.tsx index 97271a5..9f5d85f 100644 --- a/components/StationDiagram/StationDiagramView.tsx +++ b/components/StationDiagram/StationDiagramView.tsx @@ -20,6 +20,7 @@ import { Switch } from "react-native-elements"; import { customTrainDataDetector } from "../custom-train-data"; import { getTrainType } from "@/lib/getTrainType"; import { trainTypeID } from "@/lib/CommonTypes"; +import { SearchInputSuggestBox } from "./SearchBox/SearchInputSuggestBox"; type props = { route: { @@ -129,8 +130,10 @@ export const StationDiagramView: FC = ({ route }) => { // //条件によってフィルタリング if (!threw && timeType && timeType.includes("通")) return; if (!showLastStop && timeType && timeType.includes("着")) return; - if(selectedTypeList.findIndex((item) => item === "SPCL") === -1){ - if(d.match(/9\d\d\d[D,M,S]/)) return; + if ( + selectedTypeList.findIndex((item) => item === "SPCL") === -1 + ) { + if (d.match(/9\d\d\d[D,M,S]/)) return; } if ( selectedTypeList.length > 0 && @@ -174,9 +177,17 @@ export const StationDiagramView: FC = ({ route }) => { useEffect(() => { const showSubscription = Keyboard.addListener("keyboardDidShow", () => { + LayoutAnimation.configureNext({ + duration: 600, + update: { type: "spring", springDamping: 0.6 }, + }); setKeyBoardVisible(true); }); const hideSubscription = Keyboard.addListener("keyboardDidHide", () => { + LayoutAnimation.configureNext({ + duration: 600, + update: { type: "spring", springDamping: 0.6 }, + }); setKeyBoardVisible(false); }); @@ -217,100 +228,142 @@ export const StationDiagramView: FC = ({ route }) => { keyboardVerticalOffset={80} enabled={Platform.OS === "ios"} > - - { - setIsThrew(!threw); + height: 35, + flexDirection: "row", + display: "flex", }} > - { + setIsThrew(!threw); }} > - 通過 - - - { - setShowLastStop(!showLastStop); - }} - > - + 通過 + + + { + setShowLastStop(!showLastStop); }} > - 当駅止 - - - - {showTypeFiltering ? ( - <> - - - - - - + + 当駅止 + + + + {showTypeFiltering ? ( + <> + + + + + + + { + LayoutAnimation.configureNext( + LayoutAnimation.Presets.easeInEaseOut + ); + setShowTypeFiltering(false); + }} + > + + < + + + + ) : ( = ({ route }) => { LayoutAnimation.configureNext( LayoutAnimation.Presets.easeInEaseOut ); - setShowTypeFiltering(false); + setShowTypeFiltering(true); }} > = ({ route }) => { margin: 5, }} > - < + > - - ) : ( + )} + = ({ route }) => { borderRadius: 100, }} onPress={() => { - LayoutAnimation.configureNext( - LayoutAnimation.Presets.easeInEaseOut - ); - setShowTypeFiltering(true); + setDisplayMode(displayMode === "list" ? "grid" : "list"); }} > = ({ route }) => { margin: 5, }} > - > + {displayMode === "list" ? "横並びモード" : "リストモード"} - )} - - { - setDisplayMode(displayMode === "list" ? "grid" : "list"); - }} - > - - {displayMode === "list" ? "横並びモード" : "リストモード"} - - - + + ) : ( + + + + )}