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