From c996b31dad836bed1994d4f25997f75b61cb661c Mon Sep 17 00:00:00 2001 From: harukin-DeskMini Date: Sun, 29 Jan 2023 06:37:52 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=B5=E3=81=81=E3=81=BC=E3=82=8A=E3=81=99?= =?UTF-8?q?=E3=81=A8=E3=82=92=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 6 ++ components/FavoriteList.js | 115 +++++++++++++++++++++++++++++++++++++ components/trainMenu.js | 5 +- 3 files changed, 122 insertions(+), 4 deletions(-) create mode 100644 components/FavoriteList.js diff --git a/App.js b/App.js index 8a4557c..74cbb29 100644 --- a/App.js +++ b/App.js @@ -16,6 +16,7 @@ import menu from "./menu"; import News from "./components/news.js"; import Setting from "./components/settings.js"; import trainMenu from "./components/trainMenu.js"; +import FavoriteList from "./components/FavoriteList.js"; const Stack = createStackNavigator(); const Tab = createBottomTabNavigator(); if (Platform.OS === "android") { @@ -95,6 +96,11 @@ const top = () => ( /> + ); function menuPage() { diff --git a/components/FavoriteList.js b/components/FavoriteList.js new file mode 100644 index 0000000..4f52447 --- /dev/null +++ b/components/FavoriteList.js @@ -0,0 +1,115 @@ +import React, { Component, useRef, useState, useEffect } from "react"; +import { View, Text, TouchableOpacity, ScrollView } from "react-native"; +import { WebView } from "react-native-webview"; +import { ListItem } from "native-base"; +import Icon from "react-native-vector-icons/Entypo"; +import StatusbarDetect from "../StatusbarDetect"; +import { AS } from "../storageControl"; +import { news } from "../config/newsUpdate"; +import { getStationList, lineList } from "../lib/getStationList"; +var Status = StatusbarDetect(); +export default function FavoriteList(props) { + const { + route: { + params: { webview, stationData }, + }, + navigation: { navigate }, + } = props; + + const [favoriteStation, setFavoriteStation] = useState([]); + + useEffect(() => { + AS.getItem("favoriteStation") + .then((d) => { + console.log(d); + const returnData = JSON.parse(d); + console.log(returnData); + setFavoriteStation(returnData); + }) + .catch((d) => console.log(d)); + }, []); + + return ( + + + {favoriteStation + .filter((d) => d[0].StationMap) + .map((currentStation) => { + console.log(currentStation); + return ( + { + const getStationLine = (now) => { + const returnData = Object.keys(stationData).filter((d) => { + const cache = stationData[d].findIndex( + (data) => data.Station_JP == now.Station_JP + ); + return cache != -1; + }); + return returnData[0]; + }; + const lineName = getStationLine(currentStation[0]); + + webview.current?.injectJavaScript( + `MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}')` + ); + navigate("Apps"); + }} + > + + {currentStation + .map((d) => d.StationNumber) + .filter((d) => d !== null) + .join("/")} + + + {currentStation[0].Station_JP} + + + + 移動する + + + + ); + })} + + + お気に入り登録した駅のうち、位置情報システムで移動可能な駅が表示されています。タップすることで位置情報システムの当該の駅に移動します。 + + { + navigate("trainMenu"); + }} + > + + + 閉じる + + + + + ); +} diff --git a/components/trainMenu.js b/components/trainMenu.js index 4c9d001..5921c1d 100644 --- a/components/trainMenu.js +++ b/components/trainMenu.js @@ -68,10 +68,7 @@ export default function trainMenu({ icon="star" flex={1} onPressButton={() => - /* Linking.openURL( - "https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box" - ) */ - alert("お気に入り駅登録機能は現在開発中です!レイアウト募集中!") + navigate("favoriteList", { webview, stationData }) } > お気に入り