= ({ isMatsuyama, children }) => {
+ const { width } = useWindowDimensions();
const lineID = children.slice(0, 1);
const lineName = children.slice(1);
+ const 下枠駅ナンバー: ViewStyle = {
+ alignContent: "center",
+ alignItems: "center",
+ width: width * 0.08,
+ height: width * 0.08,
+ margin: width * 0.01,
+ backgroundColor: "white",
+ borderWidth: parseInt("3%"),
+ borderRadius: parseInt("100%"),
+ };
+ const 下枠駅ナンバーB: ViewStyle = {
+ alignContent: "center",
+ alignItems: "center",
+ width: width * 0.07,
+ height: width * 0.07,
+ margin: width * 0.02,
+ backgroundColor: "white",
+ borderWidth: parseInt("3%"),
+ borderRadius: parseInt("100%"),
+ };
return (
= ({ isMatsuyama, children }) => {
);
};
-
-const 下枠フレーム: ViewStyle = {
- flex: 1,
- flexDirection: "row",
- alignContent: "center",
- alignItems: "center",
-};
-const 下枠左右マーク: TextStyle = {
- fontWeight: "bold",
- fontSize: parseInt("20%"),
- color: "white",
- paddingHorizontal: 5,
- textAlignVertical: "center",
-};
-const 下枠駅ナンバー: ViewStyle = {
- alignContent: "center",
- alignItems: "center",
- width: wp("8%"),
- height: wp("8%"),
- margin: wp("1%"),
- backgroundColor: "white",
- borderWidth: parseInt("3%"),
- borderRadius: parseInt("100%"),
-};
-const 下枠駅ナンバーB: ViewStyle = {
- alignContent: "center",
- alignItems: "center",
- width: wp("7%"),
- height: wp("7%"),
- margin: wp("2%"),
- backgroundColor: "white",
- borderWidth: parseInt("3%"),
- borderRadius: parseInt("100%"),
-};
diff --git a/components/駅名表/Sign.js b/components/駅名表/Sign.js
index 7cd1723..f7a3929 100644
--- a/components/駅名表/Sign.js
+++ b/components/駅名表/Sign.js
@@ -1,6 +1,10 @@
import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
-import { View, Text, TouchableOpacity } from "react-native";
-import { widthPercentageToDP as wp } from "react-native-responsive-screen";
+import {
+ View,
+ Text,
+ TouchableOpacity,
+ useWindowDimensions,
+} from "react-native";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import LottieView from "lottie-react-native";
import { useInterval } from "../../lib/useInterval";
@@ -15,7 +19,14 @@ import { AddressText } from "./AddressText";
import { useStationList } from "../../stateBox/useStationList";
export default function Sign(props) {
- const { currentStation, oP, oLP, isCurrentStation = false } = props;
+ const { oP, oLP, isCurrentStation = false, stationID } = props;
+
+ const { width, height } = useWindowDimensions();
+ const { getStationDataFromId } = useStationList();
+ if (!stationID) {
+ return <>>;
+ }
+ const [currentStationData] = useState(getStationDataFromId(stationID));
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
const [nexPrePosition, setNexPrePosition] = useState(0);
const { originalStationList } = useStationList();
@@ -26,48 +37,40 @@ export default function Sign(props) {
useLayoutEffect(() => {
const isFavorite = favoriteStation.filter((d) => {
const compare = JSON.stringify(d);
- const current = JSON.stringify(currentStation);
- if (compare === current) {
- return true;
- } else {
- return false;
- }
+ const current = JSON.stringify(currentStationData);
+ return compare === current;
});
setTestButtonStatus(isFavorite.length == 0 ? false : true);
- }, [favoriteStation, currentStation]);
+ }, [favoriteStation, currentStationData]);
useEffect(() => {
const isFavorite = favoriteStation.filter((d) => {
const compare = JSON.stringify(d);
- const current = JSON.stringify(currentStation);
- if (compare === current) {
- return true;
- } else {
- return false;
- }
+ const current = JSON.stringify(currentStationData);
+ return compare === current;
});
setTestButtonStatus(isFavorite.length == 0 ? false : true);
- }, [favoriteStation, currentStation]);
+ }, [favoriteStation, currentStationData]);
useInterval(() => {
- if (currentStation.length == 1) {
+ if (currentStationData.length == 1) {
setNexPrePosition(0);
return () => {};
}
setNexPrePosition(
- nexPrePosition + 1 == currentStation.length ? 0 : nexPrePosition + 1
+ nexPrePosition + 1 == currentStationData.length ? 0 : nexPrePosition + 1
);
}, 2000);
useEffect(() => {
setNexPrePosition(0);
- getPreNextStation(currentStation[0]);
- if (currentStation.length == 1) return () => {};
- getPreNextStation(currentStation[1]);
- }, [currentStation]);
+ getPreNextStation(currentStationData[0]);
+ if (currentStationData.length == 1) return () => {};
+ getPreNextStation(currentStationData[1]);
+ }, [currentStationData]);
useEffect(() => {
- if (!currentStation[nexPrePosition]) return () => {};
- getPreNextStation(currentStation[nexPrePosition]);
+ if (!currentStationData[nexPrePosition]) return () => {};
+ getPreNextStation(currentStationData[nexPrePosition]);
}, [nexPrePosition]);
const getPreNextStation = (now) => {
const lineList = [
@@ -101,25 +104,81 @@ export default function Sign(props) {
if (returnData[1]) setNexStation(returnData[1]);
}
};
- const isMatsuyama = currentStation[0].StationNumber == "Y55";
+ const isMatsuyama = currentStationData[0].StationNumber == "Y55";
//const isMatsuyama = true;
const favoliteChanger = () => {
if (testButtonStatus) {
const otherData = favoriteStation.filter((d) => {
const compare = JSON.stringify(d);
- const current = JSON.stringify(currentStation);
+ const current = JSON.stringify(currentStationData);
return compare !== current;
});
AS.setItem("favoriteStation", JSON.stringify(otherData));
setFavoriteStation(otherData);
} else {
let ret = favoriteStation;
- ret.push(currentStation);
+ ret.push(currentStationData);
AS.setItem("favoriteStation", JSON.stringify(ret));
setFavoriteStation(ret);
}
setTestButtonStatus(!testButtonStatus);
};
+
+ const styleSheet = {
+ 外枠: {
+ width: width * 0.8,
+ height: ((width * 0.8) / 20) * 9,
+ borderColor: "#0099CC",
+ borderWidth: 1,
+ backgroundColor: "white",
+ },
+ 外枠B: {
+ width: width * 0.8,
+ height: ((width * 0.8) / 20) * 9,
+ borderWidth: 0,
+ },
+ 下帯: {
+ position: "absolute",
+ bottom: "8%",
+ left: "0%",
+ width: "100%",
+ height: "27%",
+ backgroundColor: "#0099CC",
+ },
+ 下帯B: {
+ position: "absolute",
+ bottom: "0%",
+ left: "0%",
+ width: "100%",
+ height: "26%",
+ backgroundColor: "#454545",
+ },
+ JRStyle: {
+ position: "absolute",
+ top: "2%",
+ left: "2%",
+ fontWeight: "bold",
+ fontSize: parseInt("25%"),
+ color: "#0099CC",
+ },
+ 下帯内容: {
+ position: "absolute",
+ bottom: "8%",
+ height: "27%",
+ width: "100%",
+ alignItems: "center",
+ flexDirection: "column",
+ },
+ 下帯内容B: {
+ position: "absolute",
+ bottom: "0%",
+ height: "26%",
+ width: "100%",
+ alignItems: "center",
+ flexDirection: "column",
+ },
+ };
+
return (
)}
-
-
+
+
{isCurrentStation ? (
-
+
);
}
-
-const styleSheet = {
- 外枠: {
- width: wp("80%"),
- height: (wp("80%") / 20) * 9,
- borderColor: "#0099CC",
- borderWidth: 1,
- backgroundColor: "white",
- },
- 外枠B: {
- width: wp("80%"),
- height: (wp("80%") / 20) * 9,
- borderWidth: 0,
- },
- 下帯: {
- position: "absolute",
- bottom: "8%",
- left: "0%",
- width: "100%",
- height: "27%",
- backgroundColor: "#0099CC",
- },
- 下帯B: {
- position: "absolute",
- bottom: "0%",
- left: "0%",
- width: "100%",
- height: "26%",
- backgroundColor: "#454545",
- },
- JRStyle: {
- position: "absolute",
- top: "2%",
- left: "2%",
- fontWeight: "bold",
- fontSize: parseInt("25%"),
- color: "#0099CC",
- },
- 下帯内容: {
- position: "absolute",
- bottom: "8%",
- height: "27%",
- width: "100%",
- alignItems: "center",
- flexDirection: "column",
- },
- 下帯内容B: {
- position: "absolute",
- bottom: "0%",
- height: "26%",
- width: "100%",
- alignItems: "center",
- flexDirection: "column",
- },
-};
diff --git a/components/駅名表/StationNumberMaker.tsx b/components/駅名表/StationNumberMaker.tsx
index dbeef0e..bd38e40 100644
--- a/components/駅名表/StationNumberMaker.tsx
+++ b/components/駅名表/StationNumberMaker.tsx
@@ -1,10 +1,11 @@
import React from "react";
import { Text, View } from "react-native";
-import { widthPercentageToDP as wp } from "react-native-responsive-screen";
+import { useWindowDimensions } from "react-native";
import lineColorList from "../../assets/originData/lineColorList";
export const StationNumberMaker = (props) => {
const { currentStation, isMatsuyama } = props;
+ const { width } = useWindowDimensions();
const getTop = (array: number[], index: number) => {
if (array.length == 1) return 20;
else if (index == 0) return 5;
@@ -24,8 +25,8 @@ export const StationNumberMaker = (props) => {
alignItems: "center",
top: `${getTop(array, index)}%`,
right: "10%",
- width: wp("10%"),
- height: wp("10%"),
+ width: (width / 100 * 10),
+ height: (width / 100 * 10),
borderColor: lineColorList[lineID],
backgroundColor: "white",
borderWidth: parseInt("3%"),
diff --git a/config/newsUpdate.ts b/config/newsUpdate.ts
index 04902c9..c3e61f4 100644
--- a/config/newsUpdate.ts
+++ b/config/newsUpdate.ts
@@ -1 +1 @@
-export const news = "2025-03-06";
+export const news = "2025-07-09";
diff --git a/lib/getStationList.ts b/lib/getStationList.ts
index 1a851f3..45d3e17 100644
--- a/lib/getStationList.ts
+++ b/lib/getStationList.ts
@@ -40,6 +40,17 @@ export const lineListPair = {
N: "鳴門線(池谷-鳴門間)[N]",
M: "瀬戸大橋線(児島-宇多津間)[M]",
};
+export const lineList_LineWebID = {
+ "予讃線(高松-松山間)[Y]" : "yosan",
+ "予讃線(松山-宇和島間)[U]" : "uwajima",
+ "予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]" : "uwajima2",
+ "土讃線(多度津-高知間)[D]" : "dosan",
+ "土讃線(高知-窪川間)[K]" : "dosan2",
+ "高徳線(高松-徳島間)[T]" : "koutoku",
+ "徳島線(徳島-阿波池田間)[B]" : "tokushima",
+ "鳴門線(池谷-鳴門間)[N]" : "naruto",
+ "瀬戸大橋線(児島-宇多津間)[M]" : "seto",
+};
export const getStationList2 = async () => {
return {
yosan,
@@ -167,6 +178,11 @@ export const getStationList = async () => {
予讃線,
stationList["日英対応表"]
);
+ stationList["予讃線(松山-宇和島間)[U]"] = addStationPosition(
+ concatBetweenStations(stationList["予讃線(松山-宇和島間)[U]"]),
+ 内子線,
+ stationList["日英対応表"]
+ );
stationList["予讃線/愛ある伊予灘線(向井原-伊予大洲間)[S]"] =
addStationPosition(
concatBetweenStations(
@@ -195,15 +211,11 @@ export const getStationList = async () => {
鳴門線,
stationList["日英対応表"]
);
- const tokushimaCurrent = addStationPosition(
+ stationList["徳島線(徳島-阿波池田間)[B]"] = addStationPosition(
concatBetweenStations(stationList["徳島線(徳島-阿波池田間)[B]"]),
徳島線,
stationList["日英対応表"]
);
- stationList["徳島線(徳島-阿波池田間)[B]"] = [
- tokushimaCurrent[tokushimaCurrent.length - 1],
- ...tokushimaCurrent,
- ];
stationList["徳島線(徳島-阿波池田間)[B]"].pop();
stationList["瀬戸大橋線(児島-宇多津間)[M]"] = [
{
diff --git a/lib/getTrainType.ts b/lib/getTrainType.ts
index 5dda2d3..151630c 100644
--- a/lib/getTrainType.ts
+++ b/lib/getTrainType.ts
@@ -5,7 +5,7 @@ type nameString =
| "SPCL"
| "Normal"
| string;
-type colorString = "aqua" | "red" | "#297bff" | "white";
+type colorString = "aqua" | "red" | "#297bff" | "white" | "pink";
type trainTypeString =
| "快速"
| "特急"
@@ -28,7 +28,7 @@ export const getTrainType: getTrainType = (nameString) => {
case "LTDEXP":
return { color: "red", name: "特急", data: "express" };
case "NightLTDEXP":
- return { color: "red", name: "寝台特急", data: "express" };
+ return { color: "pink", name: "寝台特急", data: "express" };
case "SPCL":
case "SPCL_Rapid":
case "SPCL_EXP":
diff --git a/lib/webViewInjectjavascript.ts b/lib/webViewInjectjavascript.ts
index 492d280..c0484d7 100644
--- a/lib/webViewInjectjavascript.ts
+++ b/lib/webViewInjectjavascript.ts
@@ -2,13 +2,15 @@ type InjectJavascriptData = (
a: string,
b: string,
c: string,
- d: string
+ d: string,
+ e: string
) => string;
export const injectJavascriptData: InjectJavascriptData = (
mapSwitch,
iconSetting,
stationMenu,
- trainMenu
+ trainMenu,
+ uiSetting
) => {
// 一番上のメニュー非表示 地図スイッチによって切り替え
const topMenu =
@@ -28,10 +30,29 @@ export const injectJavascriptData: InjectJavascriptData = (
// 上部ヘッダーの取り扱い、自動再読み込み、setStringsの実行
const bootData = `
+ let stationList = {};
+ fetch("https://n8n.haruk.in/webhook/jr-shikoku-station-list").then((response) => response.json()).then((data) => {
+ stationList = data;
+ });
let trainDataList = [];
fetch("https://n8n.haruk.in/webhook/jr-shikoku-position-custom-datalist").then((response) => response.json()).then((data) => {
trainDataList = data[0].data;
}).then(()=>setReload());
+ let trainDiagramData2 = {};
+ fetch("https://n8n.haruk.in/webhook/JR-shikoku-diagram-migrate-original")
+ .then((response) => response.json())
+ .then((res)=>res.data)
+ .then((res) => {
+ const data = {};
+ res.forEach((d) => {
+ const keys = Object.keys(d);
+ data[keys] = d[keys];
+ });
+ return data;
+ })
+ .then((data) => {
+ trainDiagramData2 = data;
+ });
let probremsData = [];
fetch("https://n8n.haruk.in/webhook/jrshikoku-position-problems").then((response) => response.json()).then((data) => {
probremsData = data.data;
@@ -52,7 +73,7 @@ export const injectJavascriptData: InjectJavascriptData = (
const trainIcon = `
const setStationIcon = (setIconElem,img,hasProblem) =>{
const position = setIconElem.getAttribute("style").includes("left");
- setIconElem.insertAdjacentHTML('beforebegin', "
");
+ setIconElem.insertAdjacentHTML('beforebegin', "
");
setIconElem.remove();
}
@@ -998,20 +1019,54 @@ export const injectJavascriptData: InjectJavascriptData = (
`;
const normal_train_name = `
+ const getJRF = num =>{
+ switch(num){
+ case "71":
+ return "東京(タ)→高松(タ)";
+ case "73":
+ case "75":
+ return "大阪(タ)→高松(タ)";
+ case "3079":
+ return "高松(タ)→伊予三島";
+ case "3071":
+ case "3077":
+ return "高松(タ)→新居浜";
+ case "3073":
+ return "高松(タ)→松山貨物";
+ case "70":
+ return "高松(タ)→東京(タ)";
+ case "74":
+ case "76":
+ return "高松(タ)→大阪(タ)";
+ case "3078":
+ return "伊予三島→高松(タ)";
+ case "3070":
+ return "新居浜→高松(タ)";
+ case "3076":
+ return "新居浜→高松(タ)";
+ case "3072":
+ return "松山貨物→高松(タ)";
+ case "9070":
+ return "臨時貨物";
+ default:
+ return undefined;
+ }
+ }
const nameReplace = (列車名データ,列番データ,行き先情報,hasProblem) =>{
let isWanman = false;
let trainName = "";
+ let trainType = "";
+ let trainTypeColor = "black";
let viaData = "";
let ToData = "";
let TrainNumber = 列番データ;
try{
- const diagram = trainTimeInfo[列番データ];
+ const diagram = trainDiagramData2[列番データ] || trainTimeInfo[列番データ];
if(diagram){
const diagramData = diagram.split("#");
ToData = diagramData[diagramData.length - 2].split(",")[0];
}
-
}catch(e){}
if(列車名データ.split(":")[1]){
const textBase = 列車名データ.split(":")[1].replace("\\r","");
@@ -1039,42 +1094,20 @@ export const injectJavascriptData: InjectJavascriptData = (
else if(列番データ.indexOf("R") != -1){
trainName = "回送";
}
+ else if(列番データ.indexOf("E") != -1){
+ trainName = "回送";
+ }
+ else if(列番データ.indexOf("A") != -1){
+ trainName = "回送";
+ }
+ else if(列番データ.indexOf("B") != -1){
+ trainName = "回送";
+ }
else if(列番データ.indexOf("S") != -1){
trainName = "臨時列車";
}
- const getJRF = num =>{
- switch(num){
- case "71":
- return "東京(タ)→高松(タ)";
- case "73":
- case "75":
- return "大阪(タ)→高松(タ)";
- case "3079":
- return "高松(タ)→伊予三島";
- case "3071":
- case "3077":
- return "高松(タ)→新居浜";
- case "3073":
- return "高松(タ)→松山貨物";
- case "70":
- return "高松(タ)→東京(タ)";
- case "74":
- case "76":
- return "高松(タ)→大阪(タ)";
- case "3078":
- return "伊予三島→高松(タ)";
- case "3070":
- return "新居浜→高松(タ)";
- case "3076":
- return "新居浜→高松(タ)";
- case "3072":
- return "松山貨物→高松(タ)";
- case "9070":
- return "臨時貨物";
- }
- }
let JRF = true;
const JRFTemp = getJRF(列番データ);
@@ -1231,10 +1264,49 @@ export const injectJavascriptData: InjectJavascriptData = (
getThrew(列番データ);
if(trainDataList.find(e => e.id === 列番データ) !== undefined){
const data = trainDataList.find(e => e.id === 列番データ);
- //{id,isWanman,trainName,viaData,ToData}
+ //{id,isWanman,trainName,viaData,ToData,TrainNumber,JRF,type,infoUrl,trainNumDistance,info,infogram}
+ trainType = (()=>{
+ switch(data.type){
+ case "Normal":
+ trainTypeColor = "black";
+ return "普通";
+ case "OneMan":
+ trainTypeColor = "black";
+ return "普通";
+ case "Freight":
+ trainTypeColor = "black";
+ return "貨物";
+ case "SPCL_Normal":
+ trainTypeColor = "#297bff";
+ return "臨時";
+ case "SPCL_Rapid":
+ trainTypeColor = "#297bff";
+ return "臨時快速";
+ case "SPCL_LTDEXP":
+ trainTypeColor = "#297bff";
+ return "臨時特急";
+ case "LTDEXP":
+ trainTypeColor = "red";
+ return "特急";
+ case "NightLTDEXP":
+ trainTypeColor = "rgb(211, 0, 176)";
+ return "寝台特急";
+ case "OneManRapid":
+ trainTypeColor = "rgba(0, 140, 255, 1)";
+ return "快速";
+ case "Rapid":
+ trainTypeColor = "rgba(0, 140, 255, 1)";
+ return "快速";
+ default:
+ return "";
+ }
+ })();
isWanman = data.isWanman;
if(data.trainName != ""){
trainName = data.trainName;
+ if(data.trainNumDistance != null){
+ trainName += parseInt(列番データ.replace("M", "").replace("D", "")) - data.trainNumDistance+"号";
+ }
}
if(data.viaData != ""){
viaData = data.viaData;
@@ -1247,18 +1319,167 @@ export const injectJavascriptData: InjectJavascriptData = (
const returnText1 = (isWanman ? "ワンマン " : "") + trainName + viaData;
const returnText2 = (ToData ? ToData+"行 " : ToData)+ TrainNumber;
行き先情報.innerText = "";
- 行き先情報.insertAdjacentHTML('beforebegin', "" + returnText1 + "
");
- 行き先情報.insertAdjacentHTML('beforebegin', "" + (ToData ? ToData + "行 " : ToData) + "
" + TrainNumber + (JRF ? "":"レ") + "
");
- 行き先情報.insertAdjacentHTML('beforebegin', "" + (hasProblem ? "‼️停止中‼️" : "") + "
");
- }
+ ${uiSetting === "tokyo" ? `
+ let stationIDs = [];
+ let stationLines = [];
+ Object.keys(stationList).forEach((key) => {
+ const data = stationList[key].find(e => e.Station_JP === ToData )?.StationNumber;
+ if(data){
+ stationIDs.push(data);
+ stationLines.push(key);
+ }
+ });
+ let getColors = [];
+ if(stationLines.length === 0){
+ getColors = ["rgba(97, 96, 96, 0.81)"];
+ }else{
+ getColors = stationLines.map(e => GetLineBarColor(e));
+ }
+ let yosan2Color = undefined;
+ if(viaData == "(内子経由)"){
+ yosan2Color ="#F5AC13";
+ }
+ else if(viaData == "(海経由)"){
+ yosan2Color = "#9AA7D7";
+ }
+
+ const gradient = getColors.length > 1 ? "linear-gradient(130deg, " + getColors[0] + " 0%, "+ getColors[0]+"50%, "+ getColors[1]+"50%, " + getColors[1] + " 100%)" : getColors[0];
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + TrainNumber + (JRF ? "":"レ") + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + (isWanman ? "ワンマン " : "") + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + viaData + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + trainName + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + (ToData ? ToData + "行" : ToData) + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + (hasProblem ? "‼️停止中‼️" : "") + "
");
+ `: `
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + returnText1 + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + (ToData ? ToData + "行 " : ToData) + "
" + TrainNumber + (JRF ? "":"レ") + "
");
+ 行き先情報.insertAdjacentHTML('beforebegin', "" + (hasProblem ? "‼️停止中‼️" : "") + "
");
+ `}
+ }
`;
const textInsert =
`
+
+
+const setNewTrainItem = (element,hasProblem)=>{
+ var 列番データ = element.getAttribute('offclick').split('"')[1];
+ const JRFTemp = getJRF(列番データ);
+ if(element.getAttribute('offclick').includes("express")){
+ element.style.borderColor = 'rgba(255, 0, 0, 1)';
+ }else if(element.getAttribute('offclick').includes("rapid")){
+ element.style.borderColor = 'rgba(0, 140, 255, 1)';
+ }else if(JRFTemp){
+ element.style.borderColor = 'rgba(0, 134, 158, 0.8)';
+ }else{
+ element.style.borderColor = 'white';
+ }
+ element.style.borderWidth = '2px';
+ element.style.borderStyle = 'solid';
+ element.style.borderRadius = '10%';
+ switch(true){
+ case 列番データ.indexOf("H") != -1:
+ case 列番データ.indexOf("R") != -1:
+ case 列番データ.indexOf("E") != -1:
+ case 列番データ.indexOf("A") != -1:
+ case 列番データ.indexOf("B") != -1:
+ case !!JRFTemp:
+ element.style.backgroundColor = 'rgba(199, 199, 199, 0.8)';
+ break;
+ default:
+ element.style.backgroundColor = 'rgba(255, 255, 255, 0.8)';
+ break;
+ }
+ if(hasProblem){
+ element.style.boxShadow = '0 0 10px rgba(255, 0, 0, 0.9)';
+ }else{
+ element.style.boxShadow = '0 0 4px rgba(0, 0, 0, 0.2)';
+ }
+ element.style.margin = '2px';
+ element.style.display = 'flex';
+ element.style.alignItems = 'center';
+ element.style.justifyContent = 'center';
+ element.style.width = '4.5em';
+ element.style.minHeight = '80px';
+ element.style.height = '100%';
+ element.getElementsByTagName("img")[0].style.float = 'unset';
+ element.style.webkitTapHighlightColor = 'rgba(0, 0, 0, 0)';
+ element.style.transition = 'transform 0.1s ease-in-out';
+ element.addEventListener('touchstart', () => element.style.transform = 'scale(0.8)');
+ element.addEventListener('touchend', () => element.style.transform = 'scale(1)');
+ if(element.getAttribute("style").includes("left")){
+ // borderを使って五角形を生成 下り
+ element.style.borderRadius = '10% 10% 40% 40%';
+ element.style.flexDirection = 'column-reverse';
+ }
+ else if(element.getAttribute("style").includes("right")){
+ // borderを使って五角形を生成 上り
+ element.style.borderRadius = '40% 40% 10% 10%';
+ element.style.flexDirection = 'column';
+ }
+
+}
//列番付与
const setStrings = () =>{
try {
const elements = document.querySelectorAll('#disp > div > div > div[onclick]');
+ const setNewTrainItemUI = ()=>{
+ const elementBaseBase = document.querySelectorAll('[id^="stationBlock"]');
+ elementBaseBase.forEach(e=>{ //それぞれの駅ブロック横一列
+ e.style.display = 'flex';
+ e.style.height = "unset";
+ e.style.flexDirection = 'row';
+ //e.style.alignItems = "left";
+ e.style.justifyContent = 'center';
+ const x = e.querySelectorAll(':scope > div');//配下のdiv要素を選択
+ //x[0] 登りブロック x[2] 下りブロック x[1] 駅ブロック
+ const aaa = (x2,pos) => {
+ x2.style.display = 'flex';
+ x2.style.flexDirection = 'row';
+ if(pos == "right"){
+ x2.style.alignItems = 'flex-start';
+ x2.style.justifyContent = 'flex-start';
+ }else if(pos == "left"){
+ x2.style.alignItems = 'flex-end';
+ x2.style.justifyContent = 'flex-end';
+ }
+ x2.style.flexWrap = 'wrap';
+ x2.style.width = '100%';
+ x2.style.height = "100%";
+
+ }
+ const aaa2 = (x2) => {
+ x2.style.display = 'flex';
+ x2.style.flexDirection = 'row';
+ x2.style.alignItems = 'center';
+ x2.style.justifyContent = 'center';
+ x2.style.flexWrap = 'wrap';
+ x2.style.width = '100%';
+ x2.style.height = "unset";
+ const x3 = x2.querySelectorAll(":scope > div");
+ x3.forEach(i=>{
+ i.style.position = "unset";
+ i.style.display = "flex";
+ i.style.flexDirection = "column";
+ i.style.flex = "1";
+ i.style.backgroundColor = "#00000000";
+ i.querySelectorAll(":scope > *").forEach(j=>{
+ j.style.width = "100%";
+ j.style.textAlign = "center";
+ j.style.margin = "5px";
+ j.style.padding = "5px";
+ });
+ });
+ }
+ aaa(x[0],"left");
+ aaa2(x[1]);
+ aaa(x[2],"right");
+
+ });
+ }
+
+ ${uiSetting === "tokyo" ? `setNewTrainItemUI();`: ``}
for (let element of elements) {
if(element.getAttribute('offclick')){ continue; }
element.setAttribute('offclick',element.getAttribute('onclick'))
@@ -1266,7 +1487,7 @@ const setStrings = () =>{
var 行き先情報 = element.getElementsByTagName("p")[0];
var 列番データ = element.getAttribute('offclick').split('"')[1];
var 列車名データ = element.getAttribute('offclick').split('"')[3];
- const trainData = trainPositionDatas.find(e => e.TrainNum == 列番データ);
+ const trainData = trainPositionDatas.filter(e=>!(e.Pos && e.Pos.includes("予告窓"))).find(e => e.TrainNum == 列番データ);
const hasProblem = probremsData.find((e)=>{
return e.TrainNum == trainData.TrainNum && e.Pos == trainData.Pos;
});
@@ -1289,6 +1510,7 @@ const setStrings = () =>{
}
` : ""}
nameReplace(列車名データ,列番データ,行き先情報,hasProblem);
+ ${uiSetting === "tokyo" ? `setNewTrainItem(element,hasProblem);`: ``}
}
try{
for(let d of document.getElementById('disp').childNodes){
diff --git a/menu.js b/menu.js
index 42a8592..bc51c70 100644
--- a/menu.js
+++ b/menu.js
@@ -1,71 +1,106 @@
-import React, { useRef, useState, useEffect } from "react";
-import Carousel from "react-native-reanimated-carousel";
+import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
import {
Platform,
View,
ScrollView,
- Linking,
+ useWindowDimensions,
+ LayoutAnimation,
Text,
TouchableOpacity,
- LayoutAnimation,
- Dimensions,
} from "react-native";
import Constants from "expo-constants";
-import * as Location from "expo-location";
+import {
+ configureReanimatedLogger,
+ ReanimatedLogLevel,
+} from "react-native-reanimated";
import StatusbarDetect from "./StatusbarDetect";
-import { widthPercentageToDP as wp } from "react-native-responsive-screen";
-import { Ionicons } from "@expo/vector-icons";
-import LottieView from "lottie-react-native";
-import { parseAllTrainDiagram } from "./lib/parseAllTrainDiagram";
import LED_vision from "./components/発車時刻表/LED_vidion";
-import Sign from "./components/駅名表/Sign";
import { TitleBar } from "./components/Menu/TitleBar";
import { FixedContentBottom } from "./components/Menu/FixedContentBottom";
-import { UsefulBox } from "./components/atom/UsefulBox";
-import { lineList } from "./lib/getStationList";
-import useInterval from "./lib/useInterval";
-import { HeaderConfig } from "./lib/HeaderConfig";
+import { lineList, stationIDPair } from "./lib/getStationList";
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
-import { SheetManager } from "react-native-actions-sheet";
-import { useTrainDelayData } from "./stateBox/useTrainDelayData";
import { useNavigation } from "@react-navigation/native";
import { useStationList } from "./stateBox/useStationList";
-import { StationNumber } from "./components/Menu/StationPagination";
-import lineColorList from "./assets/originData/lineColorList";
+import { TopMenuButton } from "@/components/Menu/TopMenuButton";
+import { JRSTraInfoBox } from "@/components/Menu/JRSTraInfoBox";
+import MapView, { Marker } from "react-native-maps";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs";
+import { CarouselBox } from "./components/Menu/Carousel/CarouselBox";
+import { CarouselTypeChanger } from "./components/Menu/Carousel/CarouselTypeChanger";
+import { useUserPosition } from "./stateBox/useUserPosition";
import { AS } from "./storageControl";
-import { SimpleDot } from "./components/Menu/SimpleDot";
-import { useAllTrainDiagram } from "./stateBox/useAllTrainDiagram";
-
-export default function Menu({ getCurrentTrain }) {
- const { navigate } = useNavigation();
+import { lineList_LineWebID } from "./lib/getStationList";
+import { Ionicons } from "@expo/vector-icons";
+import { SearchUnitBox } from "./components/Menu/RailScope/SearchUnitBox";
+configureReanimatedLogger({
+ level: ReanimatedLogLevel.error, // Set the log level to error
+ strict: true, // Reanimated runs in strict mode by default
+});
+export default function Menu(props) {
+ const { scrollRef, mapHeight, MapFullHeight, mapMode, setMapMode } = props;
+ const { navigate, addListener, isFocused } = useNavigation();
const { favoriteStation } = useFavoriteStation();
const { originalStationList } = useStationList();
-
- //位置情報
- const [locationStatus, setLocationStatus] = useState(null);
+ const { height, width } = useWindowDimensions();
+ const { bottom, left, right, top } = useSafeAreaInsets();
+ const tabBarHeight = useBottomTabBarHeight();
+ const [stationListMode, setStationListMode] = useState(
+ /*<"position"|"favorite">*/ "position"
+ );
useEffect(() => {
- if (Platform.OS == "web") return;
- Location.requestForegroundPermissionsAsync().then((data) => {
- setLocationStatus(
- Platform.OS == "ios"
- ? data.status == "granted"
- : data.android.accuracy == "fine"
- );
- });
+ AS.getItem("stationListMode")
+ .then((res) => setStationListMode(res))
+ .catch((e) => {
+ // AS.setItem("stationListMode", "position");
+ });
}, []);
-
- const getCurrentPosition = () => {
- if (!locationStatus) return () => {};
- Location.getCurrentPositionAsync({}).then((location) =>
- makeCurrentStation(location)
- );
+ const mapsRef = useRef(null);
+ const returnToTop = (bool = true) => {
+ scrollRef?.current.scrollTo({
+ y: mapHeight > 80 ? mapHeight - 80 : 0,
+ animated: bool,
+ });
};
+ const goToMap = () => {
+ scrollRef?.current.scrollTo({
+ y: 0,
+ animated: true,
+ });
+ };
+ useEffect(() => {
+ setTimeout(() => {
+ returnToTop(false);
+ }, 10);
+ }, [mapHeight]);
+ const [scrollStartPosition, setScrollStartPosition] = useState(0);
+ const onScrollBeginDrag = (e) => {
+ LayoutAnimation.configureNext({
+ duration: 300,
+ create: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ update: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ });
+ setScrollStartPosition(e.nativeEvent.contentOffset.y);
+ setMapMode(false);
+ };
+ //現在地基準の駅名標リストアップ機能
+ const { position, locationStatus } = useUserPosition();
+ useEffect(() => {
+ if (!position) return () => {};
+ makeCurrentStation(position);
+ }, [position, stationListMode]);
const makeCurrentStation = (location) => {
if (!originalStationList) return () => {};
const findStationEachLine = (selectLine) => {
- const searchArea = 0.002;
+ const searchArea = 0.055; //検索範囲
const _calcDistance = (from, to) => {
let lat = Math.abs(from.lat - to.lat);
let lng = Math.abs(from.lng - to.lng);
@@ -78,94 +113,135 @@ export default function Menu({ getCurrentTrain }) {
lng: location.coords.longitude,
}) < searchArea
);
+ //NearStationを距離の近い順にソート
+ NearStation.sort((a, b) => {
+ return (
+ _calcDistance(a, {
+ lat: location.coords.latitude,
+ lng: location.coords.longitude,
+ }) -
+ _calcDistance(b, {
+ lat: location.coords.latitude,
+ lng: location.coords.longitude,
+ })
+ );
+ });
return NearStation;
};
- let returnDataBase = lineList
+ let _stList = lineList
.map((d) => findStationEachLine(originalStationList[d]))
.filter((d) => d.length > 0)
.reduce((pre, current) => {
pre.push(...current);
return pre;
}, []);
- if (returnDataBase.length) {
- let currentStation = currentStation == undefined ? [] : currentStation;
- if (currentStation.toString() != returnDataBase.toString()) {
- setCurrentStation(returnDataBase);
- }
- } else {
- setCurrentStation(undefined);
+ if (_stList.length == 0) setNearPositionStation([]);
+ else {
+ let returnData = [];
+ _stList.forEach((d, index, array) => {
+ const stationName = d.Station_JP;
+ if (returnData.findIndex((d) => d[0].Station_JP == stationName) != -1)
+ return;
+ returnData.push(array.filter((d2) => d2.Station_JP == stationName));
+ });
+ //returnDataを距離の近い順にソート
+ returnData.sort((a, b) => {
+ 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);
+ };
+ return (
+ _calcDistance(a[0], {
+ lat: location.coords.latitude,
+ lng: location.coords.longitude,
+ }) -
+ _calcDistance(b[0], {
+ lat: location.coords.latitude,
+ lng: location.coords.longitude,
+ })
+ );
+ });
+ setNearPositionStation(returnData);
}
};
- useEffect(getCurrentPosition, [locationStatus]);
- useInterval(getCurrentPosition, 5000);
+ const [nearPositionStation, setNearPositionStation] = useState([]); //第三要素
- const [currentStation, setCurrentStation] = useState(undefined); //第三要素
+ const [listIndex, setListIndex] = useState(0);
- const carouselRef = useRef();
- const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
-
- const [allStationData, setAllStationData] = useState([]);
+ const [listUpStation, setListUpStation] = useState([]);
+ const [isSearchMode, setisSearchMode] = useState(false);
+ useLayoutEffect(() => {
+ if (!!isSearchMode) {
+ const returnData = [];
+ Object.keys(lineList_LineWebID).forEach((d, indexBase) => {
+ originalStationList[d].forEach((D, index) => {
+ if (
+ isSearchMode &&
+ isSearchMode != stationIDPair[lineList_LineWebID[d]]
+ )
+ return;
+ const latlng = [D.lat, D.lng];
+ if (latlng.length == 0) return null;
+ if (D.StationNumber == undefined) {
+ return null;
+ }
+ returnData.push([D]);
+ });
+ });
+ if (JSON.stringify(returnData) == JSON.stringify(listUpStation)) return;
+ setListUpStation(returnData);
+ } else if (stationListMode == "position") {
+ const returnData = nearPositionStation.filter((d) => d != undefined);
+ if (JSON.stringify(returnData) == JSON.stringify(listUpStation)) return;
+ setListUpStation(returnData);
+ } else {
+ const returnData = favoriteStation.filter((d) => d != undefined);
+ if (JSON.stringify(returnData) == JSON.stringify(listUpStation)) return;
+ setListUpStation(returnData);
+ }
+ }, [nearPositionStation, favoriteStation, stationListMode, isSearchMode]);
useEffect(() => {
- setAllStationData(
- [currentStation, ...favoriteStation].filter((d) => d != undefined)
- );
- }, [currentStation, favoriteStation]);
- useEffect(() => {
- if (allStationData.length == 0) {
- setSelectedCurrentStation(0);
+ if (listUpStation.length == 0) {
+ setListIndex(0);
return;
}
- if (allStationData[selectedCurrentStation] == undefined) {
- const count = selectedCurrentStation - 1;
- setSelectedCurrentStation(count);
+ if (listUpStation.length == 1) {
+ setListIndex(0);
+ return;
}
- }, [selectedCurrentStation, currentStation, allStationData]);
+ if (listUpStation[listIndex] == undefined) {
+ const count = listIndex - 1;
+ setMapMode(false);
+ setListIndex(count);
+ }
+ }, [listIndex, listUpStation, isSearchMode]);
useEffect(() => {
- if (!carouselRef.current) return;
- carouselRef?.current.scrollTo({
- count: selectedCurrentStation - carouselRef.current.getCurrentIndex(),
- animated: true,
- });
- }, [selectedCurrentStation]);
-
- //全列車ダイヤリストを作成するuseEffect
- const { allTrainDiagram:trainDiagram} = useAllTrainDiagram();
-
- const oPSign = () => {
- const payload = {
- currentStation:
- originalStationList &&
- allStationData.length != 0 &&
- allStationData[selectedCurrentStation],
- navigate: navigate,
- goTo: "menu",
- useShow: () => SheetManager.show("StationDetailView", { payload }),
- onExit: () => SheetManager.hide("StationDetailView"),
+ if (originalStationList == undefined) return;
+ if (listUpStation.length == 0) return;
+ if (listUpStation[listIndex] == undefined) return;
+ const { lat, lng } = listUpStation[listIndex][0];
+ const mapRegion = {
+ latitude: lat,
+ longitude: lng,
+ latitudeDelta: 0.05,
+ longitudeDelta: 0.05,
};
- SheetManager.show("StationDetailView", { payload });
- };
+ if (mapMode) {
+ mapsRef?.current.fitToCoordinates(
+ listUpStation.map((d) => ({
+ latitude: parseFloat(d[0].lat),
+ longitude: parseFloat(d[0].lng),
+ })),
+ { edgePadding: { top: 80, bottom: 120, left: 50, right: 50 } } // Add margin values here
+ );
+ } else {
+ mapsRef.current.animateToRegion(mapRegion, 1000);
+ }
+ }, [listIndex, listUpStation]);
- const [dotButton, setDotButton] = useState(false);
-
- useEffect(() => {
- AS.getItem("CarouselSettings/activeDotSettings").then((data) => {
- setDotButton(data === "true");
- });
- }, []);
- const oLPSign = () => {
- LayoutAnimation.configureNext({
- duration: 600,
- update: { type: "spring", springDamping: 0.5 },
- });
- AS.setItem(
- "CarouselSettings/activeDotSettings",
- !dotButton ? "true" : "false"
- );
- setDotButton(!dotButton);
- };
- const width = Dimensions.get("window").width;
return (
-
-
-
- {originalStationList.length != 0 && allStationData.length != 0 && (
-
-
+ ) : (
+ <>>
+ //
+ // JRShikoku RailScope
+ //
+ )}
+ {
+ if (e.nativeEvent.contentOffset.y < mapHeight - 80) {
+ if (scrollStartPosition > e.nativeEvent.contentOffset.y) {
+ goToMap();
+ } else {
+ returnToTop();
+ }
+ }
+ }}
+ >
+ {
+ LayoutAnimation.configureNext({
+ duration: 300,
+ create: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ update: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ });
+ setMapMode(true);
+ goToMap();
+ }}
+ >
+ {listUpStation.map(([{ lat, lng, StationNumber }], index) => (
+ {
- return (
-
-
-
-
-
- );
+ image={require("@/assets/reccha-small.png")}
+ onPress={() => {
+ setMapMode(false);
+ setListIndex(index);
+ if (mapsRef.current) {
+ mapsRef.current.animateToRegion(
+ {
+ latitude: parseFloat(lat),
+ longitude: parseFloat(lng),
+ latitudeDelta: 0.05,
+ longitudeDelta: 0.05,
+ },
+ 1000
+ );
+ }
+ LayoutAnimation.configureNext({
+ duration: 300,
+ create: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ update: {
+ type: LayoutAnimation.Types.easeInEaseOut,
+ property: LayoutAnimation.Properties.opacity,
+ },
+ });
+ returnToTop();
}}
/>
-
- {originalStationList &&
- allStationData.map((d, index) => {
- const active = index == selectedCurrentStation;
- const numberIndex = d[0].StationNumber;
- if (dotButton) {
- return (
- setSelectedCurrentStation(index)}
- currentStation={d}
- active={active}
- index={numberIndex}
- />
- );
- } else {
- return (
- setSelectedCurrentStation(index)}
- active={active}
- index={numberIndex}
- />
- );
- }
- })}
-
-
+ ))}
+
+ {!mapMode && (
+
)}
- {allStationData.length != 0 &&
- originalStationList.length != 0 &&
- allStationData[selectedCurrentStation] && (
- {}}
+
+ {originalStationList.length != 0 && (
+ <>
+
- )}
+ {listUpStation[listIndex] && (
+ {}}
+ />
+ )}
+ >
+ )}
+
+
+ {mapMode && (
+
+ )}
);
}
-
-const TopMenuButton = () => {
- const buttonList = [
- {
- backgroundColor: "#F89038",
- icon: "train-car",
- onPress: () =>
- Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/"),
- title: "駅・鉄道情報",
- },
- {
- backgroundColor: "#EA4752",
- icon: "google-spreadsheet",
- onPress: () =>
- Linking.openURL(
- "https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box"
- ),
- title: "運賃表",
- },
- {
- backgroundColor: "#91C31F",
- icon: "clipboard-list-outline",
- onPress: () => Linking.openURL("https://www.jr-shikoku.co.jp/e5489/"),
- title: "予約",
- },
- ];
- return (
-
- {buttonList.map((d, index) => (
-
- {d.title}
-
- ))}
-
- );
-};
-
-const JRSTraInfoBox = () => {
- const { getTime, delayData, loadingDelayData, setLoadingDelayData } =
- useTrainDelayData();
- const styles = {
- touch: {
- backgroundColor: "#0099CC",
- borderRadius: 5,
- margin: 10,
- borderColor: "black",
- borderWidth: 2,
- overflow: "hidden",
- },
- scroll: {
- backgroundColor: "#0099CC",
- borderRadius: 5,
- maxHeight: 300,
- },
- bottom: {
- position: "absolute",
- top: 250,
- alignItems: "center",
- width: "100%",
- height: 50,
- backgroundColor: "#007FCC88",
- },
- box: {
- padding: 10,
- backgroundColor: "white",
- borderBottomLeftRadius: 5,
- borderBottomRightRadius: 5,
- },
- };
- return (
- SheetManager.show("JRSTraInfo")}
- style={styles.touch}
- >
-
-
-
- 列車遅延速報EX
-
-
-
- {getTime
- ? getTime.toLocaleTimeString("ja-JP").split(":")[0] +
- ":" +
- getTime.toLocaleTimeString("ja-JP").split(":")[1]
- : NaN}
-
- {
- setLoadingDelayData(true);
- }}
- />
-
-
- {loadingDelayData ? (
-
-
-
- ) : delayData ? (
- delayData.map((d, index, array) => {
- let data = d.split(" ");
- return (
-
-
- {data[0].replace("\n", "")}
-
- {data[1]}
- {data[3]}
-
- );
- })
- ) : (
- 現在、5分以上の遅れはありません。
- )}
-
-
-
-
-
- 詳細を見る
-
-
-
-
- );
-};
diff --git a/stateBox/useAllTrainDiagram.js b/stateBox/useAllTrainDiagram.js
index 4f8b589..2ed4173 100644
--- a/stateBox/useAllTrainDiagram.js
+++ b/stateBox/useAllTrainDiagram.js
@@ -4,6 +4,7 @@ import React, { createContext, useContext, useEffect, useState } from "react";
const initialState = {
allTrainDiagram: undefined,
setAllTrainDiagram: () => {},
+ allCustonTrainData: [],
};
const AllTrainDiagramContext = createContext(initialState);
@@ -12,6 +13,7 @@ export const useAllTrainDiagram = () => useContext(AllTrainDiagramContext);
export const AllTrainDiagramProvider = ({ children }) => {
const [allTrainDiagram, setAllTrainDiagram] = useState(trainList);
+ const [allCustonTrainData, setAllCustonTrainData] = useState([]); // カスタム列車データ
const [keyList, setKeyList] = useState(); // 第二要素
useEffect(
() => allTrainDiagram && setKeyList(Object.keys(allTrainDiagram)),
@@ -41,10 +43,26 @@ export const AllTrainDiagramProvider = ({ children }) => {
});
});
}, []);
+ useEffect(() => {
+ // カスタム列車データの取得
+ fetch("https://n8n.haruk.in/webhook/jr-shikoku-position-custom-datalist")
+ .then((res) => res.json())
+ .then((res) => {
+ setAllCustonTrainData(res[0].data);
+ })
+ .catch(() => {
+ alert("カスタム列車データの取得に失敗しました。");
+ });
+ }, []);
return (
{children}
diff --git a/stateBox/useCurrentTrain.js b/stateBox/useCurrentTrain.js
index e49290a..15f6b44 100644
--- a/stateBox/useCurrentTrain.js
+++ b/stateBox/useCurrentTrain.js
@@ -15,6 +15,7 @@ const initialState = {
currentTrainLoading: "loading",
setCurrentTrainLoading: () => {},
getCurrentTrain: () => {},
+ inject: (i) => {},
};
const CurrentTrainContext = createContext(initialState);
diff --git a/stateBox/useFavoriteStation.tsx b/stateBox/useFavoriteStation.tsx
index dbc09d2..d4f5893 100644
--- a/stateBox/useFavoriteStation.tsx
+++ b/stateBox/useFavoriteStation.tsx
@@ -29,10 +29,10 @@ type Props = {
};
export const FavoriteStationProvider:FC = ({ children }) => {
const [favoriteStation, setFavoriteStation] = useState([]);
- const { getStationData } = useStationList();
+ const { getStationDataFromName } = useStationList();
const lodAddMigration = () => {
const migration = favoriteStation.map((d) => {
- return getStationData(d[0].Station_JP);
+ return getStationDataFromName(d[0].Station_JP);
});
setFavoriteStation(migration);
};
diff --git a/stateBox/useStationList.tsx b/stateBox/useStationList.tsx
index f718064..7073735 100644
--- a/stateBox/useStationList.tsx
+++ b/stateBox/useStationList.tsx
@@ -5,19 +5,27 @@ import React, {
useEffect,
FC,
} from "react";
-import { lineList, getStationList } from "../lib/getStationList";
+import {
+ lineList,
+ getStationList,
+ lineList_LineWebID,
+} from "../lib/getStationList";
type initialStateType = {
originalStationList: any[][];
setOriginalStationList: React.Dispatch>;
- getStationData: (id: string) => void;
+ getStationDataFromName: (id: string) => any[];
+ getStationDataFromId: (id: string) => any[];
stationList: any[];
+ getInjectJavascriptAddress: (StationNumber: string) => string;
};
const initialState = {
originalStationList: [[]],
setOriginalStationList: () => {},
- getStationData: () => {},
+ getStationDataFromName: () => [],
+ getStationDataFromId: () => [],
stationList: [],
+ getInjectJavascriptAddress: (StationNumber: string) => "",
};
const StationListContext = createContext(initialState);
@@ -33,7 +41,21 @@ export const StationListProvider: FC = ({ children }) => {
useEffect(() => {
getStationList().then(setOriginalStationList);
}, []);
- const getStationData: (name: string) => void = (name) => {
+ const getStationDataFromId: (id: string) => any[] = (id) => {
+ let returnArray = [];
+ Object.keys(originalStationList).forEach((key) => {
+ originalStationList[key].forEach((station) => {
+ if (station.StationNumber === id) {
+ returnArray = [
+ ...returnArray,
+ ...getStationDataFromName(station.Station_JP),
+ ];
+ }
+ });
+ });
+ return returnArray;
+ };
+ const getStationDataFromName: (name: string) => any[] = (name) => {
const returnArray = [];
Object.keys(originalStationList).forEach((key) => {
originalStationList[key].forEach((station) => {
@@ -45,22 +67,55 @@ export const StationListProvider: FC = ({ children }) => {
return returnArray;
};
const [stationList, setStationList] = useState([[]]);
- useEffect(()=>{
- if(originalStationList.length === 0) return;
- const stationList =
- originalStationList &&
- lineList.map((d) =>
- originalStationList[d].map((a) => ({
- StationNumber: a.StationNumber,
- StationName: a.Station_JP,
- }))
- );
- setStationList(stationList)
- },[originalStationList])
-
+ useEffect(() => {
+ if (originalStationList.length === 0) return;
+ const stationList = lineList.map((d) =>
+ originalStationList[d].map((a) => ({
+ StationNumber: a.StationNumber,
+ StationName: a.Station_JP,
+ }))
+ );
+ setStationList(stationList);
+ }, [originalStationList]);
+
+ const getInjectJavascriptAddress = (StationNumber: string) => {
+ const bootStationList = [];
+ Object.keys(originalStationList).forEach((d) => {
+ let findNearStations = false;
+ originalStationList[d].forEach((x) => {
+ let lineName = lineList_LineWebID[d];
+ if (findNearStations) {
+ if (x.MyStation) {
+ bootStationList.push({ line: lineName, station: x });
+ findNearStations = false;
+ }
+ return;
+ }
+ if (x.StationNumber == StationNumber) {
+ if (!x.MyStation) findNearStations = true;
+ else bootStationList.push({ line: lineName, station: x });
+ }
+ });
+ if (StationNumber == "M12") {
+ bootStationList.push({
+ line: "seto",
+ station: { Station_JP: "児島", MyStation: "0" },
+ });
+ }
+ });
+ return `MoveDisplayStation('${bootStationList[0].line}_${bootStationList[0].station.MyStation}_${bootStationList[0].station.Station_JP}');document.getElementById("disp").insertAdjacentHTML("afterbegin", "");`;
+ };
+
return (
{children}
diff --git a/stateBox/useTopMenu.tsx b/stateBox/useTopMenu.tsx
new file mode 100644
index 0000000..b5b35c0
--- /dev/null
+++ b/stateBox/useTopMenu.tsx
@@ -0,0 +1,68 @@
+import React, {
+ createContext,
+ useContext,
+ useState,
+ useEffect,
+ FC,
+} from "react";
+import { lineList, getStationList } from "../lib/getStationList";
+
+type initialStateType = {
+ originalStationList: any[][];
+ setOriginalStationList: React.Dispatch>;
+ getStationData: (id: string) => void;
+ stationList: any[];
+};
+const initialState = {
+ originalStationList: [[]],
+ setOriginalStationList: () => {},
+ getStationData: () => {},
+ stationList: [],
+};
+
+const TopMenuContext = createContext(initialState);
+type Props = {
+ children: React.ReactNode;
+};
+export const useTopMenu = () => {
+ return useContext(TopMenuContext);
+};
+
+export const TopMenuProvider: FC = ({ children }) => {
+ const [originalStationList, setOriginalStationList] = useState([]);
+ useEffect(() => {
+ getStationList().then(setOriginalStationList);
+ }, []);
+ const getStationData: (name: string) => void = (name) => {
+ const returnArray = [];
+ Object.keys(originalStationList).forEach((key) => {
+ originalStationList[key].forEach((station) => {
+ if (station.Station_JP === name) {
+ if (!!station.jslodApi) returnArray.push(station);
+ }
+ });
+ });
+ return returnArray;
+ };
+ const [stationList, setStationList] = useState([[]]);
+ useEffect(()=>{
+ if(originalStationList.length === 0) return;
+ const stationList =
+ originalStationList &&
+ lineList.map((d) =>
+ originalStationList[d].map((a) => ({
+ StationNumber: a.StationNumber,
+ StationName: a.Station_JP,
+ }))
+ );
+ setStationList(stationList)
+ },[originalStationList])
+
+ return (
+
+ {children}
+
+ );
+};
diff --git a/stateBox/useTrainDelayData.js b/stateBox/useTrainDelayData.js
index 28e977f..56087e3 100644
--- a/stateBox/useTrainDelayData.js
+++ b/stateBox/useTrainDelayData.js
@@ -3,7 +3,7 @@ const initialState = {
getTime: new Date(),
setGetTime: () => {},
loadingDelayData: true,
- setLoadingDelayData: () => {},
+ setLoadingDelayData: (loading) => {},
delayData: undefined,
setDelayData: () => {},
};
diff --git a/stateBox/useTrainMenu.js b/stateBox/useTrainMenu.js
index fca06d7..f169fc0 100644
--- a/stateBox/useTrainMenu.js
+++ b/stateBox/useTrainMenu.js
@@ -5,6 +5,8 @@ import { ASCore } from "../storageControl";
import { getStationList2 } from "../lib/getStationList";
import { injectJavascriptData } from "../lib/webViewInjectjavascript";
+import { useNotification } from "../stateBox/useNotifications";
+
const initialState = {
selectedLine: undefined,
setSelectedLine: () => {},
@@ -16,6 +18,8 @@ const initialState = {
setMapSwitch: () => {},
stationMenu: undefined,
setStationMenu: () => {},
+ uiSetting: undefined,
+ setUiSetting: () => {},
LoadError: false,
setLoadError: () => {},
trainInfo: {
@@ -26,6 +30,8 @@ const initialState = {
setTrainInfo: () => {},
trainMenu: "true",
setTrainMenu: () => {},
+ updatePermission : false,
+ setUpdatePermission : () => {},
injectJavascript: "",
};
@@ -36,6 +42,7 @@ export const useTrainMenu = () => {
};
export const TrainMenuProvider = ({ children }) => {
+ const { expoPushToken } = useNotification();
const [selectedLine, setSelectedLine] = useState(undefined);
const [mapsStationData, setMapsStationData] = useState(undefined);
useEffect(() => {
@@ -48,6 +55,19 @@ export const TrainMenuProvider = ({ children }) => {
const [stationMenu, setStationMenu] = useState(undefined);
const [LoadError, setLoadError] = useState(false);
+ //更新権限所有確認
+ const [updatePermission, setUpdatePermission] = useState(false);
+ useEffect(()=>{
+ fetch("https://n8n.haruk.in/webhook/data-edit-permission?token=" + expoPushToken).then((res)=>res.json())
+ .then((res)=>{
+ if(res.data == true){
+ setUpdatePermission(true);
+ }else{
+ setUpdatePermission(false);
+ }
+ })
+ }, [expoPushToken])
+
//列車情報表示関連
const [trainInfo, setTrainInfo] = useState({
trainNum: undefined,
@@ -58,12 +78,16 @@ export const TrainMenuProvider = ({ children }) => {
//駅情報画面用
const [trainMenu, setTrainMenu] = useState("true");
+ //GUIデザインベース
+ const [uiSetting, setUiSetting] = useState("tokyo");
+
//地図表示テキスト
const injectJavascript = injectJavascriptData(
mapSwitch,
iconSetting,
stationMenu,
- trainMenu
+ trainMenu,
+ uiSetting
);
useEffect(() => {
@@ -75,6 +99,8 @@ export const TrainMenuProvider = ({ children }) => {
ASCore({ k: "stationSwitch", s: setStationMenu, d: "true", u: true });
//列車メニュースイッチ
ASCore({ k: "trainSwitch", s: setTrainMenu, d: "true", u: true });
+ //GUIデザインベーススイッチ
+ ASCore({ k: "uiSetting", s: setUiSetting, d: "tokyo", u: true });
}, []);
return (
@@ -90,12 +116,16 @@ export const TrainMenuProvider = ({ children }) => {
setMapSwitch,
stationMenu,
setStationMenu,
+ uiSetting,
+ setUiSetting,
LoadError,
setLoadError,
trainInfo,
setTrainInfo,
trainMenu,
setTrainMenu,
+ updatePermission,
+ setUpdatePermission,
injectJavascript,
}}
>
diff --git a/stateBox/useUserPosition.tsx b/stateBox/useUserPosition.tsx
new file mode 100644
index 0000000..2b4cb83
--- /dev/null
+++ b/stateBox/useUserPosition.tsx
@@ -0,0 +1,76 @@
+import React, {
+ createContext,
+ useContext,
+ useState,
+ useEffect,
+ FC,
+} from "react";
+import {
+ LocationObject,
+ requestForegroundPermissionsAsync,
+ getCurrentPositionAsync,
+} from "expo-location";
+import { Platform } from "react-native";
+import useInterval from "@/lib/useInterval";
+
+type initialStateType = {
+ position: LocationObject | undefined;
+ getCurrentPosition: () => void;
+ locationStatus: boolean | null;
+ getLocationPermission: () => void;
+};
+const initialState = {
+ position: undefined,
+ getCurrentPosition: () => {},
+ locationStatus: null,
+ getLocationPermission: () => {},
+};
+
+const UserPositionContext = createContext(initialState);
+type Props = {
+ children: React.ReactNode;
+};
+export const useUserPosition = () => {
+ return useContext(UserPositionContext);
+};
+
+export const UserPositionProvider: FC = ({ children }) => {
+ //位置情報
+ const [locationStatus, setLocationStatus] = useState(null);
+ const [position, setPosition] = useState(
+ undefined
+ );
+
+ const getLocationPermission = async () => {
+ return requestForegroundPermissionsAsync().then((data) => {
+ setLocationStatus(
+ Platform.OS == "ios"
+ ? data.status == "granted"
+ : data.android.accuracy == "fine"
+ );
+ });
+ };
+ const getCurrentPosition = () => {
+ if (!locationStatus) return () => {};
+ getCurrentPositionAsync({}).then((location) => setPosition(location));
+ };
+ useEffect(() => {
+ if (Platform.OS == "web") return;
+ getLocationPermission();
+ }, []);
+ useEffect(getCurrentPosition, [locationStatus]);
+ useInterval(getCurrentPosition, 5000);
+
+ return (
+
+ {children}
+
+ );
+};