diff --git a/components/AllTrainDiagramView.js b/components/AllTrainDiagramView.js index 22a9640..17e0672 100644 --- a/components/AllTrainDiagramView.js +++ b/components/AllTrainDiagramView.js @@ -21,9 +21,10 @@ import { BigButton } from "./atom/BigButton"; import { Switch } from "react-native-elements"; export default function AllTrainDiagramView() { const { navigate } = useNavigation(); - const { keyList } = useAllTrainDiagram(); + const { keyList, allTrainDiagram } = useAllTrainDiagram(); const [input, setInput] = useState(""); // 文字入力 const [keyBoardVisible, setKeyBoardVisible] = useState(false); + const [useStationName, setUseStationName] = useState(false); const [useRegex, setUseRegex] = useState(false); const regexTextStyle = { color: "white", @@ -75,7 +76,12 @@ export default function AllTrainDiagramView() { { - console.log(d); + if (useStationName) { + const ls = input.split(",").map((stationName) => { + return allTrainDiagram[d].includes(stationName); + }); + return !ls.includes(false); + } if (useRegex) { try { const regex = new RegExp(input); @@ -100,6 +106,7 @@ export default function AllTrainDiagramView() { value={useRegex} onValueChange={() => { setUseRegex(!useRegex); + setUseStationName(false); }} color="red" style={{ margin: 5 }} @@ -107,6 +114,18 @@ export default function AllTrainDiagramView() { 正規表現を使用 + { + setUseRegex(false); + setUseStationName(!useStationName); + }} + color="red" + style={{ margin: 5 }} + /> + + 駅名で検索 + 正規表現のサンプル: - setInput("D")}>気動車を選択 - setInput("3\\d\\d\\dM")}>マリンライナーを選択 - setInput("[4,5]\\d\\d\\d[D,M]")}>ワンマン列車を選択 - setInput("^\\d?\\dM")}>しおかぜを選択 - setInput("^\\d?[0,2,4,6,8]D")}>下り南風を選択 - setInput("^([\\d])+\\1")}>数字が二桁揃っている列車を選択 - Linking.openURL("https://qiita.com/tossh/items/635aea9a529b9deb3038")}>参考資料(Qiita) + setInput("D")}> + 気動車を選択 + + setInput("3\\d\\d\\dM")} + > + マリンライナーを選択 + + setInput("[4,5]\\d\\d\\d[D,M]")} + > + ワンマン列車を選択 + + setInput("^\\d?\\dM")} + > + しおかぜを選択 + + setInput("^\\d?[0,2,4,6,8]D")} + > + 下り南風を選択 + + setInput("^([\\d])+\\1")} + > + 数字が二桁揃っている列車を選択 + + + Linking.openURL( + "https://qiita.com/tossh/items/635aea9a529b9deb3038" + ) + } + > + 参考資料(Qiita) +