import React, { Component, useRef, useState, useEffect } from "react"; import { StatusBar, Platform, View, LayoutAnimation, ScrollView, Linking, Text, TouchableOpacity, } from "react-native"; import Image from "react-native-remote-svg"; import Constants from "expo-constants"; import { List, ListItem } from "native-base"; import Icon from "react-native-vector-icons/Entypo"; import * as Location from "expo-location"; import StatusbarDetect from "./StatusbarDetect"; import { useNavigation } from "@react-navigation/native"; import AutoHeightImage from "react-native-auto-height-image"; import { widthPercentageToDP as wp, heightPercentageToDP as hp, } from "react-native-responsive-screen"; import { FontAwesome, Fontisto, Foundation, Ionicons, MaterialCommunityIcons, } from "@expo/vector-icons"; import * as WebBrowser from "expo-web-browser"; import ActionSheet from "react-native-actions-sheet"; import LottieView from "lottie-react-native"; import SvgUri from "react-native-svg-uri"; import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView"; import 予讃線 from "./assets/四国旅客鉄道予讃線.json"; import 土讃線 from "./assets/四国旅客鉄道土讃線.json"; import 高徳線 from "./assets/四国旅客鉄道高徳線.json"; import 内子線 from "./assets/四国旅客鉄道内子線.json"; import 徳島線 from "./assets/四国旅客鉄道徳島線.json"; import 鳴門線 from "./assets/四国旅客鉄道鳴門線.json"; import LED_vision from "./components/発車時刻表/LED_vidion"; import Sign from "./components/駅名表/Sign"; import { UsefulBox } from "./components/atom/UsefulBox"; import { TicketBox } from "./components/atom/TicketBox"; import { TextBox } from "./components/atom/TextBox"; import { getStationList } from "./lib/getStationList"; import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo"; export default function Menu(props) { const { navigation: { navigate }, } = props; const JRSTraInfoEXAcSR = useRef(null); const StationBoardAcSR = useRef(null); const navigation = useNavigation(); //位置情報 const [location, setLocation] = useState(null); const [errorMsg, setErrorMsg] = useState(null); useEffect(() => { Location.requestForegroundPermissionsAsync().then((data) => { if (data.status !== "granted") { setErrorMsg("Permission to access location was denied"); return () => {}; } Location.getCurrentPositionAsync({}).then((location) => setLocation(location) ); }); setInterval(() => { Location.getCurrentPositionAsync({}).then((location) => setLocation(location) ); }, 10000); }, []); const [originalStationList, setOriginalStationList] = useState(); useEffect(() => getStationList().then(setOriginalStationList), []); const [stationName, setStationName] = useState(undefined); const [currentStation, setCurrentStation] = useState(undefined); useEffect(() => { if (!location) return () => {}; if (!originalStationList) return () => {}; const findStationEachLine = (selectLine) => { const searchArea = 0.0015; const _calcDistance = (from, to) => { let lat = Math.abs(from.lat - to.lat); let lng = Math.abs(from.lng - to.lng); return Math.sqrt(lat * lat + lng * lng); }; let NearStation = selectLine.filter( (d) => _calcDistance(d, { lat: location.coords.latitude, lng: location.coords.longitude, }) < searchArea ); return NearStation; }; const lineList = [ "予讃線", "松宇線", "伊予灘線", "土讃線", "窪川線", "高徳線", "徳島線", "鳴門線", "瀬戸大橋線", ]; let returnDataBase = lineList .map((d) => findStationEachLine(originalStationList[d])) .filter((d) => d.length > 0) .reduce((pre, current) => { pre.push(...current); return pre; }, []); LayoutAnimation.spring(); if (returnDataBase.length) { let currentStation = currentStation == undefined ? [] : currentStation; if (currentStation.toString() != returnDataBase.toString()) { setCurrentStation(returnDataBase); } } else { setCurrentStation(undefined); StationBoardAcSR.current?.hide(); } }, [location, originalStationList]); const [count, setCount] = useState(0); const [delayData, setDelayData] = useState(undefined); const [getTime, setGetTime] = useState(new Date()); const [loadingDelayData, setLoadingDelayData] = useState(true); useEffect(() => { fetch( "https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec" ) .then((response) => response.text()) .then((data) => setDelayData(data !== "" ? data.split("^") : null)) .then(LayoutAnimation.easeInEaseOut) .then(() => setGetTime(new Date())) .finally(() => setLoadingDelayData(false)); }, [loadingDelayData]); return ( Linking.openURL("https://www.jr-shikoku.co.jp")} > Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/") } > 駅・鉄道情報 Linking.openURL( "https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box" ) } > 運賃表 Linking.openURL("https://www.jr-shikoku.co.jp/e5489/") } > 予約 Linking.openURL( "https://www.jr-shikoku.co.jp/02_information/suspension/sp/" ) } > 新型コロナウイルスに関するお知らせ 列車の運行計画・混雑状況・感染症対策への取り組み {currentStation && ( <> )} 列車遅延速報EX {getTime ? getTime.toLocaleTimeString("ja-JP").split(":")[0] + ":" + getTime.toLocaleTimeString("ja-JP").split(":")[1] : NaN} { LayoutAnimation.easeInEaseOut(); setLoadingDelayData(true); }} /> {loadingDelayData ? ( ) : delayData ? ( delayData.map((d) => { let data = d.split(" "); return ( {data[0].replace("\n", "")} {data[1]} {data[3]} ); }) ) : ( 現在、5分以上の遅れはありません。 )} 詳細を見る } flex={1} onPressButton={() => Linking.openURL("https://www.jr-eki.com/ticket/brand") } > トクトク切符 } flex={1} onPressButton={() => Linking.openURL( "https://www.jr-shikoku.co.jp/01_trainbus/event_train/sp/" ) } > 観光列車 } flex={1} onPressButton={() => Linking.openURL("https://www.jr-eki.com/tour/brand") } > 旅行ツアー Linking.openURL("https://www.jr-eki.com/smart-eki/index.html") } > スマートえきちゃん JR四国のチケットレススマホアプリです。 Linking.openURL( "https://www.jr-shikoku.co.jp/sp/index.html#menu-box" ) } > 臨時列車などのお知らせ 区間縮小・計画運休・イベント・季節臨時列車など Linking.openURL("https://www.jr-shikoku.co.jp/03_news/press/") } > ニュースリリース 公式プレス記事はこちら Linking.openURL("https://www.jr-shikoku.co.jp/teiki/") } > 定期運賃計算 通常/学生/快て〜き等はこちら Linking.openURL("https://www.jr-shikoku.co.jp/04_company/group/sp/") } > JR四国のお店・サービス JR四国グループの施設をご案内 Linking.openURL("https://www.jr-odekake.net/smt/")} > 時刻・運賃計算 (マイ・ダイヤ) マイ・ダイヤはJR西日本提供のサービスです。 Linking.openURL("tel:0570-00-4592")} > JR四国案内センター 0570-00-4592 (8:00~20:00 年中無休) (通話料がかかります) JR四国公式Twitter一族 {((data) => data.map((d) => ( Linking.openURL(d.url)}> {d.name} )))([ { url: "https://twitter.com/JRshikoku_eigyo", name: "JR四国営業部【公式】", }, { url: "https://twitter.com/JRshikoku_tokyo", name: "JR四国 東京営業情報【公式】", }, { url: "https://twitter.com/JRshikoku_osaka", name: "JR四国 大阪営業部【公式】", }, { url: "https://twitter.com/jr_shikoku_info", name: "JR四国列車運行情報【公式】", }, { url: "https://twitter.com/Smile_Eki_Chan", name: "すまいるえきちゃん♡JR四国【公式】", }, { url: "https://twitter.com/jrs_matsuyama", name: "JR四国 松山駅 【公式】", }, { url: "https://twitter.com/jrshikoku_kochi", name: "JR四国 高知駅【公式】", }, { url: "https://twitter.com/jr_tokust", name: "JR四国 徳島駅【公式】", }, { url: "https://twitter.com/jrshikoku_uwjm", name: "JR四国 宇和島駅【公式】", }, { url: "https://twitter.com/JRshikoku_wkoch", name: "JR四国 ワープ高知支店【公式】", }, { url: "https://twitter.com/jrshikoku_nihaw", name: "JR四国 ワープ新居浜営業所【公式】", }, { url: "https://twitter.com/Yoakemonogatari", name: "志国土佐 時代の夜明けのものがたり【公式】", }, ])} このアプリについて このアプリはXprocess(HARUKIN)が製作しているJR四国の完全非公式アシストアプリケーションです。このアプリに関することでのJR四国公式へ問合せすることはお控えください。以下のTwitterよりお願いします。 Linking.openURL("https://twitter.com/Xprocess_main") } > XprocessのTwitter 制作運営のTwitterです。 navigate("setting")} > アプリの設定 アプリの設定画面を表示します。 {/* */} ); }