Compare commits
175 Commits
feature/ap
...
special/ro
Author | SHA1 | Date | |
---|---|---|---|
|
9a6b0bb9e9 | ||
|
e2349cca15 | ||
|
68cced053e | ||
|
553e1eeb65 | ||
|
7a06a5d86a | ||
|
80d41de6b4 | ||
|
a3ecc80d28 | ||
|
70a0815d01 | ||
|
7048333b07 | ||
|
5773975070 | ||
|
9301780212 | ||
|
2a3e6c95b3 | ||
|
58ef72c9df | ||
|
43a5c5864a | ||
|
8310712e5b | ||
|
19a74dbc37 | ||
|
025d5655d9 | ||
|
ad34feb191 | ||
|
717569993e | ||
|
fc7edb9e37 | ||
|
ee1ef94c02 | ||
|
14c1c3ddd2 | ||
|
c8008d5339 | ||
|
2290c96ca7 | ||
|
fa7c32298e | ||
|
54ae681f00 | ||
|
8a94b81052 | ||
|
24e784a236 | ||
|
db40351fec | ||
|
431c4c9c0b | ||
|
19e9fd8fd8 | ||
|
ebdec28693 | ||
|
2dd8e62f85 | ||
|
485102b591 | ||
|
0937fbb619 | ||
|
65080e68f2 | ||
|
32edab3289 | ||
|
87129c6815 | ||
|
26d9037963 | ||
|
263cb750ce | ||
|
fa96e68770 | ||
|
b54f2f6f7e | ||
|
1681be4437 | ||
|
0e06b66368 | ||
|
0753bf7023 | ||
|
16f7d1f7ad | ||
|
7f96c44e88 | ||
|
0f0d69b22d | ||
|
7d485c466c | ||
|
29c84bcc1c | ||
|
9e7931926f | ||
|
60d8caaefa | ||
|
f72ac1d97b | ||
|
3ca91f402e | ||
|
7869cbee6d | ||
|
a4e85ff2e6 | ||
|
c2ad681891 | ||
|
57459d975b | ||
|
23402aef79 | ||
|
e4ce671e67 | ||
|
789af1aa37 | ||
|
163f9ead18 | ||
|
b23b59eab3 | ||
|
611fc9953f | ||
|
e38f550b94 | ||
|
fd95e99874 | ||
|
9b70843e9c | ||
|
f1e98344ca | ||
|
2debff6051 | ||
|
b7c56f4b90 | ||
|
761543af90 | ||
|
36b199ef98 | ||
|
049b138ca5 | ||
|
6c3b186c9b | ||
|
5678ad5b35 | ||
|
6233c94a80 | ||
|
305d386fcc | ||
|
f62fadffb7 | ||
|
8f23faacd7 | ||
|
91fb41dab0 | ||
|
ac1c4f3902 | ||
|
9306a9cb25 | ||
|
d6f727710f | ||
|
171df01a0d | ||
|
d5fab2f49b | ||
|
94558b784a | ||
|
644f066c96 | ||
|
fc091a2ae6 | ||
|
47bba10c04 | ||
|
b98f61a802 | ||
|
ccf764005c | ||
|
f5d0f993db | ||
|
a6a2a6dfbb | ||
|
2199e9cc57 | ||
|
e11d8f534e | ||
|
831b632e7d | ||
|
b7e763d265 | ||
|
d47191761a | ||
|
5e3ef414f6 | ||
|
0afa6f402b | ||
|
eacce53775 | ||
|
0e11f63bc3 | ||
|
84d36b88cc | ||
|
47b1eb325e | ||
|
a145e2c24f | ||
|
711f0bbe9f | ||
|
dbae477bea | ||
|
0de3d73ced | ||
|
49098308db | ||
|
bfec537f56 | ||
|
bf78287563 | ||
|
d511b80437 | ||
|
e90ffd8926 | ||
|
4446019ab2 | ||
|
92b9a4a044 | ||
|
f504497bdf | ||
|
dfdd9a7f37 | ||
|
b0b15f726c | ||
|
e8906495c2 | ||
|
d3c9bca4d3 | ||
|
eb806e3f8a | ||
|
dfe3c831bc | ||
|
946f669eb0 | ||
|
b1ecbb1cfe | ||
|
480bcbfcd3 | ||
|
420a805f3c | ||
|
7e092671a2 | ||
|
1b16e09633 | ||
|
52b15288b9 | ||
|
b2ee75205b | ||
|
5115656050 | ||
|
f5491200eb | ||
|
26111e7ce8 | ||
|
b2624d319b | ||
|
0618ff0180 | ||
|
b4c306bce3 | ||
|
cdea9a1e05 | ||
|
0ff05f911c | ||
|
84efa42e57 | ||
|
610f9c21ce | ||
|
9fee43d6ff | ||
|
ce9dccc158 | ||
|
7f67fc6cc8 | ||
|
ed76462436 | ||
|
a643ab5c56 | ||
|
ea1c505453 | ||
|
35907df3c4 | ||
|
180bc95a80 | ||
|
6f7f02e4fa | ||
|
df7608acaf | ||
|
34413f522f | ||
|
07adaf2ef5 | ||
|
34f907ef9b | ||
|
f815b31720 | ||
|
06b1933d1c | ||
|
862742cd3e | ||
|
1aac1e40df | ||
|
4ef5a13dc3 | ||
|
d5f2d367dd | ||
|
0f56a7ceea | ||
|
1622cd2ab8 | ||
|
a3e8e3cbbe | ||
|
a83bb27f60 | ||
|
320a94565d | ||
|
fd7fd7f623 | ||
|
cfbd126fe3 | ||
|
bfd6decfcc | ||
|
b1f72f18b5 | ||
|
81f394d6ca | ||
|
d4d86fb7eb | ||
|
056a059a68 | ||
|
357490314a | ||
|
bb115afe35 | ||
|
c00073bb32 | ||
|
12676d59cf |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,3 +5,4 @@ npm-debug.*
|
||||
*.p12
|
||||
*.key
|
||||
*.mobileprovision
|
||||
dist/
|
290
App.js
290
App.js
@@ -1,59 +1,77 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { NavigationContainer } from "@react-navigation/native";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { createStackNavigator } from "@react-navigation/stack";
|
||||
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
|
||||
import { AntDesign, Ionicons } from "@expo/vector-icons";
|
||||
import { Platform, UIManager } from "react-native";
|
||||
import { UpdateAsync } from "./UpdateAsync.js";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
import { AS } from "./storageControl";
|
||||
import Apps from "./Apps";
|
||||
import TNDView from "./ndView";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import Menu from "./menu";
|
||||
import News from "./components/news.js";
|
||||
import Setting from "./components/settings.js";
|
||||
import TrainMenu from "./components/trainMenu.js";
|
||||
import FavoriteList from "./components/FavoriteList.js";
|
||||
import { LogBox } from "react-native";
|
||||
|
||||
import useInterval from "./lib/useInterval";
|
||||
import { HeaderConfig } from "./lib/HeaderConfig";
|
||||
import { initIcon } from "./lib/initIcon";
|
||||
import {
|
||||
useFavoriteStation,
|
||||
FavoriteStationProvider,
|
||||
} from "./stateBox/useFavoriteStation";
|
||||
import { Top } from "./Top.js";
|
||||
import { MenuPage } from "./MenuPage.js";
|
||||
import {
|
||||
useCurrentTrain,
|
||||
CurrentTrainProvider,
|
||||
} from "./stateBox/useCurrentTrain.js";
|
||||
import { useAreaInfo, AreaInfoProvider } from "./stateBox/useAreaInfo.js";
|
||||
import {
|
||||
useBusAndTrainData,
|
||||
BusAndTrainDataProvider,
|
||||
} from "./stateBox/useBusAndTrainData.js";
|
||||
import { AllTrainDiagramProvider } from "./stateBox/useAllTrainDiagram.js";
|
||||
import { SheetProvider } from "react-native-actions-sheet";
|
||||
import "./components/ActionSheetComponents/sheets.js";
|
||||
import { TrainDelayDataProvider } from "./stateBox/useTrainDelayData.js";
|
||||
import { SafeAreaProvider } from "react-native-safe-area-context";
|
||||
LogBox.ignoreLogs([
|
||||
"ViewPropTypes will be removed",
|
||||
"ColorPropType will be removed",
|
||||
]);
|
||||
const Stack = createStackNavigator();
|
||||
const Tab = createBottomTabNavigator();
|
||||
if (Platform.OS === "android") {
|
||||
if (UIManager.setLayoutAnimationEnabledExperimental) {
|
||||
UIManager.setLayoutAnimationEnabledExperimental(true);
|
||||
}
|
||||
}
|
||||
export default function App() {
|
||||
useEffect(() => {
|
||||
UpdateAsync();
|
||||
}, []);
|
||||
const [favoriteStation, setFavoriteStation] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setFavoriteStation(returnData);
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
}, []);
|
||||
const [busAndTrainData, setBusAndTrainData] = useState([]);
|
||||
export default function App() {
|
||||
useEffect(() => UpdateAsync(), []);
|
||||
return (
|
||||
<SafeAreaProvider>
|
||||
<FavoriteStationProvider>
|
||||
<TrainDelayDataProvider>
|
||||
<CurrentTrainProvider>
|
||||
<AreaInfoProvider>
|
||||
<AllTrainDiagramProvider>
|
||||
<BusAndTrainDataProvider>
|
||||
<SheetProvider>
|
||||
<AppContainer />
|
||||
</SheetProvider>
|
||||
</BusAndTrainDataProvider>
|
||||
</AllTrainDiagramProvider>
|
||||
</AreaInfoProvider>
|
||||
</CurrentTrainProvider>
|
||||
</TrainDelayDataProvider>
|
||||
</FavoriteStationProvider>
|
||||
</SafeAreaProvider>
|
||||
);
|
||||
}
|
||||
export function AppContainer() {
|
||||
const { setBusAndTrainData } = useBusAndTrainData();
|
||||
useEffect(() => {
|
||||
AS.getItem("busAndTrain")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setBusAndTrainData(returnData);
|
||||
})
|
||||
.catch((d) => {
|
||||
.catch(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbw0UW6ZeCDgUYFRP0zxpc_Oqfy-91dBdbWv-cM8n3narKp14IyCd2wy5HW7taXcW7E/exec"
|
||||
)
|
||||
@@ -65,9 +83,21 @@ export default function App() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const { areaInfo, setAreaInfo } = useAreaInfo();
|
||||
const getAreaData = () =>
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
||||
)
|
||||
.then((d) => d.text())
|
||||
.then((d) => setAreaInfo(d));
|
||||
useEffect(getAreaData, []);
|
||||
useInterval(getAreaData, 60000); //60秒毎に全在線列車取得
|
||||
|
||||
return (
|
||||
<NavigationContainer name="Root" style={{ flex: 1 }}>
|
||||
<Tab.Navigator detachInactiveScreens={false}>
|
||||
<Tab.Navigator
|
||||
tabBarOptions={{ keyboardHidesTabBar: Platform.OS === "android" }}
|
||||
>
|
||||
<Tab.Screen
|
||||
name="login"
|
||||
options={{
|
||||
@@ -77,14 +107,7 @@ export default function App() {
|
||||
tabBarIcon: initIcon("barchart", "AntDesign"),
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Top
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
/>
|
||||
)}
|
||||
{(props) => <Top {...props} />}
|
||||
</Tab.Screen>
|
||||
<Tab.Screen
|
||||
name="menuPage"
|
||||
@@ -95,14 +118,7 @@ export default function App() {
|
||||
tabBarIcon: initIcon("ios-radio", "Ionicons"),
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<MenuPage
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
/>
|
||||
)}
|
||||
{(props) => <MenuPage {...props} />}
|
||||
</Tab.Screen>
|
||||
<Tab.Screen
|
||||
name="home"
|
||||
@@ -111,6 +127,7 @@ export default function App() {
|
||||
headerTransparent: true,
|
||||
gestureEnabled: true,
|
||||
tabBarIcon: initIcon("md-train", "Ionicons"),
|
||||
tabBarBadge: areaInfo ? "!" : undefined,
|
||||
}}
|
||||
>
|
||||
{(props) => <TNDView {...props} />}
|
||||
@@ -119,178 +136,3 @@ export default function App() {
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
|
||||
const initIcon = (name, type) => {
|
||||
switch (type) {
|
||||
case "Ionicons":
|
||||
return ({ focused, color, size }) => (
|
||||
<Ionicons name={name} size={32} color={focused ? "#0099CC" : "black"} />
|
||||
);
|
||||
case "AntDesign":
|
||||
return ({ focused, color, size }) => (
|
||||
<AntDesign
|
||||
name={name}
|
||||
size={32}
|
||||
color={focused ? "#0099CC" : "black"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const Top = ({
|
||||
navigation,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
}) => {
|
||||
const webview = useRef();
|
||||
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
getStationList2().then(setMapsStationData);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", (e) => {
|
||||
navigation.navigate("favoriteList");
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="Apps"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Apps
|
||||
{...props}
|
||||
webview={webview}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
title: "トレインビジョン",
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
title: "使い方",
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="news" options={optionData}>
|
||||
{(props) => <News {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="trainMenu" options={optionData}>
|
||||
{(props) => (
|
||||
<TrainMenu
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="favoriteList"
|
||||
options={{ ...optionData, gestureEnabled: false }}
|
||||
>
|
||||
{(props) => (
|
||||
<FavoriteList
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
};
|
||||
function MenuPage({
|
||||
navigation,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
}) {
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
if (favoriteStation.toString() != d) {
|
||||
setFavoriteStation(returnData);
|
||||
}
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="menu"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Menu
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="setting" options={optionData}>
|
||||
{(props) => <Setting {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
||||
const optionData = {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
};
|
||||
|
229
Apps.js
229
Apps.js
@@ -1,56 +1,53 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
View,
|
||||
Platform,
|
||||
ToastAndroid,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import { View, Platform, Text, TouchableOpacity } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import Constants from "expo-constants";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
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 { getStationList2 } from "./lib/getStationList2";
|
||||
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
/*
|
||||
import StatusbarDetect from './StatusbarDetect';
|
||||
var Status = StatusbarDetect(); */
|
||||
|
||||
export default function Apps({
|
||||
navigation,
|
||||
webview,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
stationData,
|
||||
}) {
|
||||
export default function Apps({ navigation, webview, stationData }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const { navigate } = navigation;
|
||||
var urlcache = "";
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
//画面表示関連
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [LoadError, setLoadError] = useState(false);
|
||||
|
||||
//列車情報表示関連
|
||||
const [trainInfo, setTrainInfo] = useState({
|
||||
trainNum: undefined,
|
||||
limited: undefined,
|
||||
trainData: undefined,
|
||||
});
|
||||
|
||||
//駅情報画面用
|
||||
const StationBoardAcSR = useRef(null);
|
||||
const [stationBoardData, setStationBoardData] = useState(undefined);
|
||||
const [originalStationList, setOriginalStationList] = useState();
|
||||
const [selectedStation, setSelectedStation] = useState(undefined);
|
||||
const [trainMenu, setTrainMenu] = useState("true");
|
||||
let once = false;
|
||||
useEffect(() => {
|
||||
getStationList().then(setOriginalStationList);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {}, [stationData, favoriteStation]);
|
||||
//地図表示テキスト
|
||||
const injectJavascript = injectJavascriptData(
|
||||
mapSwitch,
|
||||
iconSetting,
|
||||
stationMenu
|
||||
stationMenu,
|
||||
trainMenu
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -59,7 +56,7 @@ export default function Apps({
|
||||
.then((d) => {
|
||||
if (d != news) navigate("news");
|
||||
})
|
||||
.catch((e) => navigate("news"));
|
||||
.catch(() => navigate("news"));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -72,7 +69,7 @@ export default function Apps({
|
||||
AS.setItem("iconSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("iconSwitch", "true").then(Updates.reloadAsync));
|
||||
.catch(() => AS.setItem("iconSwitch", "true").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -85,7 +82,7 @@ export default function Apps({
|
||||
AS.setItem("mapSwitch", "false").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("mapSwitch", "false").then(Updates.reloadAsync));
|
||||
.catch(() => AS.setItem("mapSwitch", "false").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -98,13 +95,25 @@ export default function Apps({
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) =>
|
||||
.catch(() =>
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync)
|
||||
);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
//列車メニュースイッチ
|
||||
AS.getItem("trainSwitch")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setTrainMenu(d);
|
||||
} else {
|
||||
AS.setItem("trainSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch(() => AS.setItem("trainSwitch", "true").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
const onMessage = (event) => {
|
||||
if (!event.nativeEvent.data.includes("PopUpMenu")) {
|
||||
if (event.nativeEvent.data.includes("train.html")) {
|
||||
navigate("trainbase", { info: event.nativeEvent.data, from: "Train" });
|
||||
return;
|
||||
}
|
||||
@@ -112,34 +121,77 @@ export default function Apps({
|
||||
alert("駅名標データを取得中...");
|
||||
return;
|
||||
}
|
||||
const selectedStationPDFAddress = event.nativeEvent.data
|
||||
.split(",")[3]
|
||||
.replace("'", "")
|
||||
.replace("'", "");
|
||||
const dataSet = JSON.parse(event.nativeEvent.data);
|
||||
switch (dataSet.type) {
|
||||
case "LoadError": {
|
||||
setLoadError(true);
|
||||
return;
|
||||
}
|
||||
case "PopUpMenu":
|
||||
{
|
||||
const selectedStationPDFAddress = dataSet.pdf;
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter(
|
||||
(d) => d.StationTimeTable == selectedStationPDFAddress
|
||||
);
|
||||
return NearStation;
|
||||
};
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter(
|
||||
(d) => d.StationTimeTable == selectedStationPDFAddress
|
||||
);
|
||||
return NearStation;
|
||||
};
|
||||
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
if (returnDataBase.length) {
|
||||
setStationBoardData(returnDataBase);
|
||||
StationBoardAcSR.current?.setModalVisible();
|
||||
} else {
|
||||
setStationBoardData(undefined);
|
||||
StationBoardAcSR.current?.hide();
|
||||
if (returnDataBase.length) {
|
||||
const payload = {
|
||||
currentStation: returnDataBase,
|
||||
originalStationList: originalStationList,
|
||||
navigate: navigate,
|
||||
goTo: "Apps",
|
||||
useShow: () =>
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
}),
|
||||
onExit: () => {
|
||||
SheetManager.hide("StationDetailView");
|
||||
},
|
||||
};
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
case "ShowTrainTimeInfo": {
|
||||
const { trainNum, limited } = dataSet;
|
||||
//alert(trainNum, limited);
|
||||
setTrainInfo({
|
||||
trainNum,
|
||||
limited,
|
||||
trainData: checkDuplicateTrainData(
|
||||
currentTrain.filter((a) => a.num == trainNum)
|
||||
),
|
||||
}); //遅延情報は未実装
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum,
|
||||
limited,
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
const onNavigationStateChange = (event) => {
|
||||
@@ -148,7 +200,7 @@ export default function Apps({
|
||||
urlcache = event.url;
|
||||
|
||||
if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) {
|
||||
if (Platform.OS === "android") navigate("howto");
|
||||
if (Platform.OS === "android") navigate("howto", { info: event.url });
|
||||
webview?.current.goBack();
|
||||
//Actions.howto();
|
||||
} else if (
|
||||
@@ -161,7 +213,59 @@ export default function Apps({
|
||||
}
|
||||
}
|
||||
};
|
||||
function sleep(waitSec, callbackFunc) {
|
||||
// 経過時間(秒)
|
||||
var spanedSec = 0;
|
||||
|
||||
// 1秒間隔で無名関数を実行
|
||||
var id = setInterval(function () {
|
||||
spanedSec++;
|
||||
|
||||
// 経過時間 >= 待機時間の場合、待機終了。
|
||||
if (spanedSec >= waitSec) {
|
||||
// タイマー停止
|
||||
clearInterval(id);
|
||||
|
||||
// 完了時、コールバック関数を実行
|
||||
if (callbackFunc) callbackFunc();
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
|
||||
const openStationACFromEachTrainInfo = async (stationName) => {
|
||||
await SheetManager.hide("EachTrainInfo");
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter((d) => d.Station_JP == stationName);
|
||||
return NearStation;
|
||||
};
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
if (returnDataBase.length) {
|
||||
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");
|
||||
}
|
||||
};
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -185,7 +289,6 @@ export default function Apps({
|
||||
onNavigationStateChange={onNavigationStateChange}
|
||||
onMessage={onMessage}
|
||||
injectedJavaScript={injectJavascript}
|
||||
onTouchMove={() => StationBoardAcSR.current?.hide()}
|
||||
onLoadEnd={() => {
|
||||
if (once) return () => {};
|
||||
if (!stationData) return () => {};
|
||||
@@ -215,15 +318,7 @@ export default function Apps({
|
||||
<ReloadButton
|
||||
onPress={() => webview.current.reload()}
|
||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||
/>
|
||||
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={stationBoardData}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
LoadError={LoadError}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -265,7 +360,7 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||
const styles = {
|
||||
touch: {
|
||||
position: "absolute",
|
||||
@@ -273,7 +368,7 @@ const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
right: 10,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: "#0099CC",
|
||||
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||
borderColor: "white",
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
|
97
MenuPage.js
Normal file
97
MenuPage.js
Normal file
@@ -0,0 +1,97 @@
|
||||
import React, { useEffect } from "react";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { AS } from "./storageControl";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import Menu from "./menu";
|
||||
import Setting from "./components/settings.js";
|
||||
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 }) {
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
const { getCurrentTrain } = useCurrentTrain();
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
if (favoriteStation.toString() != d) {
|
||||
setFavoriteStation(returnData);
|
||||
}
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="menu"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => <Menu {...props} getCurrentTrain={getCurrentTrain} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="setting" options={optionData}>
|
||||
{(props) => <Setting {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="currentTrainIDList"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <CurrentTrainListView {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="AllTrainIDList"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => <AllTrainDiagramView {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
100
Top.js
Normal file
100
Top.js
Normal file
@@ -0,0 +1,100 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
import Apps from "./Apps";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import News from "./components/news.js";
|
||||
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 }) => {
|
||||
const webview = useRef();
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
const { getCurrentTrain } = useCurrentTrain();
|
||||
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
getStationList2().then(setMapsStationData);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", (e) => {
|
||||
navigation.navigate("favoriteList");
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="Apps"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Apps
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
title: "トレインビジョン",
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="news" options={optionData}>
|
||||
{(props) => <News {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="trainMenu" options={optionData}>
|
||||
{(props) => (
|
||||
<TrainMenu
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="favoriteList"
|
||||
options={{ ...optionData, gestureEnabled: false }}
|
||||
>
|
||||
{(props) => (
|
||||
<FavoriteList
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
};
|
12
app.json
12
app.json
@@ -7,7 +7,7 @@
|
||||
"ios",
|
||||
"android"
|
||||
],
|
||||
"version": "4.5",
|
||||
"version": "4.6",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"splash": {
|
||||
@@ -16,13 +16,14 @@
|
||||
"backgroundColor": "#00b8ff"
|
||||
},
|
||||
"updates": {
|
||||
"fallbackToCacheTimeout": 0
|
||||
"fallbackToCacheTimeout": 0,
|
||||
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||
},
|
||||
"assetBundlePatterns": [
|
||||
"**/*"
|
||||
],
|
||||
"ios": {
|
||||
"buildNumber": "26",
|
||||
"buildNumber": "31",
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn",
|
||||
"config": {
|
||||
@@ -31,7 +32,7 @@
|
||||
},
|
||||
"android": {
|
||||
"package": "jrshikokuinfo.xprocess.hrkn",
|
||||
"versionCode": 18,
|
||||
"versionCode": 20,
|
||||
"permissions": [
|
||||
"ACCESS_FINE_LOCATION"
|
||||
],
|
||||
@@ -46,6 +47,9 @@
|
||||
"eas": {
|
||||
"projectId": "398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||
}
|
||||
},
|
||||
"runtimeVersion": {
|
||||
"policy": "sdkVersion"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
assets/A.png
Normal file
BIN
assets/A.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 439 KiB |
BIN
assets/B.png
Normal file
BIN
assets/B.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 405 KiB |
@@ -971,20 +971,96 @@
|
||||
"9003D":"高松,発,8:45#坂出,発,9:02#宇多津,発,9:07#丸亀,発,9:11#多度津,着,9:17#",
|
||||
"9005M":"高松,発,9:42#坂出,発,9:56#宇多津,発,10:01#丸亀,発,10:05#多度津,着,10:10#",
|
||||
"9007D":"高松,発,10:47#坂出,発,11:04#宇多津,発,11:09#丸亀,発,11:12#多度津,着,11:17#",
|
||||
"9007M":"高松,発,10:47#坂出,発,11:04#宇多津,発,11:09#丸亀,発,11:12#多度津,着,11:17#",
|
||||
"9009D":"高松,発,11:50#坂出,発,12:04#宇多津,発,12:09#丸亀,発,12:13#多度津,着,12:18#",
|
||||
"9009M":"高松,発,11:50#坂出,発,12:04#宇多津,発,12:09#丸亀,発,12:13#多度津,着,12:18#",
|
||||
"9011M":"高松,発,12:50#坂出,発,13:04#宇多津,発,13:09#丸亀,発,13:13#多度津,着,13:18#",
|
||||
"9013M":"高松,発,13:50#坂出,発,14:04#宇多津,発,14:10#丸亀,発,14:14#多度津,着,14:18#",
|
||||
"9015M":"高松,発,14:50#坂出,発,15:04#宇多津,発,15:10#丸亀,発,15:14#多度津,着,15:19#",
|
||||
"9017M":"高松,発,15:50#坂出,発,16:04#宇多津,発,16:10#丸亀,発,16:14#多度津,着,16:19#",
|
||||
"9019D":"高松,発,16:50#坂出,発,17:04#宇多津,発,17:10#丸亀,発,17:13#多度津,着,17:18#",
|
||||
"9019M":"高松,発,16:50#坂出,発,17:04#宇多津,発,17:10#丸亀,発,17:13#多度津,着,17:18#",
|
||||
"9021M":"高松,発,17:53#坂出,発,18:08#宇多津,発,18:13#丸亀,発,18:17#多度津,着,18:21#",
|
||||
"9023D":"高松,発,18:59#坂出,発,19:13#宇多津,発,19:17#丸亀,発,19:20#多度津,着,19:26#",
|
||||
"9023M":"高松,発,18:59#坂出,発,19:13#宇多津,発,19:17#丸亀,発,19:20#多度津,着,19:26#",
|
||||
"9025D":"高松,発,19:52#坂出,発,20:07#宇多津,発,20:12#丸亀,発,20:16#多度津,着,20:20#",
|
||||
"9025M":"高松,発,19:52#坂出,発,20:07#宇多津,発,20:12#丸亀,発,20:16#多度津,着,20:20#",
|
||||
"9027M":"高松,発,20:59#坂出,発,21:13#宇多津,発,21:18#丸亀,発,21:21#多度津,着,21:26#",
|
||||
"9057D":"高松,発,18:27#坂出,発,18:41#宇多津,発,18:46#丸亀,発,18:49#多度津,着,18:55#",
|
||||
"9004D":"宇多津,発,7:14#坂出,発,7:21#高松,着,7:36#",
|
||||
"9006M":"宇多津,発,8:26#坂出,発,8:31#高松,着,8:45#",
|
||||
"9008D":"宇多津,発,9:25#坂出,発,9:32#高松,着,9:47#",
|
||||
"9008M":"宇多津,発,9:25#坂出,発,9:32#高松,着,9:47#",
|
||||
"9010D":"宇多津,発,10:19#坂出,発,10:24#高松,着,10:39#",
|
||||
"9010M":"宇多津,発,10:19#坂出,発,10:24#高松,着,10:39#",
|
||||
"9012M":"宇多津,発,11:33#坂出,発,11:39#高松,着,11:54#",
|
||||
"9014M":"宇多津,発,12:33#坂出,発,12:39#高松,着,12:54#",
|
||||
"9016M":"宇多津,発,13:34#坂出,発,13:39#高松,着,13:55#",
|
||||
"9018M":"宇多津,発,14:34#坂出,発,14:39#高松,着,14:55#",
|
||||
"9020D":"宇多津,発,15:34#坂出,発,15:39#高松,着,15:55#",
|
||||
"9020M":"宇多津,発,15:34#坂出,発,15:39#高松,着,15:55#",
|
||||
"9022M":"宇多津,発,16:34#坂出,発,16:39#高松,着,16:54#",
|
||||
"9024D":"宇多津,発,17:35#坂出,発,17:41#高松,着,17:57#",
|
||||
"9024M":"宇多津,発,17:35#坂出,発,17:41#高松,着,17:57#",
|
||||
"9026D":"宇多津,発,18:36#坂出,発,18:40#高松,着,18:54#",
|
||||
"9026M":"宇多津,発,18:36#坂出,発,18:40#高松,着,18:54#",
|
||||
"9028M":"宇多津,発,19:38#坂出,発,19:43#高松,着,19:56#",
|
||||
"9054D":"宇多津,発,9:00#坂出,発,9:07#高松,着,9:21#",
|
||||
"9095D":"松山,発,10:34#伊予市,発,10:54#下灘,発,11:51#喜多灘,発,12:07#伊予白滝,発,12:42#伊予大洲,着,13:07#",
|
||||
"9096D":"伊予大洲,発,13:30#伊予白滝,発,13:47#伊予長浜,発,14:24#喜多灘,発,14:36#下灘,発,15:09#伊予上灘,発,15:31#北伊予,発,15:54#松山,着,16:00#",
|
||||
"9323D":"高松,発,9:32#栗林,発,9:53#屋島,発,10:24#八栗口,発,10:40#志度,発,11:32#造田,発,12:14#讃岐津田,発,12:36#三本松,発,13:02#讃岐相生,発,13:31#阿波大宮,発,13:46#板野,発,14:06#板東,発,14:24#池谷,発,14:33#勝瑞,発,14:43#徳島,着,14:56#",
|
||||
"9105D":"児島,発,13:44#坂出,発,14:10#鴨川,発,14:37#端岡,発,14:52#高松,着,15:01#",
|
||||
"9104D":"高松,発,10:21#鴨川,発,10:38#坂出,発,11:08#児島,着,11:29#"
|
||||
"9104D":"高松,発,10:21#鴨川,発,10:38#坂出,発,11:08#児島,着,11:29#",
|
||||
"9633D":"八幡浜,発,10:08#双岩,発,10:24#伊予石城,発,10:43#上宇和,発,10:47#卯之町,着,10:50#",
|
||||
"9637D":"八幡浜,発,14:31#双岩,発,14:40#伊予石城,発,14:59#上宇和,発,15:03#卯之町,着,15:06#",
|
||||
"9665D":"八幡浜,発,13:40#双岩,発,13:47#伊予石城,発,14:04#上宇和,発,14:08#卯之町,発,14:34#下宇和,発,14:38#立間,発,14:45#伊予吉田,発,15:04#高光,発,15:10#北宇和島,発,15:14#宇和島,着,15:16#",
|
||||
"9662D":"宇和島,発,10:00#北宇和島,発,10:04#高光,発,10:07#伊予吉田,発,10:13#立間,発,10:19#下宇和,発,10:30#卯之町,発,10:34#上宇和,発,10:37#伊予石城,発,10:45#双岩,発,10:51#八幡浜,着,10:57#",
|
||||
"9634D":"卯之町,発,11:22#上宇和,発,11:25#伊予石城,発,11:40#双岩,発,11:46#八幡浜,着,11:52#",
|
||||
"9636D":"卯之町,発,15:35#上宇和,発,15:38#伊予石城,発,15:52#双岩,発,15:58#八幡浜,着,16:04#",
|
||||
"9091D":"松山,発,8:26#市坪,発,8:33#伊予市,発,8:44#下灘,発,9:26#喜多灘,発,9:42#伊予大洲,着,10:28#",
|
||||
"9641M":"松山,発,15:00#市坪,着,15:04#",
|
||||
"9643M":"松山,発,15:41#市坪,着,15:45#",
|
||||
"9645M":"松山,発,16:06#市坪,着,16:10#",
|
||||
"9647M":"松山,発,16:27#市坪,着,16:31#",
|
||||
"9649M":"松山,発,16:59#市坪,着,17:03#",
|
||||
"9651M":"松山,発,17:46#市坪,着,17:50#",
|
||||
"9661D":"松山,発,21:38#市坪,発,21:42#北伊予,発,21:46#南伊予,発,21:49#伊予横田,発,21:51#鳥ノ木,発,21:54#伊予市,着,21:56#",
|
||||
"9652M":"市坪,発,18:59#松山,着,19:03#",
|
||||
"9654M":"市坪,発,19:54#松山,着,19:58#",
|
||||
"9656M":"市坪,発,20:32#松山,着,20:36#",
|
||||
"9658D":"市坪,発,20:51#松山,着,20:55#",
|
||||
"9660M":"市坪,発,21:19#松山,着,21:23#",
|
||||
"9662M":"市坪,発,21:50#松山,着,21:54#",
|
||||
"9664M":"市坪,発,22:13#松山,着,22:17#",
|
||||
"9666D":"北伊予,発,22:46#市坪,発,22:50#松山,着,22:55#",
|
||||
"9668M":"市坪,発,23:00#松山,着,23:04#",
|
||||
"9052D":"窪川,発,15:13#土佐久礼,発,15:46#安和,発,15:57#須崎,発,16:25#佐川,発,16:54#日下,発,17:11#伊野,発,17:32#朝倉,発,17:42#高知,着,17:53#",
|
||||
"9062D":"大歩危,発,14:21#小歩危,発,14:38#阿波川口,発,15:01#阿波池田,発,15:26#坪尻,発,15:53#讃岐財田,発,16:15#琴平,発,16:50#善通寺,発,17:01#金蔵寺,発,17:09#多度津,着,17:14#",
|
||||
"9920D":"伊予大洲,発,14:33#五郎,発,14:39#伊予白滝,発,14:59#伊予長浜,発,15:09#下灘,発,15:23#伊予上灘,発,15:30#伊予市,発,15:44#南伊予,発,15:49#北伊予,発,15:55#松山,着,16:01#",
|
||||
"9051D":"高知,発,12:04#朝倉,発,12:29#伊野,発,12:49#日下,発,13:06#西佐川,発,13:21#須崎,発,13:45#安和,発,14:05#土佐久礼,発,14:17#影野,発,14:31#窪川,着,14:40#",
|
||||
"9061D":"多度津,発,10:19#善通寺,発,10:26#琴平,発,10:48#讃岐財田,発,11:12#坪尻,発,11:41#阿波池田,発,12:10#三縄,発,12:19#大歩危,着,12:47#",
|
||||
"9523D":"川之江,発,9:00#伊予三島,発,9:15#伊予寒川,発,9:31#伊予土居,発,10:03#関川,発,10:16#多喜浜,発,10:31#中萩,発,10:49#伊予西条,着,10:57#",
|
||||
"9524D":"伊予西条,発,11:11#新居浜,発,11:35#伊予土居,発,11:59#伊予寒川,発,12:08#伊予三島,発,12:17#川之江,着,12:24#",
|
||||
"9987D":"鳴門,発,22:15#撫養,発,22:18#金比羅前,発,22:21#教会前,発,22:24#立道,発,22:27#阿波大谷,発,22:31#池谷,発,22:36#勝瑞,発,22:41#吉成,発,22:44#佐古,発,22:57#徳島,着,23:00#",
|
||||
"9093D":"松山,発,13:31#北伊予,発,13:42#下灘,発,14:22#喜多灘,発,14:38#伊予大洲,発,15:13#伊予平野,発,15:37#八幡浜,着,15:50#",
|
||||
"9094D":"八幡浜,発,16:14#伊予大洲,発,16:33#伊予長浜,発,16:57#下灘,発,17:24#伊予上灘,発,17:36#伊予市,発,17:53#北伊予,発,18:03#市坪,発,18:12#松山,着,18:17#",
|
||||
"9205D":"児島,発,15:10#宇多津,発,15:28#丸亀,発,15:31#多度津,発,15:36#琴平,発,15:47#讃岐財田,発,16:14#坪尻,発,16:35#佃,発,16:51#阿波池田,発,16:57#阿波川口,発,17:16#大歩危,発,17:35#大田口,発,17:58#大杉,発,18:30#土佐北川,発,18:47#繁藤,発,19:02#土佐山田,発,19:17#後免,発,19:22#土佐一宮,発,19:43#高知,着,19:47#",
|
||||
"9204D":"高知,発,8:43#土佐一宮,発,8:49#繁藤,発,9:16#大杉,発,9:28#土佐岩原,発,9:48#大歩危,発,10:08#阿波川口,発,10:29#阿波池田,発,10:42#讃岐財田,発,11:09#琴平,発,11:33#金蔵寺,発,11:59#多度津,発,12:06#丸亀,発,12:10#児島,着,12:25#",
|
||||
"9003M":"高松,発,8:45#坂出,発,9:02#宇多津,着,9:06#",
|
||||
"9005D":"高松,発,9:42#坂出,発,9:56#宇多津,発,10:01#丸亀,発,10:05#多度津,着,10:10#",
|
||||
"9004M":"宇多津,発,7:14#坂出,発,7:21#高松,着,7:36#",
|
||||
"9006D":"宇多津,発,8:26#坂出,発,8:31#高松,着,8:45#",
|
||||
"9253M":"児島,発,11:02#多度津,発,11:30#善通寺,発,11:54#琴平,着,12:00#",
|
||||
"9256M":"琴平,発,15:20#善通寺,発,15:26#多度津,発,15:35#宇多津,発,15:44#児島,着,16:04#",
|
||||
"9057M":"高松,発,18:27#坂出,発,18:41#宇多津,発,18:46#丸亀,発,18:49#多度津,着,18:55#",
|
||||
"9054M":"宇多津,発,9:00#坂出,発,9:07#高松,着,9:21#",
|
||||
//9001: "岡山,発,10:11#児島,発,11:05#坂出,発,11:41#高松,着,12:00#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9001: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第1章\n-瀬戸の海に想いを馳せながら-\n岡山・高松・琴平,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
//9029: "高松,発,12:42#琴平,着,13:57#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9029: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第1章\n-瀬戸の海に想いを馳せながら-\n岡山・高松・琴平,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
//9003: "多度津,発,10:09#今治,発,13:20#伊予亀岡,発,13:55#菊間,発,14:04#松山,着,14:50#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9003: "湯山荘 阿讃琴南,頃,9:00#多度津,頃,10:10#松山,頃,14:50#宿泊施設,以降,14:50#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第2章\n -四国の伝統文化を感じて-\n多度津・坂出・松山,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9055: "宿泊施設→バス,着,10:30#松山,頃,10:30#今治,頃,14:15#しまなみエリア観光,以降,14:15#Azumi Setoda,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第3章\n-凪の誘い・瀬戸内の絶景-\n今治・しまなみ海道,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9056: "宿泊施設→バス,着,10:30#松山,頃,10:30#今治,頃,14:15#しまなみエリア観光,以降,14:15#Azumi Setoda,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第3章\n-凪の誘い・瀬戸内の絶景-\n今治・しまなみ海道,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9004: "Azumi Setoda,頃,9:30#今治,頃,10:30#高松,頃,14:30#高松港\n↓\n瀬戸内クルーズ(貸切)\n「おりんぴあどりーむ せと」\n↓ \n 新岡山港,以降,14:15#岡山駅,頃,18:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS フィナーレ\n-四国・瀬戸内の彩りに囲まれて-\n今治・高松・岡山,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
}
|
BIN
assets/雑.png
Normal file
BIN
assets/雑.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
802
components/ActionSheetComponents/EachTrainInfo.js
Normal file
802
components/ActionSheetComponents/EachTrainInfo.js
Normal file
@@ -0,0 +1,802 @@
|
||||
import React, { useEffect, useState, useRef } from "react";
|
||||
import {
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
TouchableWithoutFeedback,
|
||||
TouchableHighlight,
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import ActionSheet, {
|
||||
SheetManager,
|
||||
useScrollHandlers,
|
||||
} from "react-native-actions-sheet";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { AS } from "../../storageControl";
|
||||
import LottieView from "lottie-react-native";
|
||||
import trainList from "../../assets/originData/trainList";
|
||||
import { lineList } from "../../lib/getStationList";
|
||||
import {
|
||||
heightPercentageToDP,
|
||||
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 <></>;
|
||||
const {
|
||||
data,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo = () => {},
|
||||
from,
|
||||
} = props.payload;
|
||||
const [trainData, setTrainData] = useState([]);
|
||||
const [isTop, setIsTop] = useState(true);
|
||||
const [currentPosition, setCurrentPosition] = useState([]);
|
||||
|
||||
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")
|
||||
.then((d) => {
|
||||
if (d) {
|
||||
setTrainPositionSwitch(d);
|
||||
} else {
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("trainPositionSwitch", "false"));
|
||||
}, []);
|
||||
const insets = useSafeAreaInsets();
|
||||
const getStationData = (stationName) => {
|
||||
const Stations = stationList.map((a) =>
|
||||
a.filter((d) => d.StationName == stationName)
|
||||
);
|
||||
const Station =
|
||||
Stations &&
|
||||
Stations.reduce((newArray, e) => {
|
||||
return newArray.concat(e);
|
||||
}, []);
|
||||
if (!Station[0]) return [];
|
||||
return Station.map((d) => d.StationNumber)[0];
|
||||
};
|
||||
useEffect(() => {
|
||||
//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(currentTrainData?.Pos)]);
|
||||
}
|
||||
}, [currentTrainData]);
|
||||
|
||||
const stationList =
|
||||
originalStationList &&
|
||||
lineList.map((d) =>
|
||||
originalStationList[d].map((a) => ({
|
||||
StationNumber: a.StationNumber,
|
||||
StationName: a.Station_JP,
|
||||
}))
|
||||
);
|
||||
const stopStationIDList = 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);
|
||||
return StationNumbers[0];
|
||||
});
|
||||
function findReversalPoints(array) {
|
||||
try {
|
||||
// arrayは現在位置の駅ID(駅在宅の場合は1つの配列、駅間の場合は2つの配列)
|
||||
// stopStationIDListは停車駅の駅IDの配列
|
||||
if (!stopStationIDList.length) return [];
|
||||
// arrayが二次元配列だったら早期リターン
|
||||
if (!array instanceof Array) return [];
|
||||
if (!array.length) return [];
|
||||
if (array[0] instanceof Array) return [];
|
||||
const arrayNumber = array.map((d) => ({
|
||||
line: d
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
.join(""),
|
||||
ID: d
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
}));
|
||||
const stopStationIDListNumber = stopStationIDList.map((d) => {
|
||||
if (!d) return { line: [], ID: [] };
|
||||
return {
|
||||
line: d
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
.join(""),
|
||||
ID: d
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
};
|
||||
});
|
||||
// 完全一致
|
||||
if (array.length == 1) {
|
||||
const index = stopStationIDList.indexOf(array[0]);
|
||||
if (index != -1) return [index];
|
||||
// 通過駅の場合
|
||||
for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
|
||||
if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 駅間の場合
|
||||
if (array.length == 2) {
|
||||
const index1 = stopStationIDList.indexOf(array[0]);
|
||||
const index2 = stopStationIDList.indexOf(array[1]);
|
||||
if (index1 != -1 && index2 != -1) {
|
||||
// 駅間で通過駅も無い場合
|
||||
if (index1 < index2) {
|
||||
if (index1 + 1 == index2) {
|
||||
return [index2];
|
||||
} else {
|
||||
const returnArray = [];
|
||||
for (let i = index1 + 1; i <= index2; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
if (index1 > index2) {
|
||||
if (index2 + 1 == index1) return [index1];
|
||||
else {
|
||||
const returnArray = [];
|
||||
for (let i = index2 + 1; i <= index1; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const getNearStationID = (stationID) => {
|
||||
for (let i = 0; i <= stopStationIDListNumber.length; i++) {
|
||||
if (stopStationIDListNumber[i].ID < stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let newIndex1 = index1;
|
||||
let newIndex2 = index2;
|
||||
if (index1 == -1) {
|
||||
newIndex1 = getNearStationID(arrayNumber[0].ID);
|
||||
}
|
||||
if (index2 == -1) {
|
||||
newIndex2 = getNearStationID(arrayNumber[1].ID);
|
||||
}
|
||||
if (newIndex1 && newIndex2) {
|
||||
return [newIndex1, newIndex2];
|
||||
}
|
||||
|
||||
// 通過駅の場合
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
// 使用例
|
||||
const points =
|
||||
trainPositionSwitch == "true" ? findReversalPoints(currentPosition) : [];
|
||||
|
||||
useEffect(() => {
|
||||
setIsTop(true);
|
||||
if (!data.trainNum) return;
|
||||
const TD = trainList[data.trainNum];
|
||||
if (!TD) {
|
||||
setTrainData([]);
|
||||
return;
|
||||
}
|
||||
setTrainData(TD.split("#").filter((d) => d != ""));
|
||||
}, [data]);
|
||||
const getType = (string) => {
|
||||
switch (string) {
|
||||
case "express":
|
||||
return "特急";
|
||||
case "rapid":
|
||||
return "快速";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
const migrateTrainName = (string) => {
|
||||
return string
|
||||
.replace("マリン", "マリンライナー")
|
||||
.replace("ライナーライナー", "ライナー");
|
||||
};
|
||||
const actionSheetRef = useRef(null);
|
||||
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
|
||||
return (
|
||||
<ActionSheet
|
||||
gestureEnabled={isTop}
|
||||
CustomHeaderComponent={<></>}
|
||||
ref={actionSheetRef}
|
||||
drawUnderStatusBar={false}
|
||||
isModal={Platform.OS == "ios"}
|
||||
containerStyle={
|
||||
Platform.OS == "android"
|
||||
? {
|
||||
paddingBottom: insets.bottom,
|
||||
}
|
||||
: {}
|
||||
}
|
||||
useBottomSafeAreaPadding={Platform.OS == "android"}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
borderTopRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
>
|
||||
<View style={{ height: 26, width: "100%" }}>
|
||||
<View
|
||||
style={{
|
||||
height: 6,
|
||||
width: 45,
|
||||
borderRadius: 100,
|
||||
backgroundColor: "#f0f0f0",
|
||||
marginVertical: 10,
|
||||
alignSelf: "center",
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<View
|
||||
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
||||
>
|
||||
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
||||
{data.limited
|
||||
? getType(data.limited.split(":")[0]) +
|
||||
migrateTrainName(
|
||||
data.limited.split(":")[1] ||
|
||||
(trainData.length > 0
|
||||
? trainData[trainData.length - 1].split(",")[0] + "行き"
|
||||
: " ")
|
||||
)
|
||||
: ""}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 20, fontWeight: "bold", color: "white" }}>
|
||||
{data.trainNum}
|
||||
</Text>
|
||||
{data.limited != undefined &&
|
||||
getType(data.limited.split(":")[0]) &&
|
||||
!data.limited.split(":")[1].match("サンポート") && (
|
||||
<Ionicons
|
||||
name="subway"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ margin: 5 }}
|
||||
onPress={() => {
|
||||
LayoutAnimation.easeInEaseOut(); //setLoadingDelayData(true);
|
||||
navigate("trainbase", {
|
||||
info: "train.html?tn=" + data.trainNum,
|
||||
from,
|
||||
});
|
||||
SheetManager.hide("EachTrainInfo");
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
{from == "AllTrainDiagramView" || (
|
||||
<ScrollView
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
//width: widthPercentageToDP("200%"),
|
||||
minHeight: 200,
|
||||
height: heightPercentageToDP("20%"),
|
||||
}}
|
||||
horizontal
|
||||
pagingEnabled
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
minHeight: 200,
|
||||
height: heightPercentageToDP("20%"),
|
||||
width: widthPercentageToDP("100%"),
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
現在地 {currentPosition.toString()}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{currentTrainData?.Pos && currentTrainData?.Pos.match("~") ? (
|
||||
<>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
currentTrainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[0]
|
||||
}
|
||||
</Text>
|
||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||
~
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
currentTrainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[1]
|
||||
}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{currentTrainData?.Pos}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "column" }}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
{isNaN(currentTrainData?.delay) ? "状態" : "遅延時分"}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{currentTrainData?.delay}
|
||||
{isNaN(currentTrainData?.delay) ? "" : "分"}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>列番</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{currentTrainData?.num}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{/* <View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
height: heightPercentageToDP("20%"),
|
||||
flex: 1,
|
||||
width: widthPercentageToDP("100%"),
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>行先</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
岡山
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<View
|
||||
style={{
|
||||
flex: 3,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>車両案内</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
宇多津でうずしお号と連結
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
編成(使用車両:2700系)
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
color: "#0099CC",
|
||||
textAlign: "left",
|
||||
}}
|
||||
>
|
||||
{"[<自][自>][アン自|指>][アン指|G>]"}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</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={{
|
||||
maxHeight: heightPercentageToDP(
|
||||
from == "AllTrainDiagramView" ? "70%" : "50%"
|
||||
),
|
||||
}}
|
||||
onScroll={(e) => {
|
||||
if (!Platform.OS !== "android") return;
|
||||
setIsTop(e.nativeEvent.contentOffset.y < 0);
|
||||
}}
|
||||
>
|
||||
<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> */}
|
||||
|
||||
{trainData.map((i, index) => {
|
||||
const [station, se, time] = i.split(",");
|
||||
if(se == "提"){
|
||||
return (
|
||||
<TouchableWithoutFeedback
|
||||
onPress={() => Linking.openURL(time)}
|
||||
key={station}
|
||||
>
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
padding: 8,
|
||||
flexDirection: "row",
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "#f0f0f0",
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 20 }}>{station}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 18 }}>
|
||||
提供元<MaterialCommunityIcons name={"open-in-new"} color="black" size={20} />
|
||||
</Text>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
);
|
||||
}
|
||||
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}
|
||||
>
|
||||
<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
|
||||
style={{
|
||||
fontSize: 20,
|
||||
marginRight: 70,
|
||||
}}
|
||||
>
|
||||
🚊
|
||||
</Text>
|
||||
) : 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>
|
||||
</View>
|
||||
</TouchableWithoutFeedback>
|
||||
);
|
||||
})}
|
||||
|
||||
<View style={{ flexDirection: "row" }}>
|
||||
<View
|
||||
style={{
|
||||
padding: 8,
|
||||
flexDirection: "row",
|
||||
borderBottomWidth: 1,
|
||||
borderBottomColor: "#f0f0f0",
|
||||
flex: 1,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 20 }}> </Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</ActionSheet>
|
||||
);
|
||||
};
|
@@ -1,4 +1,4 @@
|
||||
import React from "react";
|
||||
import React, { useRef } from "react";
|
||||
import {
|
||||
View,
|
||||
LayoutAnimation,
|
||||
@@ -6,28 +6,38 @@ import {
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import ActionSheet, { useScrollHandlers } from "react-native-actions-sheet";
|
||||
import LottieView from "lottie-react-native";
|
||||
export const JRSTraInfo = (props) => {
|
||||
const {
|
||||
JRSTraInfoEXAcSR,
|
||||
getTime,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
delayData,
|
||||
} = props;
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import { useTrainDelayData } from "../../stateBox/useTrainDelayData";
|
||||
export const JRSTraInfo = () => {
|
||||
const { getTime, delayData, loadingDelayData, setLoadingDelayData } =
|
||||
useTrainDelayData();
|
||||
const actionSheetRef = useRef(null);
|
||||
const scrollHandlers = useScrollHandlers("scrollview-1", actionSheetRef);
|
||||
const insets = useSafeAreaInsets();
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={JRSTraInfoEXAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={<></>}
|
||||
ref={actionSheetRef}
|
||||
isModal={Platform.OS == "ios"}
|
||||
containerStyle={
|
||||
Platform.OS == "android"
|
||||
? {
|
||||
paddingBottom: insets.bottom,
|
||||
}
|
||||
: {}
|
||||
}
|
||||
useBottomSafeAreaPadding={Platform.OS == "android"}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
borderRadius: 5,
|
||||
borderTopRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
@@ -71,13 +81,11 @@ export const JRSTraInfo = (props) => {
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
<ScrollView>
|
||||
<ScrollView {...scrollHandlers}>
|
||||
<View
|
||||
style={{
|
||||
padding: 10,
|
||||
backgroundColor: "white",
|
||||
borderBottomLeftRadius: 5,
|
||||
borderBottomRightRadius: 5,
|
||||
}}
|
||||
>
|
||||
{loadingDelayData ? (
|
||||
@@ -125,12 +133,14 @@ export const JRSTraInfo = (props) => {
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => Linking.openURL("https://twitter.com/JRSTrainfoEX")}
|
||||
onPress={() =>
|
||||
Linking.openURL("https://mstdn.y-zu.org/@JRSTraInfoEX")
|
||||
}
|
||||
>
|
||||
<MaterialCommunityIcons name="twitter" color="white" size={30} />
|
||||
<MaterialCommunityIcons name="mastodon" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
TwitterBOTはこちら!
|
||||
MastodonBOTはこちら!
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
|
@@ -1,35 +1,29 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import { View, Linking, Text, TouchableOpacity, Platform } from "react-native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons";
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import Sign from "../../components/駅名表/Sign";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
|
||||
import { TicketBox } from "../atom/TicketBox";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import lineColorList from "../../assets/originData/lineColorList";
|
||||
import { getPDFViewURL } from "../../lib/getPdfViewURL";
|
||||
import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData";
|
||||
import { AS } from "../../storageControl";
|
||||
|
||||
export const StationDeteilView = (props) => {
|
||||
if (!props.payload) return <></>;
|
||||
const {
|
||||
StationBoardAcSR,
|
||||
currentStation,
|
||||
originalStationList,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
} = props;
|
||||
navigate,
|
||||
onExit,
|
||||
goTo,
|
||||
useShow,
|
||||
} = props.payload;
|
||||
const { busAndTrainData } = useBusAndTrainData();
|
||||
const [trainBus, setTrainBus] = useState();
|
||||
useEffect(() => {
|
||||
if (!currentStation) return () => {};
|
||||
@@ -42,17 +36,35 @@ export const StationDeteilView = (props) => {
|
||||
setTrainBus(data[0]);
|
||||
}, [currentStation]);
|
||||
|
||||
const [usePDFView, setUsePDFView] = useState(undefined);
|
||||
useEffect(() => {
|
||||
AS.getItem("usePDFView").then(setUsePDFView);
|
||||
}, []);
|
||||
const info =
|
||||
currentStation &&
|
||||
(currentStation[0].StationTimeTable.match(".pdf")
|
||||
? getPDFViewURL(currentStation[0].StationTimeTable)
|
||||
: currentStation[0].StationTimeTable);
|
||||
const insets = useSafeAreaInsets();
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={StationBoardAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={<></>}
|
||||
isModal={Platform.OS == "ios"}
|
||||
containerStyle={
|
||||
Platform.OS == "android"
|
||||
? {
|
||||
paddingBottom: insets.bottom,
|
||||
}
|
||||
: {}
|
||||
}
|
||||
useBottomSafeAreaPadding={Platform.OS == "android"}
|
||||
>
|
||||
<View
|
||||
key={currentStation}
|
||||
style={{
|
||||
backgroundColor: "white",
|
||||
borderRadius: 5,
|
||||
borderTopRadius: 5,
|
||||
borderColor: "dark",
|
||||
borderWidth: 1,
|
||||
}}
|
||||
@@ -80,9 +92,17 @@ export const StationDeteilView = (props) => {
|
||||
<Sign
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
oP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
||||
oP={() => {
|
||||
usePDFView == "true"
|
||||
? Linking.openURL(currentStation[0].StationTimeTable)
|
||||
: navigate("howto", {
|
||||
info,
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
oLP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
||||
/>
|
||||
</View>
|
||||
)}
|
||||
@@ -91,14 +111,29 @@ export const StationDeteilView = (props) => {
|
||||
<NexPreStationLine
|
||||
currentStation={d}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
/>
|
||||
))} */}
|
||||
{currentStation &&
|
||||
currentStation[0].JrHpUrl &&
|
||||
currentStation[0].StationNumber != "M12" && (
|
||||
<駅構内図 //高松/阿波池田&後免&須崎kounai.png児島例外/
|
||||
oP={() => {
|
||||
navigate("howto", {
|
||||
info:
|
||||
currentStation[0].JrHpUrl.replace("/index.html", "/") +
|
||||
"/kounai_map.html",
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
oLP={() => {
|
||||
Linking.openURL(
|
||||
currentStation[0].JrHpUrl.replace("/index.html", "/") +
|
||||
"/kounai_map.html"
|
||||
);
|
||||
}}
|
||||
uri={currentStation[0].JrHpUrl.replace("/index.html", "/")}
|
||||
/>
|
||||
)}
|
||||
@@ -109,7 +144,16 @@ export const StationDeteilView = (props) => {
|
||||
backgroundColor={"#AD7FA8"}
|
||||
icon={<Foundation name="web" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
onPressButton={() => {
|
||||
navigate("howto", {
|
||||
info: currentStation[0].JrHpUrl,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() =>
|
||||
Linking.openURL(currentStation[0].JrHpUrl)
|
||||
}
|
||||
>
|
||||
@@ -121,7 +165,18 @@ export const StationDeteilView = (props) => {
|
||||
backgroundColor={"#8F5902"}
|
||||
icon={<FontAwesome name="table" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
onPressButton={() => {
|
||||
usePDFView == "true"
|
||||
? Linking.openURL(currentStation[0].StationTimeTable)
|
||||
: navigate("howto", {
|
||||
info,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() =>
|
||||
Linking.openURL(currentStation[0].StationTimeTable)
|
||||
}
|
||||
>
|
||||
@@ -145,7 +200,16 @@ export const StationDeteilView = (props) => {
|
||||
backgroundColor={"#CE5C00"}
|
||||
icon={<Ionicons name="bus" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() => Linking.openURL(trainBus.address)}
|
||||
onPressButton={() => {
|
||||
navigate("howto", {
|
||||
info: trainBus.address,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() => Linking.openURL(trainBus.address)}
|
||||
>
|
||||
並行バス
|
||||
</TicketBox>
|
||||
@@ -168,13 +232,7 @@ const StationName = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const NexPreStationLine = ({
|
||||
currentStation,
|
||||
originalStationList,
|
||||
oP,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
}) => {
|
||||
const NexPreStationLine = ({ currentStation, originalStationList }) => {
|
||||
const [preStation, setPreStation] = useState();
|
||||
const [nexStation, setNexStation] = useState();
|
||||
const [lineName, setLineName] = useState();
|
||||
@@ -312,7 +370,8 @@ const 駅構内図 = (props) => {
|
||||
alignItems: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={() => Linking.openURL(props.uri + "/kounai_map.html")}
|
||||
onPress={props.oP}
|
||||
onLongPress={props.oLP}
|
||||
//onPress={() => setOpen(!open)}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
|
10
components/ActionSheetComponents/sheets.js
Normal file
10
components/ActionSheetComponents/sheets.js
Normal file
@@ -0,0 +1,10 @@
|
||||
import { registerSheet } from "react-native-actions-sheet";
|
||||
import { EachTrainInfo } from "./EachTrainInfo";
|
||||
import { JRSTraInfo } from "./JRSTraInfo";
|
||||
import { StationDeteilView } from "./StationDeteilView";
|
||||
|
||||
registerSheet("EachTrainInfo", EachTrainInfo);
|
||||
registerSheet("JRSTraInfo", JRSTraInfo);
|
||||
registerSheet("StationDetailView", StationDeteilView);
|
||||
|
||||
export {};
|
164
components/AllTrainDiagramView.js
Normal file
164
components/AllTrainDiagramView.js
Normal file
@@ -0,0 +1,164 @@
|
||||
import React, { useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
Linking,
|
||||
ScrollView,
|
||||
FlatList,
|
||||
KeyboardAvoidingView,
|
||||
TextInput,
|
||||
Platform,
|
||||
Keyboard,
|
||||
} from "react-native";
|
||||
import MapView, { Marker } from "react-native-maps";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
import { useAreaInfo } from "../stateBox/useAreaInfo";
|
||||
import { useAllTrainDiagram } from "../stateBox/useAllTrainDiagram";
|
||||
|
||||
import { customTrainDataDetector } from "./custom-train-data";
|
||||
import { getStationList, lineList } from "../lib/getStationList";
|
||||
import { getTrainType } from "../lib/getTrainType";
|
||||
import { checkDuplicateTrainData } from "../lib/checkDuplicateTrainData";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
export default function AllTrainDiagramView({ navigation: { navigate } }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const { areaInfo } = useAreaInfo();
|
||||
const { allTrainDiagram } = useAllTrainDiagram();
|
||||
const [originalStationList, setOriginalStationList] = useState(); // 第一要素
|
||||
const [keyList, setKeyList] = useState(); // 第二要素
|
||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
useEffect(
|
||||
() => allTrainDiagram && setKeyList(Object.keys(allTrainDiagram)),
|
||||
[]
|
||||
);
|
||||
const [input, setInput] = useState(""); // 文字入力
|
||||
const [keyBoardVisible, setKeyBoardVisible] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const showSubscription = Keyboard.addListener("keyboardDidShow", () => {
|
||||
setKeyBoardVisible(true);
|
||||
});
|
||||
const hideSubscription = Keyboard.addListener("keyboardDidHide", () => {
|
||||
setKeyBoardVisible(false);
|
||||
});
|
||||
|
||||
return () => {
|
||||
showSubscription.remove();
|
||||
hideSubscription.remove();
|
||||
};
|
||||
}, []);
|
||||
|
||||
const openTrainInfo = (d) => {
|
||||
const train = customTrainDataDetector(d);
|
||||
let TrainNumber = "";
|
||||
if (train.trainNumDistance != undefined) {
|
||||
const timeInfo =
|
||||
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
from: "AllTrainDiagramView",
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<View style={{ backgroundColor: "#0099CC", height: "100%" }}>
|
||||
<FlatList
|
||||
style={{ flex: 1 }}
|
||||
data={keyList?.filter((d) => d.includes(input))}
|
||||
renderItem={({ item }) => (
|
||||
<Item openTrainInfo={openTrainInfo} id={item} />
|
||||
)}
|
||||
keyExtractor={(item) => item}
|
||||
initialNumToRender={100}
|
||||
/>
|
||||
<KeyboardAvoidingView
|
||||
behavior="padding"
|
||||
keyboardVerticalOffset={80}
|
||||
enabled={Platform.OS === "ios"}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
height: 35,
|
||||
margin: 5,
|
||||
alignItems: "center",
|
||||
backgroundColor: "#F4F4F4",
|
||||
flexDirection: "row",
|
||||
paddingLeft: 10,
|
||||
paddingRight: 10,
|
||||
borderRadius: 25,
|
||||
borderColor: "#F4F4F4",
|
||||
}}
|
||||
>
|
||||
<TextInput
|
||||
placeholder="列番を入力してフィルタリングします。"
|
||||
onFocus={() => {
|
||||
setKeyBoardVisible(true);
|
||||
}}
|
||||
onEndEditing={() => {}}
|
||||
onChange={(ret) => {
|
||||
setInput(ret.nativeEvent.text);
|
||||
}}
|
||||
value={input}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
</View>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
display:
|
||||
Platform.OS === "ios" ? "flex" : keyBoardVisible ? "none" : "flex",
|
||||
}}
|
||||
onPress={() => navigate("menu")}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const Item = ({ id, openTrainInfo }) => {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 5,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 5,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => openTrainInfo(id)}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
{id}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
51
components/CurrentTrainListView.js
Normal file
51
components/CurrentTrainListView.js
Normal file
@@ -0,0 +1,51 @@
|
||||
import React, { useRef } from "react";
|
||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||
import MapView, { Marker } from "react-native-maps";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
export default function CurrentTrainListView({ navigation: { navigate } }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
{currentTrain && currentTrain.map((d) => <Text>{d.num}</Text>)}
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => navigate("menu")}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const UsefulBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
@@ -1,21 +1,11 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import React from "react";
|
||||
import { View, Text, TouchableOpacity, ScrollView } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import { ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import StatusbarDetect from "../StatusbarDetect";
|
||||
import { AS } from "../storageControl";
|
||||
import { news } from "../config/newsUpdate";
|
||||
import { getStationList, lineList } from "../lib/getStationList";
|
||||
var Status = StatusbarDetect();
|
||||
export default function FavoriteList({
|
||||
navigation,
|
||||
webview,
|
||||
stationData,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
}) {
|
||||
import { useFavoriteStation } from "../stateBox/useFavoriteStation";
|
||||
export default function FavoriteList({ navigation, webview, stationData }) {
|
||||
const { navigate } = navigation;
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
|
@@ -7,8 +7,8 @@ export const TextBox = (props) => {
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
height: 70,
|
||||
padding: 5,
|
||||
minHeight: 70,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
margin: 2,
|
||||
|
@@ -1,7 +1,14 @@
|
||||
import { TouchableOpacity, Text } from "react-native";
|
||||
|
||||
export const TicketBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
const {
|
||||
icon,
|
||||
backgroundColor,
|
||||
flex,
|
||||
onPressButton,
|
||||
children,
|
||||
onLongPressButton,
|
||||
} = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
@@ -14,6 +21,7 @@ export const TicketBox = (props) => {
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
onLongPress={onLongPressButton}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
|
@@ -412,19 +412,27 @@ export const customTrainDataDetector = (TrainNumber) => {
|
||||
case "1052D":
|
||||
case "1056D":
|
||||
case "1058D":
|
||||
case "1062D":
|
||||
case "1064D":
|
||||
case "1068D":
|
||||
case "1070D":
|
||||
case "1074D":
|
||||
case "1076D":
|
||||
case "1078D":
|
||||
case "1080D":
|
||||
case "1082D":
|
||||
case "1051D":
|
||||
case "1053D":
|
||||
case "1057D":
|
||||
case "1059D":
|
||||
case "1063D":
|
||||
case "1065D":
|
||||
case "1069D":
|
||||
case "1071D":
|
||||
case "1073D":
|
||||
case "1075D":
|
||||
case "1077D":
|
||||
case "1053D":
|
||||
case "1079D":
|
||||
return {
|
||||
type: "LTDEXP",
|
||||
trainName: "宇和海",
|
||||
@@ -435,19 +443,11 @@ export const customTrainDataDetector = (TrainNumber) => {
|
||||
//2000 アンパン込み
|
||||
case "1054D":
|
||||
case "1060D":
|
||||
case "1062D":
|
||||
case "1066D":
|
||||
case "1068D":
|
||||
case "1072D":
|
||||
case "1078D":
|
||||
case "1055D":
|
||||
case "1057D":
|
||||
case "1061D":
|
||||
case "1063D":
|
||||
case "1067D":
|
||||
case "1069D":
|
||||
case "1073D":
|
||||
case "1079D":
|
||||
case "1081D":
|
||||
return {
|
||||
type: "LTDEXP",
|
||||
@@ -608,6 +608,43 @@ export const customTrainDataDetector = (TrainNumber) => {
|
||||
info: "",
|
||||
};
|
||||
|
||||
/////ロイヤルエクスプレス
|
||||
case "9001":
|
||||
case "9029":
|
||||
return {
|
||||
type: "SPCL",
|
||||
trainName: "THE ROYAL EXPRESS",
|
||||
trainIcon: "http://trainfrontview.net/p/izq2100rex1.png",
|
||||
trainNumDistance: null,
|
||||
info: "[団体専用] 第1章 -瀬戸の海に想いを馳せながら- 岡山・高松・琴平",
|
||||
};
|
||||
/////ロイヤルエクスプレス
|
||||
case "9003":
|
||||
return {
|
||||
type: "SPCL",
|
||||
trainName: "THE ROYAL EXPRESS",
|
||||
trainIcon: "http://trainfrontview.net/p/izq2100rex1.png",
|
||||
trainNumDistance: null,
|
||||
info: "[団体専用] 第2章 -四国の伝統文化を感じて- 多度津・坂出・松山",
|
||||
};
|
||||
/////ロイヤルエクスプレス
|
||||
case "9055":
|
||||
case "9056":
|
||||
return {
|
||||
type: "SPCL",
|
||||
trainName: "THE ROYAL EXPRESS",
|
||||
trainIcon: "http://trainfrontview.net/p/izq2100rex1.png",
|
||||
trainNumDistance: null,
|
||||
info: "[団体専用] 第3章 -凪の誘い・瀬戸内の絶景- 今治・しまなみ海道",
|
||||
};
|
||||
case "9004":
|
||||
return {
|
||||
type: "SPCL",
|
||||
trainName: "THE ROYAL EXPRESS",
|
||||
trainIcon: "http://trainfrontview.net/p/izq2100rex1.png",
|
||||
trainNumDistance: null,
|
||||
info: "[団体専用] フィナーレ -四国・瀬戸内の彩りに囲まれて- 今治・高松・岡山",
|
||||
};
|
||||
default:
|
||||
return {
|
||||
type: "Normal",
|
||||
@@ -619,3 +656,37 @@ export const customTrainDataDetector = (TrainNumber) => {
|
||||
break;
|
||||
}
|
||||
};
|
||||
export const getJRF = (num) => {
|
||||
switch (num) {
|
||||
case "71":
|
||||
return "東京(タ)→高松(タ)\\n";
|
||||
case "73":
|
||||
case "75":
|
||||
return "大阪(タ)→高松(タ)\\n";
|
||||
case "3079":
|
||||
return "高松(タ)→伊予三島\\n";
|
||||
case "3071":
|
||||
case "3077":
|
||||
return "高松(タ)→新居浜\\n";
|
||||
case "3073":
|
||||
return "高松(タ)→松山貨物\\n";
|
||||
case "70":
|
||||
return "高松(タ)→東京(タ)\\n";
|
||||
case "74":
|
||||
case "76":
|
||||
return "高松(タ)→大阪(タ)\\n";
|
||||
case "3078":
|
||||
return "伊予三島→高松(タ)\\n";
|
||||
case "3070":
|
||||
return "新居浜→高松(タ)\\n";
|
||||
case "3076":
|
||||
return "新居浜→高松(タ)\\n";
|
||||
case "3072":
|
||||
return "松山貨物→高松(タ)\\n";
|
||||
case "9070":
|
||||
return "臨時貨物\\n";
|
||||
default:
|
||||
JRF = true;
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { View, Text, TouchableOpacity } from "react-native";
|
||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||
import * as Updates from "expo-updates";
|
||||
import StatusbarDetect from "../StatusbarDetect";
|
||||
import { AS } from "../storageControl";
|
||||
@@ -10,13 +10,19 @@ export default function Setting(props) {
|
||||
const {
|
||||
navigation: { navigate },
|
||||
} = props;
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [iconSetting, setIconSetting] = useState(false);
|
||||
const [mapSwitch, setMapSwitch] = useState(false);
|
||||
const [stationMenu, setStationMenu] = useState(false);
|
||||
const [usePDFView, setUsePDFView] = useState(false);
|
||||
const [trainMenu, setTrainMenu] = useState(false);
|
||||
const [trainPosition, setTrainPosition] = useState(false);
|
||||
useEffect(() => {
|
||||
AS.getItem("iconSwitch").then(setIconSetting);
|
||||
AS.getItem("mapSwitch").then(setMapSwitch);
|
||||
AS.getItem("stationSwitch").then(setStationMenu);
|
||||
AS.getItem("usePDFView").then(setUsePDFView);
|
||||
AS.getItem("trainSwitch").then(setTrainMenu);
|
||||
AS.getItem("trainPositionSwitch").then(setTrainPosition);
|
||||
}, []);
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
@@ -83,7 +89,7 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
駅メニューを表示(beta)
|
||||
駅メニューを表示
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
@@ -102,7 +108,64 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
内部バージョン: 4.5.2
|
||||
時刻表PDFをアプリ外で表示
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={usePDFView == "true" ? true : false}
|
||||
color={usePDFView == "true" ? "red" : null}
|
||||
onValueChange={(value) => setUsePDFView(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
列車メニュー
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={trainMenu == "true" ? true : false}
|
||||
color={trainMenu == "true" ? "red" : null}
|
||||
onValueChange={(value) => setTrainMenu(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
→列車現在位置表示(alpha)
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={trainPosition == "true" ? true : false}
|
||||
color={trainPosition == "true" ? "red" : null}
|
||||
onValueChange={(value) => setTrainPosition(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
内部バージョン: 4.6.4
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
@@ -116,10 +179,31 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
releaseChannel: {Updates.releaseChannel}
|
||||
releaseChannel: {Updates.channel}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
style={{ flexDirection: "row", padding: 10 }}
|
||||
onPress={() =>
|
||||
Linking.openURL(
|
||||
"https://nexcloud.haruk.in/sites/press-harukin/JRShikokuApps/policy"
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
プライバシーポリシー
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
<TouchableOpacity
|
||||
@@ -137,6 +221,9 @@ export default function Setting(props) {
|
||||
AS.setItem("iconSwitch", iconSetting.toString()),
|
||||
AS.setItem("mapSwitch", mapSwitch.toString()),
|
||||
AS.setItem("stationSwitch", stationMenu.toString()),
|
||||
AS.setItem("usePDFView", usePDFView.toString()),
|
||||
AS.setItem("trainSwitch", trainMenu.toString()),
|
||||
AS.setItem("trainPositionSwitch", trainPosition.toString()),
|
||||
]).then(() => {
|
||||
Updates.reloadAsync();
|
||||
});
|
||||
|
@@ -58,7 +58,11 @@ export default function TrainMenu({
|
||||
backgroundColor={"#F89038"}
|
||||
icon="train-car"
|
||||
flex={1}
|
||||
onPressButton={() => navigate("howto")}
|
||||
onPressButton={() =>
|
||||
navigate("howto", {
|
||||
info: "https://train.jr-shikoku.co.jp/usage.htm",
|
||||
})
|
||||
}
|
||||
>
|
||||
使い方
|
||||
</UsefulBox>
|
||||
|
@@ -3,13 +3,16 @@ 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, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { customTrainDataDetector } from "../custom-train-data";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
import trainList from "../../assets/originData/trainList";
|
||||
import { objectIsEmpty } from "../../lib/objectIsEmpty";
|
||||
|
||||
let diagramData = undefined;
|
||||
import { getTrainType } from "../../lib/getTrainType";
|
||||
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
||||
import { useAreaInfo } from "../../stateBox/useAreaInfo";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -41,47 +44,20 @@ let diagramData = undefined;
|
||||
* 9062D 四国まんなか千年ものがたり(臨時?)
|
||||
*/
|
||||
export default function LED_vision(props) {
|
||||
const HeaderConfig = {
|
||||
headers: {
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
};
|
||||
const [trainDiagram, setTrainDiagram] = useState(null); // 全列車のダイヤを列番ベースで整理
|
||||
const {
|
||||
station,
|
||||
trainDiagram,
|
||||
getCurrentTrain,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
} = props;
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
|
||||
const [currentTrain, setCurrentTrain] = useState(null); //現在在線中の全列車
|
||||
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading");
|
||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||
|
||||
const parseAllTrainDiagram = (text) => {
|
||||
const val = text.replace("[\r\n", "").split(",\r\n");
|
||||
let trainDiagram = {};
|
||||
val.forEach((element) => {
|
||||
try {
|
||||
let data = JSON.parse(element);
|
||||
Object.keys(data).forEach((key) => (trainDiagram[key] = data[key]));
|
||||
} catch (e) {}
|
||||
});
|
||||
return trainDiagram;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
//全列車リストを生成する副作用[無条件初回実行]
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((d) => {
|
||||
if (d.indexOf("<title>404 Not Found</title>") != -1) throw Error;
|
||||
setTrainDiagram(parseAllTrainDiagram(d));
|
||||
})
|
||||
.catch((d) => {
|
||||
console.log("fallback");
|
||||
setTrainDiagram(trainList);
|
||||
});
|
||||
}, []);
|
||||
const { areaInfo } = useAreaInfo();
|
||||
|
||||
useEffect(() => {
|
||||
// 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報]
|
||||
@@ -91,52 +67,54 @@ export default function LED_vision(props) {
|
||||
}
|
||||
let returnData = {};
|
||||
Object.keys(trainDiagram).forEach((key) => {
|
||||
if (trainDiagram[key].match(props.station.Station_JP + ",")) {
|
||||
if (trainDiagram[key].match(station.Station_JP + ",")) {
|
||||
returnData[key] = trainDiagram[key];
|
||||
}
|
||||
});
|
||||
setStationDiagram(returnData);
|
||||
}, [trainDiagram, props.station]);
|
||||
}, [trainDiagram, station]);
|
||||
|
||||
const getCurrentTrain = () =>
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train",
|
||||
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((e) => {
|
||||
console.log("えらー");
|
||||
setCurrentTrainLoading("error");
|
||||
});
|
||||
const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null);
|
||||
|
||||
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
||||
useEffect(() => {
|
||||
//現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット
|
||||
if (objectIsEmpty(stationDiagram)) return () => {};
|
||||
const getTimeData = getTime(stationDiagram, station);
|
||||
setTrainTimeAndNumber(getTimeData);
|
||||
}, [stationDiagram]);
|
||||
|
||||
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
||||
const [selectedTrain, setSelectedTrain] = useState([]);
|
||||
useEffect(() => {
|
||||
if (!trainTimeAndNumber) return () => {};
|
||||
if (!currentTrain) return () => {};
|
||||
const data = trainTimeAndNumber
|
||||
.filter((d) => currentTrain.map((m) => m.num).includes(d.train))
|
||||
.filter(timeFiltering)
|
||||
.filter((d) => !!finalSwitch || d.lastStation != "当駅止");
|
||||
setSelectedTrain(data);
|
||||
}, [trainTimeAndNumber, currentTrain, finalSwitch]);
|
||||
|
||||
const getTime = (stationDiagram, station) => {
|
||||
const returnData = Object.keys(stationDiagram).map((d) => {
|
||||
let a = {};
|
||||
stationDiagram[d].split("#").forEach((data) => {
|
||||
const returnData = Object.keys(stationDiagram).map((trainNum) => {
|
||||
let trainData = {};
|
||||
stationDiagram[trainNum].split("#").forEach((data) => {
|
||||
if (data.match("着")) {
|
||||
a.lastStation = data.split(",着,")[0];
|
||||
trainData.lastStation = data.split(",着,")[0];
|
||||
}
|
||||
if (data.split(",")[0] === station.Station_JP) {
|
||||
if (data.match(",発,")) {
|
||||
a.time = data.split(",発,")[1];
|
||||
trainData.time = data.split(",発,")[1];
|
||||
} else {
|
||||
a.time = data.split(",着,")[1];
|
||||
a.lastStation = "当駅止";
|
||||
trainData.time = data.split(",着,")[1];
|
||||
trainData.lastStation = "当駅止";
|
||||
}
|
||||
}
|
||||
});
|
||||
return { train: d, time: a.time, lastStation: a.lastStation };
|
||||
return {
|
||||
train: trainNum,
|
||||
time: trainData.time,
|
||||
lastStation: trainData.lastStation,
|
||||
};
|
||||
});
|
||||
return returnData.sort((a, b) => {
|
||||
switch (true) {
|
||||
@@ -152,15 +130,6 @@ export default function LED_vision(props) {
|
||||
});
|
||||
};
|
||||
|
||||
const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
//現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット
|
||||
if (objectIsEmpty(stationDiagram)) return () => {};
|
||||
const getTimeData = getTime(stationDiagram, props.station);
|
||||
setTrainTimeAndNumber(getTimeData);
|
||||
}, [stationDiagram]);
|
||||
|
||||
const timeFiltering = (d) => {
|
||||
const date = new Date();
|
||||
const newDate = new Date();
|
||||
@@ -178,16 +147,34 @@ export default function LED_vision(props) {
|
||||
return false;
|
||||
};
|
||||
|
||||
const [selectedTrain, setSelectedTrain] = useState([]);
|
||||
const [areaString, setAreaString] = useState("");
|
||||
const [areaStringLength, setAreaStringLength] = useState(0);
|
||||
const [move, setMove] = useState(0);
|
||||
useInterval(
|
||||
() => {
|
||||
if (areaInfo != "") {
|
||||
if (areaStringLength < move) {
|
||||
setMove(0);
|
||||
} else {
|
||||
setMove(move + 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
350,
|
||||
true
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!trainTimeAndNumber) return () => {};
|
||||
if (!currentTrain) return () => {};
|
||||
const data = trainTimeAndNumber
|
||||
.filter((d) => currentTrain.map((m) => m.num).includes(d.train))
|
||||
.filter(timeFiltering)
|
||||
.filter((d) => !!finalSwitch || d.lastStation != "当駅止");
|
||||
setSelectedTrain(data);
|
||||
}, [trainTimeAndNumber, currentTrain, finalSwitch]);
|
||||
if (!areaInfo) return () => {};
|
||||
setAreaString(
|
||||
areaInfo.substring(move, areaInfo.length) + areaInfo.substring(0, move)
|
||||
);
|
||||
}, [move]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!areaInfo) return () => {};
|
||||
setAreaStringLength(areaInfo.length);
|
||||
}, [areaInfo]);
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -198,22 +185,27 @@ export default function LED_vision(props) {
|
||||
marginHorizontal: wp("1%"),
|
||||
}}
|
||||
>
|
||||
<Header
|
||||
currentTrainLoading={currentTrainLoading}
|
||||
setCurrentTrainLoading={setCurrentTrainLoading}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
{selectedTrain.map((d, index) => (
|
||||
<Header getCurrentTrain={getCurrentTrain} />
|
||||
{selectedTrain.map((d) => (
|
||||
<EachData
|
||||
d={d}
|
||||
trainIDSwitch={trainIDSwitch}
|
||||
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||
props={props}
|
||||
currentTrain={currentTrain}
|
||||
station={station}
|
||||
customTrainDataDetector={customTrainDataDetector}
|
||||
navigate={props.navigate}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
))}
|
||||
{areaString != "" && (
|
||||
<Description
|
||||
numberOfLines={1}
|
||||
info={areaString.replace("\n", "").replace("\r", "")}
|
||||
onClick={() => alert(areaInfo)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Footer
|
||||
trainIDSwitch={trainIDSwitch}
|
||||
setTrainIDSwitch={setTrainIDSwitch}
|
||||
@@ -225,101 +217,80 @@ export default function LED_vision(props) {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const Header = ({
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
getCurrentTrain,
|
||||
}) => (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
marginVertical: 10,
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }}></View>
|
||||
<View style={{}}>
|
||||
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
||||
次の列車
|
||||
</Text>
|
||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||
const Header = ({ getCurrentTrain }) => {
|
||||
const { currentTrainLoading, setCurrentTrainLoading } = useCurrentTrain();
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
marginVertical: 10,
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }}></View>
|
||||
<View style={{}}>
|
||||
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
||||
次の列車
|
||||
</Text>
|
||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||
{currentTrainLoading == "loading" ? (
|
||||
<LottieView
|
||||
autoPlay
|
||||
loop
|
||||
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||
source={require("../../assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
) : currentTrainLoading == "error" ? (
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ marginRight: 30 }}
|
||||
onPress={() => {
|
||||
setCurrentTrainLoading("loading");
|
||||
getCurrentTrain();
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||
{currentTrainLoading == "loading" ? (
|
||||
<LottieView
|
||||
autoPlay
|
||||
loop
|
||||
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||
source={require("../../assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
) : currentTrainLoading == "error" ? (
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ marginRight: 30 }}
|
||||
onPress={() => {
|
||||
setCurrentTrainLoading("loading");
|
||||
getCurrentTrain();
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const Footer = (props) => {
|
||||
const {
|
||||
trainIDSwitch,
|
||||
setTrainIDSwitch,
|
||||
trainDescriptionSwitch,
|
||||
setTrainDescriptionSwitch,
|
||||
finalSwitch,
|
||||
setFinalSwitch,
|
||||
} = props;
|
||||
|
||||
const textStyle = {
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
color: "white",
|
||||
};
|
||||
|
||||
const Footer = ({
|
||||
trainIDSwitch,
|
||||
setTrainIDSwitch,
|
||||
trainDescriptionSwitch,
|
||||
setTrainDescriptionSwitch,
|
||||
finalSwitch,
|
||||
setFinalSwitch,
|
||||
}) => {
|
||||
return (
|
||||
<View style={{ flexDirection: "row", padding: 10, alignItems: "center" }}>
|
||||
<Text
|
||||
style={{
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
種別名 / 列番
|
||||
</Text>
|
||||
<Text style={textStyle}>種別名 / 列番</Text>
|
||||
<Switch value={trainIDSwitch} onValueChange={setTrainIDSwitch} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
列車情報
|
||||
</Text>
|
||||
<Text style={textStyle}>列車情報</Text>
|
||||
<Switch
|
||||
value={trainDescriptionSwitch}
|
||||
onValueChange={setTrainDescriptionSwitch}
|
||||
/>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
color: "white",
|
||||
}}
|
||||
>
|
||||
当駅止表示
|
||||
</Text>
|
||||
<Text style={textStyle}>当駅止表示</Text>
|
||||
<Switch value={finalSwitch} onValueChange={setFinalSwitch} />
|
||||
</View>
|
||||
);
|
||||
@@ -329,27 +300,46 @@ const EachData = ({
|
||||
d,
|
||||
trainIDSwitch,
|
||||
trainDescriptionSwitch,
|
||||
props,
|
||||
currentTrain,
|
||||
station,
|
||||
customTrainDataDetector,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
}) => {
|
||||
const getTrainType = (data) => {
|
||||
switch (data) {
|
||||
case "Rapid":
|
||||
return { color: "aqua", name: "快速" };
|
||||
case "LTDEXP":
|
||||
return { color: "red", name: "特急" };
|
||||
case "NightLTDEXP":
|
||||
return { color: "red", name: "寝台特急" };
|
||||
case "Normal":
|
||||
return { color: "white", name: "普通列車" };
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const openTrainInfo = (d) => {
|
||||
let TrainNumber = "";
|
||||
if (train.trainNumDistance != undefined) {
|
||||
const timeInfo =
|
||||
parseInt(d.train.replace("M", "").replace("D", "")) -
|
||||
train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d.train,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
from: "LED",
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
};
|
||||
const [train, setTrain] = useState(customTrainDataDetector(d.train));
|
||||
useEffect(() => {
|
||||
setTrain(customTrainDataDetector(d.train));
|
||||
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||
// 土讃線複数存在対策
|
||||
const trainDelayStatus = getTrainDelayStatus(
|
||||
checkDuplicateTrainData(currentTrain.filter((a) => a.num == d.train)),
|
||||
station.Station_JP
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<TouchableOpacity
|
||||
@@ -362,126 +352,86 @@ const EachData = ({
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
onPress={() => {
|
||||
if (train.type != "Normal") {
|
||||
navigate("trainbase", {
|
||||
info: "train.html?tn=" + d.train,
|
||||
from: "LED",
|
||||
});
|
||||
}
|
||||
}}
|
||||
onPress={() => openTrainInfo(d)}
|
||||
>
|
||||
<TrainName
|
||||
train={train}
|
||||
trainName={train.trainName}
|
||||
trainNumDistance={train.trainNumDistance}
|
||||
trainIDSwitch={trainIDSwitch}
|
||||
d={d}
|
||||
getTrainType={getTrainType(train.type)}
|
||||
/>
|
||||
<LastStation d={d} />
|
||||
<DependTime d={d} />
|
||||
<StatusAndDelay
|
||||
currentTrain={currentTrain}
|
||||
d={d}
|
||||
props={props}
|
||||
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||
trainID={d.train}
|
||||
type={train.type}
|
||||
/>
|
||||
<LastStation lastStation={d.lastStation} />
|
||||
<DependTime time={d.time} />
|
||||
<StatusAndDelay trainDelayStatus={trainDelayStatus} />
|
||||
</TouchableOpacity>
|
||||
{trainDescriptionSwitch && !!train.info && <Description train={train} />}
|
||||
{trainDescriptionSwitch && !!train.info && (
|
||||
<Description info={train.info} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const TrainName = ({ train, trainIDSwitch, d, getTrainType }) => {
|
||||
const { trainName, trainNumDistance } = train;
|
||||
let TrainNumber = "";
|
||||
if (trainNumDistance != undefined) {
|
||||
const timeInfo =
|
||||
parseInt(d.train.replace("M", "").replace("D", "")) - trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const TrainName = ({
|
||||
trainName,
|
||||
trainNumDistance,
|
||||
trainIDSwitch,
|
||||
trainID,
|
||||
type,
|
||||
}) => {
|
||||
const { name, color } = getTrainType(type);
|
||||
let TrainNumber =
|
||||
trainNumDistance != undefined
|
||||
? `${
|
||||
parseInt(trainID.replace("M", "").replace("D", "")) - trainNumDistance
|
||||
}号`
|
||||
: "";
|
||||
return (
|
||||
<View style={{ flex: 9 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: trainName.length > 6 ? parseInt("13%") : parseInt("18%"),
|
||||
color: getTrainType.color,
|
||||
color: color,
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{trainIDSwitch
|
||||
? d.train
|
||||
: `${getTrainType.name} ${trainName}${TrainNumber}`}
|
||||
{trainIDSwitch ? trainID : `${name} ${trainName}${TrainNumber}`}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const LastStation = ({ d }) => {
|
||||
const LastStation = ({ lastStation }) => {
|
||||
return (
|
||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize:
|
||||
d.lastStation.length > 4 ? parseInt("13%") : parseInt("18%"),
|
||||
fontSize: lastStation.length > 4 ? parseInt("13%") : parseInt("18%"),
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.lastStation}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
const DependTime = ({ d }) => {
|
||||
return (
|
||||
<View style={{ flex: 3 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: parseInt("18%"),
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{d.time}
|
||||
{lastStation}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
||||
const checkDuplicateTrainData = (currentTrainArray) => {
|
||||
const notNyujoData = currentTrainArray.filter((d) => d.delay !== "入線");
|
||||
if (currentTrainArray.length == 1) return currentTrainArray[0];
|
||||
if (notNyujoData.length == 0) return currentTrainArray[0];
|
||||
else return notNyujoData[0];
|
||||
};
|
||||
const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => {
|
||||
const [status, setStatus] = useState("");
|
||||
useEffect(() => {
|
||||
const array = currentTrain.filter((a) => a.num == d.train);
|
||||
const current = checkDuplicateTrainData(array);
|
||||
// 土讃線複数存在対策
|
||||
if (!current) return () => {};
|
||||
const delay = current.delay;
|
||||
switch (true) {
|
||||
case delay === "入線":
|
||||
if (current.Pos === props.station.Station_JP) {
|
||||
setStatus("当駅始発");
|
||||
break;
|
||||
} else {
|
||||
setStatus("発車前");
|
||||
break;
|
||||
}
|
||||
case isNaN(delay):
|
||||
setStatus(delay);
|
||||
break;
|
||||
case delay === 0:
|
||||
setStatus("定刻通り");
|
||||
break;
|
||||
default:
|
||||
setStatus(delay + "分遅れ");
|
||||
break;
|
||||
}
|
||||
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||
const DependTime = ({ time }) => (
|
||||
<View style={{ flex: 3 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: parseInt("18%"),
|
||||
color: "white",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{time}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
|
||||
const StatusAndDelay = ({ trainDelayStatus }) => {
|
||||
return (
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
@@ -492,36 +442,37 @@ const StatusAndDelay = ({ currentTrain, d, props, trainDescriptionSwitch }) => {
|
||||
paddingLeft: 1,
|
||||
}}
|
||||
>
|
||||
{status}
|
||||
{trainDelayStatus}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
const Description = ({ train }) => {
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "94%",
|
||||
marginVertical: 5,
|
||||
marginHorizontal: "3%",
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: parseInt("18%"),
|
||||
color: "green",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
>
|
||||
{" "}
|
||||
> {train.info}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
const Description = ({ info, numberOfLines = 0, onClick }) => (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "94%",
|
||||
marginVertical: 5,
|
||||
marginHorizontal: "3%",
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
onPress={onClick}
|
||||
>
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: parseInt("18%"),
|
||||
color: "green",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
numberOfLines={numberOfLines}
|
||||
>
|
||||
{" "}
|
||||
> {info}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
@@ -1,35 +1,21 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import React, { useRef, 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 { 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,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
} = props;
|
||||
const { currentStation, originalStationList, oP, oLP } = props;
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
const [nexPrePosition, setNexPrePosition] = useState(0);
|
||||
|
||||
const [preStation, setPreStation] = useState();
|
||||
const [nexStation, setNexStation] = useState();
|
||||
const [testButtonStatus, setTestButtonStatus] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const isFavorite = favoriteStation.filter((d) => {
|
||||
const compare = JSON.stringify(d);
|
||||
@@ -40,7 +26,7 @@ export default function Sign(props) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
setTestButtonStatus(isFavorite.length != 0);
|
||||
setTestButtonStatus(isFavorite.length == 0 ? false : true);
|
||||
}, [favoriteStation, currentStation]);
|
||||
|
||||
useInterval(() => {
|
||||
@@ -91,7 +77,7 @@ export default function Sign(props) {
|
||||
};
|
||||
const lottieRef = useRef();
|
||||
return (
|
||||
<TouchableOpacity style={styleSheet.外枠} onPress={oP}>
|
||||
<TouchableOpacity style={styleSheet.外枠} onPress={oP} onLongPress={oLP}>
|
||||
<StationNumberMaker currentStation={currentStation} />
|
||||
<StationNameArea currentStation={currentStation} />
|
||||
<TouchableOpacity
|
||||
@@ -162,7 +148,6 @@ const LottieDelayView = ({
|
||||
ref={lottieRef}
|
||||
loop={loop}
|
||||
onAnimationFinish={(isCanceled) => {
|
||||
console.log("finish");
|
||||
setProgressState(progress);
|
||||
}}
|
||||
/>
|
||||
@@ -237,26 +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%"),
|
||||
}}
|
||||
>
|
||||
<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("13%"),
|
||||
margin: 0,
|
||||
padding: 0,
|
||||
textAlign: "center",
|
||||
}}
|
||||
>
|
||||
{lineID + "\n" + lineName}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const StationNameArea = (props) => {
|
||||
|
@@ -1 +1 @@
|
||||
export const news = "2023-3-27";
|
||||
export const news = "2023-12-25";
|
||||
|
12
eas.json
12
eas.json
@@ -5,10 +5,12 @@
|
||||
"build": {
|
||||
"development": {
|
||||
"developmentClient": true,
|
||||
"distribution": "internal"
|
||||
"distribution": "internal",
|
||||
"channel": "development"
|
||||
},
|
||||
"preview": {
|
||||
"distribution": "internal"
|
||||
"distribution": "internal",
|
||||
"channel": "preview"
|
||||
},
|
||||
"mapsbuild": {
|
||||
"releaseChannel": "mapsbuild"
|
||||
@@ -21,6 +23,12 @@
|
||||
},
|
||||
"production4.5": {
|
||||
"releaseChannel": "buyma"
|
||||
},
|
||||
"beta4.6": {
|
||||
"channel": "catch"
|
||||
},
|
||||
"production4.6": {
|
||||
"channel": "costoco"
|
||||
}
|
||||
},
|
||||
"submit": {
|
||||
|
37
howto.js
37
howto.js
@@ -2,21 +2,28 @@ const WEBVIEW = "WEBVIEW";
|
||||
import React, { Component } from "react";
|
||||
import { StatusBar, View, TouchableOpacity, Text } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
export default ({ navigation: { navigate } }) => (
|
||||
<View style={styles.View}>
|
||||
<WebView
|
||||
useWebKit
|
||||
source={{ uri: "https://train.jr-shikoku.co.jp/usage.htm" }}
|
||||
/>
|
||||
<TouchableOpacity style={styles.touch} onPress={() => navigate("Apps")}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
export default ({ navigation: { navigate }, route }) => {
|
||||
const { info, goTo, useShow } = route.params;
|
||||
const onExit = () => {
|
||||
navigate(goTo);
|
||||
useShow();
|
||||
};
|
||||
return (
|
||||
<View style={styles.View}>
|
||||
<WebView
|
||||
useWebKit
|
||||
source={{ uri: info.replace("http://", "https://") }}
|
||||
/>
|
||||
<TouchableOpacity style={styles.touch} onPress={onExit}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
const styles = {
|
||||
View: { height: "100%", backgroundColor: "#0099CC" },
|
||||
touch: {
|
||||
|
5
lib/HeaderConfig.js
Normal file
5
lib/HeaderConfig.js
Normal file
@@ -0,0 +1,5 @@
|
||||
export const HeaderConfig = {
|
||||
headers: {
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
};
|
6
lib/checkDuplicateTrainData.js
Normal file
6
lib/checkDuplicateTrainData.js
Normal file
@@ -0,0 +1,6 @@
|
||||
export const checkDuplicateTrainData = (currentTrainArray) => {
|
||||
const notNyujoData = currentTrainArray.filter((d) => d.delay !== "入線");
|
||||
if (currentTrainArray.length == 1) return currentTrainArray[0];
|
||||
if (notNyujoData.length == 0) return currentTrainArray[0];
|
||||
else return notNyujoData[0];
|
||||
};
|
7
lib/getPdfViewURL.js
Normal file
7
lib/getPdfViewURL.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { Platform } from "react-native";
|
||||
|
||||
export const getPDFViewURL = (url) => {
|
||||
if (Platform.OS == "ios") return url;
|
||||
else
|
||||
return `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURI(url)}`;
|
||||
};
|
@@ -33,11 +33,6 @@ export const lineList = [
|
||||
export const getStationList = async (props) => {
|
||||
if (status) return status;
|
||||
//駅リストイニシャライズ
|
||||
const HeaderConfig = {
|
||||
headers: {
|
||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||
},
|
||||
};
|
||||
return await Promise.all([
|
||||
yosan,
|
||||
uwajima,
|
||||
|
18
lib/getTrainDelayStatus.js
Normal file
18
lib/getTrainDelayStatus.js
Normal file
@@ -0,0 +1,18 @@
|
||||
export const getTrainDelayStatus = (current, Station_JP) => {
|
||||
if (!current) return () => {};
|
||||
const delay = current.delay;
|
||||
switch (true) {
|
||||
case delay === "入線":
|
||||
if (current.Pos === Station_JP) {
|
||||
return "当駅始発";
|
||||
} else {
|
||||
return "発車前";
|
||||
}
|
||||
case isNaN(delay):
|
||||
return delay;
|
||||
case delay === 0:
|
||||
return "定刻通り";
|
||||
default:
|
||||
return delay + "分遅れ";
|
||||
}
|
||||
};
|
16
lib/getTrainType.js
Normal file
16
lib/getTrainType.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export const getTrainType = (nameString) => {
|
||||
switch (nameString) {
|
||||
case "Rapid":
|
||||
return { color: "aqua", name: "快速", data: "rapid" };
|
||||
case "LTDEXP":
|
||||
return { color: "red", name: "特急", data: "express" };
|
||||
case "NightLTDEXP":
|
||||
return { color: "red", name: "寝台特急", data: "express" };
|
||||
case "SPCL":
|
||||
return { color: "blue", name: "臨時", data: "normal" };
|
||||
case "Normal":
|
||||
return { color: "white", name: "普通列車", data: "normal" };
|
||||
default:
|
||||
return { color: "white", name: "その他", data: "normal" };
|
||||
}
|
||||
};
|
19
lib/initIcon.js
Normal file
19
lib/initIcon.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import React from "react";
|
||||
import { Ionicons, AntDesign } from "@expo/vector-icons";
|
||||
|
||||
export const initIcon = (name, type) => {
|
||||
switch (type) {
|
||||
case "Ionicons":
|
||||
return ({ focused, color, size }) => (
|
||||
<Ionicons name={name} size={32} color={focused ? "#0099CC" : "black"} />
|
||||
);
|
||||
case "AntDesign":
|
||||
return ({ focused, color, size }) => (
|
||||
<AntDesign
|
||||
name={name}
|
||||
size={32}
|
||||
color={focused ? "#0099CC" : "black"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
11
lib/parseAllTrainDiagram.js
Normal file
11
lib/parseAllTrainDiagram.js
Normal file
@@ -0,0 +1,11 @@
|
||||
export const parseAllTrainDiagram = (text) => {
|
||||
const val = text.replace("[\r\n", "").split(",\r\n");
|
||||
let trainDiagram = {};
|
||||
val.forEach((element) => {
|
||||
try {
|
||||
let data = JSON.parse(element);
|
||||
Object.keys(data).forEach((key) => (trainDiagram[key] = data[key]));
|
||||
} catch (e) {}
|
||||
});
|
||||
return trainDiagram;
|
||||
};
|
8
lib/stackOption.js
Normal file
8
lib/stackOption.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { TransitionPresets } from "@react-navigation/stack";
|
||||
export const optionData = {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
};
|
File diff suppressed because it is too large
Load Diff
210
menu.js
210
menu.js
@@ -1,4 +1,4 @@
|
||||
import React, { useRef, useState, useEffect } from "react";
|
||||
import React, { useRef, useState, useEffect, useLayoutEffect } from "react";
|
||||
import Carousel from "react-native-snap-carousel";
|
||||
import {
|
||||
Platform,
|
||||
@@ -7,14 +7,12 @@ import {
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
ToastAndroid,
|
||||
} from "react-native";
|
||||
import Constants from "expo-constants";
|
||||
import { ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import * as Location from "expo-location";
|
||||
import StatusbarDetect from "./StatusbarDetect";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import {
|
||||
@@ -24,7 +22,8 @@ import {
|
||||
MaterialCommunityIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import LottieView from "lottie-react-native";
|
||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||
import { parseAllTrainDiagram } from "./lib/parseAllTrainDiagram";
|
||||
import trainList from "./assets/originData/trainList";
|
||||
|
||||
import LED_vision from "./components/発車時刻表/LED_vidion";
|
||||
import Sign from "./components/駅名表/Sign";
|
||||
@@ -33,19 +32,18 @@ import { UsefulBox } from "./components/atom/UsefulBox";
|
||||
import { TicketBox } from "./components/atom/TicketBox";
|
||||
import { TextBox } from "./components/atom/TextBox";
|
||||
import { getStationList, lineList } from "./lib/getStationList";
|
||||
import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo";
|
||||
import useInterval from "./lib/useInterval";
|
||||
import { HeaderConfig } from "./lib/HeaderConfig";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
import { useTrainDelayData } from "./stateBox/useTrainDelayData";
|
||||
|
||||
export default function Menu(props) {
|
||||
const {
|
||||
navigation: { navigate },
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
getCurrentTrain,
|
||||
} = props;
|
||||
const JRSTraInfoEXAcSR = useRef(null);
|
||||
const StationBoardAcSR = useRef(null);
|
||||
const navigation = useNavigation();
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
//位置情報
|
||||
const [locationStatus, setLocationStatus] = useState(null);
|
||||
@@ -103,34 +101,22 @@ export default function Menu(props) {
|
||||
const [currentStation, setCurrentStation] = useState(undefined); //第三要素
|
||||
|
||||
const [originalStationList, setOriginalStationList] = useState(); // 第一要素
|
||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
useLayoutEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
|
||||
const [count, setCount] = useState(0);
|
||||
const [delayData, setDelayData] = useState(undefined);
|
||||
const [getTime, setGetTime] = useState(new Date());
|
||||
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
||||
const carouselRef = useRef();
|
||||
const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
|
||||
|
||||
const [allStationData, setAllStationData] = useState([]);
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((data) => setDelayData(data !== "" ? data.split("^") : null))
|
||||
.then(() => setGetTime(new Date()))
|
||||
.finally(() => setLoadingDelayData(false));
|
||||
}, [loadingDelayData]);
|
||||
const allStationData = [currentStation, ...favoriteStation].filter(
|
||||
(d) => d != undefined
|
||||
);
|
||||
console.log(allStationData);
|
||||
setAllStationData(
|
||||
[currentStation, ...favoriteStation].filter((d) => d != undefined)
|
||||
);
|
||||
}, [currentStation, favoriteStation]);
|
||||
useEffect(() => {
|
||||
if (allStationData.length == 0) {
|
||||
setSelectedCurrentStation(0);
|
||||
return;
|
||||
}
|
||||
console.log(allStationData[selectedCurrentStation]);
|
||||
if (allStationData[selectedCurrentStation] == undefined) {
|
||||
const count = selectedCurrentStation - 1;
|
||||
setSelectedCurrentStation(count);
|
||||
@@ -138,12 +124,54 @@ export default function Menu(props) {
|
||||
}, [selectedCurrentStation, currentStation, favoriteStation]);
|
||||
useEffect(() => {
|
||||
if (!carouselRef.current) return;
|
||||
console.log(carouselRef.current);
|
||||
if (carouselRef.current?._itemToSnapTo != selectedCurrentStation) {
|
||||
carouselRef.current.snapToItem(0);
|
||||
carouselRef.current.snapToItem(selectedCurrentStation);
|
||||
}
|
||||
}, [selectedCurrentStation]);
|
||||
|
||||
//全列車ダイヤリストを作成するuseEffect
|
||||
const [trainDiagram, setTrainDiagram] = useState(null); // 全列車のダイヤを列番ベースで整理
|
||||
useEffect(() => {
|
||||
//全列車リストを生成する副作用[無条件初回実行]
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((d) => {
|
||||
if (d.indexOf("<title>404 Not Found</title>") != -1) throw Error;
|
||||
setTrainDiagram(parseAllTrainDiagram(d));
|
||||
})
|
||||
.catch(() => {
|
||||
console.log("fallback");
|
||||
setTrainDiagram(trainList);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const openStationACFromEachTrainInfo = () => {
|
||||
// EachTrainInfoAsSR.current?.hide();
|
||||
// const findStationEachLine = (selectLine) => {
|
||||
// let NearStation = selectLine.filter((d) => d.Station_JP == stationName);
|
||||
// return NearStation;
|
||||
// };
|
||||
// let returnDataBase = lineList
|
||||
// .map((d) => findStationEachLine(originalStationList[d]))
|
||||
// .filter((d) => d.length > 0)
|
||||
// .reduce((pre, current) => {
|
||||
// pre.push(...current);
|
||||
// return pre;
|
||||
// }, []);
|
||||
// if (returnDataBase.length) {
|
||||
// setStationBoardData(returnDataBase);
|
||||
// sleep(30, function () {
|
||||
// StationBoardAcSR.current?.show();
|
||||
// });
|
||||
// } else {
|
||||
// setStationBoardData(undefined);
|
||||
// StationBoardAcSR.current?.hide();
|
||||
// }
|
||||
};
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -169,7 +197,7 @@ export default function Menu(props) {
|
||||
onSnapToItem={(d) => {
|
||||
setSelectedCurrentStation(d);
|
||||
}}
|
||||
renderItem={({ item, index }) => {
|
||||
renderItem={({ item }) => {
|
||||
return (
|
||||
<View
|
||||
style={{ marginVertical: 10 }}
|
||||
@@ -178,9 +206,27 @@ export default function Menu(props) {
|
||||
<Sign
|
||||
currentStation={item}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
oP={StationBoardAcSR.current?.setModalVisible}
|
||||
oP={() => {
|
||||
const payload = {
|
||||
currentStation:
|
||||
originalStationList &&
|
||||
allStationData.length != 0 &&
|
||||
allStationData[selectedCurrentStation],
|
||||
originalStationList: originalStationList,
|
||||
navigate: navigate,
|
||||
goTo: "menu",
|
||||
useShow: () =>
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
}),
|
||||
onExit: () => {
|
||||
SheetManager.hide("StationDetailView");
|
||||
},
|
||||
};
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -194,38 +240,16 @@ export default function Menu(props) {
|
||||
station={
|
||||
originalStationList && allStationData[selectedCurrentStation][0]
|
||||
}
|
||||
trainDiagram={trainDiagram}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
)}
|
||||
<JRSTraInfoBox
|
||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||
getTime={getTime}
|
||||
setLoadingDelayData={setLoadingDelayData}
|
||||
loadingDelayData={loadingDelayData}
|
||||
delayData={delayData}
|
||||
/>
|
||||
<JRSTraInfoBox />
|
||||
<FixedContentBottom navigate={navigate} />
|
||||
</ScrollView>
|
||||
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={
|
||||
originalStationList &&
|
||||
allStationData.length != 0 &&
|
||||
allStationData[selectedCurrentStation]
|
||||
}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
/>
|
||||
<JRSTraInfo
|
||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||
getTime={getTime}
|
||||
loadingDelayData={loadingDelayData}
|
||||
setLoadingDelayData={setLoadingDelayData}
|
||||
delayData={delayData}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -288,14 +312,15 @@ const TopMenuButton = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const JRSTraInfoBox = (props) => {
|
||||
const JRSTraInfoBox = () => {
|
||||
const {
|
||||
JRSTraInfoEXAcSR,
|
||||
getTime,
|
||||
setLoadingDelayData,
|
||||
loadingDelayData,
|
||||
setGetTime,
|
||||
delayData,
|
||||
} = props;
|
||||
setDelayData,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
} = useTrainDelayData();
|
||||
const styles = {
|
||||
touch: {
|
||||
backgroundColor: "#0099CC",
|
||||
@@ -327,7 +352,7 @@ const JRSTraInfoBox = (props) => {
|
||||
};
|
||||
return (
|
||||
<TouchableOpacity
|
||||
onPress={JRSTraInfoEXAcSR.current?.setModalVisible}
|
||||
onPress={() => SheetManager.show("JRSTraInfo")}
|
||||
style={styles.touch}
|
||||
>
|
||||
<ScrollView scrollEnabled={false} style={styles.scroll}>
|
||||
@@ -366,7 +391,7 @@ const JRSTraInfoBox = (props) => {
|
||||
/>
|
||||
</View>
|
||||
) : delayData ? (
|
||||
delayData.map((d, index) => {
|
||||
delayData.map((d) => {
|
||||
let data = d.split(" ");
|
||||
return (
|
||||
<View style={{ flexDirection: "row" }} key={data[1] + "key"}>
|
||||
@@ -394,26 +419,10 @@ const JRSTraInfoBox = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const FixedContentTop = (props) => {
|
||||
const FixedContentTop = () => {
|
||||
return (
|
||||
<>
|
||||
<TopMenuButton />
|
||||
<TextBox
|
||||
backgroundColor="#0099CC"
|
||||
flex={1}
|
||||
onPressButton={() =>
|
||||
Linking.openURL(
|
||||
"https://www.jr-shikoku.co.jp/02_information/suspension/sp/"
|
||||
)
|
||||
}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
新型コロナウイルスに関するお知らせ
|
||||
</Text>
|
||||
<Text style={{ color: "white", fontSize: 15 }}>
|
||||
列車の運行計画・混雑状況・感染症対策への取り組み
|
||||
</Text>
|
||||
</TextBox>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -601,14 +610,7 @@ const FixedContentBottom = (props) => {
|
||||
borderBottomRightRadius: 10,
|
||||
}}
|
||||
>
|
||||
{((data) =>
|
||||
data.map((d) => (
|
||||
<ListItem onPress={() => Linking.openURL(d.url)}>
|
||||
<Text>{d.name}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
)))([
|
||||
{[
|
||||
{
|
||||
url: "https://twitter.com/JRshikoku_eigyo",
|
||||
name: "JR四国営業部【公式】",
|
||||
@@ -657,15 +659,35 @@ const FixedContentBottom = (props) => {
|
||||
url: "https://twitter.com/Yoakemonogatari",
|
||||
name: "志国土佐 時代の夜明けのものがたり【公式】",
|
||||
},
|
||||
])}
|
||||
].map((d) => (
|
||||
<ListItem onPress={() => Linking.openURL(d.url)}>
|
||||
<Text>{d.name}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Icon name="chevron-right" size={20} />
|
||||
</ListItem>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>上級者向け機能</Text>
|
||||
<TextBox
|
||||
backgroundColor="#8c00d6"
|
||||
flex={1}
|
||||
onPressButton={() => props.navigate("AllTrainIDList")}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 20 }}>
|
||||
列番探索
|
||||
</Text>
|
||||
<Text style={{ color: "white", fontSize: 18 }}>
|
||||
データベースに存在する全列車のダイヤを探索
|
||||
</Text>
|
||||
</TextBox>
|
||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>
|
||||
このアプリについて
|
||||
</Text>
|
||||
<Text>
|
||||
このアプリはXprocess(HARUKIN)が製作しているJR四国の完全非公式アシストアプリケーションです。このアプリに関することでのJR四国公式へ問合せすることはお控えください。以下のTwitterよりお願いします。
|
||||
</Text>
|
||||
|
||||
<TextBox
|
||||
backgroundColor="#CC0000"
|
||||
flex={1}
|
||||
|
54
ndView.js
54
ndView.js
@@ -1,8 +1,11 @@
|
||||
import React from "react";
|
||||
import { View, Platform } from "react-native";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { View, Platform, TouchableOpacity } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import Constants from "expo-constants";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
export default function tndView() {
|
||||
const webview = useRef();
|
||||
const [LoadError, setLoadError] = useState(false);
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@@ -13,11 +16,22 @@ export default function tndView() {
|
||||
>
|
||||
<WebView
|
||||
useWebKit={true}
|
||||
ref={webview}
|
||||
source={{ uri: "https://www.jr-shikoku.co.jp/info/" }}
|
||||
originWhitelist={["https://www.jr-shikoku.co.jp"]}
|
||||
mixedContentMode={"compatibility"}
|
||||
javaScriptEnabled={true}
|
||||
injectedJavaScript={jsa}
|
||||
pullToRefreshEnabled
|
||||
onError={(syntheticEvent) => {
|
||||
//webViewの再読み込みを行う
|
||||
this.webView.reload();
|
||||
}}
|
||||
/>
|
||||
<ReloadButton
|
||||
onPress={() => webview.current.reload()}
|
||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||
LoadError={LoadError}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -26,3 +40,39 @@ const jsa = `
|
||||
document.querySelector('.sitettl').style.display = 'none';
|
||||
document.querySelector('.attention').style.display = 'none';
|
||||
`;
|
||||
|
||||
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||
const styles = {
|
||||
touch: {
|
||||
position: "absolute",
|
||||
top,
|
||||
right: 10,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||
borderColor: "white",
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
borderRadius: 50,
|
||||
alignContent: "center",
|
||||
alignSelf: "center",
|
||||
alignItems: "center",
|
||||
display: mapSwitch,
|
||||
},
|
||||
text: {
|
||||
textAlign: "center",
|
||||
width: "auto",
|
||||
height: "auto",
|
||||
textAlignVertical: "center",
|
||||
fontWeight: "bold",
|
||||
color: "white",
|
||||
},
|
||||
};
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Ionicons name="reload" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
38
package.json
38
package.json
@@ -8,43 +8,47 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^13.0.0",
|
||||
"@react-native-async-storage/async-storage": "1.17.11",
|
||||
"@react-native-async-storage/async-storage": "1.18.2",
|
||||
"@react-native-community/masked-view": "0.1.10",
|
||||
"@react-navigation/bottom-tabs": "^5.11.11",
|
||||
"@react-navigation/native": "^5.9.4",
|
||||
"@react-navigation/stack": "^5.14.5",
|
||||
"expo": "^48.0.0",
|
||||
"expo-font": "~11.1.1",
|
||||
"expo-location": "~15.1.1",
|
||||
"expo-updates": "~0.16.3",
|
||||
"expo-web-browser": "~12.1.1",
|
||||
"dayjs": "^1.11.9",
|
||||
"eas-cli": "^5.9.1",
|
||||
"expo": "^49.0.21",
|
||||
"expo-device": "~5.4.0",
|
||||
"expo-font": "~11.4.0",
|
||||
"expo-location": "~16.1.0",
|
||||
"expo-notifications": "~0.20.1",
|
||||
"expo-updates": "~0.18.17",
|
||||
"expo-web-browser": "~12.3.2",
|
||||
"firebase": "8.2.3",
|
||||
"lottie-react-native": "5.1.4",
|
||||
"lottie-react-native": "5.1.6",
|
||||
"native-base": "^2.15.2",
|
||||
"npm": "^7.18.1",
|
||||
"pushy-react-native": "^1.0.18",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.71.3",
|
||||
"react-native-actions-sheet": "^0.4.9",
|
||||
"react-native": "0.72.6",
|
||||
"react-native-actions-sheet": "0.8.21",
|
||||
"react-native-auto-height-image": "^3.2.4",
|
||||
"react-native-elements": "^3.4.2",
|
||||
"react-native-gesture-handler": "~2.9.0",
|
||||
"react-native-maps": "1.3.2",
|
||||
"react-native-reanimated": "~2.14.4",
|
||||
"react-native-gesture-handler": "~2.12.0",
|
||||
"react-native-maps": "1.7.1",
|
||||
"react-native-reanimated": "^3.6.1",
|
||||
"react-native-remote-svg": "^2.0.6",
|
||||
"react-native-responsive-screen": "^1.4.2",
|
||||
"react-native-router-flux": "^4.3.1",
|
||||
"react-native-safe-area-context": "4.5.0",
|
||||
"react-native-screens": "~3.20.0",
|
||||
"react-native-safe-area-context": "4.6.3",
|
||||
"react-native-screens": "~3.22.0",
|
||||
"react-native-snap-carousel": "^3.9.1",
|
||||
"react-native-storage": "^1.0.1",
|
||||
"react-native-svg": "13.4.0",
|
||||
"react-native-svg": "13.9.0",
|
||||
"react-native-svg-uri": "^1.2.3",
|
||||
"react-native-vector-icons": "^8.1.0",
|
||||
"react-native-webview": "11.26.0"
|
||||
"react-native-webview": "^13.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-expo": "^9.3.0"
|
||||
"babel-preset-expo": "^9.5.0"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
52
stateBox/useAllTrainDiagram.js
Normal file
52
stateBox/useAllTrainDiagram.js
Normal file
@@ -0,0 +1,52 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
const initialState = {
|
||||
allTrainDiagram: undefined,
|
||||
setAllTrainDiagram: () => {},
|
||||
};
|
||||
|
||||
const AllTrainDiagramContext = createContext(initialState);
|
||||
|
||||
export const useAllTrainDiagram = () => {
|
||||
return useContext(AllTrainDiagramContext);
|
||||
};
|
||||
|
||||
export const AllTrainDiagramProvider = ({ children }) => {
|
||||
const [allTrainDiagram, setAllTrainDiagram] = useState();
|
||||
const customData = {
|
||||
//9001: "岡山,発,10:11#児島,発,11:05#坂出,発,11:41#高松,着,12:00#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9001: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第1章\n-瀬戸の海に想いを馳せながら-\n岡山・高松・琴平,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
//9029: "高松,発,12:42#琴平,着,13:57#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9029: "ウェルカムセレモニー,頃,9:40#岡山,頃,10:10#琴平,頃,14:00#琴平観光,以降,14:00#湯山荘 阿讃琴南,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第1章\n-瀬戸の海に想いを馳せながら-\n岡山・高松・琴平,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
//9003: "多度津,発,10:09#今治,発,13:20#伊予亀岡,発,13:55#菊間,発,14:04#松山,着,14:50#独自補完データ,提,https://x.com/makkun3/status/1750490886293848372#",
|
||||
9003: "湯山荘 阿讃琴南,頃,9:00#多度津,頃,10:10#松山,頃,14:50#宿泊施設,以降,14:50#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第2章\n -四国の伝統文化を感じて-\n多度津・坂出・松山,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9055: "宿泊施設→バス,着,10:30#松山,頃,10:30#今治,頃,14:15#しまなみエリア観光,以降,14:15#Azumi Setoda,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第3章\n-凪の誘い・瀬戸内の絶景-\n今治・しまなみ海道,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9056: "宿泊施設→バス,着,10:30#松山,頃,10:30#今治,頃,14:15#しまなみエリア観光,以降,14:15#Azumi Setoda,頃,16:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS 第3章\n-凪の誘い・瀬戸内の絶景-\n今治・しまなみ海道,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
9004: "Azumi Setoda,頃,9:30#今治,頃,10:30#高松,頃,14:30#高松港\n↓\n瀬戸内クルーズ(貸切)\n「おりんぴあどりーむ せと」\n↓ \n 新岡山港,以降,14:15#岡山駅,頃,18:00#独自補完データ,提,https://www.the-royalexpress.jp/plan/2614/#ROYAL EXPRESS フィナーレ\n-四国・瀬戸内の彩りに囲まれて-\n今治・高松・岡山,提,https://www.the-royalexpress.jp/plan/2614/#",
|
||||
};
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec"
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
const data = {};
|
||||
res.forEach((d) => {
|
||||
const keys = Object.keys(d);
|
||||
data[keys] = d[keys];
|
||||
});
|
||||
return data;
|
||||
})
|
||||
.then((res) => {
|
||||
Object.assign(res, customData);
|
||||
setAllTrainDiagram(res);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AllTrainDiagramContext.Provider
|
||||
value={{ allTrainDiagram, setAllTrainDiagram }}
|
||||
>
|
||||
{children}
|
||||
</AllTrainDiagramContext.Provider>
|
||||
);
|
||||
};
|
21
stateBox/useAreaInfo.js
Normal file
21
stateBox/useAreaInfo.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
const initialState = {
|
||||
areaInfo: "",
|
||||
setAreainfo: () => {},
|
||||
};
|
||||
|
||||
const AreaInfoContext = createContext(initialState);
|
||||
|
||||
export const useAreaInfo = () => {
|
||||
return useContext(AreaInfoContext);
|
||||
};
|
||||
|
||||
export const AreaInfoProvider = ({ children }) => {
|
||||
const [areaInfo, setAreaInfo] = useState("");
|
||||
|
||||
return (
|
||||
<AreaInfoContext.Provider value={{ areaInfo, setAreaInfo }}>
|
||||
{children}
|
||||
</AreaInfoContext.Provider>
|
||||
);
|
||||
};
|
23
stateBox/useBusAndTrainData.js
Normal file
23
stateBox/useBusAndTrainData.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
const initialState = {
|
||||
busAndTrainData: [],
|
||||
setBusAndTrainData: () => {},
|
||||
};
|
||||
|
||||
const BusAndTrainDataContext = createContext(initialState);
|
||||
|
||||
export const useBusAndTrainData = () => {
|
||||
return useContext(BusAndTrainDataContext);
|
||||
};
|
||||
|
||||
export const BusAndTrainDataProvider = ({ children }) => {
|
||||
const [busAndTrainData, setBusAndTrainData] = useState([]);
|
||||
|
||||
return (
|
||||
<BusAndTrainDataContext.Provider
|
||||
value={{ busAndTrainData, setBusAndTrainData }}
|
||||
>
|
||||
{children}
|
||||
</BusAndTrainDataContext.Provider>
|
||||
);
|
||||
};
|
56
stateBox/useCurrentTrain.js
Normal file
56
stateBox/useCurrentTrain.js
Normal file
@@ -0,0 +1,56 @@
|
||||
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);
|
||||
|
||||
export const useCurrentTrain = () => {
|
||||
return useContext(CurrentTrainContext);
|
||||
};
|
||||
|
||||
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={{
|
||||
currentTrain,
|
||||
setCurrentTrain,
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
getCurrentTrain,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</CurrentTrainContext.Provider>
|
||||
);
|
||||
};
|
36
stateBox/useFavoriteStation.js
Normal file
36
stateBox/useFavoriteStation.js
Normal file
@@ -0,0 +1,36 @@
|
||||
import React, {
|
||||
createContext,
|
||||
useContext,
|
||||
useState,
|
||||
useLayoutEffect,
|
||||
} from "react";
|
||||
import { AS } from "../storageControl";
|
||||
const initialState = {
|
||||
favoriteStation: [],
|
||||
setFavoriteStation: () => {},
|
||||
};
|
||||
|
||||
const FavoriteStationContext = createContext(initialState);
|
||||
|
||||
export const useFavoriteStation = () => {
|
||||
return useContext(FavoriteStationContext);
|
||||
};
|
||||
|
||||
export const FavoriteStationProvider = ({ children }) => {
|
||||
const [favoriteStation, setFavoriteStation] = useState([]);
|
||||
useLayoutEffect(() => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setFavoriteStation(returnData);
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
}, []);
|
||||
return (
|
||||
<FavoriteStationContext.Provider
|
||||
value={{ favoriteStation, setFavoriteStation }}
|
||||
>
|
||||
{children}
|
||||
</FavoriteStationContext.Provider>
|
||||
);
|
||||
};
|
45
stateBox/useTrainDelayData.js
Normal file
45
stateBox/useTrainDelayData.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
const initialState = {
|
||||
getTime: new Date(),
|
||||
setGetTime: () => {},
|
||||
loadingDelayData: true,
|
||||
setLoadingDelayData: () => {},
|
||||
delayData: undefined,
|
||||
setDelayData: () => {},
|
||||
};
|
||||
|
||||
const TrainDelayDataContext = createContext(initialState);
|
||||
|
||||
export const useTrainDelayData = () => {
|
||||
return useContext(TrainDelayDataContext);
|
||||
};
|
||||
|
||||
export const TrainDelayDataProvider = ({ children }) => {
|
||||
const [delayData, setDelayData] = useState(undefined);
|
||||
const [getTime, setGetTime] = useState(new Date());
|
||||
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((data) => setDelayData(data !== "" ? data.split("^") : null))
|
||||
.then(() => setGetTime(new Date()))
|
||||
.finally(() => setLoadingDelayData(false));
|
||||
}, [loadingDelayData]);
|
||||
|
||||
return (
|
||||
<TrainDelayDataContext.Provider
|
||||
value={{
|
||||
getTime,
|
||||
setGetTime,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
delayData,
|
||||
setDelayData,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</TrainDelayDataContext.Provider>
|
||||
);
|
||||
};
|
@@ -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} />
|
||||
|
Reference in New Issue
Block a user