Compare commits
61 Commits
feature/ne
...
feature/fi
Author | SHA1 | Date | |
---|---|---|---|
|
58340bb608 | ||
|
32fb402126 | ||
|
44b6a113ff | ||
|
e93fe7095e | ||
|
bb89149876 | ||
|
12f23bef16 | ||
|
f580e319cf | ||
|
7dc72ef433 | ||
|
746c996cba | ||
|
556b04e3b0 | ||
|
67f9b8b698 | ||
|
3ff585a577 | ||
|
f5e4947c3b | ||
|
fae18a6a47 | ||
|
40fb55c8cf | ||
|
1fd2be5ddf | ||
|
e35ab09002 | ||
|
f993577e34 | ||
|
7f8a77d9fa | ||
|
50973db9ce | ||
|
2fbd54eb7f | ||
|
7595dd845a | ||
|
d475b5c8a4 | ||
|
3a45288eee | ||
|
c996b31dad | ||
|
2040d829fe | ||
|
9eaa32a0f2 | ||
|
a17626042a | ||
|
1dc1b9a636 | ||
|
a56dfc7618 | ||
|
178fda07af | ||
|
bf016b1c8b | ||
|
1a1227dfeb | ||
|
29963ab876 | ||
|
a5523d61c3 | ||
|
337179b4c4 | ||
|
052c121179 | ||
|
7321f6d514 | ||
|
ff48198c87 | ||
|
690df1d2bc | ||
|
0251b9fc2f | ||
|
67eed85c22 | ||
|
cb94b545dc | ||
|
1ef8870153 | ||
|
18e046dc33 | ||
|
f64ccfa271 | ||
|
5406d98195 | ||
|
a923ac8b20 | ||
|
03d6f02de5 | ||
|
1ecb9ec046 | ||
|
796464c03a | ||
|
3723b01401 | ||
|
59c60d7791 | ||
|
10ea09cb00 | ||
|
7810b770cc | ||
|
00e0dbab9d | ||
|
923a28e1a5 | ||
|
151edd5fff | ||
|
f7965be3ef | ||
|
32f6fa3b60 | ||
|
5474b3eab2 |
187
App.js
187
App.js
@@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { NavigationContainer } from "@react-navigation/native";
|
import { NavigationContainer } from "@react-navigation/native";
|
||||||
import {
|
import {
|
||||||
createStackNavigator,
|
createStackNavigator,
|
||||||
@@ -8,14 +8,23 @@ import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
|
|||||||
import { AntDesign, Ionicons } from "@expo/vector-icons";
|
import { AntDesign, Ionicons } from "@expo/vector-icons";
|
||||||
import { Platform, UIManager } from "react-native";
|
import { Platform, UIManager } from "react-native";
|
||||||
import { UpdateAsync } from "./UpdateAsync.js";
|
import { UpdateAsync } from "./UpdateAsync.js";
|
||||||
|
import { getStationList2 } from "./lib/getStationList2";
|
||||||
|
import { AS } from "./storageControl";
|
||||||
import Apps from "./Apps";
|
import Apps from "./Apps";
|
||||||
import tndView from "./ndView";
|
import TNDView from "./ndView";
|
||||||
import trainbase from "./trainbaseview";
|
import TrainBase from "./trainbaseview";
|
||||||
import howto from "./howto";
|
import HowTo from "./howto";
|
||||||
import menu from "./menu";
|
import Menu from "./menu";
|
||||||
import News from "./components/news.js";
|
import News from "./components/news.js";
|
||||||
import Setting from "./components/settings.js";
|
import Setting from "./components/settings.js";
|
||||||
import trainMenu from "./components/trainMenu.js";
|
import TrainMenu from "./components/trainMenu.js";
|
||||||
|
import FavoriteList from "./components/FavoriteList.js";
|
||||||
|
import { LogBox } from "react-native";
|
||||||
|
|
||||||
|
LogBox.ignoreLogs([
|
||||||
|
"ViewPropTypes will be removed",
|
||||||
|
"ColorPropType will be removed",
|
||||||
|
]);
|
||||||
const Stack = createStackNavigator();
|
const Stack = createStackNavigator();
|
||||||
const Tab = createBottomTabNavigator();
|
const Tab = createBottomTabNavigator();
|
||||||
if (Platform.OS === "android") {
|
if (Platform.OS === "android") {
|
||||||
@@ -24,96 +33,210 @@ if (Platform.OS === "android") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const navigationRef = useRef();
|
useEffect(() => {
|
||||||
useEffect(UpdateAsync, []);
|
UpdateAsync();
|
||||||
|
}, []);
|
||||||
|
const [favoriteStation, setFavoriteStation] = useState([]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
AS.getItem("favoriteStation")
|
||||||
|
.then((d) => {
|
||||||
|
const returnData = JSON.parse(d);
|
||||||
|
setFavoriteStation(returnData);
|
||||||
|
})
|
||||||
|
.catch((d) => console.log(d));
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationContainer name="Root" ref={navigationRef} style={{ flex: 1 }}>
|
<NavigationContainer name="Root" style={{ flex: 1 }}>
|
||||||
<Tab.Navigator>
|
<Tab.Navigator>
|
||||||
<Stack.Screen
|
<Tab.Screen
|
||||||
name="login"
|
name="login"
|
||||||
component={top}
|
|
||||||
options={{
|
options={{
|
||||||
tabBarLabel: "位置情報",
|
tabBarLabel: "位置情報",
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
tabBarIcon: () => <AntDesign name="barchart" size={32} />,
|
tabBarIcon: initIcon("barchart", "AntDesign"),
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
{(props) => (
|
||||||
|
<Top
|
||||||
|
{...props}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
)}
|
||||||
|
</Tab.Screen>
|
||||||
|
<Tab.Screen
|
||||||
name="menuPage"
|
name="menuPage"
|
||||||
component={menuPage}
|
|
||||||
options={{
|
options={{
|
||||||
tabBarLabel: "リンク",
|
tabBarLabel: "リンク",
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
tabBarIcon: () => <Ionicons name="ios-radio" size={32} />,
|
tabBarIcon: initIcon("ios-radio", "Ionicons"),
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
{(props) => (
|
||||||
|
<MenuPage
|
||||||
|
{...props}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
)}
|
||||||
|
</Tab.Screen>
|
||||||
|
<Tab.Screen
|
||||||
name="home"
|
name="home"
|
||||||
component={tndView}
|
|
||||||
options={{
|
options={{
|
||||||
tabBarLabel: "運行情報",
|
tabBarLabel: "運行情報",
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
tabBarIcon: () => <Ionicons name="md-train" size={32} />,
|
tabBarIcon: initIcon("md-train", "Ionicons"),
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
{(props) => <TNDView {...props} />}
|
||||||
|
</Tab.Screen>
|
||||||
</Tab.Navigator>
|
</Tab.Navigator>
|
||||||
</NavigationContainer>
|
</NavigationContainer>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function top() {
|
|
||||||
|
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 }) => {
|
||||||
|
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 (
|
return (
|
||||||
<Stack.Navigator>
|
<Stack.Navigator>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="Apps"
|
name="Apps"
|
||||||
component={Apps}
|
|
||||||
options={{
|
options={{
|
||||||
headerShown: false,
|
headerShown: false,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
{(props) => (
|
||||||
|
<Apps
|
||||||
|
{...props}
|
||||||
|
webview={webview}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
</Stack.Screen>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="trainbase"
|
name="trainbase"
|
||||||
component={trainbase}
|
|
||||||
options={{
|
options={{
|
||||||
title: "トレインビジョン",
|
title: "トレインビジョン",
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
...TransitionPresets.SlideFromRightIOS,
|
...TransitionPresets.SlideFromRightIOS,
|
||||||
}}
|
}}
|
||||||
/>
|
>
|
||||||
|
{(props) => <TrainBase {...props} />}
|
||||||
|
</Stack.Screen>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="howto"
|
name="howto"
|
||||||
component={howto}
|
|
||||||
options={{
|
options={{
|
||||||
title: "使い方",
|
title: "使い方",
|
||||||
...optionData,
|
...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 name="news" component={News} options={optionData} />
|
)}
|
||||||
|
</Stack.Screen>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="trainMenu"
|
name="favoriteList"
|
||||||
component={trainMenu}
|
options={{ ...optionData, gestureEnabled: false }}
|
||||||
options={optionData}
|
>
|
||||||
|
{(props) => (
|
||||||
|
<FavoriteList
|
||||||
|
{...props}
|
||||||
|
webview={webview}
|
||||||
|
stationData={mapsStationData}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
</Stack.Screen>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
function menuPage() {
|
function MenuPage({ favoriteStation, setFavoriteStation }) {
|
||||||
return (
|
return (
|
||||||
<Stack.Navigator>
|
<Stack.Navigator>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="menu"
|
name="menu"
|
||||||
component={menu}
|
|
||||||
options={{
|
options={{
|
||||||
headerShown: false,
|
headerShown: false,
|
||||||
gestureEnabled: true,
|
gestureEnabled: true,
|
||||||
headerTransparent: true,
|
headerTransparent: true,
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
{(props) => (
|
||||||
|
<Menu
|
||||||
|
{...props}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen name="setting" component={Setting} options={optionData} />
|
)}
|
||||||
|
</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>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
271
Apps.js
271
Apps.js
@@ -8,9 +8,10 @@ import {
|
|||||||
} from "react-native";
|
} from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
import Constants from "expo-constants";
|
import Constants from "expo-constants";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
import { AS } from "./storageControl";
|
||||||
import { news } from "./config/newsUpdate";
|
import { news } from "./config/newsUpdate";
|
||||||
import { getStationList } from "./lib/getStationList";
|
import { getStationList, lineList } from "./lib/getStationList";
|
||||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||||
import { getStationList2 } from "./lib/getStationList2";
|
import { getStationList2 } from "./lib/getStationList2";
|
||||||
@@ -18,32 +19,28 @@ import { getStationList2 } from "./lib/getStationList2";
|
|||||||
import StatusbarDetect from './StatusbarDetect';
|
import StatusbarDetect from './StatusbarDetect';
|
||||||
var Status = StatusbarDetect(); */
|
var Status = StatusbarDetect(); */
|
||||||
|
|
||||||
export default function Apps(props) {
|
export default function Apps({
|
||||||
const {
|
navigation,
|
||||||
navigation: { navigate },
|
webview,
|
||||||
} = props;
|
favoriteStation,
|
||||||
|
setFavoriteStation,
|
||||||
|
}) {
|
||||||
|
const { navigate } = navigation;
|
||||||
var urlcache = "";
|
var urlcache = "";
|
||||||
const webview = useRef();
|
|
||||||
//画面表示関連
|
//画面表示関連
|
||||||
const [iconSetting, setIconSetting] = useState(undefined);
|
const [iconSetting, setIconSetting] = useState(undefined);
|
||||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||||
const [stationMenu, setStationMenu] = useState(undefined);
|
const [stationMenu, setStationMenu] = useState(undefined);
|
||||||
|
|
||||||
//地図用
|
|
||||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
|
||||||
useEffect(() => {
|
|
||||||
getStationList2().then((data) => {
|
|
||||||
console.log(data);
|
|
||||||
setMapsStationData(data);
|
|
||||||
});
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
//駅情報画面用
|
//駅情報画面用
|
||||||
const StationBoardAcSR = useRef(null);
|
const StationBoardAcSR = useRef(null);
|
||||||
const [stationBoardData, setStationBoardData] = useState(undefined);
|
const [stationBoardData, setStationBoardData] = useState(undefined);
|
||||||
const [originalStationList, setOriginalStationList] = useState();
|
const [originalStationList, setOriginalStationList] = useState();
|
||||||
const [selectedStation, setSelectedStation] = useState(undefined);
|
const [selectedStation, setSelectedStation] = useState(undefined);
|
||||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
useEffect(() => {
|
||||||
|
getStationList().then(setOriginalStationList);
|
||||||
|
}, []);
|
||||||
|
|
||||||
//地図表示テキスト
|
//地図表示テキスト
|
||||||
const injectJavascript = injectJavascriptData(
|
const injectJavascript = injectJavascriptData(
|
||||||
@@ -54,110 +51,63 @@ export default function Apps(props) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//ニュース表示
|
//ニュース表示
|
||||||
AsyncStorage.getItem("status")
|
AS.getItem("status")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d != news) navigate("news");
|
if (d != news) navigate("news");
|
||||||
})
|
})
|
||||||
.catch((e) => navigate("news"));
|
.catch((e) => navigate("news"));
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
//列車アイコンスイッチ
|
//列車アイコンスイッチ
|
||||||
AsyncStorage.getItem("iconSwitch")
|
AS.getItem("iconSwitch")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
setIconSetting(d);
|
setIconSetting(d);
|
||||||
} else {
|
} else {
|
||||||
AsyncStorage.setItem("iconSwitch", "true").then(() =>
|
AS.setItem("iconSwitch", "true").then(Updates.reloadAsync);
|
||||||
Updates.reloadAsync()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((d) =>
|
.catch((d) => AS.setItem("iconSwitch", "true").then(Updates.reloadAsync));
|
||||||
AsyncStorage.setItem("iconSwitch", "true").then(() =>
|
}, []);
|
||||||
Updates.reloadAsync()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
//地図スイッチ
|
//地図スイッチ
|
||||||
AsyncStorage.getItem("mapSwitch")
|
AS.getItem("mapSwitch")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
setMapSwitch(d);
|
setMapSwitch(d);
|
||||||
} else {
|
} else {
|
||||||
AsyncStorage.setItem("mapSwitch", "false").then(() =>
|
AS.setItem("mapSwitch", "false").then(Updates.reloadAsync);
|
||||||
Updates.reloadAsync()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((d) =>
|
.catch((d) => AS.setItem("mapSwitch", "false").then(Updates.reloadAsync));
|
||||||
AsyncStorage.setItem("mapSwitch", "false").then(() =>
|
}, []);
|
||||||
Updates.reloadAsync()
|
|
||||||
)
|
useEffect(() => {
|
||||||
);
|
|
||||||
//駅メニュースイッチ
|
//駅メニュースイッチ
|
||||||
AsyncStorage.getItem("stationSwitch")
|
AS.getItem("stationSwitch")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
setStationMenu(d);
|
setStationMenu(d);
|
||||||
} else {
|
} else {
|
||||||
AsyncStorage.setItem("stationSwitch", "true").then(() =>
|
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync);
|
||||||
Updates.reloadAsync()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((d) =>
|
.catch((d) =>
|
||||||
AsyncStorage.setItem("stationSwitch", "true").then(() =>
|
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync)
|
||||||
Updates.reloadAsync()
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
const onMessage = (event) => {
|
||||||
<View
|
if (!event.nativeEvent.data.includes("PopUpMenu")) {
|
||||||
style={{
|
navigate("trainbase", { info: event.nativeEvent.data, from: "Train" });
|
||||||
height: "100%",
|
return;
|
||||||
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* {Status} */}
|
|
||||||
<WebView
|
|
||||||
useWebKit={true}
|
|
||||||
ref={webview}
|
|
||||||
source={{ uri: "https://train.jr-shikoku.co.jp/sp.html" }}
|
|
||||||
originWhitelist={[
|
|
||||||
"https://train.jr-shikoku.co.jp",
|
|
||||||
"https://train.jr-shikoku.co.jp/sp.html",
|
|
||||||
]}
|
|
||||||
mixedContentMode={"compatibility"}
|
|
||||||
javaScriptEnabled={true}
|
|
||||||
allowsBackForwardNavigationGestures={true}
|
|
||||||
setSupportMultipleWindows={true}
|
|
||||||
onNavigationStateChange={(event) => {
|
|
||||||
if (event.url != urlcache) {
|
|
||||||
//URL二重判定回避
|
|
||||||
urlcache = event.url;
|
|
||||||
|
|
||||||
if (
|
|
||||||
event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")
|
|
||||||
) {
|
|
||||||
if (Platform.OS === "android") navigate("howto");
|
|
||||||
webview?.current.goBack();
|
|
||||||
//Actions.howto();
|
|
||||||
} else if (
|
|
||||||
event.url.includes("https://train.jr-shikoku.co.jp/train.html")
|
|
||||||
) {
|
|
||||||
//Actions.trainbase({info: event.url});
|
|
||||||
if (Platform.OS === "android")
|
|
||||||
navigate("trainbase", { info: event.url });
|
|
||||||
webview?.current.goBack();
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}}
|
|
||||||
onMessage={(event) => {
|
|
||||||
if (!originalStationList) {
|
if (!originalStationList) {
|
||||||
alert("駅名標データを取得中...");
|
alert("駅名標データを取得中...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.nativeEvent.data.includes("PopUpMenu")) {
|
|
||||||
const selectedStationPDFAddress = event.nativeEvent.data
|
const selectedStationPDFAddress = event.nativeEvent.data
|
||||||
.split(",")[3]
|
.split(",")[3]
|
||||||
.replace("'", "")
|
.replace("'", "")
|
||||||
@@ -170,17 +120,6 @@ export default function Apps(props) {
|
|||||||
return NearStation;
|
return NearStation;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lineList = [
|
|
||||||
"予讃線",
|
|
||||||
"松宇線",
|
|
||||||
"伊予灘線",
|
|
||||||
"土讃線",
|
|
||||||
"窪川線",
|
|
||||||
"高徳線",
|
|
||||||
"徳島線",
|
|
||||||
"鳴門線",
|
|
||||||
"瀬戸大橋線",
|
|
||||||
];
|
|
||||||
let returnDataBase = lineList
|
let returnDataBase = lineList
|
||||||
.map((d) => findStationEachLine(originalStationList[d]))
|
.map((d) => findStationEachLine(originalStationList[d]))
|
||||||
.filter((d) => d.length > 0)
|
.filter((d) => d.length > 0)
|
||||||
@@ -189,8 +128,6 @@ export default function Apps(props) {
|
|||||||
return pre;
|
return pre;
|
||||||
}, []);
|
}, []);
|
||||||
if (returnDataBase.length) {
|
if (returnDataBase.length) {
|
||||||
let currentStation =
|
|
||||||
currentStation == undefined ? [] : currentStation;
|
|
||||||
setStationBoardData(returnDataBase);
|
setStationBoardData(returnDataBase);
|
||||||
StationBoardAcSR.current?.setModalVisible();
|
StationBoardAcSR.current?.setModalVisible();
|
||||||
} else {
|
} else {
|
||||||
@@ -199,19 +136,79 @@ export default function Apps(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
const onNavigationStateChange = (event) => {
|
||||||
|
if (event.url != urlcache) {
|
||||||
|
//URL二重判定回避
|
||||||
|
urlcache = event.url;
|
||||||
|
|
||||||
|
if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) {
|
||||||
|
if (Platform.OS === "android") navigate("howto");
|
||||||
|
webview?.current.goBack();
|
||||||
|
//Actions.howto();
|
||||||
|
} else if (
|
||||||
|
event.url.includes("https://train.jr-shikoku.co.jp/train.html")
|
||||||
|
) {
|
||||||
|
//Actions.trainbase({info: event.url});
|
||||||
|
if (Platform.OS === "android")
|
||||||
|
navigate("trainbase", { info: event.url });
|
||||||
|
webview?.current.goBack();
|
||||||
}
|
}
|
||||||
navigate("trainbase", { info: event.nativeEvent.data });
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
height: "100%",
|
||||||
|
paddingTop: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
||||||
}}
|
}}
|
||||||
|
>
|
||||||
|
{/* {Status} */}
|
||||||
|
<WebView
|
||||||
|
useWebKit
|
||||||
|
ref={webview}
|
||||||
|
source={{ uri: "https://train.jr-shikoku.co.jp/sp.html" }}
|
||||||
|
originWhitelist={[
|
||||||
|
"https://train.jr-shikoku.co.jp",
|
||||||
|
"https://train.jr-shikoku.co.jp/sp.html",
|
||||||
|
]}
|
||||||
|
mixedContentMode={"compatibility"}
|
||||||
|
javaScriptEnabled
|
||||||
|
allowsBackForwardNavigationGestures
|
||||||
|
setSupportMultipleWindows
|
||||||
|
onNavigationStateChange={onNavigationStateChange}
|
||||||
|
onMessage={onMessage}
|
||||||
injectedJavaScript={injectJavascript}
|
injectedJavaScript={injectJavascript}
|
||||||
onTouchMove={() => StationBoardAcSR.current?.hide()}
|
onTouchMove={() => StationBoardAcSR.current?.hide()}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<MapsButton
|
||||||
onPress={() =>
|
onPress={() => navigate("trainMenu", { webview })}
|
||||||
navigate("trainMenu", { webview, stationData: mapsStationData })
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
}
|
mapSwitch={mapSwitch == "true" ? "flex" : "none"}
|
||||||
style={{
|
/>
|
||||||
|
<ReloadButton
|
||||||
|
onPress={() => webview.current.reload()}
|
||||||
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<StationDeteilView
|
||||||
|
StationBoardAcSR={StationBoardAcSR}
|
||||||
|
currentStation={stationBoardData}
|
||||||
|
originalStationList={originalStationList}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const MapsButton = ({ onPress, top, mapSwitch }) => {
|
||||||
|
const styles = {
|
||||||
|
touch: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
top,
|
||||||
left: 10,
|
left: 10,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
@@ -223,30 +220,58 @@ export default function Apps(props) {
|
|||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
alignSelf: "center",
|
alignSelf: "center",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
display: mapSwitch == "true" ? "flex" : "none",
|
display: mapSwitch,
|
||||||
}}
|
},
|
||||||
>
|
text: {
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
textAlign: "center",
|
textAlign: "center",
|
||||||
width: "auto",
|
width: "auto",
|
||||||
height: "auto",
|
height: "auto",
|
||||||
textAlignVertical: "center",
|
textAlignVertical: "center",
|
||||||
fontWeight: "bold",
|
fontWeight: "bold",
|
||||||
color: "white",
|
color: "white",
|
||||||
}}
|
},
|
||||||
>
|
};
|
||||||
三
|
return (
|
||||||
</Text>
|
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={styles.text}>三</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
<StationDeteilView
|
|
||||||
StationBoardAcSR={StationBoardAcSR}
|
|
||||||
currentStation={stationBoardData}
|
|
||||||
originalStationList={originalStationList}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||||
|
const styles = {
|
||||||
|
touch: {
|
||||||
|
position: "absolute",
|
||||||
|
top,
|
||||||
|
right: 10,
|
||||||
|
width: 50,
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: "#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>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
import { ToastAndroid } from "react-native";
|
import { ToastAndroid } from "react-native";
|
||||||
import * as Updates from "expo-updates";
|
import * as Updates from "expo-updates";
|
||||||
|
|
||||||
export const UpdateAsync = () =>
|
export const UpdateAsync = () => {
|
||||||
Updates.checkForUpdateAsync()
|
Updates.checkForUpdateAsync()
|
||||||
.then((update) => {
|
.then((update) => {
|
||||||
if (!update.isAvailable) return;
|
if (!update.isAvailable) return;
|
||||||
@@ -34,3 +34,4 @@ export const UpdateAsync = () =>
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
4
app.json
4
app.json
@@ -4,7 +4,7 @@
|
|||||||
"slug": "jrshikoku",
|
"slug": "jrshikoku",
|
||||||
"privacy": "public",
|
"privacy": "public",
|
||||||
"platforms": ["ios", "android"],
|
"platforms": ["ios", "android"],
|
||||||
"version": "4.4",
|
"version": "4.5",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"icon": "./assets/icon.png",
|
"icon": "./assets/icon.png",
|
||||||
"splash": {
|
"splash": {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
},
|
},
|
||||||
"assetBundlePatterns": ["**/*"],
|
"assetBundlePatterns": ["**/*"],
|
||||||
"ios": {
|
"ios": {
|
||||||
"buildNumber": "22",
|
"buildNumber": "23",
|
||||||
"supportsTablet": true,
|
"supportsTablet": true,
|
||||||
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn",
|
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn",
|
||||||
"config": {
|
"config": {
|
||||||
|
1
assets/939-star.json
Normal file
1
assets/939-star.json
Normal file
File diff suppressed because one or more lines are too long
1049
assets/originData/trainList.js
Normal file
1049
assets/originData/trainList.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,5 @@
|
|||||||
import React, { Component, useRef, useState, useEffect } from "react";
|
import React from "react";
|
||||||
import {
|
import {
|
||||||
StatusBar,
|
|
||||||
Platform,
|
|
||||||
View,
|
View,
|
||||||
LayoutAnimation,
|
LayoutAnimation,
|
||||||
ScrollView,
|
ScrollView,
|
||||||
@@ -9,30 +7,9 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import Image from "react-native-remote-svg";
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import Constants from "expo-constants";
|
|
||||||
import { List, ListItem } from "native-base";
|
|
||||||
import Icon from "react-native-vector-icons/Entypo";
|
|
||||||
import * as Location from "expo-location";
|
|
||||||
import StatusbarDetect from "../../StatusbarDetect";
|
|
||||||
var Status = StatusbarDetect();
|
|
||||||
import { useNavigation } from "@react-navigation/native";
|
|
||||||
import AutoHeightImage from "react-native-auto-height-image";
|
|
||||||
import {
|
|
||||||
widthPercentageToDP as wp,
|
|
||||||
heightPercentageToDP as hp,
|
|
||||||
} from "react-native-responsive-screen";
|
|
||||||
import {
|
|
||||||
FontAwesome,
|
|
||||||
Fontisto,
|
|
||||||
Foundation,
|
|
||||||
Ionicons,
|
|
||||||
MaterialCommunityIcons,
|
|
||||||
} from "@expo/vector-icons";
|
|
||||||
import * as WebBrowser from "expo-web-browser";
|
|
||||||
import ActionSheet from "react-native-actions-sheet";
|
import ActionSheet from "react-native-actions-sheet";
|
||||||
import LottieView from "lottie-react-native";
|
import LottieView from "lottie-react-native";
|
||||||
import SvgUri from "react-native-svg-uri";
|
|
||||||
export const JRSTraInfo = (props) => {
|
export const JRSTraInfo = (props) => {
|
||||||
const {
|
const {
|
||||||
JRSTraInfoEXAcSR,
|
JRSTraInfoEXAcSR,
|
||||||
@@ -45,7 +22,7 @@ export const JRSTraInfo = (props) => {
|
|||||||
<ActionSheet
|
<ActionSheet
|
||||||
ref={JRSTraInfoEXAcSR}
|
ref={JRSTraInfoEXAcSR}
|
||||||
gestureEnabled
|
gestureEnabled
|
||||||
CustomHeaderComponent={() => { }}
|
CustomHeaderComponent={<></>}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -116,7 +93,7 @@ export const JRSTraInfo = (props) => {
|
|||||||
delayData.map((d) => {
|
delayData.map((d) => {
|
||||||
let data = d.split(" ");
|
let data = d.split(" ");
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: "row" }}>
|
<View style={{ flexDirection: "row" }} key={data[1]}>
|
||||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||||
{data[0].replace("\n", "")}
|
{data[0].replace("\n", "")}
|
||||||
</Text>
|
</Text>
|
||||||
|
@@ -1,21 +1,29 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { View, ScrollView, Linking } from "react-native";
|
import { View, Linking } from "react-native";
|
||||||
import StatusbarDetect from "../../StatusbarDetect";
|
|
||||||
var Status = StatusbarDetect();
|
|
||||||
import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons";
|
import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons";
|
||||||
import ActionSheet from "react-native-actions-sheet";
|
import ActionSheet from "react-native-actions-sheet";
|
||||||
import Sign from "../../components/駅名表/Sign";
|
import Sign from "../../components/駅名表/Sign";
|
||||||
|
|
||||||
import { TicketBox } from "../atom/TicketBox";
|
import { TicketBox } from "../atom/TicketBox";
|
||||||
|
import {
|
||||||
|
widthPercentageToDP as wp,
|
||||||
|
heightPercentageToDP as hp,
|
||||||
|
} from "react-native-responsive-screen";
|
||||||
|
|
||||||
export const StationDeteilView = (props) => {
|
export const StationDeteilView = (props) => {
|
||||||
const { StationBoardAcSR, currentStation, originalStationList } = props;
|
const {
|
||||||
|
StationBoardAcSR,
|
||||||
|
currentStation,
|
||||||
|
originalStationList,
|
||||||
|
favoriteStation,
|
||||||
|
setFavoriteStation,
|
||||||
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ActionSheet
|
<ActionSheet
|
||||||
ref={StationBoardAcSR}
|
ref={StationBoardAcSR}
|
||||||
gestureEnabled
|
gestureEnabled
|
||||||
CustomHeaderComponent={() => {}}
|
CustomHeaderComponent={<></>}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
key={currentStation}
|
key={currentStation}
|
||||||
@@ -40,11 +48,20 @@ export const StationDeteilView = (props) => {
|
|||||||
</View>
|
</View>
|
||||||
<View>
|
<View>
|
||||||
{currentStation && (
|
{currentStation && (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
margin: 10,
|
||||||
|
marginHorizontal: wp("10%"),
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Sign
|
<Sign
|
||||||
currentStation={currentStation}
|
currentStation={currentStation}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
oP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
oP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
||||||
/>
|
/>
|
||||||
|
</View>
|
||||||
)}
|
)}
|
||||||
{currentStation && (
|
{currentStation && (
|
||||||
<View style={{ flexDirection: "row" }}>
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
112
components/FavoriteList.js
Normal file
112
components/FavoriteList.js
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
import React, { Component, useRef, useState, useEffect } 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,
|
||||||
|
}) {
|
||||||
|
const { navigate } = navigation;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
textAlign: "center",
|
||||||
|
fontSize: 25,
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
paddingVertical: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
位置情報クイック移動メニュー
|
||||||
|
</Text>
|
||||||
|
<ScrollView style={{ height: "100%", backgroundColor: "white" }}>
|
||||||
|
{favoriteStation
|
||||||
|
.filter((d) => d[0].StationMap)
|
||||||
|
.map((currentStation) => {
|
||||||
|
console.log(currentStation);
|
||||||
|
return (
|
||||||
|
<ListItem
|
||||||
|
onPress={() => {
|
||||||
|
const getStationLine = (now) => {
|
||||||
|
const returnData = Object.keys(stationData).filter((d) => {
|
||||||
|
const cache = stationData[d].findIndex(
|
||||||
|
(data) => data.Station_JP == now.Station_JP
|
||||||
|
);
|
||||||
|
return cache != -1;
|
||||||
|
});
|
||||||
|
return returnData[0];
|
||||||
|
};
|
||||||
|
const lineName = getStationLine(currentStation[0]);
|
||||||
|
|
||||||
|
webview.current?.injectJavaScript(
|
||||||
|
`MoveDisplayStation('${lineName}_${currentStation[0].MyStation}_${currentStation[0].Station_JP}')`
|
||||||
|
);
|
||||||
|
navigate("Apps");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 20, flex: 2 }}>
|
||||||
|
{currentStation
|
||||||
|
.map((d) => d.StationNumber)
|
||||||
|
.filter((d) => d !== null)
|
||||||
|
.join("/")}
|
||||||
|
</Text>
|
||||||
|
<Text style={{ fontSize: 20, flex: 3 }}>
|
||||||
|
{currentStation[0].Station_JP}
|
||||||
|
</Text>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 2,
|
||||||
|
flexDirection: "row",
|
||||||
|
alignContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ fontSize: 20 }}>移動する</Text>
|
||||||
|
<Icon name="chevron-right" size={20} />
|
||||||
|
</View>
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ScrollView>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
backgroundColor: "white",
|
||||||
|
borderWidth: 1,
|
||||||
|
borderStyle: "solid",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
お気に入り登録した駅のうち、位置情報システムで移動可能な駅が表示されています。タップすることで位置情報システムの当該の駅に移動します。
|
||||||
|
</Text>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "white",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
onPress={() => navigation.goBack()}
|
||||||
|
>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||||
|
閉じる
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
@@ -2,7 +2,7 @@ import React from "react";
|
|||||||
import { View, Text, TouchableOpacity } from "react-native";
|
import { View, Text, TouchableOpacity } from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
import StatusbarDetect from "../StatusbarDetect";
|
import StatusbarDetect from "../StatusbarDetect";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import { AS } from "../storageControl";
|
||||||
import { news } from "../config/newsUpdate";
|
import { news } from "../config/newsUpdate";
|
||||||
var Status = StatusbarDetect();
|
var Status = StatusbarDetect();
|
||||||
export default function News(props) {
|
export default function News(props) {
|
||||||
@@ -30,7 +30,7 @@ export default function News(props) {
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
AsyncStorage.setItem("status", news);
|
AS.setItem("status", news);
|
||||||
navigate("Apps");
|
navigate("Apps");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
@@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import { View, Text, TouchableOpacity } from "react-native";
|
import { View, Text, TouchableOpacity } from "react-native";
|
||||||
import * as Updates from "expo-updates";
|
import * as Updates from "expo-updates";
|
||||||
import StatusbarDetect from "../StatusbarDetect";
|
import StatusbarDetect from "../StatusbarDetect";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
import { AS } from "../storageControl";
|
||||||
var Status = StatusbarDetect();
|
var Status = StatusbarDetect();
|
||||||
import { Switch } from "react-native-elements";
|
import { Switch } from "react-native-elements";
|
||||||
|
|
||||||
@@ -14,9 +14,9 @@ export default function Setting(props) {
|
|||||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||||
const [stationMenu, setStationMenu] = useState(undefined);
|
const [stationMenu, setStationMenu] = useState(undefined);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
AsyncStorage.getItem("iconSwitch").then(setIconSetting);
|
AS.getItem("iconSwitch").then(setIconSetting);
|
||||||
AsyncStorage.getItem("mapSwitch").then(setMapSwitch);
|
AS.getItem("mapSwitch").then(setMapSwitch);
|
||||||
AsyncStorage.getItem("stationSwitch").then(setStationMenu);
|
AS.getItem("stationSwitch").then(setStationMenu);
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||||
@@ -102,7 +102,7 @@ export default function Setting(props) {
|
|||||||
textAlignVertical: "center",
|
textAlignVertical: "center",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
内部バージョン: 4.4.2.3
|
内部バージョン: 4.5 beta-1
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
</View>
|
</View>
|
||||||
@@ -134,9 +134,9 @@ export default function Setting(props) {
|
|||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
AsyncStorage.setItem("iconSwitch", iconSetting.toString()),
|
AS.setItem("iconSwitch", iconSetting.toString()),
|
||||||
AsyncStorage.setItem("mapSwitch", mapSwitch.toString()),
|
AS.setItem("mapSwitch", mapSwitch.toString()),
|
||||||
AsyncStorage.setItem("stationSwitch", stationMenu.toString()),
|
AS.setItem("stationSwitch", stationMenu.toString()),
|
||||||
]).then(() => {
|
]).then(() => {
|
||||||
Updates.reloadAsync();
|
Updates.reloadAsync();
|
||||||
});
|
});
|
||||||
|
@@ -1,22 +1,11 @@
|
|||||||
import React, { useState, useEffect, useRef } from "react";
|
import React, { useRef } from "react";
|
||||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import MapView, { Marker } from "react-native-maps";
|
||||||
import StatusbarDetect from "../StatusbarDetect";
|
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
export default function TrainMenu({
|
||||||
import MapView, { Marker, Geojson, PROVIDER_GOOGLE } from "react-native-maps";
|
|
||||||
import {
|
|
||||||
FontAwesome,
|
|
||||||
Fontisto,
|
|
||||||
Foundation,
|
|
||||||
Ionicons,
|
|
||||||
MaterialCommunityIcons,
|
|
||||||
} from "@expo/vector-icons";
|
|
||||||
var Status = StatusbarDetect();
|
|
||||||
export default function trainMenu({
|
|
||||||
route: {
|
|
||||||
params: { webview, stationData },
|
|
||||||
},
|
|
||||||
navigation: { navigate },
|
navigation: { navigate },
|
||||||
|
webview,
|
||||||
|
stationData,
|
||||||
}) {
|
}) {
|
||||||
const mapRef = useRef();
|
const mapRef = useRef();
|
||||||
return (
|
return (
|
||||||
@@ -54,7 +43,6 @@ export default function trainMenu({
|
|||||||
longitude: parseFloat(latlng[1]),
|
longitude: parseFloat(latlng[1]),
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log(stationData);
|
|
||||||
webview.current?.injectJavaScript(
|
webview.current?.injectJavaScript(
|
||||||
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}')`
|
`MoveDisplayStation('${d}_${D.MyStation}_${D.Station_JP}')`
|
||||||
);
|
);
|
||||||
@@ -78,12 +66,7 @@ export default function trainMenu({
|
|||||||
backgroundColor={"#EA4752"}
|
backgroundColor={"#EA4752"}
|
||||||
icon="star"
|
icon="star"
|
||||||
flex={1}
|
flex={1}
|
||||||
onPressButton={() =>
|
onPressButton={() => navigate("favoriteList")}
|
||||||
/* Linking.openURL(
|
|
||||||
"https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box"
|
|
||||||
) */
|
|
||||||
alert("お気に入り駅登録機能は現在開発中です!レイアウト募集中!")
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
お気に入り
|
お気に入り
|
||||||
</UsefulBox>
|
</UsefulBox>
|
||||||
@@ -110,10 +93,7 @@ export default function trainMenu({
|
|||||||
borderRadius: 5,
|
borderRadius: 5,
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
}}
|
}}
|
||||||
onPress={() => {
|
onPress={() => navigate("Apps")}
|
||||||
AsyncStorage.setItem("status", "2022/04/14");
|
|
||||||
navigate("Apps");
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||||
|
@@ -1,20 +1,13 @@
|
|||||||
import React, { Component, useRef, useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import {
|
import { View, Text, TouchableOpacity } from "react-native";
|
||||||
StatusBar,
|
|
||||||
View,
|
|
||||||
LayoutAnimation,
|
|
||||||
ScrollView,
|
|
||||||
Linking,
|
|
||||||
Text,
|
|
||||||
TouchableOpacity,
|
|
||||||
} from "react-native";
|
|
||||||
import { Switch } from "react-native-elements";
|
import { Switch } from "react-native-elements";
|
||||||
import {
|
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||||
widthPercentageToDP as wp,
|
import LottieView from "lottie-react-native";
|
||||||
heightPercentageToDP as hp,
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
} from "react-native-responsive-screen";
|
|
||||||
import { customTrainDataDetector } from "../custom-train-data";
|
import { customTrainDataDetector } from "../custom-train-data";
|
||||||
import { useInterval } from "../../lib/useInterval";
|
import { useInterval } from "../../lib/useInterval";
|
||||||
|
import trainList from "../../assets/originData/trainList";
|
||||||
|
import { objectIsEmpty } from "../../lib/objectIsEmpty";
|
||||||
|
|
||||||
let diagramData = undefined;
|
let diagramData = undefined;
|
||||||
|
|
||||||
@@ -53,21 +46,16 @@ export default function LED_vision(props) {
|
|||||||
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
referer: "https://train.jr-shikoku.co.jp/sp.html",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const [trainDiagram, setTrainDiagram] = useState(null);
|
const [trainDiagram, setTrainDiagram] = useState(null); // 全列車のダイヤを列番ベースで整理
|
||||||
const [stationDiagram, setStationDiagram] = useState(null);
|
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
|
||||||
const [currentTrain, setCurrentTrain] = useState(null);
|
const [currentTrain, setCurrentTrain] = useState(null); //現在在線中の全列車
|
||||||
|
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading");
|
||||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
const parseAllTrainDiagram = (text) => {
|
||||||
fetch(
|
const val = text.replace("[\r\n", "").split(",\r\n");
|
||||||
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=traintimeinfo&arg3=dia",
|
|
||||||
HeaderConfig
|
|
||||||
)
|
|
||||||
.then((response) => response.text())
|
|
||||||
.then((d) => {
|
|
||||||
const val = d.replace("[\r\n", "").split(",\r\n");
|
|
||||||
let trainDiagram = {};
|
let trainDiagram = {};
|
||||||
val.forEach((element) => {
|
val.forEach((element) => {
|
||||||
try {
|
try {
|
||||||
@@ -75,33 +63,71 @@ export default function LED_vision(props) {
|
|||||||
Object.keys(data).forEach((key) => (trainDiagram[key] = data[key]));
|
Object.keys(data).forEach((key) => (trainDiagram[key] = data[key]));
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
});
|
});
|
||||||
setTrainDiagram(trainDiagram);
|
|
||||||
return trainDiagram;
|
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));
|
||||||
})
|
})
|
||||||
.then((trainDiagram) => {
|
.catch((d) => {
|
||||||
let returnData = {};
|
console.log("fallback");
|
||||||
|
setTrainDiagram(trainList);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報]
|
||||||
if (!trainDiagram) {
|
if (!trainDiagram) {
|
||||||
setStationDiagram(returnData);
|
setStationDiagram({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let returnData = {};
|
||||||
Object.keys(trainDiagram).forEach((key) => {
|
Object.keys(trainDiagram).forEach((key) => {
|
||||||
if (trainDiagram[key].match(props.station.Station_JP)) {
|
if (trainDiagram[key].match(props.station.Station_JP + ",")) {
|
||||||
returnData[key] = trainDiagram[key];
|
returnData[key] = trainDiagram[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setStationDiagram(returnData);
|
setStationDiagram(returnData);
|
||||||
});
|
}, [trainDiagram, props.station]);
|
||||||
}, []);
|
|
||||||
|
|
||||||
const getTime = () => {
|
const getCurrentTrain = () =>
|
||||||
const returnData = [];
|
fetch(
|
||||||
Object.keys(stationDiagram).forEach((d) => {
|
"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");
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(getCurrentTrain, []); //初回だけ現在の全在線列車取得
|
||||||
|
|
||||||
|
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
||||||
|
|
||||||
|
const getTime = (stationDiagram, station) => {
|
||||||
|
const returnData = Object.keys(stationDiagram).map((d) => {
|
||||||
let a = {};
|
let a = {};
|
||||||
stationDiagram[d].split("#").forEach((data) => {
|
stationDiagram[d].split("#").forEach((data) => {
|
||||||
if (data.match("着")) {
|
if (data.match("着")) {
|
||||||
a.lastStation = data.split(",着,")[0];
|
a.lastStation = data.split(",着,")[0];
|
||||||
}
|
}
|
||||||
if (data.match(props.station.Station_JP)) {
|
if (data.split(",")[0] === station.Station_JP) {
|
||||||
if (data.match(",発,")) {
|
if (data.match(",発,")) {
|
||||||
a.time = data.split(",発,")[1];
|
a.time = data.split(",発,")[1];
|
||||||
} else {
|
} else {
|
||||||
@@ -110,9 +136,9 @@ export default function LED_vision(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
returnData.push({ train: d, time: a.time, lastStation: a.lastStation });
|
return { train: d, time: a.time, lastStation: a.lastStation };
|
||||||
});
|
});
|
||||||
|
console.log(returnData);
|
||||||
return returnData.sort((a, b) => {
|
return returnData.sort((a, b) => {
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
case parseInt(a.time.split(":")[0]) < parseInt(b.time.split(":")[0]):
|
||||||
@@ -126,19 +152,15 @@ export default function LED_vision(props) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
const trainTimeAndNumber = stationDiagram != null ? getTime() : null;
|
|
||||||
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 })))
|
|
||||||
.then(setCurrentTrain);
|
|
||||||
|
|
||||||
useEffect(getCurrentTrain, []);
|
const [trainTimeAndNumber, setTrainTimeAndNumber] = useState(null);
|
||||||
|
|
||||||
useInterval(getCurrentTrain, 15000);
|
useEffect(() => {
|
||||||
|
//現在の駅に停車する列車から時刻を切り出してLEDベースにフォーマット
|
||||||
|
if (objectIsEmpty(stationDiagram)) return () => {};
|
||||||
|
const getTimeData = getTime(stationDiagram, props.station);
|
||||||
|
setTrainTimeAndNumber(getTimeData);
|
||||||
|
}, [stationDiagram]);
|
||||||
|
|
||||||
const timeFiltering = (d) => {
|
const timeFiltering = (d) => {
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
@@ -156,6 +178,17 @@ export default function LED_vision(props) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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]);
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
@@ -166,6 +199,38 @@ export default function LED_vision(props) {
|
|||||||
marginHorizontal: wp("1%"),
|
marginHorizontal: wp("1%"),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<Header
|
||||||
|
currentTrainLoading={currentTrainLoading}
|
||||||
|
setCurrentTrainLoading={setCurrentTrainLoading}
|
||||||
|
getCurrentTrain={getCurrentTrain}
|
||||||
|
/>
|
||||||
|
{selectedTrain.map((d, index) => (
|
||||||
|
<EachData
|
||||||
|
d={d}
|
||||||
|
trainIDSwitch={trainIDSwitch}
|
||||||
|
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||||
|
props={props}
|
||||||
|
currentTrain={currentTrain}
|
||||||
|
customTrainDataDetector={customTrainDataDetector}
|
||||||
|
navigate={props.navigate}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<Footer
|
||||||
|
trainIDSwitch={trainIDSwitch}
|
||||||
|
setTrainIDSwitch={setTrainIDSwitch}
|
||||||
|
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||||
|
setTrainDescriptionSwitch={setTrainDescriptionSwitch}
|
||||||
|
finalSwitch={finalSwitch}
|
||||||
|
setFinalSwitch={setFinalSwitch}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const Header = ({
|
||||||
|
currentTrainLoading,
|
||||||
|
setCurrentTrainLoading,
|
||||||
|
getCurrentTrain,
|
||||||
|
}) => (
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
alignContent: "center",
|
alignContent: "center",
|
||||||
@@ -182,147 +247,39 @@ export default function LED_vision(props) {
|
|||||||
</Text>
|
</Text>
|
||||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1 }}></View>
|
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||||
</View>
|
{currentTrainLoading == "loading" ? (
|
||||||
{trainTimeAndNumber
|
<LottieView
|
||||||
? currentTrain &&
|
autoPlay
|
||||||
trainTimeAndNumber
|
loop
|
||||||
.filter((d) => currentTrain.map((m) => m.num).includes(d.train))
|
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||||
.filter(timeFiltering)
|
source={require("../../assets/51690-loading-diamonds.json")}
|
||||||
.filter((d) => !!finalSwitch || d.lastStation != "当駅止")
|
/>
|
||||||
.map((d, index) => {
|
) : currentTrainLoading == "error" ? (
|
||||||
const train = customTrainDataDetector(d.train);
|
<Ionicons
|
||||||
return [
|
name="reload"
|
||||||
<View
|
color="white"
|
||||||
style={{
|
size={30}
|
||||||
alignContent: "center",
|
style={{ marginRight: 30 }}
|
||||||
alignItems: "center",
|
onPress={() => {
|
||||||
width: "94%",
|
setCurrentTrainLoading("loading");
|
||||||
marginVertical: 5,
|
getCurrentTrain();
|
||||||
marginHorizontal: "3%",
|
|
||||||
backgroundColor: "#000",
|
|
||||||
flexDirection: "row",
|
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<View style={{ flex: 9 }}>
|
) : null}
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: train.trainName.length > 6 ? 15 : 20,
|
|
||||||
color: (() => {
|
|
||||||
switch (train.type) {
|
|
||||||
case "Rapid":
|
|
||||||
return "aqua";
|
|
||||||
case "LTDEXP":
|
|
||||||
return "red";
|
|
||||||
case "NightLTDEXP":
|
|
||||||
return "red";
|
|
||||||
case "Normal":
|
|
||||||
return "white";
|
|
||||||
}
|
|
||||||
})(),
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{trainIDSwitch
|
|
||||||
? d.train
|
|
||||||
: (() => {
|
|
||||||
switch (train.type) {
|
|
||||||
case "Rapid":
|
|
||||||
return "快速";
|
|
||||||
case "LTDEXP":
|
|
||||||
return "特急";
|
|
||||||
case "NightLTDEXP":
|
|
||||||
return "寝台特急";
|
|
||||||
case "Normal":
|
|
||||||
return "普通列車";
|
|
||||||
}
|
|
||||||
})() +
|
|
||||||
" " +
|
|
||||||
train.trainName +
|
|
||||||
(train.trainNumDistance == undefined
|
|
||||||
? ""
|
|
||||||
: parseInt(
|
|
||||||
d.train.replace("M", "").replace("D", "")
|
|
||||||
) -
|
|
||||||
train.trainNumDistance +
|
|
||||||
"号")}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
<View style={{ flex: 4, flexDirection: "row" }}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: d.lastStation.length > 4 ? 15 : 20,
|
|
||||||
color: "white",
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{d.lastStation}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
<View style={{ flex: 3 }}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: 20,
|
|
||||||
color: "white",
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{d.time}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
<View style={{ flex: 4 }}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: 20,
|
|
||||||
color: "white",
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{(() => {
|
|
||||||
const delay = currentTrain.filter(
|
|
||||||
(a) => a.num == d.train
|
|
||||||
)[0].delay;
|
|
||||||
switch (true) {
|
|
||||||
case isNaN(delay):
|
|
||||||
return delay;
|
|
||||||
case delay == 0:
|
|
||||||
return "定刻通り";
|
|
||||||
default:
|
|
||||||
return delay + "分遅れ";
|
|
||||||
}
|
|
||||||
})()}
|
|
||||||
</Text>
|
|
||||||
</View>
|
|
||||||
</View>,
|
|
||||||
trainDescriptionSwitch && !!train.info && (
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
alignContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
width: "94%",
|
|
||||||
marginVertical: 5,
|
|
||||||
marginHorizontal: "3%",
|
|
||||||
backgroundColor: "#000",
|
|
||||||
flexDirection: "row",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 4 }}>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: 20,
|
|
||||||
color: "green",
|
|
||||||
fontWeight: "bold",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
> {train.info}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
),
|
);
|
||||||
];
|
|
||||||
})
|
const Footer = ({
|
||||||
: null}
|
trainIDSwitch,
|
||||||
|
setTrainIDSwitch,
|
||||||
|
trainDescriptionSwitch,
|
||||||
|
setTrainDescriptionSwitch,
|
||||||
|
finalSwitch,
|
||||||
|
setFinalSwitch,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||||
<Text
|
<Text
|
||||||
style={{
|
style={{
|
||||||
@@ -366,6 +323,204 @@ export default function LED_vision(props) {
|
|||||||
</Text>
|
</Text>
|
||||||
<Switch value={finalSwitch} onValueChange={setFinalSwitch} />
|
<Switch value={finalSwitch} onValueChange={setFinalSwitch} />
|
||||||
</View>
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const EachData = ({
|
||||||
|
d,
|
||||||
|
trainIDSwitch,
|
||||||
|
trainDescriptionSwitch,
|
||||||
|
props,
|
||||||
|
currentTrain,
|
||||||
|
customTrainDataDetector,
|
||||||
|
navigate,
|
||||||
|
}) => {
|
||||||
|
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 [train, setTrain] = useState(customTrainDataDetector(d.train));
|
||||||
|
useEffect(() => {
|
||||||
|
setTrain(customTrainDataDetector(d.train));
|
||||||
|
}, [currentTrain, d.train, trainDescriptionSwitch]);
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
alignContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
width: "94%",
|
||||||
|
marginVertical: 5,
|
||||||
|
marginHorizontal: "3%",
|
||||||
|
backgroundColor: "#000",
|
||||||
|
flexDirection: "row",
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
|
if (train.type != "Normal") {
|
||||||
|
navigate("trainbase", {
|
||||||
|
info: "train.html?tn=" + d.train,
|
||||||
|
from: "LED",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TrainName
|
||||||
|
train={train}
|
||||||
|
trainIDSwitch={trainIDSwitch}
|
||||||
|
d={d}
|
||||||
|
getTrainType={getTrainType(train.type)}
|
||||||
|
/>
|
||||||
|
<LastStation d={d} />
|
||||||
|
<DependTime d={d} />
|
||||||
|
<StatusAndDelay
|
||||||
|
currentTrain={currentTrain}
|
||||||
|
d={d}
|
||||||
|
props={props}
|
||||||
|
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
{trainDescriptionSwitch && !!train.info && <Description train={train} />}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
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 + "号";
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<View style={{ flex: 9 }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: trainName.length > 6 ? 15 : 20,
|
||||||
|
color: getTrainType.color,
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{trainIDSwitch
|
||||||
|
? d.train
|
||||||
|
: `${getTrainType.name} ${trainName}${TrainNumber}`}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const LastStation = ({ d }) => {
|
||||||
|
return (
|
||||||
|
<View style={{ flex: 4, flexDirection: "row" }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: d.lastStation.length > 4 ? 15 : 20,
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{d.lastStation}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
const DependTime = ({ d }) => {
|
||||||
|
return (
|
||||||
|
<View style={{ flex: 3 }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 20,
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{d.time}
|
||||||
|
</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]);
|
||||||
|
return (
|
||||||
|
<View style={{ flex: 4 }}>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize: 20,
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{status}
|
||||||
|
</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: 20,
|
||||||
|
color: "green",
|
||||||
|
fontWeight: "bold",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
> {train.info}
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@@ -12,10 +12,57 @@ import {
|
|||||||
widthPercentageToDP as wp,
|
widthPercentageToDP as wp,
|
||||||
heightPercentageToDP as hp,
|
heightPercentageToDP as hp,
|
||||||
} from "react-native-responsive-screen";
|
} from "react-native-responsive-screen";
|
||||||
|
import LottieView from "lottie-react-native";
|
||||||
import { useInterval } from "../../lib/useInterval";
|
import { useInterval } from "../../lib/useInterval";
|
||||||
|
import { AS } from "../../storageControl";
|
||||||
|
|
||||||
export default function Sign(props) {
|
export default function Sign(props) {
|
||||||
const { currentStation, originalStationList, oP } = props;
|
const {
|
||||||
|
currentStation,
|
||||||
|
originalStationList,
|
||||||
|
oP,
|
||||||
|
favoriteStation,
|
||||||
|
setFavoriteStation,
|
||||||
|
} = props;
|
||||||
|
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);
|
||||||
|
const current = JSON.stringify(currentStation);
|
||||||
|
if (compare === current) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
setTestButtonStatus(isFavorite.length != 0);
|
||||||
|
}, [favoriteStation, currentStation]);
|
||||||
|
|
||||||
|
useInterval(() => {
|
||||||
|
if (currentStation.length == 1) {
|
||||||
|
setNexPrePosition(0);
|
||||||
|
return () => {};
|
||||||
|
}
|
||||||
|
LayoutAnimation.easeInEaseOut();
|
||||||
|
setNexPrePosition(
|
||||||
|
nexPrePosition + 1 == currentStation.length ? 0 : nexPrePosition + 1
|
||||||
|
);
|
||||||
|
}, 2000);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setNexPrePosition(0);
|
||||||
|
getPreNextStation(currentStation[0]);
|
||||||
|
}, [currentStation]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!currentStation[nexPrePosition]) return () => {};
|
||||||
|
getPreNextStation(currentStation[nexPrePosition]);
|
||||||
|
}, [nexPrePosition]);
|
||||||
const getPreNextStation = (now) => {
|
const getPreNextStation = (now) => {
|
||||||
const lineList = [
|
const lineList = [
|
||||||
"予讃線",
|
"予讃線",
|
||||||
@@ -40,27 +87,61 @@ export default function Sign(props) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return returnData;
|
setPreStation(returnData[0]);
|
||||||
|
setNexStation(returnData[1]);
|
||||||
};
|
};
|
||||||
const [nexPrePosition, setNexPrePosition] = useState(0);
|
const lottieRef = useRef();
|
||||||
useInterval(() => {
|
|
||||||
if (currentStation.length == 1) return;
|
|
||||||
LayoutAnimation.easeInEaseOut();
|
|
||||||
setNexPrePosition(
|
|
||||||
nexPrePosition + 1 == currentStation.length ? 0 : nexPrePosition + 1
|
|
||||||
);
|
|
||||||
}, 2000);
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity style={styleSheet.外枠} onPress={oP}>
|
<TouchableOpacity style={styleSheet.外枠} onPress={oP}>
|
||||||
<StationNumberMaker currentStation={currentStation} />
|
<StationNumberMaker currentStation={currentStation} />
|
||||||
<StationNameArea currentStation={currentStation} />
|
<StationNameArea currentStation={currentStation} />
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{ position: "absolute", right: -15, top: -20 }}
|
||||||
|
onPress={() => {
|
||||||
|
if (testButtonStatus) {
|
||||||
|
lottieRef.current.play(35, 7);
|
||||||
|
const otherData = favoriteStation.filter((d) => {
|
||||||
|
const compare = JSON.stringify(d);
|
||||||
|
const current = JSON.stringify(currentStation);
|
||||||
|
if (compare !== current) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
AS.setItem("favoriteStation", JSON.stringify(otherData));
|
||||||
|
setFavoriteStation(otherData);
|
||||||
|
} else {
|
||||||
|
lottieRef.current.play(7, 35);
|
||||||
|
let ret = favoriteStation;
|
||||||
|
console.log(currentStation);
|
||||||
|
ret.push(currentStation);
|
||||||
|
AS.setItem("favoriteStation", JSON.stringify(ret));
|
||||||
|
setFavoriteStation(ret);
|
||||||
|
}
|
||||||
|
setTestButtonStatus(!testButtonStatus);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<LottieView
|
||||||
|
progress={testButtonStatus ? 1 : 0}
|
||||||
|
speed={1.4}
|
||||||
|
style={{ width: 80, height: 80 }}
|
||||||
|
source={require("../../assets/939-star.json")}
|
||||||
|
ref={lottieRef}
|
||||||
|
loop={false}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
|
||||||
<Text style={styleSheet.JRStyle}>JR</Text>
|
<Text style={styleSheet.JRStyle}>JR</Text>
|
||||||
<View style={styleSheet.下帯} />
|
<View style={styleSheet.下帯} />
|
||||||
<View style={styleSheet.下帯内容}>
|
<View style={styleSheet.下帯内容}>
|
||||||
{(() => {
|
<NexPreStationLine preStation={preStation} nexStation={nexStation} />
|
||||||
let [preStation, nexStation] = getPreNextStation(
|
</View>
|
||||||
currentStation[nexPrePosition]
|
</TouchableOpacity>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const NexPreStationLine = ({ nexStation, preStation }) => {
|
||||||
return (
|
return (
|
||||||
<View style={styleSheet.下枠フレーム}>
|
<View style={styleSheet.下枠フレーム}>
|
||||||
<View style={styleSheet.下枠フレーム}>
|
<View style={styleSheet.下枠フレーム}>
|
||||||
@@ -98,9 +179,7 @@ export default function Sign(props) {
|
|||||||
{nexStation.StationNumber && (
|
{nexStation.StationNumber && (
|
||||||
<View style={styleSheet.下枠駅ナンバー}>
|
<View style={styleSheet.下枠駅ナンバー}>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text
|
<Text style={{ fontSize: parseInt("10%"), color: "white" }}>
|
||||||
style={{ fontSize: parseInt("10%"), color: "white" }}
|
|
||||||
>
|
|
||||||
{nexStation.StationNumber}
|
{nexStation.StationNumber}
|
||||||
</Text>
|
</Text>
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
@@ -112,29 +191,24 @@ export default function Sign(props) {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})()}
|
};
|
||||||
</View>
|
|
||||||
</TouchableOpacity>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const StationNumberMaker = (props) => {
|
const StationNumberMaker = (props) => {
|
||||||
return props.currentStation
|
const getTop = (array, index) => {
|
||||||
.filter((d) => (d.StationNumber ? true : false))
|
|
||||||
.map((d, index, array) => (
|
|
||||||
<View
|
|
||||||
key={d + index}
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
alignContent: "center",
|
|
||||||
alignItems: "center",
|
|
||||||
top:
|
|
||||||
(() => {
|
|
||||||
if (array.length == 1) return 20;
|
if (array.length == 1) return 20;
|
||||||
else if (index == 0) return 5;
|
else if (index == 0) return 5;
|
||||||
else if (index == 1) return 35;
|
else if (index == 1) return 35;
|
||||||
else return 20;
|
else return 20;
|
||||||
})() + "%",
|
};
|
||||||
|
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%",
|
right: "10%",
|
||||||
width: wp("10%"),
|
width: wp("10%"),
|
||||||
height: wp("10%"),
|
height: wp("10%"),
|
||||||
@@ -185,8 +259,7 @@ const styleSheet = {
|
|||||||
height: (wp("80%") / 20) * 9,
|
height: (wp("80%") / 20) * 9,
|
||||||
borderColor: "#2E94BB",
|
borderColor: "#2E94BB",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
margin: 10,
|
backgroundColor: "white",
|
||||||
marginHorizontal: wp("10%"),
|
|
||||||
},
|
},
|
||||||
下帯: {
|
下帯: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
|
6
eas.json
6
eas.json
@@ -15,6 +15,12 @@
|
|||||||
},
|
},
|
||||||
"production": {
|
"production": {
|
||||||
"releaseChannel": "aliexpress"
|
"releaseChannel": "aliexpress"
|
||||||
|
},
|
||||||
|
"beta4.5": {
|
||||||
|
"releaseChannel": "base"
|
||||||
|
},
|
||||||
|
"production4.5": {
|
||||||
|
"releaseChannel": "buyma"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"submit": {
|
"submit": {
|
||||||
|
29
howto.js
29
howto.js
@@ -3,23 +3,12 @@ import React, { Component } from "react";
|
|||||||
import { StatusBar, View, TouchableOpacity, Text } from "react-native";
|
import { StatusBar, View, TouchableOpacity, Text } from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
export default ({ navigation: { navigate } }) => (
|
export default ({ navigation: { navigate } }) => (
|
||||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
<View style={styles.View}>
|
||||||
<WebView
|
<WebView
|
||||||
useWebKit={true}
|
useWebKit
|
||||||
source={{ uri: "https://train.jr-shikoku.co.jp/usage.htm" }}
|
source={{ uri: "https://train.jr-shikoku.co.jp/usage.htm" }}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity style={styles.touch} onPress={() => navigate("Apps")}>
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
borderColor: "white",
|
|
||||||
borderWidth: 1,
|
|
||||||
margin: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
onPress={() => navigate("Apps")}
|
|
||||||
>
|
|
||||||
<View style={{ flex: 1 }} />
|
<View style={{ flex: 1 }} />
|
||||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||||
閉じる
|
閉じる
|
||||||
@@ -28,3 +17,15 @@ export default ({ navigation: { navigate } }) => (
|
|||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
const styles = {
|
||||||
|
View: { height: "100%", backgroundColor: "#0099CC" },
|
||||||
|
touch: {
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "white",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
@@ -18,6 +18,18 @@ import train_lang from "../assets/originData/train_lang";
|
|||||||
|
|
||||||
let status = undefined;
|
let status = undefined;
|
||||||
|
|
||||||
|
export const lineList = [
|
||||||
|
"予讃線",
|
||||||
|
"松宇線",
|
||||||
|
"伊予灘線",
|
||||||
|
"土讃線",
|
||||||
|
"窪川線",
|
||||||
|
"高徳線",
|
||||||
|
"徳島線",
|
||||||
|
"鳴門線",
|
||||||
|
"瀬戸大橋線",
|
||||||
|
];
|
||||||
|
|
||||||
export const getStationList = async (props) => {
|
export const getStationList = async (props) => {
|
||||||
if (status) return status;
|
if (status) return status;
|
||||||
//駅リストイニシャライズ
|
//駅リストイニシャライズ
|
||||||
|
3
lib/objectIsEmpty.js
Normal file
3
lib/objectIsEmpty.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export const objectIsEmpty = (obj) => {
|
||||||
|
return !Object.keys(obj).length;
|
||||||
|
};
|
@@ -109,7 +109,7 @@ case "1017M":
|
|||||||
case "1025M":
|
case "1025M":
|
||||||
case "1027M":
|
case "1027M":
|
||||||
case "1029M":
|
case "1029M":
|
||||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/f/s8000nr.png');
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//8000 アンパン
|
//8000 アンパン
|
||||||
@@ -135,7 +135,7 @@ case "1023M":
|
|||||||
//MEXP
|
//MEXP
|
||||||
//8000
|
//8000
|
||||||
case "1092M":
|
case "1092M":
|
||||||
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000no.png');
|
setStationIcon(element.getElementsByTagName("img")[0],'http://www.trainfrontview.net/b/s8000nr.png');
|
||||||
break;
|
break;
|
||||||
//8600
|
//8600
|
||||||
case "1091M":
|
case "1091M":
|
||||||
|
469
menu.js
469
menu.js
@@ -1,6 +1,6 @@
|
|||||||
import React, { Component, useRef, useState, useEffect } from "react";
|
import React, { useRef, useState, useEffect } from "react";
|
||||||
|
import Carousel from "react-native-snap-carousel";
|
||||||
import {
|
import {
|
||||||
StatusBar,
|
|
||||||
Platform,
|
Platform,
|
||||||
View,
|
View,
|
||||||
LayoutAnimation,
|
LayoutAnimation,
|
||||||
@@ -9,49 +9,38 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
} from "react-native";
|
} from "react-native";
|
||||||
import Image from "react-native-remote-svg";
|
|
||||||
import Constants from "expo-constants";
|
import Constants from "expo-constants";
|
||||||
import { List, ListItem } from "native-base";
|
import { ListItem } from "native-base";
|
||||||
import Icon from "react-native-vector-icons/Entypo";
|
import Icon from "react-native-vector-icons/Entypo";
|
||||||
import * as Location from "expo-location";
|
import * as Location from "expo-location";
|
||||||
import StatusbarDetect from "./StatusbarDetect";
|
import StatusbarDetect from "./StatusbarDetect";
|
||||||
import { useNavigation } from "@react-navigation/native";
|
import { useNavigation } from "@react-navigation/native";
|
||||||
import AutoHeightImage from "react-native-auto-height-image";
|
import AutoHeightImage from "react-native-auto-height-image";
|
||||||
import {
|
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||||
widthPercentageToDP as wp,
|
|
||||||
heightPercentageToDP as hp,
|
|
||||||
} from "react-native-responsive-screen";
|
|
||||||
import {
|
import {
|
||||||
FontAwesome,
|
FontAwesome,
|
||||||
Fontisto,
|
|
||||||
Foundation,
|
Foundation,
|
||||||
Ionicons,
|
Ionicons,
|
||||||
MaterialCommunityIcons,
|
MaterialCommunityIcons,
|
||||||
} from "@expo/vector-icons";
|
} from "@expo/vector-icons";
|
||||||
import * as WebBrowser from "expo-web-browser";
|
|
||||||
import ActionSheet from "react-native-actions-sheet";
|
|
||||||
import LottieView from "lottie-react-native";
|
import LottieView from "lottie-react-native";
|
||||||
import SvgUri from "react-native-svg-uri";
|
|
||||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||||
|
|
||||||
import 予讃線 from "./assets/四国旅客鉄道予讃線.json";
|
|
||||||
import 土讃線 from "./assets/四国旅客鉄道土讃線.json";
|
|
||||||
import 高徳線 from "./assets/四国旅客鉄道高徳線.json";
|
|
||||||
import 内子線 from "./assets/四国旅客鉄道内子線.json";
|
|
||||||
import 徳島線 from "./assets/四国旅客鉄道徳島線.json";
|
|
||||||
import 鳴門線 from "./assets/四国旅客鉄道鳴門線.json";
|
|
||||||
import LED_vision from "./components/発車時刻表/LED_vidion";
|
import LED_vision from "./components/発車時刻表/LED_vidion";
|
||||||
import Sign from "./components/駅名表/Sign";
|
import Sign from "./components/駅名表/Sign";
|
||||||
|
|
||||||
import { UsefulBox } from "./components/atom/UsefulBox";
|
import { UsefulBox } from "./components/atom/UsefulBox";
|
||||||
import { TicketBox } from "./components/atom/TicketBox";
|
import { TicketBox } from "./components/atom/TicketBox";
|
||||||
import { TextBox } from "./components/atom/TextBox";
|
import { TextBox } from "./components/atom/TextBox";
|
||||||
import { getStationList } from "./lib/getStationList";
|
import { getStationList, lineList } from "./lib/getStationList";
|
||||||
import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo";
|
import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo";
|
||||||
|
import useInterval from "./lib/useInterval";
|
||||||
|
|
||||||
export default function Menu(props) {
|
export default function Menu(props) {
|
||||||
const {
|
const {
|
||||||
navigation: { navigate },
|
navigation: { navigate },
|
||||||
|
favoriteStation,
|
||||||
|
setFavoriteStation,
|
||||||
} = props;
|
} = props;
|
||||||
const JRSTraInfoEXAcSR = useRef(null);
|
const JRSTraInfoEXAcSR = useRef(null);
|
||||||
const StationBoardAcSR = useRef(null);
|
const StationBoardAcSR = useRef(null);
|
||||||
@@ -59,26 +48,48 @@ export default function Menu(props) {
|
|||||||
|
|
||||||
//位置情報
|
//位置情報
|
||||||
const [location, setLocation] = useState(null);
|
const [location, setLocation] = useState(null);
|
||||||
const [errorMsg, setErrorMsg] = useState(null);
|
const [locationStatus, setLocationStatus] = useState(null);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Location.requestForegroundPermissionsAsync().then((data) => {
|
Location.requestForegroundPermissionsAsync().then((data) => {
|
||||||
if (data.status !== "granted") {
|
setLocationStatus(data.status);
|
||||||
setErrorMsg("Permission to access location was denied");
|
|
||||||
return () => {};
|
|
||||||
}
|
|
||||||
Location.getCurrentPositionAsync({}).then((location) =>
|
|
||||||
setLocation(location)
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
setInterval(() => {
|
}, []);
|
||||||
|
useEffect(() => {
|
||||||
|
if (locationStatus !== "granted") return () => {};
|
||||||
|
getCurrentPosition();
|
||||||
|
}, [locationStatus]);
|
||||||
|
|
||||||
|
const getCurrentPosition = () => {
|
||||||
Location.getCurrentPositionAsync({}).then((location) =>
|
Location.getCurrentPositionAsync({}).then((location) =>
|
||||||
setLocation(location)
|
setLocation(location)
|
||||||
);
|
);
|
||||||
}, 10000);
|
};
|
||||||
}, []);
|
|
||||||
|
useInterval(() => {
|
||||||
|
if (locationStatus !== "granted") return () => {};
|
||||||
|
getCurrentPosition();
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
const [originalStationList, setOriginalStationList] = useState();
|
const [originalStationList, setOriginalStationList] = useState();
|
||||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
useEffect(() => {
|
||||||
|
getStationList().then(setOriginalStationList);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const [locationAndFavorite, setLocationAndFavorite] = useState([]);
|
||||||
|
useEffect(() => {
|
||||||
|
if (!favoriteStation) return () => {};
|
||||||
|
const data = favoriteStation.filter((d) =>
|
||||||
|
JSON.stringify(d) === JSON.stringify(currentStation) ? false : true
|
||||||
|
);
|
||||||
|
setLocationAndFavorite(data);
|
||||||
|
}, [currentStation, favoriteStation]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!(selectedCurrentStation < favoriteStation.length)) {
|
||||||
|
setSelectedCurrentStation(favoriteStation.length - 1);
|
||||||
|
carouselRef.current.snapToItem(favoriteStation.length - 1);
|
||||||
|
}
|
||||||
|
}, [favoriteStation]);
|
||||||
|
|
||||||
const [stationName, setStationName] = useState(undefined);
|
const [stationName, setStationName] = useState(undefined);
|
||||||
const [currentStation, setCurrentStation] = useState(undefined);
|
const [currentStation, setCurrentStation] = useState(undefined);
|
||||||
@@ -102,17 +113,6 @@ export default function Menu(props) {
|
|||||||
return NearStation;
|
return NearStation;
|
||||||
};
|
};
|
||||||
|
|
||||||
const lineList = [
|
|
||||||
"予讃線",
|
|
||||||
"松宇線",
|
|
||||||
"伊予灘線",
|
|
||||||
"土讃線",
|
|
||||||
"窪川線",
|
|
||||||
"高徳線",
|
|
||||||
"徳島線",
|
|
||||||
"鳴門線",
|
|
||||||
"瀬戸大橋線",
|
|
||||||
];
|
|
||||||
let returnDataBase = lineList
|
let returnDataBase = lineList
|
||||||
.map((d) => findStationEachLine(originalStationList[d]))
|
.map((d) => findStationEachLine(originalStationList[d]))
|
||||||
.filter((d) => d.length > 0)
|
.filter((d) => d.length > 0)
|
||||||
@@ -120,7 +120,7 @@ export default function Menu(props) {
|
|||||||
pre.push(...current);
|
pre.push(...current);
|
||||||
return pre;
|
return pre;
|
||||||
}, []);
|
}, []);
|
||||||
LayoutAnimation.spring();
|
LayoutAnimation.easeInEaseOut();
|
||||||
if (returnDataBase.length) {
|
if (returnDataBase.length) {
|
||||||
let currentStation = currentStation == undefined ? [] : currentStation;
|
let currentStation = currentStation == undefined ? [] : currentStation;
|
||||||
if (currentStation.toString() != returnDataBase.toString()) {
|
if (currentStation.toString() != returnDataBase.toString()) {
|
||||||
@@ -136,6 +136,10 @@ export default function Menu(props) {
|
|||||||
const [delayData, setDelayData] = useState(undefined);
|
const [delayData, setDelayData] = useState(undefined);
|
||||||
const [getTime, setGetTime] = useState(new Date());
|
const [getTime, setGetTime] = useState(new Date());
|
||||||
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
||||||
|
const carouselRef = useRef();
|
||||||
|
const scrollRef = useRef();
|
||||||
|
const [isScroll, setIsScroll] = useState(true);
|
||||||
|
const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetch(
|
fetch(
|
||||||
@@ -157,52 +161,9 @@ export default function Menu(props) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<StatusbarDetect />
|
<StatusbarDetect />
|
||||||
<View style={{ alignItems: "center" }}>
|
<TitleBar />
|
||||||
<TouchableOpacity
|
<ScrollView ref={scrollRef} scrollEnabled={isScroll}>
|
||||||
onPress={() => Linking.openURL("https://www.jr-shikoku.co.jp")}
|
<TopMenuButton />
|
||||||
>
|
|
||||||
<AutoHeightImage
|
|
||||||
source={require("./assets/Header.png")}
|
|
||||||
resizeMode="contain"
|
|
||||||
width={wp("100%")}
|
|
||||||
/>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
<ScrollView>
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<UsefulBox
|
|
||||||
backgroundColor={"#F89038"}
|
|
||||||
icon="train-car"
|
|
||||||
flex={1}
|
|
||||||
onPressButton={() =>
|
|
||||||
Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
駅・鉄道情報
|
|
||||||
</UsefulBox>
|
|
||||||
<UsefulBox
|
|
||||||
backgroundColor={"#EA4752"}
|
|
||||||
icon="google-spreadsheet"
|
|
||||||
flex={1}
|
|
||||||
onPressButton={() =>
|
|
||||||
Linking.openURL(
|
|
||||||
"https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
運賃表
|
|
||||||
</UsefulBox>
|
|
||||||
<UsefulBox
|
|
||||||
backgroundColor={"#91C31F"}
|
|
||||||
icon="clipboard-list-outline"
|
|
||||||
flex={1}
|
|
||||||
onPressButton={() =>
|
|
||||||
Linking.openURL("https://www.jr-shikoku.co.jp/e5489/")
|
|
||||||
}
|
|
||||||
>
|
|
||||||
予約
|
|
||||||
</UsefulBox>
|
|
||||||
</View>
|
|
||||||
<TextBox
|
<TextBox
|
||||||
backgroundColor="#0099CC"
|
backgroundColor="#0099CC"
|
||||||
flex={1}
|
flex={1}
|
||||||
@@ -219,127 +180,55 @@ export default function Menu(props) {
|
|||||||
列車の運行計画・混雑状況・感染症対策への取り組み
|
列車の運行計画・混雑状況・感染症対策への取り組み
|
||||||
</Text>
|
</Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
{currentStation && (
|
<Carousel
|
||||||
<>
|
ref={carouselRef}
|
||||||
|
layout={"default"}
|
||||||
|
data={
|
||||||
|
originalStationList &&
|
||||||
|
(currentStation
|
||||||
|
? [currentStation, ...locationAndFavorite]
|
||||||
|
: locationAndFavorite)
|
||||||
|
}
|
||||||
|
sliderWidth={wp("100%")}
|
||||||
|
itemWidth={wp("80%")}
|
||||||
|
enableMomentum
|
||||||
|
callbackOffsetMargin={1000}
|
||||||
|
activeAnimationOptions={0.3}
|
||||||
|
onSnapToItem={(d) => {
|
||||||
|
setSelectedCurrentStation(d);
|
||||||
|
}}
|
||||||
|
renderItem={({ item, index }) => {
|
||||||
|
return (
|
||||||
|
<View style={{ marginVertical: 10 }} key={item[0].StationNumber}>
|
||||||
<Sign
|
<Sign
|
||||||
currentStation={currentStation}
|
currentStation={item}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
oP={StationBoardAcSR.current?.setModalVisible}
|
oP={StationBoardAcSR.current?.setModalVisible}
|
||||||
/>
|
/>
|
||||||
<LED_vision station={currentStation[0]} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
<TouchableOpacity onPress={JRSTraInfoEXAcSR.current?.setModalVisible}>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
backgroundColor: "#0099CC",
|
|
||||||
borderRadius: 5,
|
|
||||||
margin: 10,
|
|
||||||
borderColor: "black",
|
|
||||||
borderWidth: 2,
|
|
||||||
overflow: "hidden",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ScrollView
|
|
||||||
scrollEnabled={false}
|
|
||||||
style={{
|
|
||||||
backgroundColor: "#0099CC",
|
|
||||||
borderRadius: 5,
|
|
||||||
maxHeight: 300,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 30, fontWeight: "bold", color: "white" }}
|
|
||||||
>
|
|
||||||
列車遅延速報EX
|
|
||||||
</Text>
|
|
||||||
<View style={{ flex: 1 }} />
|
|
||||||
<Text
|
|
||||||
style={{ fontSize: 30, fontWeight: "bold", color: "white" }}
|
|
||||||
>
|
|
||||||
{getTime
|
|
||||||
? getTime.toLocaleTimeString("ja-JP").split(":")[0] +
|
|
||||||
":" +
|
|
||||||
getTime.toLocaleTimeString("ja-JP").split(":")[1]
|
|
||||||
: NaN}
|
|
||||||
</Text>
|
|
||||||
<Ionicons
|
|
||||||
name="reload"
|
|
||||||
color="white"
|
|
||||||
size={30}
|
|
||||||
style={{ margin: 5 }}
|
|
||||||
onPress={() => {
|
|
||||||
LayoutAnimation.easeInEaseOut();
|
|
||||||
setLoadingDelayData(true);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
padding: 10,
|
|
||||||
backgroundColor: "white",
|
|
||||||
borderBottomLeftRadius: 5,
|
|
||||||
borderBottomRightRadius: 5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{loadingDelayData ? (
|
|
||||||
<View style={{ alignItems: "center" }}>
|
|
||||||
<LottieView
|
|
||||||
autoPlay
|
|
||||||
loop
|
|
||||||
style={{
|
|
||||||
width: 150,
|
|
||||||
height: 150,
|
|
||||||
backgroundColor: "#fff",
|
|
||||||
}}
|
|
||||||
source={require("./assets/51690-loading-diamonds.json")}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
) : delayData ? (
|
|
||||||
delayData.map((d) => {
|
|
||||||
let data = d.split(" ");
|
|
||||||
return (
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
|
||||||
<Text style={{ flex: 15, fontSize: 20 }}>
|
|
||||||
{data[0].replace("\n", "")}
|
|
||||||
</Text>
|
|
||||||
<Text style={{ flex: 5, fontSize: 20 }}>{data[1]}</Text>
|
|
||||||
<Text style={{ flex: 6, fontSize: 20 }}>{data[3]}</Text>
|
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
})
|
|
||||||
) : (
|
|
||||||
<Text>現在、5分以上の遅れはありません。</Text>
|
|
||||||
)}
|
|
||||||
</View>
|
|
||||||
</ScrollView>
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 250,
|
|
||||||
alignItems: "center",
|
|
||||||
width: "100%",
|
|
||||||
height: 50,
|
|
||||||
backgroundColor: "#007FCC88",
|
|
||||||
}}
|
}}
|
||||||
>
|
/>
|
||||||
<View style={{ flex: 1 }} />
|
{(currentStation || originalStationList) && (
|
||||||
<Text
|
<LED_vision
|
||||||
style={{ color: "white", fontWeight: "bold", fontSize: 20 }}
|
station={
|
||||||
>
|
originalStationList &&
|
||||||
詳細を見る
|
(currentStation
|
||||||
</Text>
|
? [currentStation, ...locationAndFavorite]
|
||||||
<View style={{ flex: 1 }} />
|
: locationAndFavorite)[selectedCurrentStation][0]
|
||||||
</View>
|
}
|
||||||
</View>
|
navigate={navigate}
|
||||||
</TouchableOpacity>
|
/>
|
||||||
|
)}
|
||||||
|
<JRSTraInfoBox
|
||||||
|
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||||
|
getTime={getTime}
|
||||||
|
setLoadingDelayData={setLoadingDelayData}
|
||||||
|
loadingDelayData={loadingDelayData}
|
||||||
|
delayData={delayData}
|
||||||
|
/>
|
||||||
|
|
||||||
<View style={{ flexDirection: "row" }}>
|
<View style={{ flexDirection: "row" }}>
|
||||||
<TicketBox
|
<TicketBox
|
||||||
@@ -622,8 +511,15 @@ export default function Menu(props) {
|
|||||||
</ScrollView>
|
</ScrollView>
|
||||||
<StationDeteilView
|
<StationDeteilView
|
||||||
StationBoardAcSR={StationBoardAcSR}
|
StationBoardAcSR={StationBoardAcSR}
|
||||||
currentStation={currentStation}
|
currentStation={
|
||||||
|
originalStationList &&
|
||||||
|
(currentStation
|
||||||
|
? [currentStation, ...locationAndFavorite]
|
||||||
|
: locationAndFavorite)[selectedCurrentStation]
|
||||||
|
}
|
||||||
originalStationList={originalStationList}
|
originalStationList={originalStationList}
|
||||||
|
favoriteStation={favoriteStation}
|
||||||
|
setFavoriteStation={setFavoriteStation}
|
||||||
/>
|
/>
|
||||||
<JRSTraInfo
|
<JRSTraInfo
|
||||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||||
@@ -635,3 +531,168 @@ export default function Menu(props) {
|
|||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const TitleBar = () => {
|
||||||
|
return (
|
||||||
|
<View style={{ alignItems: "center" }}>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => Linking.openURL("https://www.jr-shikoku.co.jp")}
|
||||||
|
>
|
||||||
|
<AutoHeightImage
|
||||||
|
source={require("./assets/Header.png")}
|
||||||
|
resizeMode="contain"
|
||||||
|
width={wp("100%")}
|
||||||
|
/>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const TopMenuButton = () => {
|
||||||
|
const buttonList = [
|
||||||
|
{
|
||||||
|
backgroundColor: "#F89038",
|
||||||
|
icon: "train-car",
|
||||||
|
onPress: () =>
|
||||||
|
Linking.openURL("https://www.jr-shikoku.co.jp/01_trainbus/sp/"),
|
||||||
|
title: "駅・鉄道情報",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
backgroundColor: "#EA4752",
|
||||||
|
icon: "google-spreadsheet",
|
||||||
|
onPress: () =>
|
||||||
|
Linking.openURL(
|
||||||
|
"https://www.jr-shikoku.co.jp/01_trainbus/jikoku/sp/#mainprice-box"
|
||||||
|
),
|
||||||
|
title: "運賃表",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
backgroundColor: "#91C31F",
|
||||||
|
icon: "clipboard-list-outline",
|
||||||
|
onPress: () => Linking.openURL("https://www.jr-shikoku.co.jp/e5489/"),
|
||||||
|
title: "予約",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
return (
|
||||||
|
<View style={{ flexDirection: "row" }}>
|
||||||
|
{buttonList.map((d, index) => (
|
||||||
|
<UsefulBox
|
||||||
|
backgroundColor={d.backgroundColor}
|
||||||
|
icon={d.icon}
|
||||||
|
flex={1}
|
||||||
|
onPressButton={d.onPress}
|
||||||
|
key={index + d.icon}
|
||||||
|
>
|
||||||
|
{d.title}
|
||||||
|
</UsefulBox>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const JRSTraInfoBox = (props) => {
|
||||||
|
const {
|
||||||
|
JRSTraInfoEXAcSR,
|
||||||
|
getTime,
|
||||||
|
setLoadingDelayData,
|
||||||
|
loadingDelayData,
|
||||||
|
delayData,
|
||||||
|
} = props;
|
||||||
|
const styles = {
|
||||||
|
touch: {
|
||||||
|
backgroundColor: "#0099CC",
|
||||||
|
borderRadius: 5,
|
||||||
|
margin: 10,
|
||||||
|
borderColor: "black",
|
||||||
|
borderWidth: 2,
|
||||||
|
overflow: "hidden",
|
||||||
|
},
|
||||||
|
scroll: {
|
||||||
|
backgroundColor: "#0099CC",
|
||||||
|
borderRadius: 5,
|
||||||
|
maxHeight: 300,
|
||||||
|
},
|
||||||
|
bottom: {
|
||||||
|
position: "absolute",
|
||||||
|
top: 250,
|
||||||
|
alignItems: "center",
|
||||||
|
width: "100%",
|
||||||
|
height: 50,
|
||||||
|
backgroundColor: "#007FCC88",
|
||||||
|
},
|
||||||
|
box: {
|
||||||
|
padding: 10,
|
||||||
|
backgroundColor: "white",
|
||||||
|
borderBottomLeftRadius: 5,
|
||||||
|
borderBottomRightRadius: 5,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={JRSTraInfoEXAcSR.current?.setModalVisible}
|
||||||
|
style={styles.touch}
|
||||||
|
>
|
||||||
|
<ScrollView scrollEnabled={false} style={styles.scroll}>
|
||||||
|
<View
|
||||||
|
style={{ padding: 10, flexDirection: "row", alignItems: "center" }}
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||||
|
列車遅延速報EX
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ fontSize: 30, fontWeight: "bold", color: "white" }}>
|
||||||
|
{getTime
|
||||||
|
? getTime.toLocaleTimeString("ja-JP").split(":")[0] +
|
||||||
|
":" +
|
||||||
|
getTime.toLocaleTimeString("ja-JP").split(":")[1]
|
||||||
|
: NaN}
|
||||||
|
</Text>
|
||||||
|
<Ionicons
|
||||||
|
name="reload"
|
||||||
|
color="white"
|
||||||
|
size={30}
|
||||||
|
style={{ margin: 5 }}
|
||||||
|
onPress={() => {
|
||||||
|
LayoutAnimation.easeInEaseOut();
|
||||||
|
setLoadingDelayData(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
<View style={styles.box}>
|
||||||
|
{loadingDelayData ? (
|
||||||
|
<View style={{ alignItems: "center" }}>
|
||||||
|
<LottieView
|
||||||
|
autoPlay
|
||||||
|
loop
|
||||||
|
style={{ width: 150, height: 150, backgroundColor: "#fff" }}
|
||||||
|
source={require("./assets/51690-loading-diamonds.json")}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
) : delayData ? (
|
||||||
|
delayData.map((d, index) => {
|
||||||
|
let data = d.split(" ");
|
||||||
|
return (
|
||||||
|
<View style={{ flexDirection: "row" }} key={data[1] + "key"}>
|
||||||
|
<Text style={{ flex: 15, fontSize: 20 }}>
|
||||||
|
{data[0].replace("\n", "")}
|
||||||
|
</Text>
|
||||||
|
<Text style={{ flex: 5, fontSize: 20 }}>{data[1]}</Text>
|
||||||
|
<Text style={{ flex: 6, fontSize: 20 }}>{data[3]}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<Text>現在、5分以上の遅れはありません。</Text>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</ScrollView>
|
||||||
|
<View style={styles.bottom}>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<Text style={{ color: "white", fontWeight: "bold", fontSize: 20 }}>
|
||||||
|
詳細を見る
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
import React, { Component } from "react";
|
import React from "react";
|
||||||
import { StatusBar, View, Linking, Platform, Text } from "react-native";
|
import { View, Platform } from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
import Constants from "expo-constants";
|
import Constants from "expo-constants";
|
||||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
|
||||||
export default function tndView() {
|
export default function tndView() {
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
|
@@ -36,6 +36,7 @@
|
|||||||
"react-native-router-flux": "^4.3.1",
|
"react-native-router-flux": "^4.3.1",
|
||||||
"react-native-safe-area-context": "4.2.4",
|
"react-native-safe-area-context": "4.2.4",
|
||||||
"react-native-screens": "~3.11.1",
|
"react-native-screens": "~3.11.1",
|
||||||
|
"react-native-snap-carousel": "^3.9.1",
|
||||||
"react-native-storage": "^1.0.1",
|
"react-native-storage": "^1.0.1",
|
||||||
"react-native-svg": "12.3.0",
|
"react-native-svg": "12.3.0",
|
||||||
"react-native-svg-uri": "^1.2.3",
|
"react-native-svg-uri": "^1.2.3",
|
||||||
|
27
storageConfig.js
Normal file
27
storageConfig.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import Storage from "react-native-storage";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
|
|
||||||
|
const storage = new Storage({
|
||||||
|
// maximum capacity, default 1000 key-ids
|
||||||
|
size: 10000,
|
||||||
|
|
||||||
|
// Use AsyncStorage for RN apps, or window.localStorage for web apps.
|
||||||
|
// If storageBackend is not set, data will be lost after reload.
|
||||||
|
storageBackend: AsyncStorage, // for web: window.localStorage
|
||||||
|
|
||||||
|
// expire time, default: 1 day (1000 * 3600 * 24 milliseconds).
|
||||||
|
// can be null, which means never expire.
|
||||||
|
defaultExpires: null,
|
||||||
|
|
||||||
|
// cache data in the memory. default is true.
|
||||||
|
enableCache: true,
|
||||||
|
|
||||||
|
// if data was not found in storage or expired data was found,
|
||||||
|
// the corresponding sync method will be invoked returning
|
||||||
|
// the latest data.
|
||||||
|
sync: {
|
||||||
|
// we'll talk about the details later.
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default storage;
|
14
storageControl.js
Normal file
14
storageControl.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import storage from "./storageConfig.js";
|
||||||
|
|
||||||
|
export const AS = {
|
||||||
|
getItem: (key) => storage.load({ key }),
|
||||||
|
setItem: (key, data) =>
|
||||||
|
storage.save({
|
||||||
|
key, // Note: Do not use underscore("_") in key!
|
||||||
|
data,
|
||||||
|
|
||||||
|
// if expires not specified, the defaultExpires will be applied instead.
|
||||||
|
// if set to null, then it will never expire.
|
||||||
|
expires: null,
|
||||||
|
}),
|
||||||
|
};
|
@@ -1,9 +1,18 @@
|
|||||||
import React, { Component, useRef } from "react";
|
import React, { Component, useRef } from "react";
|
||||||
import { StatusBar, Platform, View } from "react-native";
|
import {
|
||||||
|
StatusBar,
|
||||||
|
Platform,
|
||||||
|
View,
|
||||||
|
TouchableOpacity,
|
||||||
|
Text,
|
||||||
|
} from "react-native";
|
||||||
import { WebView } from "react-native-webview";
|
import { WebView } from "react-native-webview";
|
||||||
|
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||||
|
|
||||||
export default function TrainBase({ route }) {
|
export default function TrainBase({ route, navigation }) {
|
||||||
const { info } = route.params;
|
const { info, from } = route.params;
|
||||||
|
const { navigate } = navigation;
|
||||||
|
console.log(info);
|
||||||
const webview = useRef();
|
const webview = useRef();
|
||||||
const jss = `document.getElementById('Footer').style.display = 'none';
|
const jss = `document.getElementById('Footer').style.display = 'none';
|
||||||
${
|
${
|
||||||
@@ -28,6 +37,27 @@ export default function TrainBase({ route }) {
|
|||||||
setSupportMultipleWindows={false}
|
setSupportMultipleWindows={false}
|
||||||
onMessage={(event) => {}}
|
onMessage={(event) => {}}
|
||||||
/>
|
/>
|
||||||
|
{from == "LED" && (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
padding: 10,
|
||||||
|
flexDirection: "row",
|
||||||
|
borderColor: "black",
|
||||||
|
borderWidth: 1,
|
||||||
|
margin: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
alignItems: "center",
|
||||||
|
}}
|
||||||
|
onPress={() => navigate("menu")}
|
||||||
|
>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
<MaterialCommunityIcons name="close" color="black" size={30} />
|
||||||
|
<Text style={{ fontSize: 25, fontWeight: "bold", color: "black" }}>
|
||||||
|
閉じる
|
||||||
|
</Text>
|
||||||
|
<View style={{ flex: 1 }} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
36
yarn.lock
36
yarn.lock
@@ -5167,6 +5167,19 @@ fbjs-css-vars@^1.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8"
|
resolved "https://registry.yarnpkg.com/fbjs-css-vars/-/fbjs-css-vars-1.0.2.tgz#216551136ae02fe255932c3ec8775f18e2c078b8"
|
||||||
integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ==
|
integrity sha512-b2XGFAFdWZWg0phtAWLHCk836A1Xann+I+Dgd3Gk64MHKZO44FfoD1KxyvbSh0qZsIoXQGGlVztIY+oitJPpRQ==
|
||||||
|
|
||||||
|
fbjs@^0.8.4:
|
||||||
|
version "0.8.18"
|
||||||
|
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.18.tgz#9835e0addb9aca2eff53295cd79ca1cfc7c9662a"
|
||||||
|
integrity sha512-EQaWFK+fEPSoibjNy8IxUtaFOMXcWsY0JaVrQoZR9zC8N2Ygf9iDITPWjUTVIax95b6I742JFLqASHfsag/vKA==
|
||||||
|
dependencies:
|
||||||
|
core-js "^1.0.0"
|
||||||
|
isomorphic-fetch "^2.1.1"
|
||||||
|
loose-envify "^1.0.0"
|
||||||
|
object-assign "^4.1.0"
|
||||||
|
promise "^7.1.1"
|
||||||
|
setimmediate "^1.0.5"
|
||||||
|
ua-parser-js "^0.7.30"
|
||||||
|
|
||||||
fbjs@^0.8.9:
|
fbjs@^0.8.9:
|
||||||
version "0.8.17"
|
version "0.8.17"
|
||||||
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
|
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.17.tgz#c4d598ead6949112653d6588b01a5cdcd9f90fdd"
|
||||||
@@ -8399,7 +8412,7 @@ promzard@^0.3.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
read "1"
|
read "1"
|
||||||
|
|
||||||
prop-types@*:
|
prop-types@*, prop-types@^15.6.1:
|
||||||
version "15.8.1"
|
version "15.8.1"
|
||||||
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
|
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5"
|
||||||
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
|
integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==
|
||||||
@@ -8549,6 +8562,14 @@ rc@~1.2.7:
|
|||||||
minimist "^1.2.0"
|
minimist "^1.2.0"
|
||||||
strip-json-comments "~2.0.1"
|
strip-json-comments "~2.0.1"
|
||||||
|
|
||||||
|
react-addons-shallow-compare@15.6.2:
|
||||||
|
version "15.6.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-addons-shallow-compare/-/react-addons-shallow-compare-15.6.2.tgz#198a00b91fc37623db64a28fd17b596ba362702f"
|
||||||
|
integrity sha512-yAV9tOObmKPiohqne1jiMcx6kDjfz7GeL8K9KHgI+HvDsbrRv148uyUzrPc6GwepZnQcJ59Q3lp1ghrkyPwtjg==
|
||||||
|
dependencies:
|
||||||
|
fbjs "^0.8.4"
|
||||||
|
object-assign "^4.1.0"
|
||||||
|
|
||||||
react-devtools-core@^4.23.0:
|
react-devtools-core@^4.23.0:
|
||||||
version "4.24.7"
|
version "4.24.7"
|
||||||
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.24.7.tgz#43df22e6d244ed8286fd3ff16a80813998fe82a0"
|
resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.24.7.tgz#43df22e6d244ed8286fd3ff16a80813998fe82a0"
|
||||||
@@ -8741,6 +8762,14 @@ react-native-size-matters@^0.3.1:
|
|||||||
resolved "https://registry.yarnpkg.com/react-native-size-matters/-/react-native-size-matters-0.3.1.tgz#24d0cfc335a2c730f6d58bd7b43ea5a41be4b49f"
|
resolved "https://registry.yarnpkg.com/react-native-size-matters/-/react-native-size-matters-0.3.1.tgz#24d0cfc335a2c730f6d58bd7b43ea5a41be4b49f"
|
||||||
integrity sha512-mKOfBLIBFBcs9br1rlZDvxD5+mAl8Gfr5CounwJtxI6Z82rGrMO+Kgl9EIg3RMVf3G855a85YVqHJL2f5EDRlw==
|
integrity sha512-mKOfBLIBFBcs9br1rlZDvxD5+mAl8Gfr5CounwJtxI6Z82rGrMO+Kgl9EIg3RMVf3G855a85YVqHJL2f5EDRlw==
|
||||||
|
|
||||||
|
react-native-snap-carousel@^3.9.1:
|
||||||
|
version "3.9.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-native-snap-carousel/-/react-native-snap-carousel-3.9.1.tgz#6fd9bd8839546c2c6043a41d2035afbc6fe0443e"
|
||||||
|
integrity sha512-xWEGusacIgK1YaDXLi7Gao2+ISLoGPVEBR8fcMf4tOOJQufutlNwkoLu0l6B8Qgsrre0nTxoVZikRgGRDWlLaQ==
|
||||||
|
dependencies:
|
||||||
|
prop-types "^15.6.1"
|
||||||
|
react-addons-shallow-compare "15.6.2"
|
||||||
|
|
||||||
react-native-storage@^1.0.1:
|
react-native-storage@^1.0.1:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/react-native-storage/-/react-native-storage-1.0.1.tgz#2c493875ff76ec301987c951a8302f3a54381241"
|
resolved "https://registry.yarnpkg.com/react-native-storage/-/react-native-storage-1.0.1.tgz#2c493875ff76ec301987c951a8302f3a54381241"
|
||||||
@@ -10192,6 +10221,11 @@ ua-parser-js@^0.7.18:
|
|||||||
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"
|
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.21.tgz#853cf9ce93f642f67174273cc34565ae6f308777"
|
||||||
integrity sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ==
|
integrity sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ==
|
||||||
|
|
||||||
|
ua-parser-js@^0.7.30:
|
||||||
|
version "0.7.33"
|
||||||
|
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.33.tgz#1d04acb4ccef9293df6f70f2c3d22f3030d8b532"
|
||||||
|
integrity sha512-s8ax/CeZdK9R/56Sui0WM6y9OFREJarMRHqLB2EwkovemBxNQ+Bqu8GAsUnVcXKgphb++ghr/B2BZx4mahujPw==
|
||||||
|
|
||||||
uglify-es@^3.1.9:
|
uglify-es@^3.1.9:
|
||||||
version "3.3.9"
|
version "3.3.9"
|
||||||
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
|
resolved "https://registry.yarnpkg.com/uglify-es/-/uglify-es-3.3.9.tgz#0c1c4f0700bed8dbc124cdb304d2592ca203e677"
|
||||||
|
Reference in New Issue
Block a user