Merge commit '29c84bcc1ce7bd1d2512b65ef812a313507d8650'
This commit is contained in:
commit
7d485c466c
28
App.js
28
App.js
@ -80,30 +80,6 @@ export function AppContainer() {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const { setCurrentTrain, setCurrentTrainLoading } = useCurrentTrain();
|
|
||||||
|
|
||||||
const getCurrentTrain = () =>
|
|
||||||
fetch(
|
|
||||||
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
|
||||||
HeaderConfig
|
|
||||||
)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((d) =>
|
|
||||||
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
|
|
||||||
)
|
|
||||||
.then((d) => {
|
|
||||||
setCurrentTrain(d);
|
|
||||||
setCurrentTrainLoading("success");
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
console.log("えらー");
|
|
||||||
setCurrentTrainLoading("error");
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
|
||||||
|
|
||||||
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
|
||||||
|
|
||||||
const { areaInfo, setAreaInfo } = useAreaInfo();
|
const { areaInfo, setAreaInfo } = useAreaInfo();
|
||||||
const getAreaData = () =>
|
const getAreaData = () =>
|
||||||
fetch(
|
fetch(
|
||||||
@ -128,7 +104,7 @@ export function AppContainer() {
|
|||||||
tabBarIcon: initIcon("barchart", "AntDesign"),
|
tabBarIcon: initIcon("barchart", "AntDesign"),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(props) => <Top {...props} getCurrentTrain={getCurrentTrain} />}
|
{(props) => <Top {...props} />}
|
||||||
</Tab.Screen>
|
</Tab.Screen>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="menuPage"
|
name="menuPage"
|
||||||
@ -139,7 +115,7 @@ export function AppContainer() {
|
|||||||
tabBarIcon: initIcon("ios-radio", "Ionicons"),
|
tabBarIcon: initIcon("ios-radio", "Ionicons"),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{(props) => <MenuPage {...props} getCurrentTrain={getCurrentTrain} />}
|
{(props) => <MenuPage {...props} />}
|
||||||
</Tab.Screen>
|
</Tab.Screen>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="home"
|
name="home"
|
||||||
|
44
Apps.js
44
Apps.js
@ -6,9 +6,7 @@ import { Ionicons } from "@expo/vector-icons";
|
|||||||
import { AS } from "./storageControl";
|
import { AS } from "./storageControl";
|
||||||
import { news } from "./config/newsUpdate";
|
import { news } from "./config/newsUpdate";
|
||||||
import { getStationList, lineList } from "./lib/getStationList";
|
import { getStationList, lineList } from "./lib/getStationList";
|
||||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
|
||||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||||
import { EachTrainInfo } from "./components/ActionSheetComponents/EachTrainInfo";
|
|
||||||
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
||||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
||||||
@ -180,9 +178,6 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
data: {
|
data: {
|
||||||
trainNum,
|
trainNum,
|
||||||
limited,
|
limited,
|
||||||
trainData: checkDuplicateTrainData(
|
|
||||||
currentTrain.filter((a) => a.num == trainNum)
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
navigate,
|
navigate,
|
||||||
originalStationList,
|
originalStationList,
|
||||||
@ -251,23 +246,21 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
return pre;
|
return pre;
|
||||||
}, []);
|
}, []);
|
||||||
if (returnDataBase.length) {
|
if (returnDataBase.length) {
|
||||||
sleep(25, function () {
|
const payload = {
|
||||||
const payload = {
|
currentStation: returnDataBase,
|
||||||
currentStation: returnDataBase,
|
originalStationList: originalStationList,
|
||||||
originalStationList: originalStationList,
|
navigate: navigate,
|
||||||
navigate: navigate,
|
goTo: "Apps",
|
||||||
goTo: "Apps",
|
useShow: () =>
|
||||||
useShow: () =>
|
SheetManager.show("StationDetailView", {
|
||||||
SheetManager.show("StationDetailView", {
|
payload,
|
||||||
payload,
|
}),
|
||||||
}),
|
onExit: () => {
|
||||||
onExit: () => {
|
SheetManager.hide("StationDetailView");
|
||||||
SheetManager.hide("StationDetailView");
|
},
|
||||||
},
|
};
|
||||||
};
|
SheetManager.show("StationDetailView", {
|
||||||
SheetManager.show("StationDetailView", {
|
payload,
|
||||||
payload,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
SheetManager.hide("StationDetailView");
|
SheetManager.hide("StationDetailView");
|
||||||
@ -327,13 +320,6 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
LoadError={LoadError}
|
LoadError={LoadError}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<EachTrainInfo
|
|
||||||
data={trainInfo}
|
|
||||||
navigate={navigate}
|
|
||||||
originalStationList={originalStationList}
|
|
||||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
|
||||||
/>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@ import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
|||||||
import { optionData } from "./lib/stackOption.js";
|
import { optionData } from "./lib/stackOption.js";
|
||||||
import CurrentTrainListView from "./components/CurrentTrainListView.js";
|
import CurrentTrainListView from "./components/CurrentTrainListView.js";
|
||||||
import AllTrainDiagramView from "./components/AllTrainDiagramView.js";
|
import AllTrainDiagramView from "./components/AllTrainDiagramView.js";
|
||||||
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
||||||
const Stack = createStackNavigator();
|
const Stack = createStackNavigator();
|
||||||
|
|
||||||
export function MenuPage({ navigation, getCurrentTrain }) {
|
export function MenuPage({ navigation }) {
|
||||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||||
|
const { getCurrentTrain } = useCurrentTrain();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
||||||
AS.getItem("favoriteStation")
|
AS.getItem("favoriteStation")
|
||||||
|
4
Top.js
4
Top.js
@ -12,10 +12,12 @@ import TrainMenu from "./components/trainMenu.js";
|
|||||||
import FavoriteList from "./components/FavoriteList.js";
|
import FavoriteList from "./components/FavoriteList.js";
|
||||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||||
import { optionData } from "./lib/stackOption.js";
|
import { optionData } from "./lib/stackOption.js";
|
||||||
|
import { useCurrentTrain } from "./stateBox/useCurrentTrain.js";
|
||||||
const Stack = createStackNavigator();
|
const Stack = createStackNavigator();
|
||||||
export const Top = ({ navigation, getCurrentTrain }) => {
|
export const Top = ({ navigation }) => {
|
||||||
const webview = useRef();
|
const webview = useRef();
|
||||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||||
|
const { getCurrentTrain } = useCurrentTrain();
|
||||||
|
|
||||||
//地図用
|
//地図用
|
||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
|
@ -24,6 +24,8 @@ import {
|
|||||||
widthPercentageToDP,
|
widthPercentageToDP,
|
||||||
} from "react-native-responsive-screen";
|
} from "react-native-responsive-screen";
|
||||||
import lineColorList from "../../assets/originData/lineColorList";
|
import lineColorList from "../../assets/originData/lineColorList";
|
||||||
|
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
||||||
|
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||||
|
|
||||||
export const EachTrainInfo = (props) => {
|
export const EachTrainInfo = (props) => {
|
||||||
if (!props.payload) return <></>;
|
if (!props.payload) return <></>;
|
||||||
@ -40,6 +42,18 @@ export const EachTrainInfo = (props) => {
|
|||||||
|
|
||||||
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
const [trainPositionSwitch, setTrainPositionSwitch] = useState("false");
|
||||||
|
|
||||||
|
const { currentTrain } = useCurrentTrain();
|
||||||
|
|
||||||
|
const [currentTrainData, setCurrentTrainData] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setCurrentTrainData(
|
||||||
|
checkDuplicateTrainData(
|
||||||
|
currentTrain.filter((d) => d.num == data.trainNum)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}, [currentTrain]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//列車現在地アイコン表示スイッチ
|
//列車現在地アイコン表示スイッチ
|
||||||
AS.getItem("trainPositionSwitch")
|
AS.getItem("trainPositionSwitch")
|
||||||
@ -65,17 +79,17 @@ export const EachTrainInfo = (props) => {
|
|||||||
return Station.map((d) => d.StationNumber)[0];
|
return Station.map((d) => d.StationNumber)[0];
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//data.trainData.Pos = "鴨川~端岡"; //test
|
//currentTrainData.Pos = "鴨川~端岡"; //test
|
||||||
if (!data.trainData?.Pos) return;
|
if (!currentTrainData?.Pos) return;
|
||||||
if (data.trainData?.Pos.match("~")) {
|
if (currentTrainData?.Pos.match("~")) {
|
||||||
const pos = data.trainData?.Pos.replace("(下り)", "")
|
const pos = currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~");
|
.split("~");
|
||||||
setCurrentPosition([getStationData(pos[0]), getStationData(pos[1])]);
|
setCurrentPosition([getStationData(pos[0]), getStationData(pos[1])]);
|
||||||
} else {
|
} else {
|
||||||
setCurrentPosition([getStationData(data.trainData?.Pos)]);
|
setCurrentPosition([getStationData(currentTrainData?.Pos)]);
|
||||||
}
|
}
|
||||||
}, [data.trainData]);
|
}, [currentTrainData]);
|
||||||
|
|
||||||
const stationList =
|
const stationList =
|
||||||
originalStationList &&
|
originalStationList &&
|
||||||
@ -249,6 +263,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
gestureEnabled={isTop}
|
gestureEnabled={isTop}
|
||||||
CustomHeaderComponent={<></>}
|
CustomHeaderComponent={<></>}
|
||||||
ref={actionSheetRef}
|
ref={actionSheetRef}
|
||||||
|
drawUnderStatusBar={false}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@ -339,7 +354,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
現在地 {currentPosition.toString()}
|
現在地 {currentPosition.toString()}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
{data.trainData?.Pos && data.trainData?.Pos.match("~") ? (
|
{currentTrainData?.Pos && currentTrainData?.Pos.match("~") ? (
|
||||||
<>
|
<>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@ -349,7 +364,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
data.trainData?.Pos.replace("(下り)", "")
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~")[0]
|
.split("~")[0]
|
||||||
}
|
}
|
||||||
@ -365,7 +380,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
data.trainData?.Pos.replace("(下り)", "")
|
currentTrainData?.Pos.replace("(下り)", "")
|
||||||
.replace("(上り)", "")
|
.replace("(上り)", "")
|
||||||
.split("~")[1]
|
.split("~")[1]
|
||||||
}
|
}
|
||||||
@ -379,7 +394,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{data.trainData?.Pos}
|
{currentTrainData?.Pos}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
@ -394,7 +409,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||||
{isNaN(data.trainData?.delay) ? "状態" : "遅延時分"}
|
{isNaN(currentTrainData?.delay) ? "状態" : "遅延時分"}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text
|
<Text
|
||||||
@ -404,8 +419,8 @@ export const EachTrainInfo = (props) => {
|
|||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{data.trainData?.delay}
|
{currentTrainData?.delay}
|
||||||
{isNaN(data.trainData?.delay) ? "" : "分"}
|
{isNaN(currentTrainData?.delay) ? "" : "分"}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
<View
|
<View
|
||||||
@ -425,7 +440,7 @@ export const EachTrainInfo = (props) => {
|
|||||||
textAlign: "right",
|
textAlign: "right",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{data.trainData?.num}
|
{currentTrainData?.num}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@ -511,6 +526,57 @@ export const EachTrainInfo = (props) => {
|
|||||||
</View> */}
|
</View> */}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
)}
|
)}
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
alignItems: "center",
|
||||||
|
backgroundColor: "white",
|
||||||
|
flexDirection: "row",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}>停車駅</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
{!isNaN(currentTrainData?.delay) &&
|
||||||
|
currentTrainData?.delay != 0 && (
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 15,
|
||||||
|
color: "black",
|
||||||
|
position: "absolute",
|
||||||
|
right: 110,
|
||||||
|
textAlign: "right",
|
||||||
|
textDecorationLine: "line-through",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
(定刻)
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 20,
|
||||||
|
color: isNaN(currentTrainData?.delay)
|
||||||
|
? "black"
|
||||||
|
: currentTrainData?.delay == 0
|
||||||
|
? "black"
|
||||||
|
: "red",
|
||||||
|
width: 60,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
見込
|
||||||
|
</Text>
|
||||||
|
<Text style={{ fontSize: 20, width: 50 }}></Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
<ScrollView
|
<ScrollView
|
||||||
{...scrollHandlers}
|
{...scrollHandlers}
|
||||||
style={{
|
style={{
|
||||||
@ -518,211 +584,164 @@ export const EachTrainInfo = (props) => {
|
|||||||
from == "AllTrainDiagramView" ? "70%" : "50%"
|
from == "AllTrainDiagramView" ? "70%" : "50%"
|
||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
nestedScrollEnabled
|
|
||||||
onScroll={(e) => {
|
onScroll={(e) => {
|
||||||
if (!Platform.OS !== "android") return;
|
if (!Platform.OS !== "android") return;
|
||||||
setIsTop(e.nativeEvent.contentOffset.y < 0);
|
setIsTop(e.nativeEvent.contentOffset.y < 0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View style={{ padding: 10, backgroundColor: "white" }}>
|
<View style={{ backgroundColor: "white", alignItems: "center" }}>
|
||||||
<View style={{ alignItems: "center" }}>
|
{/* <LottieView
|
||||||
{/* <LottieView
|
|
||||||
autoPlay
|
autoPlay
|
||||||
loop
|
loop
|
||||||
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||||
source={require("../../assets/51690-loading-diamonds.json")}
|
source={require("../../assets/51690-loading-diamonds.json")}
|
||||||
/>
|
/>
|
||||||
<Text>ほげほげふがふが</Text> */}
|
<Text>ほげほげふがふが</Text> */}
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<View
|
{trainData.map((i, index) => {
|
||||||
style={{
|
const [station, se, time] = i.split(",");
|
||||||
padding: 8,
|
const Stations = stationList.map((a) =>
|
||||||
flexDirection: "row",
|
a.filter((d) => d.StationName == station)
|
||||||
borderBottomWidth: 1,
|
);
|
||||||
borderBottomColor: "#f0f0f0",
|
const StationNumbers =
|
||||||
flex: 1,
|
Stations &&
|
||||||
}}
|
Stations.reduce((newArray, e) => {
|
||||||
|
return newArray.concat(e);
|
||||||
|
}, [])
|
||||||
|
.filter((d) => d.StationNumber)
|
||||||
|
.map((d) => d.StationNumber);
|
||||||
|
|
||||||
|
const colorIDs =
|
||||||
|
StationNumbers != null
|
||||||
|
? StationNumbers.map((d) => {
|
||||||
|
return d.split("").filter((s) => "A" < s && s < "Z");
|
||||||
|
}).reduce((newArray, e) => {
|
||||||
|
return newArray.concat(e);
|
||||||
|
}, [])
|
||||||
|
: [];
|
||||||
|
const EachIDs =
|
||||||
|
StationNumbers != null
|
||||||
|
? StationNumbers.map((d) => {
|
||||||
|
return d
|
||||||
|
.split("")
|
||||||
|
.filter((s) => "0" <= s && s <= "9")
|
||||||
|
.join("");
|
||||||
|
})
|
||||||
|
: [];
|
||||||
|
const date = new Date();
|
||||||
|
if (time) {
|
||||||
|
date.setHours(time.split(":")[0], time.split(":")[1]);
|
||||||
|
}
|
||||||
|
if (!isNaN(currentTrainData?.delay)) {
|
||||||
|
date.setMinutes(date.getMinutes() + currentTrainData?.delay);
|
||||||
|
}
|
||||||
|
const timeString = date.toTimeString().split(" ")[0].split(":");
|
||||||
|
return (
|
||||||
|
<TouchableWithoutFeedback
|
||||||
|
onPress={() => openStationACFromEachTrainInfo(station)}
|
||||||
|
key={station}
|
||||||
>
|
>
|
||||||
<Text style={{ fontSize: 20 }}>停車駅</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
<View style={{ flexDirection: "row" }}>
|
||||||
{!isNaN(data.trainData?.delay) &&
|
<View
|
||||||
data.trainData?.delay != 0 && (
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: 15,
|
|
||||||
color: "black",
|
|
||||||
position: "absolute",
|
|
||||||
right: 110,
|
|
||||||
textAlign: "right",
|
|
||||||
textDecorationLine: "line-through",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
(定刻)
|
|
||||||
</Text>
|
|
||||||
)}
|
|
||||||
<Text
|
|
||||||
style={{
|
style={{
|
||||||
fontSize: 20,
|
width: 35,
|
||||||
color: isNaN(data.trainData?.delay)
|
position: "relative",
|
||||||
? "black"
|
marginHorizontal: 15,
|
||||||
: data.trainData?.delay == 0
|
flexDirection: "row",
|
||||||
? "black"
|
height: "101%",
|
||||||
: "red",
|
|
||||||
width: 60,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
見込
|
{colorIDs.map((color, index) => (
|
||||||
</Text>
|
<View
|
||||||
<Text style={{ fontSize: 20, width: 50 }}></Text>
|
style={{
|
||||||
</View>
|
backgroundColor: lineColorList[color],
|
||||||
</View>
|
flex: 1,
|
||||||
</View>
|
}}
|
||||||
{trainData.map((i, index) => {
|
key={color}
|
||||||
const [station, se, time] = i.split(",");
|
>
|
||||||
const Stations = stationList.map((a) =>
|
<View style={{ flex: 1 }} />
|
||||||
a.filter((d) => d.StationName == station)
|
|
||||||
);
|
|
||||||
const StationNumbers =
|
|
||||||
Stations &&
|
|
||||||
Stations.reduce((newArray, e) => {
|
|
||||||
return newArray.concat(e);
|
|
||||||
}, [])
|
|
||||||
.filter((d) => d.StationNumber)
|
|
||||||
.map((d) => d.StationNumber);
|
|
||||||
|
|
||||||
const colorIDs =
|
|
||||||
StationNumbers != null
|
|
||||||
? StationNumbers.map((d) => {
|
|
||||||
return d.split("").filter((s) => "A" < s && s < "Z");
|
|
||||||
}).reduce((newArray, e) => {
|
|
||||||
return newArray.concat(e);
|
|
||||||
}, [])
|
|
||||||
: [];
|
|
||||||
const EachIDs =
|
|
||||||
StationNumbers != null
|
|
||||||
? StationNumbers.map((d) => {
|
|
||||||
return d
|
|
||||||
.split("")
|
|
||||||
.filter((s) => "0" <= s && s <= "9")
|
|
||||||
.join("");
|
|
||||||
})
|
|
||||||
: [];
|
|
||||||
const date = new Date();
|
|
||||||
if (time) {
|
|
||||||
date.setHours(time.split(":")[0], time.split(":")[1]);
|
|
||||||
}
|
|
||||||
if (!isNaN(data.trainData?.delay)) {
|
|
||||||
date.setMinutes(date.getMinutes() + data.trainData?.delay);
|
|
||||||
}
|
|
||||||
const timeString = date.toTimeString().split(" ")[0].split(":");
|
|
||||||
return (
|
|
||||||
<TouchableWithoutFeedback
|
|
||||||
onPress={() => openStationACFromEachTrainInfo(station)}
|
|
||||||
key={station}
|
|
||||||
>
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
width: 35,
|
|
||||||
position: "relative",
|
|
||||||
marginHorizontal: 15,
|
|
||||||
flexDirection: "row",
|
|
||||||
height: "101%",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{colorIDs.map((color, index) => (
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
backgroundColor: lineColorList[color],
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
key={color}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: "white",
|
|
||||||
textAlign: "center",
|
|
||||||
fontSize: 10,
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{colorIDs[index]}
|
|
||||||
</Text>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
color: "white",
|
|
||||||
textAlign: "center",
|
|
||||||
fontSize: 10,
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{EachIDs[index]}
|
|
||||||
</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 8,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderBottomWidth: 1,
|
|
||||||
borderBottomColor: "#f0f0f0",
|
|
||||||
flex: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text style={{ fontSize: 20 }}>{station}</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
{points && points.findIndex((d) => d == index) >= 0 ? (
|
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
fontSize: 20,
|
color: "white",
|
||||||
marginRight: 70,
|
textAlign: "center",
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: "bold",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
🚊
|
{colorIDs[index]}
|
||||||
</Text>
|
</Text>
|
||||||
) : null}
|
<Text
|
||||||
{!isNaN(data.trainData?.delay) &&
|
style={{
|
||||||
data.trainData?.delay != 0 && (
|
color: "white",
|
||||||
<Text
|
textAlign: "center",
|
||||||
style={{
|
fontSize: 10,
|
||||||
fontSize: 15,
|
fontWeight: "bold",
|
||||||
color: "black",
|
}}
|
||||||
width: 60,
|
>
|
||||||
position: "absolute",
|
{EachIDs[index]}
|
||||||
right: 120,
|
</Text>
|
||||||
textAlign: "right",
|
<View style={{ flex: 1 }} />
|
||||||
textDecorationLine: "line-through",
|
</View>
|
||||||
}}
|
))}
|
||||||
>
|
</View>
|
||||||
{time}
|
<View
|
||||||
</Text>
|
style={{
|
||||||
)}
|
padding: 8,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
borderBottomColor: "#f0f0f0",
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20 }}>{station}</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
{points && points.findIndex((d) => d == index) >= 0 ? (
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
fontSize: 20,
|
fontSize: 20,
|
||||||
color: isNaN(data.trainData?.delay)
|
marginRight: 70,
|
||||||
? "black"
|
|
||||||
: data.trainData?.delay == 0
|
|
||||||
? "black"
|
|
||||||
: "red",
|
|
||||||
width: 60,
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{timeString[0]}:{timeString[1]}
|
🚊
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={{ fontSize: 18, width: 50 }}>
|
) : null}
|
||||||
{se?.replace("発", "出発").replace("着", "到着")}
|
{!isNaN(currentTrainData?.delay) &&
|
||||||
</Text>
|
currentTrainData?.delay != 0 && (
|
||||||
</View>
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 15,
|
||||||
|
color: "black",
|
||||||
|
width: 60,
|
||||||
|
position: "absolute",
|
||||||
|
right: 120,
|
||||||
|
textAlign: "right",
|
||||||
|
textDecorationLine: "line-through",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{time}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 20,
|
||||||
|
color: isNaN(currentTrainData?.delay)
|
||||||
|
? "black"
|
||||||
|
: currentTrainData?.delay == 0
|
||||||
|
? "black"
|
||||||
|
: "red",
|
||||||
|
width: 60,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{timeString[0]}:{timeString[1]}
|
||||||
|
</Text>
|
||||||
|
<Text style={{ fontSize: 18, width: 50 }}>
|
||||||
|
{se?.replace("発", "出発").replace("着", "到着")}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</TouchableWithoutFeedback>
|
</View>
|
||||||
);
|
</TouchableWithoutFeedback>
|
||||||
})}
|
);
|
||||||
</View>
|
})}
|
||||||
</View>
|
</View>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
|
@ -16,7 +16,6 @@ import { MaterialCommunityIcons } from "@expo/vector-icons";
|
|||||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||||
import { useAreaInfo } from "../stateBox/useAreaInfo";
|
import { useAreaInfo } from "../stateBox/useAreaInfo";
|
||||||
import { useAllTrainDiagram } from "../stateBox/useAllTrainDiagram";
|
import { useAllTrainDiagram } from "../stateBox/useAllTrainDiagram";
|
||||||
import { EachTrainInfo } from "./ActionSheetComponents/EachTrainInfo";
|
|
||||||
|
|
||||||
import { customTrainDataDetector } from "./custom-train-data";
|
import { customTrainDataDetector } from "./custom-train-data";
|
||||||
import { getStationList, lineList } from "../lib/getStationList";
|
import { getStationList, lineList } from "../lib/getStationList";
|
||||||
@ -65,9 +64,6 @@ export default function AllTrainDiagramView({ navigation: { navigate } }) {
|
|||||||
limited: `${getTrainType(train.type).data}:${
|
limited: `${getTrainType(train.type).data}:${
|
||||||
train.trainName
|
train.trainName
|
||||||
}${TrainNumber}`,
|
}${TrainNumber}`,
|
||||||
trainData: checkDuplicateTrainData(
|
|
||||||
currentTrain.filter((a) => a.num == d)
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
navigate,
|
navigate,
|
||||||
originalStationList,
|
originalStationList,
|
||||||
|
@ -165,7 +165,7 @@ export default function Setting(props) {
|
|||||||
textAlignVertical: "center",
|
textAlignVertical: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
内部バージョン: 4.6.1
|
内部バージョン: 4.6.2
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
</View>
|
</View>
|
||||||
|
@ -321,9 +321,6 @@ const EachData = ({
|
|||||||
limited: `${getTrainType(train.type).data}:${
|
limited: `${getTrainType(train.type).data}:${
|
||||||
train.trainName
|
train.trainName
|
||||||
}${TrainNumber}`,
|
}${TrainNumber}`,
|
||||||
trainData: checkDuplicateTrainData(
|
|
||||||
currentTrain.filter((a) => a.num == d.train)
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
navigate,
|
navigate,
|
||||||
originalStationList,
|
originalStationList,
|
||||||
|
@ -6,6 +6,8 @@ import { useInterval } from "../../lib/useInterval";
|
|||||||
import { AS } from "../../storageControl";
|
import { AS } from "../../storageControl";
|
||||||
import { useFavoriteStation } from "../../stateBox/useFavoriteStation";
|
import { useFavoriteStation } from "../../stateBox/useFavoriteStation";
|
||||||
|
|
||||||
|
import lineColorList from "../../assets/originData/lineColorList";
|
||||||
|
|
||||||
export default function Sign(props) {
|
export default function Sign(props) {
|
||||||
const { currentStation, originalStationList, oP, oLP } = props;
|
const { currentStation, originalStationList, oP, oLP } = props;
|
||||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||||
@ -24,7 +26,7 @@ export default function Sign(props) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setTestButtonStatus(isFavorite.length != 0);
|
setTestButtonStatus(isFavorite.length == 0 ? false : true);
|
||||||
}, [favoriteStation, currentStation]);
|
}, [favoriteStation, currentStation]);
|
||||||
|
|
||||||
useInterval(() => {
|
useInterval(() => {
|
||||||
@ -220,27 +222,40 @@ const StationNumberMaker = (props) => {
|
|||||||
};
|
};
|
||||||
return props.currentStation
|
return props.currentStation
|
||||||
.filter((d) => (d.StationNumber ? true : false))
|
.filter((d) => (d.StationNumber ? true : false))
|
||||||
.map((d, index, array) => (
|
.map((d, index, array) => {
|
||||||
<View
|
const lineID = d.StationNumber.slice(0, 1);
|
||||||
style={{
|
const lineName = d.StationNumber.slice(1);
|
||||||
position: "absolute",
|
return (
|
||||||
alignContent: "center",
|
<View
|
||||||
alignItems: "center",
|
style={{
|
||||||
top: getTop(array, index) + "%",
|
position: "absolute",
|
||||||
right: "10%",
|
alignContent: "center",
|
||||||
width: wp("10%"),
|
alignItems: "center",
|
||||||
height: wp("10%"),
|
top: getTop(array, index) + "%",
|
||||||
borderColor: "#2E94BB",
|
right: "10%",
|
||||||
borderWidth: parseInt("2%"),
|
width: wp("10%"),
|
||||||
borderRadius: parseInt("100%"),
|
height: wp("10%"),
|
||||||
}}
|
borderColor: lineColorList[lineID],
|
||||||
key={array[index].StationNumber}
|
borderWidth: parseInt("3%"),
|
||||||
>
|
borderRadius: parseInt("100%"),
|
||||||
<View style={{ flex: 1 }} />
|
}}
|
||||||
<Text style={{ fontSize: parseInt("20%") }}>{d.StationNumber}</Text>
|
key={array[index].StationNumber}
|
||||||
<View style={{ flex: 1 }} />
|
>
|
||||||
</View>
|
<View style={{ flex: 1 }} />
|
||||||
));
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: parseInt("15%"),
|
||||||
|
margin: 0,
|
||||||
|
padding: 0,
|
||||||
|
textAlign: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{lineID + "\n" + lineName}
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const StationNameArea = (props) => {
|
const StationNameArea = (props) => {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
import React, { createContext, useContext, useState } from "react";
|
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||||
|
import { HeaderConfig } from "../lib/HeaderConfig";
|
||||||
|
|
||||||
|
import useInterval from "../lib/useInterval";
|
||||||
const initialState = {
|
const initialState = {
|
||||||
currentTrain: [],
|
currentTrain: [],
|
||||||
setCurrentTrain: () => {},
|
setCurrentTrain: () => {},
|
||||||
currentTrainLoading: "loading",
|
currentTrainLoading: "loading",
|
||||||
setCurrentTrainLoading: () => {},
|
setCurrentTrainLoading: () => {},
|
||||||
|
getCurrentTrain: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const CurrentTrainContext = createContext(initialState);
|
const CurrentTrainContext = createContext(initialState);
|
||||||
@ -15,7 +19,27 @@ export const useCurrentTrain = () => {
|
|||||||
export const CurrentTrainProvider = ({ children }) => {
|
export const CurrentTrainProvider = ({ children }) => {
|
||||||
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
|
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
|
||||||
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
|
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
|
||||||
|
const getCurrentTrain = () =>
|
||||||
|
fetch(
|
||||||
|
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
||||||
|
HeaderConfig
|
||||||
|
)
|
||||||
|
.then((response) => response.json())
|
||||||
|
.then((d) =>
|
||||||
|
d.map((x) => ({ num: x.TrainNum, delay: x.delay, Pos: x.Pos }))
|
||||||
|
)
|
||||||
|
.then((d) => {
|
||||||
|
setCurrentTrain(d);
|
||||||
|
setCurrentTrainLoading("success");
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log("えらー");
|
||||||
|
setCurrentTrainLoading("error");
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
||||||
|
|
||||||
|
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
||||||
return (
|
return (
|
||||||
<CurrentTrainContext.Provider
|
<CurrentTrainContext.Provider
|
||||||
value={{
|
value={{
|
||||||
@ -23,6 +47,7 @@ export const CurrentTrainProvider = ({ children }) => {
|
|||||||
setCurrentTrain,
|
setCurrentTrain,
|
||||||
currentTrainLoading,
|
currentTrainLoading,
|
||||||
setCurrentTrainLoading,
|
setCurrentTrainLoading,
|
||||||
|
getCurrentTrain,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
@ -36,7 +36,7 @@ export default function TrainBase({ route, navigation }) {
|
|||||||
setSupportMultipleWindows={false}
|
setSupportMultipleWindows={false}
|
||||||
onMessage={(event) => {}}
|
onMessage={(event) => {}}
|
||||||
/>
|
/>
|
||||||
{from == "LED" && (
|
{(from == "LED" || from == "AllTrainDiagramView") && (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{
|
style={{
|
||||||
padding: 10,
|
padding: 10,
|
||||||
@ -47,7 +47,9 @@ export default function TrainBase({ route, navigation }) {
|
|||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
onPress={() => navigate("menu")}
|
onPress={() =>
|
||||||
|
navigate(from == "AllTrainDiagramView" ? "AllTrainIDList" : "menu")
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<MaterialCommunityIcons name="close" color="black" size={30} />
|
<MaterialCommunityIcons name="close" color="black" size={30} />
|
||||||
|
Loading…
Reference in New Issue
Block a user