From 019486f6656b27d67af8573731b758d6ee163c81 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Thu, 8 Aug 2024 13:18:52 +0000 Subject: [PATCH 1/7] =?UTF-8?q?=E9=81=8B=E8=A1=8C=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=83=90=E3=83=83=E3=82=B8=E3=81=AB=E5=AF=BE=E8=B1=A1=E8=B7=AF?= =?UTF-8?q?=E7=B7=9A=E8=A8=98=E5=8F=B7=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.js | 4 ++-- stateBox/useAreaInfo.js | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/App.js b/App.js index aa15106..38e843f 100644 --- a/App.js +++ b/App.js @@ -60,7 +60,7 @@ export default function App() { ); } export function AppContainer() { - const { areaInfo } = useAreaInfo(); + const { areaInfo, areaIconBadgeText } = useAreaInfo(); const navigationRef = React.useRef(); return ( @@ -98,7 +98,7 @@ export function AppContainer() { headerTransparent: true, gestureEnabled: true, tabBarIcon: initIcon("train", "Ionicons"), - tabBarBadge: areaInfo ? "!" : undefined, + tabBarBadge: areaInfo ? areaIconBadgeText : undefined, }} > {(props) => } diff --git a/stateBox/useAreaInfo.js b/stateBox/useAreaInfo.js index a37df6f..1759139 100644 --- a/stateBox/useAreaInfo.js +++ b/stateBox/useAreaInfo.js @@ -3,6 +3,7 @@ import useInterval from "../lib/useInterval"; const initialState = { areaInfo: "", setAreainfo: () => {}, + areaIconBadgeText: "", }; const AreaInfoContext = createContext(initialState); @@ -11,18 +12,43 @@ export const useAreaInfo = () => { return useContext(AreaInfoContext); }; +const areaStationPair = { + seto: ["Y"], + yosan1: ["Y"], + yosan2: ["U"], + dosan1: ["D"], + dosan2: ["K"], + kotoku: ["T"], + mugi: ["M"], + tokushima: ["B"], + naruto: ["N"], + yodo: ["G"], +}; export const AreaInfoProvider = ({ children }) => { const [areaInfo, setAreaInfo] = useState(""); - const getAreaData = () => + const [areaIconBadgeText, setAreaIconBadgeText] = useState(""); + const getAreaData = () => { fetch( "https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec" ) .then((d) => d.text()) .then((d) => setAreaInfo(d)); + fetch("https://n8n.haruk.in/webhook/jr-shikoku-trainfo-flag") + .then((d) => d.json()) + .then((d) => { + if (!d.data) return; + const text = d.data + .filter((e) => e.status) + .map((e) => `${areaStationPair[e.area].join("")}`); + setAreaIconBadgeText(text.length == 0 ? "!" : text.join(",")); + }); + }; useEffect(getAreaData, []); useInterval(getAreaData, 60000); //60秒毎に全在線列車取得 return ( - + {children} ); From 81bb5326f2aa4ba26757ee49ed72174a66af374c Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 19 Aug 2024 05:03:10 +0000 Subject: [PATCH 2/7] =?UTF-8?q?=E5=BD=93=E8=A9=B2=E9=A7=85=E6=83=85?= =?UTF-8?q?=E5=A0=B1=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=81U,S=E3=81=AE?= =?UTF-8?q?=E3=83=90=E3=82=B0=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 2 +- stateBox/useAreaInfo.js | 324 ++++++++++++++++++++++- 2 files changed, 313 insertions(+), 13 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index aeff31a..13b35bf 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -58,7 +58,7 @@ export default function LED_vision(props) { const [finalSwitch, setFinalSwitch] = useState(false); const [trainIDSwitch, setTrainIDSwitch] = useState(false); const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false); - const { areaInfo } = useAreaInfo(); + const { areaInfo, areaStationID } = useAreaInfo(); useEffect(() => { AS.getItem("LEDSettings/trainIDSwitch").then((data) => { diff --git a/stateBox/useAreaInfo.js b/stateBox/useAreaInfo.js index 1759139..a624cba 100644 --- a/stateBox/useAreaInfo.js +++ b/stateBox/useAreaInfo.js @@ -4,6 +4,7 @@ const initialState = { areaInfo: "", setAreainfo: () => {}, areaIconBadgeText: "", + areaStationID: [], }; const AreaInfoContext = createContext(initialState); @@ -11,22 +12,310 @@ const AreaInfoContext = createContext(initialState); export const useAreaInfo = () => { return useContext(AreaInfoContext); }; +const setoStationID = [ + "Y00", + "Y01", + "Y02", + "Y03", + "Y04", + "Y05", + "Y06", + "Y07", + "Y08", + "Y09", + "Y10", + "Y11", + "Y12", +]; +const yosan1StationID = [ + "Y12", + "Y13", + "Y14", + "Y15", + "Y16", + "Y17", + "Y18", + "Y19", + "Y20", + "Y21", + "Y22", + "Y23", + "Y24", + "Y25", + "Y26", + "Y27", + "Y28", + "Y29", + "Y30", + "Y31", + "Y32", + "Y33", + "Y34", + "Y35", + "Y36", + "Y37", + "Y38", + "Y39", + "Y40", + "Y41", + "Y42", + "Y43", + "Y44", + "Y45", + "Y46", + "Y47", + "Y48", + "Y49", + "Y50", + "Y51", + "Y52", + "Y53", + "Y54", + "Y55", +]; +const yosan2StationID = [ + "U00", + "U01", + "U02", + "U02-1", + "U03", + "U04", + "U05", + "U06", + "U07", + "U08", + "U09", + "U10", + "U11", + "U12", + "U13", + "U14", + "U15", + "U16", + "U17", + "U18", + "U19", + "U20", + "U21", + "U22", + "U23", + "U24", + "U25", + "U26", + "U27", + "U28", + "S06", + "S07", + "S08", + "S09", + "S10", + "S11", + "S12", + "S13", + "S14", + "S15", + "S16", + "S17", + "S18", +]; +const dosan1StationID = [ + "D12", + "D13", + "D14", + "D15", + "D16", + "D17", + "D18", + "D19", + "D20", + "D21", + "D22", + "D23", + "D24", + "D25", + "D26", + "D27", + "D28", + "D29", + "D30", + "D31", + "D32", + "D33", + "D34", + "D35", + "D36", + "D37", + "D38", + "D39", + "D40", + "D41", + "D42", + "D43", + "D44", + "D45", +]; +const dosan2StationID = [ + "K00", + "K01", + "K02", + "K03", + "K04", + "K05", + "K06", + "K07", + "K08", + "K08-1", + "K09", + "K10", + "K11", + "K12", + "K13", + "K14", + "K15", + "K16", + "K17", + "K18", + "K19", + "K20", + "K21", + "K22", + "K23", + "K24", + "K25", + "K26", +]; + +const kotokuStationID = [ + "T00", + "T01", + "T02", + "T03", + "T04", + "T05", + "T06", + "T07", + "T08", + "T09", + "T10", + "T11", + "T12", + "T13", + "T14", + "T15", + "T16", + "T17", + "T18", + "T19", + "T20", + "T21", + "T22", + "T23", + "T24", + "T25", + "T26", + "T27", + "T28", +]; +const mugiStationID = [ + "M00", + "M01", + "M02", + "M03", + "M04", + "M05", + "M06", + "M07", + "M08", + "M09", + "M10", + "M11", + "M12", + "M13", + "M14", + "M15", + "M16", + "M17", + "M18", + "M19", + "M20", + "M21", + "M22", + "M23", + "M24", + "M25", + "M26", + "M27", +]; +const tokushimaStationID = [ + "B00", + "B01", + "B02", + "B03", + "B04", + "B05", + "B06", + "B07", + "B08", + "B09", + "B10", + "B11", + "B12", + "B13", + "B14", + "B15", + "B16", + "B17", + "B18", + "B19", + "B20", + "B21", + "B22", + "B23", + "B24", + "B25", +]; + +const narutoStationID = ["N04", "N05", "N06", "N07", "N08", "N09", "N10"]; +const yodoStationID = [ + "G27", + "G28", + "G29", + "G30", + "G31", + "G32", + "G33", + "G34", + "G35", + "G36", + "G37", + "G38", + "G39", + "G40", + "G41", + "G42", + "G43", + "G44", + "G45", + "G46", + "G47", +]; const areaStationPair = { - seto: ["Y"], - yosan1: ["Y"], - yosan2: ["U"], - dosan1: ["D"], - dosan2: ["K"], - kotoku: ["T"], - mugi: ["M"], - tokushima: ["B"], - naruto: ["N"], - yodo: ["G"], + seto: { id: "Y", stationID: setoStationID }, + yosan1: { id: "Y", stationID: yosan1StationID }, + yosan2: { id: "U,S", stationID: yosan2StationID }, + dosan1: { id: "D", stationID: dosan1StationID }, + dosan2: { id: "K", stationID: dosan2StationID }, + kotoku: { id: "T", stationID: kotokuStationID }, + mugi: { id: "M", stationID: mugiStationID }, + tokushima: { id: "B", stationID: tokushimaStationID }, + naruto: { id: "N", stationID: narutoStationID }, + yodo: { id: "G", stationID: yodoStationID }, }; export const AreaInfoProvider = ({ children }) => { const [areaInfo, setAreaInfo] = useState(""); const [areaIconBadgeText, setAreaIconBadgeText] = useState(""); + const [areaStationID, setAreaStationID] = useState([]); const getAreaData = () => { fetch( "https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec" @@ -39,7 +328,18 @@ export const AreaInfoProvider = ({ children }) => { if (!d.data) return; const text = d.data .filter((e) => e.status) - .map((e) => `${areaStationPair[e.area].join("")}`); + .map((e) => { + return `${areaStationPair[e.area].id}`; + }); + let stationIDList = []; + d.data + .filter((e) => e.status) + .forEach((e) => { + stationIDList = stationIDList.concat( + areaStationPair[e.area].stationID + ); + }); + setAreaStationID(stationIDList); setAreaIconBadgeText(text.length == 0 ? "!" : text.join(",")); }); }; @@ -47,7 +347,7 @@ export const AreaInfoProvider = ({ children }) => { useInterval(getAreaData, 60000); //60秒毎に全在線列車取得 return ( {children} From ea6cc8c55a2f139eed6d7a0b5720e95c152683a8 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 19 Aug 2024 12:34:12 +0000 Subject: [PATCH 3/7] =?UTF-8?q?=E9=81=8B=E8=A1=8C=E6=83=85=E5=A0=B1?= =?UTF-8?q?=E3=81=AE=E9=A7=85=E5=88=A5=E5=8B=95=E7=9A=84=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 36 ++++++++++++++++++++---- menu.js | 2 +- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 13b35bf..a417c97 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -58,6 +58,7 @@ export default function LED_vision(props) { const [finalSwitch, setFinalSwitch] = useState(false); const [trainIDSwitch, setTrainIDSwitch] = useState(false); const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false); + const [isInfoArea, setIsInfoArea] = useState(false); const { areaInfo, areaStationID } = useAreaInfo(); useEffect(() => { @@ -93,11 +94,20 @@ export default function LED_vision(props) { } let returnData = {}; Object.keys(trainDiagram).forEach((key) => { - if (trainDiagram[key].match(station.Station_JP + ",")) { + if (trainDiagram[key].match(station[0].Station_JP + ",")) { returnData[key] = trainDiagram[key]; } }); setStationDiagram(returnData); + if ( + station.some((s) => { + return areaStationID.includes(s.StationNumber); + }) + ) { + setIsInfoArea(true); + } else { + setIsInfoArea(false); + } }, [trainDiagram, station]); const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null); @@ -105,7 +115,7 @@ export default function LED_vision(props) { useEffect(() => { //現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット if (objectIsEmpty(stationDiagram)) return () => {}; - const getTimeData = getTime(stationDiagram, station); + const getTimeData = getTime(stationDiagram, station[0]); setTrainTimeAndNumber(getTimeData); }, [stationDiagram]); @@ -223,14 +233,14 @@ export default function LED_vision(props) { d={d} trainIDSwitch={trainIDSwitch} trainDescriptionSwitch={trainDescriptionSwitch} - station={station} + station={station[0]} customTrainDataDetector={customTrainDataDetector} navigate={navigate} originalStationList={originalStationList} openStationACFromEachTrainInfo={openStationACFromEachTrainInfo} /> ))} - {areaString != "" && ( + {areaString != "" && isInfoArea && ( ( marginHorizontal: "3%", backgroundColor: "#000", flexDirection: "row", + overflow: "hidden", }} onPress={onClick} > - + + {numberOfLines == 1 ? ( + + 運行情報 + + ) : ( + <> + )} + ( }} numberOfLines={numberOfLines} > - {" "} > {info} diff --git a/menu.js b/menu.js index 64db365..24d3033 100644 --- a/menu.js +++ b/menu.js @@ -205,7 +205,7 @@ export default function Menu({ getCurrentTrain }) { allStationData[selectedCurrentStation] && ( Date: Mon, 19 Aug 2024 12:39:55 +0000 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B0=8F=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 43 +++++++----------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index a417c97..fb628c0 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -63,26 +63,13 @@ export default function LED_vision(props) { useEffect(() => { AS.getItem("LEDSettings/trainIDSwitch").then((data) => { - console.log(data); - if (data == "true") { - setTrainIDSwitch(true); - } else { - setTrainIDSwitch(false); - } + setTrainIDSwitch(data === "true"); }); AS.getItem("LEDSettings/trainDescriptionSwitch").then((data) => { - if (data == "true") { - setTrainDescriptionSwitch(true); - } else { - setTrainDescriptionSwitch(false); - } + setTrainDescriptionSwitch(data == "true"); }); AS.getItem("LEDSettings/finalSwitch").then((data) => { - if (data == "true") { - setFinalSwitch(true); - } else { - setFinalSwitch(false); - } + setFinalSwitch(data == "true"); }); }, []); @@ -520,6 +507,10 @@ const StatusAndDelay = ({ trainDelayStatus }) => { ); }; +const descriptionStyle = { + fontSize: parseInt("16%"), + fontWeight: "bold", +}; const Description = ({ info, numberOfLines = 0, onClick }) => ( ( > {numberOfLines == 1 ? ( - - 運行情報 + + 運行情報 >{" "} ) : ( - <> + > )} - > {info} + {info} From 833d93cf12e8e49ed681b8cf375c3b0cdfce8882 Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 19 Aug 2024 12:42:07 +0000 Subject: [PATCH 5/7] =?UTF-8?q?style=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/発車時刻表/LED_vidion.js | 28 ++++++------------------ 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index fb628c0..fb1a4bc 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -476,41 +476,27 @@ const LastStation = ({ lastStation }) => { ); }; +const descriptionStyle = { + fontSize: parseInt("16%"), + fontWeight: "bold", +}; + const DependTime = ({ time }) => ( - - {time} - + {time} ); const StatusAndDelay = ({ trainDelayStatus }) => { return ( - + {trainDelayStatus} ); }; -const descriptionStyle = { - fontSize: parseInt("16%"), - fontWeight: "bold", -}; const Description = ({ info, numberOfLines = 0, onClick }) => ( Date: Mon, 19 Aug 2024 13:41:55 +0000 Subject: [PATCH 6/7] =?UTF-8?q?=E3=82=B9=E3=82=A4=E3=83=83=E3=83=81?= =?UTF-8?q?=E3=83=9C=E3=83=83=E3=82=AF=E3=82=B9=E3=82=92=E3=82=B3=E3=83=B3?= =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=8D=E3=83=B3=E3=83=88=E5=88=86=E9=9B=A2?= =?UTF-8?q?=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LED_Vision_Component/SwitchBox.js | 25 ++++++ components/発車時刻表/LED_vidion.js | 86 ++++++++----------- 2 files changed, 59 insertions(+), 52 deletions(-) create mode 100644 components/発車時刻表/LED_Vision_Component/SwitchBox.js diff --git a/components/発車時刻表/LED_Vision_Component/SwitchBox.js b/components/発車時刻表/LED_Vision_Component/SwitchBox.js new file mode 100644 index 0000000..bd19c6c --- /dev/null +++ b/components/発車時刻表/LED_Vision_Component/SwitchBox.js @@ -0,0 +1,25 @@ +import { Text } from "react-native"; +import { Switch } from "react-native-elements"; +import { AS } from "../../../storageControl"; +export const SwitchBox = (props) => { + const { value, setValue, setKey, title } = props; + const textStyle = { + alignItems: "center", + alignContent: "center", + textAlign: "center", + textAlignVertical: "center", + color: "white", + }; + return ( + <> + {title} + { + AS.setItem(setKey, v.toString()); + setValue(v); + }} + /> + + ); +}; diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index fb1a4bc..4ad2382 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -1,6 +1,5 @@ import React, { useState, useEffect } from "react"; import { View, Text, TouchableOpacity } from "react-native"; -import { Switch } from "react-native-elements"; import { widthPercentageToDP as wp } from "react-native-responsive-screen"; import LottieView from "lottie-react-native"; import { Ionicons } from "@expo/vector-icons"; @@ -14,6 +13,7 @@ import { useCurrentTrain } from "../../stateBox/useCurrentTrain"; import { useAreaInfo } from "../../stateBox/useAreaInfo"; import { SheetManager } from "react-native-actions-sheet"; import { AS } from "../../storageControl"; +import { SwitchBox } from "./LED_Vision_Component/SwitchBox"; /** * @@ -86,15 +86,7 @@ export default function LED_vision(props) { } }); setStationDiagram(returnData); - if ( - station.some((s) => { - return areaStationID.includes(s.StationNumber); - }) - ) { - setIsInfoArea(true); - } else { - setIsInfoArea(false); - } + setIsInfoArea(station.some((s) => areaStationID.includes(s.StationNumber))); }, [trainDiagram, station]); const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null); @@ -217,14 +209,16 @@ export default function LED_vision(props) {
{selectedTrain.map((d) => ( ))} {areaString != "" && isInfoArea && ( @@ -300,56 +294,44 @@ const Footer = (props) => { setFinalSwitch, } = props; - const textStyle = { - alignItems: "center", - alignContent: "center", - textAlign: "center", - textAlignVertical: "center", - color: "white", - }; return ( - 種別名 / 列番 - { - AS.setItem("LEDSettings/trainIDSwitch", value.toString()); - setTrainIDSwitch(value); - }} + setValue={setTrainIDSwitch} + setKey="LEDSettings/trainIDSwitch" + title="種別名 / 列番" /> - 列車情報 - { - AS.setItem("LEDSettings/trainDescriptionSwitch", value.toString()); - setTrainDescriptionSwitch(value); - }} + setValue={setTrainDescriptionSwitch} + setKey="LEDSettings/trainDescriptionSwitch" + title="列車情報" /> - 当駅止表示 - { - AS.setItem("LEDSettings/finalSwitch", value.toString()); - setFinalSwitch(value); - }} + setValue={setFinalSwitch} + setKey="LEDSettings/finalSwitch" + title="当駅止表示" /> ); }; -const EachData = ({ - d, - trainIDSwitch, - trainDescriptionSwitch, - station, - customTrainDataDetector, - navigate, - originalStationList, - openStationACFromEachTrainInfo, -}) => { +const EachData = (props) => { + const { + d, + trainIDSwitch, + trainDescriptionSwitch, + station, + customTrainDataDetector, + navigate, + originalStationList, + openStationACFromEachTrainInfo, + } = props; const { currentTrain } = useCurrentTrain(); const openTrainInfo = (d) => { let TrainNumber = ""; From 4907186b55d9dee34fa3b07a55b9c99af543b12b Mon Sep 17 00:00:00 2001 From: harukin-expo-dev-env Date: Mon, 19 Aug 2024 14:07:27 +0000 Subject: [PATCH 7/7] =?UTF-8?q?Footer=E3=81=A8Header=E3=82=92=E7=A7=BB?= =?UTF-8?q?=E5=8B=95=E3=80=81=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E6=95=B4?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../LED_Vision_Component/Footer.js | 38 ++++++ .../LED_Vision_Component/Header.js | 48 ++++++++ components/発車時刻表/LED_vidion.js | 110 +++--------------- 3 files changed, 99 insertions(+), 97 deletions(-) create mode 100644 components/発車時刻表/LED_Vision_Component/Footer.js create mode 100644 components/発車時刻表/LED_Vision_Component/Header.js diff --git a/components/発車時刻表/LED_Vision_Component/Footer.js b/components/発車時刻表/LED_Vision_Component/Footer.js new file mode 100644 index 0000000..ebf0d36 --- /dev/null +++ b/components/発車時刻表/LED_Vision_Component/Footer.js @@ -0,0 +1,38 @@ +import { View } from "react-native"; +import { SwitchBox } from "./SwitchBox"; + +export const Footer = (props) => { + const { + trainIDSwitch, + setTrainIDSwitch, + trainDescriptionSwitch, + setTrainDescriptionSwitch, + finalSwitch, + setFinalSwitch, + } = props; + + return ( + + + + + + + + ); +}; diff --git a/components/発車時刻表/LED_Vision_Component/Header.js b/components/発車時刻表/LED_Vision_Component/Header.js new file mode 100644 index 0000000..392ed13 --- /dev/null +++ b/components/発車時刻表/LED_Vision_Component/Header.js @@ -0,0 +1,48 @@ +import { View, Text } from "react-native"; +import { useCurrentTrain } from "../../../stateBox/useCurrentTrain"; +import LottieView from "lottie-react-native"; +import { Ionicons } from "@expo/vector-icons"; + +export const Header = ({ getCurrentTrain }) => { + const { currentTrainLoading, setCurrentTrainLoading } = useCurrentTrain(); + return ( + + + + + 次の列車 + + Next Train + + + {currentTrainLoading == "loading" ? ( + + ) : currentTrainLoading == "error" ? ( + { + setCurrentTrainLoading("loading"); + getCurrentTrain(); + }} + /> + ) : null} + + + ); + }; \ No newline at end of file diff --git a/components/発車時刻表/LED_vidion.js b/components/発車時刻表/LED_vidion.js index 4ad2382..e18caab 100644 --- a/components/発車時刻表/LED_vidion.js +++ b/components/発車時刻表/LED_vidion.js @@ -1,8 +1,6 @@ import React, { useState, useEffect } from "react"; import { View, Text, TouchableOpacity } from "react-native"; import { widthPercentageToDP as wp } from "react-native-responsive-screen"; -import LottieView from "lottie-react-native"; -import { Ionicons } from "@expo/vector-icons"; import { customTrainDataDetector } from "../custom-train-data"; import { useInterval } from "../../lib/useInterval"; import { objectIsEmpty } from "../../lib/objectIsEmpty"; @@ -13,7 +11,9 @@ import { useCurrentTrain } from "../../stateBox/useCurrentTrain"; import { useAreaInfo } from "../../stateBox/useAreaInfo"; import { SheetManager } from "react-native-actions-sheet"; import { AS } from "../../storageControl"; -import { SwitchBox } from "./LED_Vision_Component/SwitchBox"; +import { Footer } from "./LED_Vision_Component/Footer"; +import { Header } from "./LED_Vision_Component/Header"; + /** * @@ -155,11 +155,7 @@ export default function LED_vision(props) { date.setHours(parseInt(data[0])); date.setMinutes(parseInt(data[1]) + parseInt(delay)); - if (!(newDate > date)) { - return true; - } - - return false; + return !(newDate > date); }; const [areaString, setAreaString] = useState(""); @@ -168,11 +164,7 @@ export default function LED_vision(props) { useInterval( () => { if (areaInfo != "") { - if (areaStringLength < move) { - setMove(0); - } else { - setMove(move + 1); - } + setMove(areaStringLength < move ? 0 : move + 1); } }, 350, @@ -230,96 +222,20 @@ export default function LED_vision(props) { )}