Merge commit '9b70843e9c6ed45ebce609952b0202f5ebf877d7'
This commit is contained in:
commit
fd95e99874
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,3 +5,4 @@ npm-debug.*
|
||||
*.p12
|
||||
*.key
|
||||
*.mobileprovision
|
||||
dist/
|
320
App.js
320
App.js
@ -1,61 +1,74 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { NavigationContainer } from "@react-navigation/native";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { createStackNavigator } from "@react-navigation/stack";
|
||||
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
|
||||
import { AntDesign, Ionicons } from "@expo/vector-icons";
|
||||
import { Platform, UIManager } from "react-native";
|
||||
import { UpdateAsync } from "./UpdateAsync.js";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
import { AS } from "./storageControl";
|
||||
import Apps from "./Apps";
|
||||
import TNDView from "./ndView";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import Menu from "./menu";
|
||||
import News from "./components/news.js";
|
||||
import Setting from "./components/settings.js";
|
||||
import TrainMenu from "./components/trainMenu.js";
|
||||
import FavoriteList from "./components/FavoriteList.js";
|
||||
import { LogBox } from "react-native";
|
||||
import useInterval from "./lib/useInterval";
|
||||
import { HeaderConfig } from "./lib/HeaderConfig";
|
||||
|
||||
import { initIcon } from "./lib/initIcon";
|
||||
import {
|
||||
useFavoriteStation,
|
||||
FavoriteStationProvider,
|
||||
} from "./stateBox/useFavoriteStation";
|
||||
import { Top } from "./Top.js";
|
||||
import { MenuPage } from "./MenuPage.js";
|
||||
import {
|
||||
useCurrentTrain,
|
||||
CurrentTrainProvider,
|
||||
} from "./stateBox/useCurrentTrain.js";
|
||||
import { useAreaInfo, AreaInfoProvider } from "./stateBox/useAreaInfo.js";
|
||||
import {
|
||||
useBusAndTrainData,
|
||||
BusAndTrainDataProvider,
|
||||
} from "./stateBox/useBusAndTrainData.js";
|
||||
import { AllTrainDiagramProvider } from "./stateBox/useAllTrainDiagram.js";
|
||||
import { SheetProvider } from "react-native-actions-sheet";
|
||||
import "./components/ActionSheetComponents/sheets.js";
|
||||
import { TrainDelayDataProvider } from "./stateBox/useTrainDelayData.js";
|
||||
LogBox.ignoreLogs([
|
||||
"ViewPropTypes will be removed",
|
||||
"ColorPropType will be removed",
|
||||
]);
|
||||
const Stack = createStackNavigator();
|
||||
const Tab = createBottomTabNavigator();
|
||||
if (Platform.OS === "android") {
|
||||
if (UIManager.setLayoutAnimationEnabledExperimental) {
|
||||
UIManager.setLayoutAnimationEnabledExperimental(true);
|
||||
}
|
||||
}
|
||||
export default function App() {
|
||||
useEffect(() => {
|
||||
UpdateAsync();
|
||||
}, []);
|
||||
const [favoriteStation, setFavoriteStation] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setFavoriteStation(returnData);
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
}, []);
|
||||
const [busAndTrainData, setBusAndTrainData] = useState([]);
|
||||
export default function App() {
|
||||
useEffect(() => UpdateAsync(), []);
|
||||
return (
|
||||
<FavoriteStationProvider>
|
||||
<TrainDelayDataProvider>
|
||||
<SheetProvider>
|
||||
<CurrentTrainProvider>
|
||||
<AreaInfoProvider>
|
||||
<AllTrainDiagramProvider>
|
||||
<BusAndTrainDataProvider>
|
||||
<AppContainer />
|
||||
</BusAndTrainDataProvider>
|
||||
</AllTrainDiagramProvider>
|
||||
</AreaInfoProvider>
|
||||
</CurrentTrainProvider>
|
||||
</SheetProvider>
|
||||
</TrainDelayDataProvider>
|
||||
</FavoriteStationProvider>
|
||||
);
|
||||
}
|
||||
export function AppContainer() {
|
||||
const { setBusAndTrainData } = useBusAndTrainData();
|
||||
useEffect(() => {
|
||||
AS.getItem("busAndTrain")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setBusAndTrainData(returnData);
|
||||
})
|
||||
.catch((d) => {
|
||||
.catch(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbw0UW6ZeCDgUYFRP0zxpc_Oqfy-91dBdbWv-cM8n3narKp14IyCd2wy5HW7taXcW7E/exec"
|
||||
)
|
||||
@ -67,11 +80,11 @@ export default function App() {
|
||||
});
|
||||
}, []);
|
||||
|
||||
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
|
||||
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
|
||||
const { setCurrentTrain, setCurrentTrainLoading } = useCurrentTrain();
|
||||
|
||||
const getCurrentTrain = () =>
|
||||
fetch(
|
||||
"https://train.jr-shikoku.co.jp/g?arg1=train&arg2=train",
|
||||
"https://script.google.com/macros/s/AKfycby9Y2-Bm75J_WkbZimi7iS8v5r9wMa9wtzpdwES9sOGF4i6HIYEJOM60W6gM1gXzt1o/exec",
|
||||
HeaderConfig
|
||||
)
|
||||
.then((response) => response.json())
|
||||
@ -82,7 +95,7 @@ export default function App() {
|
||||
setCurrentTrain(d);
|
||||
setCurrentTrainLoading("success");
|
||||
})
|
||||
.catch((e) => {
|
||||
.catch(() => {
|
||||
console.log("えらー");
|
||||
setCurrentTrainLoading("error");
|
||||
});
|
||||
@ -91,6 +104,16 @@ export default function App() {
|
||||
|
||||
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
||||
|
||||
const { areaInfo, setAreaInfo } = useAreaInfo();
|
||||
const getAreaData = () =>
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
||||
)
|
||||
.then((d) => d.text())
|
||||
.then((d) => setAreaInfo(d));
|
||||
useEffect(getAreaData, []);
|
||||
useInterval(getAreaData, 60000); //60秒毎に全在線列車取得
|
||||
|
||||
return (
|
||||
<NavigationContainer name="Root" style={{ flex: 1 }}>
|
||||
<Tab.Navigator detachInactiveScreens={false}>
|
||||
@ -103,20 +126,7 @@ export default function App() {
|
||||
tabBarIcon: initIcon("barchart", "AntDesign"),
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Top
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
currentTrainState={{ currentTrain, setCurrentTrain }}
|
||||
currentTrainLoadingState={{
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
}}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
{(props) => <Top {...props} getCurrentTrain={getCurrentTrain} />}
|
||||
</Tab.Screen>
|
||||
<Tab.Screen
|
||||
name="menuPage"
|
||||
@ -127,20 +137,7 @@ export default function App() {
|
||||
tabBarIcon: initIcon("ios-radio", "Ionicons"),
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<MenuPage
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
currentTrainState={{ currentTrain, setCurrentTrain }}
|
||||
currentTrainLoadingState={{
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
}}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
{(props) => <MenuPage {...props} getCurrentTrain={getCurrentTrain} />}
|
||||
</Tab.Screen>
|
||||
<Tab.Screen
|
||||
name="home"
|
||||
@ -149,6 +146,7 @@ export default function App() {
|
||||
headerTransparent: true,
|
||||
gestureEnabled: true,
|
||||
tabBarIcon: initIcon("md-train", "Ionicons"),
|
||||
tabBarBadge: areaInfo ? "!" : undefined,
|
||||
}}
|
||||
>
|
||||
{(props) => <TNDView {...props} />}
|
||||
@ -157,197 +155,3 @@ export default function App() {
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
|
||||
const initIcon = (name, type) => {
|
||||
switch (type) {
|
||||
case "Ionicons":
|
||||
return ({ focused, color, size }) => (
|
||||
<Ionicons name={name} size={32} color={focused ? "#0099CC" : "black"} />
|
||||
);
|
||||
case "AntDesign":
|
||||
return ({ focused, color, size }) => (
|
||||
<AntDesign
|
||||
name={name}
|
||||
size={32}
|
||||
color={focused ? "#0099CC" : "black"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const Top = ({
|
||||
navigation,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
currentTrainState,
|
||||
currentTrainLoadingState,
|
||||
getCurrentTrain,
|
||||
}) => {
|
||||
const webview = useRef();
|
||||
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
getStationList2().then(setMapsStationData);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", (e) => {
|
||||
navigation.navigate("favoriteList");
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="Apps"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Apps
|
||||
{...props}
|
||||
webview={webview}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
stationData={mapsStationData}
|
||||
currentTrainState={currentTrainState}
|
||||
currentTrainLoadingState={currentTrainLoadingState}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
title: "トレインビジョン",
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="news" options={optionData}>
|
||||
{(props) => <News {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="trainMenu" options={optionData}>
|
||||
{(props) => (
|
||||
<TrainMenu
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="favoriteList"
|
||||
options={{ ...optionData, gestureEnabled: false }}
|
||||
>
|
||||
{(props) => (
|
||||
<FavoriteList
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
};
|
||||
function MenuPage({
|
||||
navigation,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
currentTrainState,
|
||||
currentTrainLoadingState,
|
||||
getCurrentTrain,
|
||||
}) {
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
if (favoriteStation.toString() != d) {
|
||||
setFavoriteStation(returnData);
|
||||
}
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="menu"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Menu
|
||||
{...props}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
currentTrainState={currentTrainState}
|
||||
currentTrainLoadingState={currentTrainLoadingState}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="setting" options={optionData}>
|
||||
{(props) => <Setting {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
||||
const optionData = {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
};
|
||||
|
170
Apps.js
170
Apps.js
@ -1,50 +1,35 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
View,
|
||||
Platform,
|
||||
ToastAndroid,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import { View, Platform, Text, TouchableOpacity } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import Constants from "expo-constants";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { AS } from "./storageControl";
|
||||
import { news } from "./config/newsUpdate";
|
||||
import { getStationList, lineList } from "./lib/getStationList";
|
||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
import { EachTrainInfo } from "./components/ActionSheetComponents/EachTrainInfo";
|
||||
import { checkDuplicateTrainData } from "./lib/checkDuplicateTrainData";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { useCurrentTrain } from "./stateBox/useCurrentTrain";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
/*
|
||||
import StatusbarDetect from './StatusbarDetect';
|
||||
var Status = StatusbarDetect(); */
|
||||
|
||||
export default function Apps({
|
||||
navigation,
|
||||
webview,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
stationData,
|
||||
currentTrainState,
|
||||
currentTrainLoadingState,
|
||||
getCurrentTrain,
|
||||
}) {
|
||||
const { currentTrain, setCurrentTrain } = currentTrainState;
|
||||
const { currentTrainLoading, setCurrentTrainLoading } =
|
||||
currentTrainLoadingState;
|
||||
export default function Apps({ navigation, webview, stationData }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const { navigate } = navigation;
|
||||
var urlcache = "";
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
//画面表示関連
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [LoadError, setLoadError] = useState(false);
|
||||
|
||||
//列車情報表示関連
|
||||
const EachTrainInfoAsSR = useRef(null);
|
||||
const [trainInfo, setTrainInfo] = useState({
|
||||
trainNum: undefined,
|
||||
limited: undefined,
|
||||
@ -52,17 +37,13 @@ export default function Apps({
|
||||
});
|
||||
|
||||
//駅情報画面用
|
||||
const StationBoardAcSR = useRef(null);
|
||||
const [stationBoardData, setStationBoardData] = useState(undefined);
|
||||
const [originalStationList, setOriginalStationList] = useState();
|
||||
const [selectedStation, setSelectedStation] = useState(undefined);
|
||||
const [trainMenu, setTrainMenu] = useState("true");
|
||||
let once = false;
|
||||
useEffect(() => {
|
||||
getStationList().then(setOriginalStationList);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {}, [stationData, favoriteStation]);
|
||||
//地図表示テキスト
|
||||
const injectJavascript = injectJavascriptData(
|
||||
mapSwitch,
|
||||
@ -77,7 +58,7 @@ export default function Apps({
|
||||
.then((d) => {
|
||||
if (d != news) navigate("news");
|
||||
})
|
||||
.catch((e) => navigate("news"));
|
||||
.catch(() => navigate("news"));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -90,7 +71,7 @@ export default function Apps({
|
||||
AS.setItem("iconSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("iconSwitch", "true").then(Updates.reloadAsync));
|
||||
.catch(() => AS.setItem("iconSwitch", "true").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -103,7 +84,7 @@ export default function Apps({
|
||||
AS.setItem("mapSwitch", "false").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) => AS.setItem("mapSwitch", "false").then(Updates.reloadAsync));
|
||||
.catch(() => AS.setItem("mapSwitch", "false").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
@ -116,7 +97,7 @@ export default function Apps({
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) =>
|
||||
.catch(() =>
|
||||
AS.setItem("stationSwitch", "true").then(Updates.reloadAsync)
|
||||
);
|
||||
}, []);
|
||||
@ -130,9 +111,7 @@ export default function Apps({
|
||||
AS.setItem("trainSwitch", "true").then(Updates.reloadAsync);
|
||||
}
|
||||
})
|
||||
.catch((d) =>
|
||||
AS.setItem("trainSwitch", "true").then(Updates.reloadAsync)
|
||||
);
|
||||
.catch(() => AS.setItem("trainSwitch", "true").then(Updates.reloadAsync));
|
||||
}, []);
|
||||
|
||||
const onMessage = (event) => {
|
||||
@ -146,31 +125,47 @@ export default function Apps({
|
||||
}
|
||||
const dataSet = JSON.parse(event.nativeEvent.data);
|
||||
switch (dataSet.type) {
|
||||
case "PopUpMenu": {
|
||||
const selectedStationPDFAddress = dataSet.pdf;
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter(
|
||||
(d) => d.StationTimeTable == selectedStationPDFAddress
|
||||
);
|
||||
return NearStation;
|
||||
};
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
|
||||
if (returnDataBase.length) {
|
||||
setStationBoardData(returnDataBase);
|
||||
StationBoardAcSR.current?.show();
|
||||
} else {
|
||||
setStationBoardData(undefined);
|
||||
StationBoardAcSR.current?.hide();
|
||||
}
|
||||
case "LoadError": {
|
||||
setLoadError(true);
|
||||
return;
|
||||
}
|
||||
case "PopUpMenu":
|
||||
{
|
||||
const selectedStationPDFAddress = dataSet.pdf;
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter(
|
||||
(d) => d.StationTimeTable == selectedStationPDFAddress
|
||||
);
|
||||
return NearStation;
|
||||
};
|
||||
let returnDataBase = lineList
|
||||
.map((d) => findStationEachLine(originalStationList[d]))
|
||||
.filter((d) => d.length > 0)
|
||||
.reduce((pre, current) => {
|
||||
pre.push(...current);
|
||||
return pre;
|
||||
}, []);
|
||||
|
||||
if (returnDataBase.length) {
|
||||
const payload = {
|
||||
currentStation: returnDataBase,
|
||||
originalStationList: originalStationList,
|
||||
navigate: navigate,
|
||||
goTo: "Apps",
|
||||
useShow: () =>
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
}),
|
||||
onExit: () => {
|
||||
SheetManager.hide("StationDetailView");
|
||||
},
|
||||
};
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
case "ShowTrainTimeInfo": {
|
||||
const { trainNum, limited } = dataSet;
|
||||
//alert(trainNum, limited);
|
||||
@ -181,7 +176,21 @@ export default function Apps({
|
||||
currentTrain.filter((a) => a.num == trainNum)
|
||||
),
|
||||
}); //遅延情報は未実装
|
||||
EachTrainInfoAsSR.current?.show();
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum,
|
||||
limited,
|
||||
trainData: checkDuplicateTrainData(
|
||||
currentTrain.filter((a) => a.num == trainNum)
|
||||
),
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
return;
|
||||
}
|
||||
default: {
|
||||
@ -229,7 +238,7 @@ export default function Apps({
|
||||
}
|
||||
|
||||
const openStationACFromEachTrainInfo = (stationName) => {
|
||||
EachTrainInfoAsSR.current?.hide();
|
||||
SheetManager.hide("EachTrainInfo");
|
||||
const findStationEachLine = (selectLine) => {
|
||||
let NearStation = selectLine.filter((d) => d.Station_JP == stationName);
|
||||
return NearStation;
|
||||
@ -242,13 +251,26 @@ export default function Apps({
|
||||
return pre;
|
||||
}, []);
|
||||
if (returnDataBase.length) {
|
||||
setStationBoardData(returnDataBase);
|
||||
sleep(25, function () {
|
||||
StationBoardAcSR.current?.show();
|
||||
const payload = {
|
||||
currentStation: returnDataBase,
|
||||
originalStationList: originalStationList,
|
||||
navigate: navigate,
|
||||
goTo: "Apps",
|
||||
useShow: () =>
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
}),
|
||||
onExit: () => {
|
||||
SheetManager.hide("StationDetailView");
|
||||
},
|
||||
};
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
});
|
||||
});
|
||||
} else {
|
||||
setStationBoardData(undefined);
|
||||
StationBoardAcSR.current?.hide();
|
||||
SheetManager.hide("StationDetailView");
|
||||
}
|
||||
};
|
||||
return (
|
||||
@ -274,7 +296,6 @@ export default function Apps({
|
||||
onNavigationStateChange={onNavigationStateChange}
|
||||
onMessage={onMessage}
|
||||
injectedJavaScript={injectJavascript}
|
||||
onTouchMove={() => StationBoardAcSR.current?.hide()}
|
||||
onLoadEnd={() => {
|
||||
if (once) return () => {};
|
||||
if (!stationData) return () => {};
|
||||
@ -304,23 +325,10 @@ export default function Apps({
|
||||
<ReloadButton
|
||||
onPress={() => webview.current.reload()}
|
||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||
LoadError={LoadError}
|
||||
/>
|
||||
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={stationBoardData}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
navigate={navigate}
|
||||
onExit={() => {
|
||||
StationBoardAcSR.current?.setModalVisible();
|
||||
navigate("Apps");
|
||||
}}
|
||||
/>
|
||||
<EachTrainInfo
|
||||
setRef={EachTrainInfoAsSR}
|
||||
data={trainInfo}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
@ -366,7 +374,7 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||
const styles = {
|
||||
touch: {
|
||||
position: "absolute",
|
||||
@ -374,7 +382,7 @@ const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
right: 10,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: "#0099CC",
|
||||
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||
borderColor: "white",
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
|
95
MenuPage.js
Normal file
95
MenuPage.js
Normal file
@ -0,0 +1,95 @@
|
||||
import React, { useEffect } from "react";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { AS } from "./storageControl";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import Menu from "./menu";
|
||||
import Setting from "./components/settings.js";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { optionData } from "./lib/stackOption.js";
|
||||
import CurrentTrainListView from "./components/CurrentTrainListView.js";
|
||||
import AllTrainDiagramView from "./components/AllTrainDiagramView.js";
|
||||
const Stack = createStackNavigator();
|
||||
|
||||
export function MenuPage({ navigation, getCurrentTrain }) {
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabPress", (e) => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
if (favoriteStation.toString() != d) {
|
||||
setFavoriteStation(returnData);
|
||||
}
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="menu"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => <Menu {...props} getCurrentTrain={getCurrentTrain} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="setting" options={optionData}>
|
||||
{(props) => <Setting {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="currentTrainIDList"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
gestureResponseDistance: { vertical: 300 },
|
||||
}}
|
||||
>
|
||||
{(props) => <CurrentTrainListView {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="AllTrainIDList"
|
||||
options={{
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerShown: false,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => <AllTrainDiagramView {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
}
|
98
Top.js
Normal file
98
Top.js
Normal file
@ -0,0 +1,98 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {
|
||||
createStackNavigator,
|
||||
TransitionPresets,
|
||||
} from "@react-navigation/stack";
|
||||
import { getStationList2 } from "./lib/getStationList2";
|
||||
import Apps from "./Apps";
|
||||
import TrainBase from "./trainbaseview";
|
||||
import HowTo from "./howto";
|
||||
import News from "./components/news.js";
|
||||
import TrainMenu from "./components/trainMenu.js";
|
||||
import FavoriteList from "./components/FavoriteList.js";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { optionData } from "./lib/stackOption.js";
|
||||
const Stack = createStackNavigator();
|
||||
export const Top = ({ navigation, getCurrentTrain }) => {
|
||||
const webview = useRef();
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
|
||||
//地図用
|
||||
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
getStationList2().then(setMapsStationData);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const unsubscribe = navigation.addListener("tabLongPress", (e) => {
|
||||
navigation.navigate("favoriteList");
|
||||
});
|
||||
|
||||
return unsubscribe;
|
||||
}, [navigation]);
|
||||
|
||||
return (
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen
|
||||
name="Apps"
|
||||
options={{
|
||||
headerShown: false,
|
||||
gestureEnabled: true,
|
||||
headerTransparent: true,
|
||||
}}
|
||||
>
|
||||
{(props) => (
|
||||
<Apps
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="trainbase"
|
||||
options={{
|
||||
title: "トレインビジョン",
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.SlideFromRightIOS,
|
||||
}}
|
||||
>
|
||||
{(props) => <TrainBase {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="howto"
|
||||
options={{
|
||||
...optionData,
|
||||
}}
|
||||
>
|
||||
{(props) => <HowTo {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="news" options={optionData}>
|
||||
{(props) => <News {...props} />}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen name="trainMenu" options={optionData}>
|
||||
{(props) => (
|
||||
<TrainMenu
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
<Stack.Screen
|
||||
name="favoriteList"
|
||||
options={{ ...optionData, gestureEnabled: false }}
|
||||
>
|
||||
{(props) => (
|
||||
<FavoriteList
|
||||
{...props}
|
||||
webview={webview}
|
||||
stationData={mapsStationData}
|
||||
/>
|
||||
)}
|
||||
</Stack.Screen>
|
||||
</Stack.Navigator>
|
||||
);
|
||||
};
|
12
app.json
12
app.json
@ -7,7 +7,7 @@
|
||||
"ios",
|
||||
"android"
|
||||
],
|
||||
"version": "4.5",
|
||||
"version": "4.6",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"splash": {
|
||||
@ -16,13 +16,14 @@
|
||||
"backgroundColor": "#00b8ff"
|
||||
},
|
||||
"updates": {
|
||||
"fallbackToCacheTimeout": 0
|
||||
"fallbackToCacheTimeout": 0,
|
||||
"url": "https://u.expo.dev/398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||
},
|
||||
"assetBundlePatterns": [
|
||||
"**/*"
|
||||
],
|
||||
"ios": {
|
||||
"buildNumber": "30",
|
||||
"buildNumber": "31",
|
||||
"supportsTablet": true,
|
||||
"bundleIdentifier": "jrshikokuinfo.xprocess.hrkn",
|
||||
"config": {
|
||||
@ -31,7 +32,7 @@
|
||||
},
|
||||
"android": {
|
||||
"package": "jrshikokuinfo.xprocess.hrkn",
|
||||
"versionCode": 18,
|
||||
"versionCode": 20,
|
||||
"permissions": [
|
||||
"ACCESS_FINE_LOCATION"
|
||||
],
|
||||
@ -46,6 +47,9 @@
|
||||
"eas": {
|
||||
"projectId": "398abf60-57a7-11e9-970c-8f04356d08bf"
|
||||
}
|
||||
},
|
||||
"runtimeVersion": {
|
||||
"policy": "sdkVersion"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@
|
||||
"9026M":"宇多津,発,18:36#坂出,発,18:40#高松,着,18:54#",
|
||||
"9028M":"宇多津,発,19:38#坂出,発,19:43#高松,着,19:56#",
|
||||
"9054D":"宇多津,発,9:00#坂出,発,9:07#高松,着,9:21#",
|
||||
"9095D":"松山,発,10:35#伊予市,発,10:54#下灘,発,11:51#喜多灘,発,12:07#伊予白滝,発,12:42#伊予大洲,着,13:07#",
|
||||
"9095D":"松山,発,10:34#伊予市,発,10:54#下灘,発,11:51#喜多灘,発,12:07#伊予白滝,発,12:42#伊予大洲,着,13:07#",
|
||||
"9096D":"伊予大洲,発,13:30#伊予白滝,発,13:47#伊予長浜,発,14:24#喜多灘,発,14:36#下灘,発,15:09#伊予上灘,発,15:31#北伊予,発,15:54#松山,着,16:00#",
|
||||
"9323D":"高松,発,9:32#栗林,発,9:53#屋島,発,10:24#八栗口,発,10:40#志度,発,11:32#造田,発,12:14#讃岐津田,発,12:36#三本松,発,13:02#讃岐相生,発,13:31#阿波大宮,発,13:46#板野,発,14:06#板東,発,14:24#池谷,発,14:33#勝瑞,発,14:43#徳島,着,14:56#",
|
||||
"9105D":"児島,発,13:44#坂出,発,14:10#鴨川,発,14:37#端岡,発,14:52#高松,着,15:01#",
|
||||
@ -1035,8 +1035,23 @@
|
||||
"9666D":"北伊予,発,22:46#市坪,発,22:50#松山,着,22:55#",
|
||||
"9668M":"市坪,発,23:00#松山,着,23:04#",
|
||||
"9052D":"窪川,発,15:13#土佐久礼,発,15:46#安和,発,15:57#須崎,発,16:25#佐川,発,16:54#日下,発,17:11#伊野,発,17:32#朝倉,発,17:42#高知,着,17:53#",
|
||||
"9062D":"大歩危,発,14:21#小歩危,発,14:38#阿波川口,発,15:01#阿波池田,発,15:26#坪尻,発,15:53#讃岐財田,発,16:15#琴平,着,16:31#",
|
||||
"9062D":"大歩危,発,14:21#小歩危,発,14:38#阿波川口,発,15:01#阿波池田,発,15:26#坪尻,発,15:53#讃岐財田,発,16:15#琴平,発,16:50#善通寺,発,17:01#金蔵寺,発,17:09#多度津,着,17:14#",
|
||||
"9920D":"伊予大洲,発,14:33#五郎,発,14:39#伊予白滝,発,14:59#伊予長浜,発,15:09#下灘,発,15:23#伊予上灘,発,15:30#伊予市,発,15:44#南伊予,発,15:49#北伊予,発,15:55#松山,着,16:01#",
|
||||
"9051D":"高知,発,12:04#朝倉,発,12:29#伊野,発,12:49#日下,発,13:06#西佐川,発,13:21#須崎,発,13:45#安和,発,14:05#土佐久礼,発,14:17#影野,発,14:31#窪川,着,14:40#",
|
||||
"9061D":"琴平,発,10:48#讃岐財田,発,11:12#坪尻,発,11:41#阿波池田,発,12:10#三縄,発,12:19#大歩危,着,12:47#"
|
||||
"9061D":"多度津,発,10:19#善通寺,発,10:26#琴平,発,10:48#讃岐財田,発,11:12#坪尻,発,11:41#阿波池田,発,12:10#三縄,発,12:19#大歩危,着,12:47#",
|
||||
"9523D":"川之江,発,9:00#伊予三島,発,9:15#伊予寒川,発,9:31#伊予土居,発,10:03#関川,発,10:16#多喜浜,発,10:31#中萩,発,10:49#伊予西条,着,10:57#",
|
||||
"9524D":"伊予西条,発,11:11#新居浜,発,11:35#伊予土居,発,11:59#伊予寒川,発,12:08#伊予三島,発,12:17#川之江,着,12:24#",
|
||||
"9987D":"鳴門,発,22:15#撫養,発,22:18#金比羅前,発,22:21#教会前,発,22:24#立道,発,22:27#阿波大谷,発,22:31#池谷,発,22:36#勝瑞,発,22:41#吉成,発,22:44#佐古,発,22:57#徳島,着,23:00#",
|
||||
"9093D":"松山,発,13:31#北伊予,発,13:42#下灘,発,14:22#喜多灘,発,14:38#伊予大洲,発,15:13#伊予平野,発,15:37#八幡浜,着,15:50#",
|
||||
"9094D":"八幡浜,発,16:14#伊予大洲,発,16:33#伊予長浜,発,16:57#下灘,発,17:24#伊予上灘,発,17:36#伊予市,発,17:53#北伊予,発,18:03#市坪,発,18:12#松山,着,18:17#",
|
||||
"9205D":"児島,発,15:10#宇多津,発,15:28#丸亀,発,15:31#多度津,発,15:36#琴平,発,15:47#讃岐財田,発,16:14#坪尻,発,16:35#佃,発,16:51#阿波池田,発,16:57#阿波川口,発,17:16#大歩危,発,17:35#大田口,発,17:58#大杉,発,18:30#土佐北川,発,18:47#繁藤,発,19:02#土佐山田,発,19:17#後免,発,19:22#土佐一宮,発,19:43#高知,着,19:47#",
|
||||
"9204D":"高知,発,8:43#土佐一宮,発,8:49#繁藤,発,9:16#大杉,発,9:28#土佐岩原,発,9:48#大歩危,発,10:08#阿波川口,発,10:29#阿波池田,発,10:42#讃岐財田,発,11:09#琴平,発,11:33#金蔵寺,発,11:59#多度津,発,12:06#丸亀,発,12:10#児島,着,12:25#",
|
||||
"9003M":"高松,発,8:45#坂出,発,9:02#宇多津,着,9:06#",
|
||||
"9005D":"高松,発,9:42#坂出,発,9:56#宇多津,発,10:01#丸亀,発,10:05#多度津,着,10:10#",
|
||||
"9004M":"宇多津,発,7:14#坂出,発,7:21#高松,着,7:36#",
|
||||
"9006D":"宇多津,発,8:26#坂出,発,8:31#高松,着,8:45#",
|
||||
"9253M":"児島,発,11:02#多度津,発,11:30#善通寺,発,11:54#琴平,着,12:00#",
|
||||
"9256M":"琴平,発,15:20#善通寺,発,15:26#多度津,発,15:35#宇多津,発,15:44#児島,着,16:04#",
|
||||
"9057M":"高松,発,18:27#坂出,発,18:41#宇多津,発,18:46#丸亀,発,18:49#多度津,着,18:55#",
|
||||
"9054M":"宇多津,発,9:00#坂出,発,9:07#高松,着,9:21#"
|
||||
}
|
@ -11,7 +11,7 @@ import {
|
||||
Platform,
|
||||
} from "react-native";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import ActionSheet, { SheetManager } from "react-native-actions-sheet";
|
||||
import { AS } from "../../storageControl";
|
||||
import LottieView from "lottie-react-native";
|
||||
import trainList from "../../assets/originData/trainList";
|
||||
@ -22,14 +22,15 @@ import {
|
||||
} from "react-native-responsive-screen";
|
||||
import lineColorList from "../../assets/originData/lineColorList";
|
||||
|
||||
export const EachTrainInfo = ({
|
||||
setRef,
|
||||
data,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
from,
|
||||
}) => {
|
||||
export const EachTrainInfo = (props) => {
|
||||
if (!props.payload) return <></>;
|
||||
const {
|
||||
data,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
from,
|
||||
} = props.payload;
|
||||
const [trainData, setTrainData] = useState([]);
|
||||
const [isTop, setIsTop] = useState(true);
|
||||
const [currentPosition, setCurrentPosition] = useState([]);
|
||||
@ -96,22 +97,15 @@ export const EachTrainInfo = ({
|
||||
return StationNumbers[0];
|
||||
});
|
||||
function findReversalPoints(array) {
|
||||
// arrayは現在位置の駅ID(駅在宅の場合は1つの配列、駅間の場合は2つの配列)
|
||||
// stopStationIDListは停車駅の駅IDの配列
|
||||
if (!stopStationIDList.length) return [];
|
||||
const arrayNumber = array.map((d) => ({
|
||||
line: d
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
.join(""),
|
||||
ID: d
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
}));
|
||||
const stopStationIDListNumber = stopStationIDList.map((d) => {
|
||||
if (!d) return { line: [], ID: [] };
|
||||
return {
|
||||
try {
|
||||
// arrayは現在位置の駅ID(駅在宅の場合は1つの配列、駅間の場合は2つの配列)
|
||||
// stopStationIDListは停車駅の駅IDの配列
|
||||
if (!stopStationIDList.length) return [];
|
||||
// arrayが二次元配列だったら早期リターン
|
||||
if (!array instanceof Array) return [];
|
||||
if (!array.length) return [];
|
||||
if (array[0] instanceof Array) return [];
|
||||
const arrayNumber = array.map((d) => ({
|
||||
line: d
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
@ -120,84 +114,99 @@ export const EachTrainInfo = ({
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
};
|
||||
});
|
||||
// 完全一致
|
||||
if (array.length == 1) {
|
||||
const index = stopStationIDList.indexOf(array[0]);
|
||||
if (index != -1) return [index];
|
||||
// 通過駅の場合
|
||||
for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
|
||||
if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 駅間の場合
|
||||
if (array.length == 2) {
|
||||
const index1 = stopStationIDList.indexOf(array[0]);
|
||||
const index2 = stopStationIDList.indexOf(array[1]);
|
||||
if (index1 != -1 && index2 != -1) {
|
||||
// 駅間で通過駅も無い場合
|
||||
if (index1 < index2) {
|
||||
if (index1 + 1 == index2) {
|
||||
return [index2];
|
||||
} else {
|
||||
const returnArray = [];
|
||||
for (let i = index1 + 1; i <= index2; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
if (index1 > index2) {
|
||||
if (index2 + 1 == index1) return [index1];
|
||||
else {
|
||||
const returnArray = [];
|
||||
for (let i = index2 + 1; i <= index1; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const getNearStationID = (stationID) => {
|
||||
for (let i = 0; i <= stopStationIDListNumber.length; i++) {
|
||||
if (stopStationIDListNumber[i].ID < stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
const stopStationIDListNumber = stopStationIDList.map((d) => {
|
||||
if (!d) return { line: [], ID: [] };
|
||||
return {
|
||||
line: d
|
||||
.split("")
|
||||
.filter((s) => "A" < s && s < "Z")
|
||||
.join(""),
|
||||
ID: d
|
||||
.split("")
|
||||
.filter((s) => "0" <= s && s <= "9")
|
||||
.join(""),
|
||||
};
|
||||
let newIndex1 = index1;
|
||||
let newIndex2 = index2;
|
||||
if (index1 == -1) {
|
||||
newIndex1 = getNearStationID(arrayNumber[0].ID);
|
||||
}
|
||||
if (index2 == -1) {
|
||||
newIndex2 = getNearStationID(arrayNumber[1].ID);
|
||||
}
|
||||
if (newIndex1 && newIndex2) {
|
||||
return [newIndex1, newIndex2];
|
||||
}
|
||||
|
||||
});
|
||||
// 完全一致
|
||||
if (array.length == 1) {
|
||||
const index = stopStationIDList.indexOf(array[0]);
|
||||
if (index != -1) return [index];
|
||||
// 通過駅の場合
|
||||
for (let i = 0; i < stopStationIDListNumber.length - 1; i++) {
|
||||
if (stopStationIDListNumber[i].ID < arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > arrayNumber[0].ID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < arrayNumber[0].ID) {
|
||||
return [i + 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 駅間の場合
|
||||
if (array.length == 2) {
|
||||
const index1 = stopStationIDList.indexOf(array[0]);
|
||||
const index2 = stopStationIDList.indexOf(array[1]);
|
||||
if (index1 != -1 && index2 != -1) {
|
||||
// 駅間で通過駅も無い場合
|
||||
if (index1 < index2) {
|
||||
if (index1 + 1 == index2) {
|
||||
return [index2];
|
||||
} else {
|
||||
const returnArray = [];
|
||||
for (let i = index1 + 1; i <= index2; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
if (index1 > index2) {
|
||||
if (index2 + 1 == index1) return [index1];
|
||||
else {
|
||||
const returnArray = [];
|
||||
for (let i = index2 + 1; i <= index1; i++) {
|
||||
returnArray.push(i);
|
||||
}
|
||||
return returnArray;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const getNearStationID = (stationID) => {
|
||||
for (let i = 0; i <= stopStationIDListNumber.length; i++) {
|
||||
if (stopStationIDListNumber[i].ID < stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID > stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
if (stopStationIDListNumber[i].ID > stationID) {
|
||||
if (stopStationIDListNumber[i + 1].ID < stationID) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let newIndex1 = index1;
|
||||
let newIndex2 = index2;
|
||||
if (index1 == -1) {
|
||||
newIndex1 = getNearStationID(arrayNumber[0].ID);
|
||||
}
|
||||
if (index2 == -1) {
|
||||
newIndex2 = getNearStationID(arrayNumber[1].ID);
|
||||
}
|
||||
if (newIndex1 && newIndex2) {
|
||||
return [newIndex1, newIndex2];
|
||||
}
|
||||
|
||||
return [];
|
||||
// 通過駅の場合
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
// 使用例
|
||||
@ -232,11 +241,7 @@ export const EachTrainInfo = ({
|
||||
};
|
||||
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={setRef}
|
||||
gestureEnabled={isTop}
|
||||
CustomHeaderComponent={<></>}
|
||||
>
|
||||
<ActionSheet gestureEnabled={isTop} CustomHeaderComponent={<></>}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
@ -289,83 +294,30 @@ export const EachTrainInfo = ({
|
||||
info: "train.html?tn=" + data.trainNum,
|
||||
from,
|
||||
});
|
||||
setRef.current?.hide();
|
||||
SheetManager.hide("EachTrainInfo");
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</View>
|
||||
<ScrollView
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
//width: widthPercentageToDP("200%"),
|
||||
minHeight: 200,
|
||||
height: heightPercentageToDP("20%"),
|
||||
}}
|
||||
horizontal
|
||||
pagingEnabled
|
||||
>
|
||||
<View
|
||||
{from == "AllTrainDiagramView" || (
|
||||
<ScrollView
|
||||
style={{
|
||||
flexDirection: "row",
|
||||
//width: widthPercentageToDP("200%"),
|
||||
minHeight: 200,
|
||||
height: heightPercentageToDP("20%"),
|
||||
width: widthPercentageToDP("100%"),
|
||||
}}
|
||||
horizontal
|
||||
pagingEnabled
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
flexDirection: "row",
|
||||
minHeight: 200,
|
||||
height: heightPercentageToDP("20%"),
|
||||
width: widthPercentageToDP("100%"),
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
現在地 {currentPosition.toString()}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{data.trainData?.Pos && data.trainData?.Pos.match("~") ? (
|
||||
<>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
data.trainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[0]
|
||||
}
|
||||
</Text>
|
||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||
~
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
data.trainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[1]
|
||||
}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<Text
|
||||
style={{ fontSize: 28, color: "#0099CC", textAlign: "right" }}
|
||||
>
|
||||
{data.trainData?.Pos}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "column" }}>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
@ -376,43 +328,101 @@ export const EachTrainInfo = ({
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
{isNaN(data.trainData?.delay) ? "状態" : "遅延時分"}
|
||||
現在地 {currentPosition.toString()}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{data.trainData?.delay}
|
||||
{isNaN(data.trainData?.delay) ? "" : "分"}
|
||||
</Text>
|
||||
{data.trainData?.Pos && data.trainData?.Pos.match("~") ? (
|
||||
<>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
data.trainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[0]
|
||||
}
|
||||
</Text>
|
||||
<Text style={{ color: "#0099CC", textAlign: "right" }}>
|
||||
~
|
||||
</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{
|
||||
data.trainData?.Pos.replace("(下り)", "")
|
||||
.replace("(上り)", "")
|
||||
.split("~")[1]
|
||||
}
|
||||
</Text>
|
||||
</>
|
||||
) : (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 28,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{data.trainData?.Pos}
|
||||
</Text>
|
||||
)}
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>列番</Text>
|
||||
<Text
|
||||
<View style={{ flex: 1, flexDirection: "column" }}>
|
||||
<View
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
{data.trainData?.num}
|
||||
</Text>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>
|
||||
{isNaN(data.trainData?.delay) ? "状態" : "遅延時分"}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{data.trainData?.delay}
|
||||
{isNaN(data.trainData?.delay) ? "" : "分"}
|
||||
</Text>
|
||||
</View>
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
margin: 10,
|
||||
}}
|
||||
>
|
||||
<Text style={{ fontSize: 15, color: "#0099CC" }}>列番</Text>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 32,
|
||||
color: "#0099CC",
|
||||
textAlign: "right",
|
||||
}}
|
||||
>
|
||||
{data.trainData?.num}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
{/* <View
|
||||
{/* <View
|
||||
style={{
|
||||
flexDirection: "column",
|
||||
height: heightPercentageToDP("20%"),
|
||||
@ -491,7 +501,8 @@ export const EachTrainInfo = ({
|
||||
</View>
|
||||
</View>
|
||||
</View> */}
|
||||
</ScrollView>
|
||||
</ScrollView>
|
||||
)}
|
||||
<ScrollView
|
||||
style={{ maxHeight: heightPercentageToDP("55%") }}
|
||||
nestedScrollEnabled
|
||||
@ -658,7 +669,7 @@ export const EachTrainInfo = ({
|
||||
>
|
||||
<Text style={{ fontSize: 20 }}>{station}</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
{points.findIndex((d) => d == index) >= 0 ? (
|
||||
{points && points.findIndex((d) => d == index) >= 0 ? (
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 20,
|
||||
|
@ -10,20 +10,12 @@ import {
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import LottieView from "lottie-react-native";
|
||||
export const JRSTraInfo = (props) => {
|
||||
const {
|
||||
JRSTraInfoEXAcSR,
|
||||
getTime,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
delayData,
|
||||
} = props;
|
||||
import { useTrainDelayData } from "../../stateBox/useTrainDelayData";
|
||||
export const JRSTraInfo = () => {
|
||||
const { getTime, delayData, loadingDelayData, setLoadingDelayData } =
|
||||
useTrainDelayData();
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={JRSTraInfoEXAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={<></>}
|
||||
>
|
||||
<ActionSheet gestureEnabled CustomHeaderComponent={<></>}>
|
||||
<View
|
||||
style={{
|
||||
backgroundColor: "#0099CC",
|
||||
@ -125,12 +117,14 @@ export const JRSTraInfo = (props) => {
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => Linking.openURL("https://twitter.com/JRSTrainfoEX")}
|
||||
onPress={() =>
|
||||
Linking.openURL("https://mstdn.y-zu.org/@JRSTraInfoEX")
|
||||
}
|
||||
>
|
||||
<MaterialCommunityIcons name="twitter" color="white" size={30} />
|
||||
<MaterialCommunityIcons name="mastodon" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
TwitterBOTはこちら!
|
||||
MastodonBOTはこちら!
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
|
@ -1,38 +1,28 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import { View, Linking, Text, TouchableOpacity } from "react-native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import { FontAwesome, Foundation, Ionicons } from "@expo/vector-icons";
|
||||
import ActionSheet from "react-native-actions-sheet";
|
||||
import Sign from "../../components/駅名表/Sign";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
|
||||
import { TicketBox } from "../atom/TicketBox";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import lineColorList from "../../assets/originData/lineColorList";
|
||||
import { getPDFViewURL } from "../../lib/getPdfViewURL";
|
||||
import { useBusAndTrainData } from "../../stateBox/useBusAndTrainData";
|
||||
import { AS } from "../../storageControl";
|
||||
|
||||
export const StationDeteilView = (props) => {
|
||||
if (!props.payload) return <></>;
|
||||
const {
|
||||
StationBoardAcSR,
|
||||
currentStation,
|
||||
originalStationList,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
navigate,
|
||||
onExit,
|
||||
} = props;
|
||||
goTo,
|
||||
useShow,
|
||||
} = props.payload;
|
||||
const { busAndTrainData } = useBusAndTrainData();
|
||||
const [trainBus, setTrainBus] = useState();
|
||||
useEffect(() => {
|
||||
if (!currentStation) return () => {};
|
||||
@ -44,17 +34,18 @@ export const StationDeteilView = (props) => {
|
||||
}
|
||||
setTrainBus(data[0]);
|
||||
}, [currentStation]);
|
||||
|
||||
const [usePDFView, setUsePDFView] = useState(undefined);
|
||||
useEffect(() => {
|
||||
AS.getItem("usePDFView").then(setUsePDFView);
|
||||
}, []);
|
||||
const info =
|
||||
currentStation &&
|
||||
(currentStation[0].StationTimeTable.match(".pdf")
|
||||
? getPDFViewURL(currentStation[0].StationTimeTable)
|
||||
: currentStation[0].StationTimeTable);
|
||||
return (
|
||||
<ActionSheet
|
||||
ref={StationBoardAcSR}
|
||||
gestureEnabled
|
||||
CustomHeaderComponent={<></>}
|
||||
>
|
||||
<ActionSheet gestureEnabled CustomHeaderComponent={<></>}>
|
||||
<View
|
||||
key={currentStation}
|
||||
style={{
|
||||
@ -87,14 +78,15 @@ export const StationDeteilView = (props) => {
|
||||
<Sign
|
||||
currentStation={currentStation}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
oP={() => {
|
||||
navigate("howto", {
|
||||
info,
|
||||
onExit,
|
||||
});
|
||||
StationBoardAcSR.current?.hide();
|
||||
usePDFView == "true"
|
||||
? Linking.openURL(currentStation[0].StationTimeTable)
|
||||
: navigate("howto", {
|
||||
info,
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
oLP={() => Linking.openURL(currentStation[0].StationTimeTable)}
|
||||
/>
|
||||
@ -105,8 +97,6 @@ export const StationDeteilView = (props) => {
|
||||
<NexPreStationLine
|
||||
currentStation={d}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
/>
|
||||
))} */}
|
||||
{currentStation &&
|
||||
@ -118,9 +108,11 @@ export const StationDeteilView = (props) => {
|
||||
info:
|
||||
currentStation[0].JrHpUrl.replace("/index.html", "/") +
|
||||
"/kounai_map.html",
|
||||
onExit,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
StationBoardAcSR.current?.hide();
|
||||
onExit();
|
||||
}}
|
||||
oLP={() => {
|
||||
Linking.openURL(
|
||||
@ -141,9 +133,11 @@ export const StationDeteilView = (props) => {
|
||||
onPressButton={() => {
|
||||
navigate("howto", {
|
||||
info: currentStation[0].JrHpUrl,
|
||||
onExit,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
StationBoardAcSR.current?.hide();
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() =>
|
||||
Linking.openURL(currentStation[0].JrHpUrl)
|
||||
@ -158,11 +152,15 @@ export const StationDeteilView = (props) => {
|
||||
icon={<FontAwesome name="table" color="white" size={50} />}
|
||||
flex={1}
|
||||
onPressButton={() => {
|
||||
navigate("howto", {
|
||||
info,
|
||||
onExit,
|
||||
});
|
||||
StationBoardAcSR.current?.hide();
|
||||
usePDFView == "true"
|
||||
? Linking.openURL(currentStation[0].StationTimeTable)
|
||||
: navigate("howto", {
|
||||
info,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() =>
|
||||
Linking.openURL(currentStation[0].StationTimeTable)
|
||||
@ -191,9 +189,11 @@ export const StationDeteilView = (props) => {
|
||||
onPressButton={() => {
|
||||
navigate("howto", {
|
||||
info: trainBus.address,
|
||||
onExit,
|
||||
|
||||
goTo,
|
||||
useShow,
|
||||
});
|
||||
StationBoardAcSR.current?.hide();
|
||||
onExit();
|
||||
}}
|
||||
onLongPressButton={() => Linking.openURL(trainBus.address)}
|
||||
>
|
||||
@ -218,13 +218,7 @@ const StationName = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const NexPreStationLine = ({
|
||||
currentStation,
|
||||
originalStationList,
|
||||
oP,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
}) => {
|
||||
const NexPreStationLine = ({ currentStation, originalStationList }) => {
|
||||
const [preStation, setPreStation] = useState();
|
||||
const [nexStation, setNexStation] = useState();
|
||||
const [lineName, setLineName] = useState();
|
||||
|
10
components/ActionSheetComponents/sheets.js
Normal file
10
components/ActionSheetComponents/sheets.js
Normal file
@ -0,0 +1,10 @@
|
||||
import { registerSheet } from "react-native-actions-sheet";
|
||||
import { EachTrainInfo } from "./EachTrainInfo";
|
||||
import { JRSTraInfo } from "./JRSTraInfo";
|
||||
import { StationDeteilView } from "./StationDeteilView";
|
||||
|
||||
registerSheet("EachTrainInfo", EachTrainInfo);
|
||||
registerSheet("JRSTraInfo", JRSTraInfo);
|
||||
registerSheet("StationDetailView", StationDeteilView);
|
||||
|
||||
export {};
|
110
components/AllTrainDiagramView.js
Normal file
110
components/AllTrainDiagramView.js
Normal file
@ -0,0 +1,110 @@
|
||||
import React, { useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
View,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
Linking,
|
||||
ScrollView,
|
||||
} from "react-native";
|
||||
import MapView, { Marker } from "react-native-maps";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
import { useAreaInfo } from "../stateBox/useAreaInfo";
|
||||
import { useAllTrainDiagram } from "../stateBox/useAllTrainDiagram";
|
||||
import { EachTrainInfo } from "./ActionSheetComponents/EachTrainInfo";
|
||||
|
||||
import { customTrainDataDetector } from "./custom-train-data";
|
||||
import { getStationList, lineList } from "../lib/getStationList";
|
||||
import { getTrainType } from "../lib/getTrainType";
|
||||
import { checkDuplicateTrainData } from "../lib/checkDuplicateTrainData";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
export default function AllTrainDiagramView({ navigation: { navigate } }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const { areaInfo } = useAreaInfo();
|
||||
const { allTrainDiagram } = useAllTrainDiagram();
|
||||
const [originalStationList, setOriginalStationList] = useState(); // 第一要素
|
||||
const [keyList, setKeyList] = useState(); // 第二要素
|
||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
useEffect(
|
||||
() => allTrainDiagram && setKeyList(Object.keys(allTrainDiagram)),
|
||||
[]
|
||||
);
|
||||
|
||||
const openTrainInfo = (d) => {
|
||||
const train = customTrainDataDetector(d);
|
||||
let TrainNumber = "";
|
||||
if (train.trainNumDistance != undefined) {
|
||||
const timeInfo =
|
||||
parseInt(d.replace("M", "").replace("D", "")) - train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
trainData: checkDuplicateTrainData(
|
||||
currentTrain.filter((a) => a.num == d)
|
||||
),
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
from: "AllTrainDiagramView",
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
};
|
||||
return (
|
||||
<View style={{ backgroundColor: "#0099CC", height: "100%" }}>
|
||||
<ScrollView>
|
||||
{keyList &&
|
||||
keyList.map((key) => (
|
||||
<Item openTrainInfo={openTrainInfo} key={key} id={key} />
|
||||
))}
|
||||
</ScrollView>
|
||||
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => navigate("menu")}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const Item = ({ id, openTrainInfo }) => {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 5,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 5,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => openTrainInfo(id)}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
{id}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
51
components/CurrentTrainListView.js
Normal file
51
components/CurrentTrainListView.js
Normal file
@ -0,0 +1,51 @@
|
||||
import React, { useRef } from "react";
|
||||
import { View, Text, TouchableOpacity, Linking } from "react-native";
|
||||
import MapView, { Marker } from "react-native-maps";
|
||||
import { MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { useCurrentTrain } from "../stateBox/useCurrentTrain";
|
||||
export default function CurrentTrainListView({ navigation: { navigate } }) {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
{currentTrain && currentTrain.map((d) => <Text>{d.num}</Text>)}
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
padding: 10,
|
||||
flexDirection: "row",
|
||||
borderColor: "white",
|
||||
borderWidth: 1,
|
||||
margin: 10,
|
||||
borderRadius: 5,
|
||||
alignItems: "center",
|
||||
}}
|
||||
onPress={() => navigate("menu")}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
閉じる
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const UsefulBox = (props) => {
|
||||
const { icon, backgroundColor, flex, onPressButton, children } = props;
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
flex: flex,
|
||||
backgroundColor: backgroundColor,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
margin: 2,
|
||||
}}
|
||||
onPress={onPressButton}
|
||||
>
|
||||
<MaterialCommunityIcons name={icon} color="white" size={50} />
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 18 }}>
|
||||
{children}
|
||||
</Text>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
@ -1,21 +1,11 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import React from "react";
|
||||
import { View, Text, TouchableOpacity, ScrollView } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import { ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import StatusbarDetect from "../StatusbarDetect";
|
||||
import { AS } from "../storageControl";
|
||||
import { news } from "../config/newsUpdate";
|
||||
import { getStationList, lineList } from "../lib/getStationList";
|
||||
var Status = StatusbarDetect();
|
||||
export default function FavoriteList({
|
||||
navigation,
|
||||
webview,
|
||||
stationData,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
}) {
|
||||
import { useFavoriteStation } from "../stateBox/useFavoriteStation";
|
||||
export default function FavoriteList({ navigation, webview, stationData }) {
|
||||
const { navigate } = navigation;
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
return (
|
||||
<View style={{ height: "100%", backgroundColor: "#0099CC" }}>
|
||||
|
@ -10,15 +10,17 @@ export default function Setting(props) {
|
||||
const {
|
||||
navigation: { navigate },
|
||||
} = props;
|
||||
const [iconSetting, setIconSetting] = useState(undefined);
|
||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [trainMenu, setTrainMenu] = useState(undefined);
|
||||
const [trainPosition, setTrainPosition] = useState(undefined);
|
||||
const [iconSetting, setIconSetting] = useState(false);
|
||||
const [mapSwitch, setMapSwitch] = useState(false);
|
||||
const [stationMenu, setStationMenu] = useState(false);
|
||||
const [usePDFView, setUsePDFView] = useState(false);
|
||||
const [trainMenu, setTrainMenu] = useState(false);
|
||||
const [trainPosition, setTrainPosition] = useState(false);
|
||||
useEffect(() => {
|
||||
AS.getItem("iconSwitch").then(setIconSetting);
|
||||
AS.getItem("mapSwitch").then(setMapSwitch);
|
||||
AS.getItem("stationSwitch").then(setStationMenu);
|
||||
AS.getItem("usePDFView").then(setUsePDFView);
|
||||
AS.getItem("trainSwitch").then(setTrainMenu);
|
||||
AS.getItem("trainPositionSwitch").then(setTrainPosition);
|
||||
}, []);
|
||||
@ -96,6 +98,25 @@ export default function Setting(props) {
|
||||
onValueChange={(value) => setStationMenu(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
fontSize: 25,
|
||||
alignItems: "center",
|
||||
alignContent: "center",
|
||||
textAlign: "center",
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
時刻表PDFをアプリ外で表示
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Switch
|
||||
value={usePDFView == "true" ? true : false}
|
||||
color={usePDFView == "true" ? "red" : null}
|
||||
onValueChange={(value) => setUsePDFView(value.toString())}
|
||||
/>
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", padding: 10 }}>
|
||||
<Text
|
||||
style={{
|
||||
@ -144,7 +165,7 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
内部バージョン: 4.5.4.1
|
||||
内部バージョン: 4.6
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
@ -158,7 +179,7 @@ export default function Setting(props) {
|
||||
textAlignVertical: "center",
|
||||
}}
|
||||
>
|
||||
releaseChannel: {Updates.releaseChannel}
|
||||
releaseChannel: {Updates.channel}
|
||||
</Text>
|
||||
<View style={{ flex: 1 }} />
|
||||
</View>
|
||||
@ -179,6 +200,7 @@ export default function Setting(props) {
|
||||
AS.setItem("iconSwitch", iconSetting.toString()),
|
||||
AS.setItem("mapSwitch", mapSwitch.toString()),
|
||||
AS.setItem("stationSwitch", stationMenu.toString()),
|
||||
AS.setItem("usePDFView", usePDFView.toString()),
|
||||
AS.setItem("trainSwitch", trainMenu.toString()),
|
||||
AS.setItem("trainPositionSwitch", trainPosition.toString()),
|
||||
]).then(() => {
|
||||
|
@ -3,16 +3,16 @@ import { View, Text, TouchableOpacity } from "react-native";
|
||||
import { Switch } from "react-native-elements";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import LottieView from "lottie-react-native";
|
||||
import { Ionicons, MaterialCommunityIcons } from "@expo/vector-icons";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { customTrainDataDetector } from "../custom-train-data";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
import { objectIsEmpty } from "../../lib/objectIsEmpty";
|
||||
import { getTrainType } from "../../lib/getTrainType";
|
||||
import { HeaderConfig } from "../../lib/HeaderConfig";
|
||||
import { getTrainDelayStatus } from "../../lib/getTrainDelayStatus";
|
||||
import { checkDuplicateTrainData } from "../../lib/checkDuplicateTrainData";
|
||||
|
||||
let diagramData = undefined;
|
||||
import { useCurrentTrain } from "../../stateBox/useCurrentTrain";
|
||||
import { useAreaInfo } from "../../stateBox/useAreaInfo";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
|
||||
/**
|
||||
*
|
||||
@ -46,20 +46,18 @@ let diagramData = undefined;
|
||||
export default function LED_vision(props) {
|
||||
const {
|
||||
station,
|
||||
setTrainInfo,
|
||||
EachTrainInfoAsSR,
|
||||
trainDiagram,
|
||||
currentTrainState,
|
||||
currentTrainLoadingState,
|
||||
getCurrentTrain,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
} = props;
|
||||
const { currentTrain, setCurrentTrain } = currentTrainState;
|
||||
const { currentTrainLoading, setCurrentTrainLoading } =
|
||||
currentTrainLoadingState;
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const [stationDiagram, setStationDiagram] = useState({}); //当該駅の全時刻表
|
||||
const [finalSwitch, setFinalSwitch] = useState(false);
|
||||
const [trainIDSwitch, setTrainIDSwitch] = useState(false);
|
||||
const [trainDescriptionSwitch, setTrainDescriptionSwitch] = useState(false);
|
||||
const { areaInfo } = useAreaInfo();
|
||||
|
||||
useEffect(() => {
|
||||
// 現在の駅に停車するダイヤを作成する副作用[列車ダイヤと現在駅情報]
|
||||
@ -149,6 +147,34 @@ export default function LED_vision(props) {
|
||||
return false;
|
||||
};
|
||||
|
||||
const [areaString, setAreaString] = useState("");
|
||||
const [areaStringLength, setAreaStringLength] = useState(0);
|
||||
const [move, setMove] = useState(0);
|
||||
useInterval(
|
||||
() => {
|
||||
if (areaInfo != "") {
|
||||
if (areaStringLength < move) {
|
||||
setMove(0);
|
||||
} else {
|
||||
setMove(move + 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
350,
|
||||
true
|
||||
);
|
||||
useEffect(() => {
|
||||
if (!areaInfo) return () => {};
|
||||
setAreaString(
|
||||
areaInfo.substring(move, areaInfo.length) + areaInfo.substring(0, move)
|
||||
);
|
||||
}, [move]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!areaInfo) return () => {};
|
||||
setAreaStringLength(areaInfo.length);
|
||||
}, [areaInfo]);
|
||||
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@ -159,23 +185,27 @@ export default function LED_vision(props) {
|
||||
marginHorizontal: wp("1%"),
|
||||
}}
|
||||
>
|
||||
<Header
|
||||
currentTrainLoading={currentTrainLoading}
|
||||
setCurrentTrainLoading={setCurrentTrainLoading}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
/>
|
||||
{selectedTrain.map((d, index) => (
|
||||
<Header getCurrentTrain={getCurrentTrain} />
|
||||
{selectedTrain.map((d) => (
|
||||
<EachData
|
||||
d={d}
|
||||
trainIDSwitch={trainIDSwitch}
|
||||
trainDescriptionSwitch={trainDescriptionSwitch}
|
||||
station={station}
|
||||
currentTrain={currentTrain}
|
||||
customTrainDataDetector={customTrainDataDetector}
|
||||
setTrainInfo={setTrainInfo}
|
||||
EachTrainInfoAsSR={EachTrainInfoAsSR}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
))}
|
||||
{areaString != "" && (
|
||||
<Description
|
||||
numberOfLines={1}
|
||||
info={areaString.replace("\n", "").replace("\r", "")}
|
||||
onClick={() => alert(areaInfo)}
|
||||
/>
|
||||
)}
|
||||
|
||||
<Footer
|
||||
trainIDSwitch={trainIDSwitch}
|
||||
setTrainIDSwitch={setTrainIDSwitch}
|
||||
@ -187,50 +217,49 @@ export default function LED_vision(props) {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const Header = ({
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
getCurrentTrain,
|
||||
}) => (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
marginVertical: 10,
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }}></View>
|
||||
<View style={{}}>
|
||||
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
||||
次の列車
|
||||
</Text>
|
||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||
const Header = ({ getCurrentTrain }) => {
|
||||
const { currentTrainLoading, setCurrentTrainLoading } = useCurrentTrain();
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
width: "100%",
|
||||
marginVertical: 10,
|
||||
flexDirection: "row",
|
||||
}}
|
||||
>
|
||||
<View style={{ flex: 1 }}></View>
|
||||
<View style={{}}>
|
||||
<Text style={{ fontSize: 25, color: "white", fontWeight: "bold" }}>
|
||||
次の列車
|
||||
</Text>
|
||||
<Text style={{ fontSize: 15, color: "white" }}>Next Train</Text>
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||
{currentTrainLoading == "loading" ? (
|
||||
<LottieView
|
||||
autoPlay
|
||||
loop
|
||||
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||
source={require("../../assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
) : currentTrainLoading == "error" ? (
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ marginRight: 30 }}
|
||||
onPress={() => {
|
||||
setCurrentTrainLoading("loading");
|
||||
getCurrentTrain();
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
<View style={{ flex: 1, flexDirection: "row-reverse" }}>
|
||||
{currentTrainLoading == "loading" ? (
|
||||
<LottieView
|
||||
autoPlay
|
||||
loop
|
||||
style={{ width: 40, height: 40, marginRight: 30 }}
|
||||
source={require("../../assets/51690-loading-diamonds.json")}
|
||||
/>
|
||||
) : currentTrainLoading == "error" ? (
|
||||
<Ionicons
|
||||
name="reload"
|
||||
color="white"
|
||||
size={30}
|
||||
style={{ marginRight: 30 }}
|
||||
onPress={() => {
|
||||
setCurrentTrainLoading("loading");
|
||||
getCurrentTrain();
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
const Footer = (props) => {
|
||||
const {
|
||||
@ -272,11 +301,12 @@ const EachData = ({
|
||||
trainIDSwitch,
|
||||
trainDescriptionSwitch,
|
||||
station,
|
||||
currentTrain,
|
||||
customTrainDataDetector,
|
||||
setTrainInfo,
|
||||
EachTrainInfoAsSR,
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
}) => {
|
||||
const { currentTrain } = useCurrentTrain();
|
||||
const openTrainInfo = (d) => {
|
||||
let TrainNumber = "";
|
||||
if (train.trainNumDistance != undefined) {
|
||||
@ -285,16 +315,24 @@ const EachData = ({
|
||||
train.trainNumDistance;
|
||||
TrainNumber = timeInfo + "号";
|
||||
}
|
||||
setTrainInfo({
|
||||
trainNum: d.train,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
trainData: checkDuplicateTrainData(
|
||||
currentTrain.filter((a) => a.num == d.train)
|
||||
),
|
||||
const payload = {
|
||||
data: {
|
||||
trainNum: d.train,
|
||||
limited: `${getTrainType(train.type).data}:${
|
||||
train.trainName
|
||||
}${TrainNumber}`,
|
||||
trainData: checkDuplicateTrainData(
|
||||
currentTrain.filter((a) => a.num == d.train)
|
||||
),
|
||||
},
|
||||
navigate,
|
||||
originalStationList,
|
||||
openStationACFromEachTrainInfo,
|
||||
from: "LED",
|
||||
};
|
||||
SheetManager.show("EachTrainInfo", {
|
||||
payload,
|
||||
});
|
||||
EachTrainInfoAsSR.current?.show();
|
||||
};
|
||||
const [train, setTrain] = useState(customTrainDataDetector(d.train));
|
||||
useEffect(() => {
|
||||
@ -413,8 +451,8 @@ const StatusAndDelay = ({ trainDelayStatus }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const Description = ({ info }) => (
|
||||
<View
|
||||
const Description = ({ info, numberOfLines = 0, onClick }) => (
|
||||
<TouchableOpacity
|
||||
style={{
|
||||
alignContent: "center",
|
||||
alignItems: "center",
|
||||
@ -424,6 +462,7 @@ const Description = ({ info }) => (
|
||||
backgroundColor: "#000",
|
||||
flexDirection: "row",
|
||||
}}
|
||||
onPress={onClick}
|
||||
>
|
||||
<View style={{ flex: 4 }}>
|
||||
<Text
|
||||
@ -432,10 +471,11 @@ const Description = ({ info }) => (
|
||||
color: "green",
|
||||
fontWeight: "bold",
|
||||
}}
|
||||
numberOfLines={numberOfLines}
|
||||
>
|
||||
{" "}
|
||||
> {info}
|
||||
</Text>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
|
@ -1,36 +1,19 @@
|
||||
import React, { Component, useRef, useState, useEffect } from "react";
|
||||
import {
|
||||
StatusBar,
|
||||
View,
|
||||
LayoutAnimation,
|
||||
ScrollView,
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
} from "react-native";
|
||||
import {
|
||||
widthPercentageToDP as wp,
|
||||
heightPercentageToDP as hp,
|
||||
} from "react-native-responsive-screen";
|
||||
import React, { useRef, useState, useEffect } from "react";
|
||||
import { View, Text, TouchableOpacity } from "react-native";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import LottieView from "lottie-react-native";
|
||||
import { useInterval } from "../../lib/useInterval";
|
||||
import { AS } from "../../storageControl";
|
||||
import { useFavoriteStation } from "../../stateBox/useFavoriteStation";
|
||||
|
||||
export default function Sign(props) {
|
||||
const {
|
||||
currentStation,
|
||||
originalStationList,
|
||||
oP,
|
||||
oLP,
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
} = props;
|
||||
const { currentStation, originalStationList, oP, oLP } = props;
|
||||
const { favoriteStation, setFavoriteStation } = useFavoriteStation();
|
||||
const [nexPrePosition, setNexPrePosition] = useState(0);
|
||||
|
||||
const [preStation, setPreStation] = useState();
|
||||
const [nexStation, setNexStation] = useState();
|
||||
const [testButtonStatus, setTestButtonStatus] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const isFavorite = favoriteStation.filter((d) => {
|
||||
const compare = JSON.stringify(d);
|
||||
@ -251,6 +234,7 @@ const StationNumberMaker = (props) => {
|
||||
borderWidth: parseInt("2%"),
|
||||
borderRadius: parseInt("100%"),
|
||||
}}
|
||||
key={array[index].StationNumber}
|
||||
>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: parseInt("20%") }}>{d.StationNumber}</Text>
|
||||
|
@ -1 +1 @@
|
||||
export const news = "2023-7-16";
|
||||
export const news = "2023-12-25";
|
||||
|
12
eas.json
12
eas.json
@ -5,10 +5,12 @@
|
||||
"build": {
|
||||
"development": {
|
||||
"developmentClient": true,
|
||||
"distribution": "internal"
|
||||
"distribution": "internal",
|
||||
"channel": "development"
|
||||
},
|
||||
"preview": {
|
||||
"distribution": "internal"
|
||||
"distribution": "internal",
|
||||
"channel": "preview"
|
||||
},
|
||||
"mapsbuild": {
|
||||
"releaseChannel": "mapsbuild"
|
||||
@ -21,6 +23,12 @@
|
||||
},
|
||||
"production4.5": {
|
||||
"releaseChannel": "buyma"
|
||||
},
|
||||
"beta4.6": {
|
||||
"channel": "catch"
|
||||
},
|
||||
"production4.6": {
|
||||
"channel": "costoco"
|
||||
}
|
||||
},
|
||||
"submit": {
|
||||
|
12
howto.js
12
howto.js
@ -3,11 +3,17 @@ import React, { Component } from "react";
|
||||
import { StatusBar, View, TouchableOpacity, Text } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
export default ({ navigation: { navigate }, route }) => {
|
||||
const { info, onExit = () => navigate("Apps") } = route.params;
|
||||
|
||||
const { info, goTo, useShow } = route.params;
|
||||
const onExit = () => {
|
||||
navigate(goTo);
|
||||
useShow();
|
||||
};
|
||||
return (
|
||||
<View style={styles.View}>
|
||||
<WebView useWebKit source={{ uri: info }} />
|
||||
<WebView
|
||||
useWebKit
|
||||
source={{ uri: info.replace("http://", "https://") }}
|
||||
/>
|
||||
<TouchableOpacity style={styles.touch} onPress={onExit}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Text style={{ fontSize: 25, fontWeight: "bold", color: "white" }}>
|
||||
|
@ -3,5 +3,5 @@ import { Platform } from "react-native";
|
||||
export const getPDFViewURL = (url) => {
|
||||
if (Platform.OS == "ios") return url;
|
||||
else
|
||||
return `https://docs.google.com/viewer?url=${encodeURI(url)}&embedded=true`;
|
||||
return `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURI(url)}`;
|
||||
};
|
||||
|
19
lib/initIcon.js
Normal file
19
lib/initIcon.js
Normal file
@ -0,0 +1,19 @@
|
||||
import React from "react";
|
||||
import { Ionicons, AntDesign } from "@expo/vector-icons";
|
||||
|
||||
export const initIcon = (name, type) => {
|
||||
switch (type) {
|
||||
case "Ionicons":
|
||||
return ({ focused, color, size }) => (
|
||||
<Ionicons name={name} size={32} color={focused ? "#0099CC" : "black"} />
|
||||
);
|
||||
case "AntDesign":
|
||||
return ({ focused, color, size }) => (
|
||||
<AntDesign
|
||||
name={name}
|
||||
size={32}
|
||||
color={focused ? "#0099CC" : "black"}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
8
lib/stackOption.js
Normal file
8
lib/stackOption.js
Normal file
@ -0,0 +1,8 @@
|
||||
import { TransitionPresets } from "@react-navigation/stack";
|
||||
export const optionData = {
|
||||
gestureEnabled: true,
|
||||
...TransitionPresets.ModalPresentationIOS,
|
||||
cardOverlayEnabled: true,
|
||||
headerTransparent: true,
|
||||
headerShown: false,
|
||||
};
|
@ -72,14 +72,14 @@ export const injectJavascriptData = (
|
||||
case "25M":
|
||||
case "27M":
|
||||
case "29M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s8000nr.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000nr.png');
|
||||
break;
|
||||
//8000 アンパン
|
||||
case "10M":
|
||||
case "22M":
|
||||
case "9M":
|
||||
case "21M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000ap.png');
|
||||
break;
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ export const injectJavascriptData = (
|
||||
case "11M":
|
||||
case "19M":
|
||||
case "23M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s8600.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8600.png');
|
||||
break;
|
||||
|
||||
//いしづちメイン
|
||||
@ -115,7 +115,7 @@ export const injectJavascriptData = (
|
||||
case "1025M":
|
||||
case "1027M":
|
||||
case "1029M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s8000nr.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000nr.png');
|
||||
break;
|
||||
|
||||
//8000 アンパン
|
||||
@ -123,7 +123,7 @@ export const injectJavascriptData = (
|
||||
case "1022M":
|
||||
case "1009M":
|
||||
case "1021M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000ap.png');
|
||||
break;
|
||||
|
||||
//8600
|
||||
@ -135,29 +135,29 @@ export const injectJavascriptData = (
|
||||
case "1011M":
|
||||
case "1019M":
|
||||
case "1023M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8600_isz.png');
|
||||
break;
|
||||
|
||||
//MEXP
|
||||
//8000
|
||||
case "1092M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s8000nr.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000nr.png');
|
||||
break;
|
||||
//8600
|
||||
case "1091M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8600_isz.png');
|
||||
break;
|
||||
//三桁いしづち
|
||||
//8000 アンパン
|
||||
case "1041M":
|
||||
case "1044M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s8000ap.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8000ap.png');
|
||||
break;
|
||||
//8600
|
||||
case "1043M":
|
||||
case "1042M":
|
||||
case "1046M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s8600_isz.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s8600_isz.png');
|
||||
break;
|
||||
|
||||
|
||||
@ -180,7 +180,7 @@ export const injectJavascriptData = (
|
||||
case "51D":
|
||||
case "53D":
|
||||
case "55D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2700.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2700.png');
|
||||
break;
|
||||
//2700アンパン
|
||||
case "32D":
|
||||
@ -193,7 +193,7 @@ export const injectJavascriptData = (
|
||||
case "45D":
|
||||
case "49D":
|
||||
case "57D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s2700apr.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2700apr.png');
|
||||
break;
|
||||
|
||||
|
||||
@ -223,7 +223,7 @@ export const injectJavascriptData = (
|
||||
case "3027D":
|
||||
case "3031D":
|
||||
case "3033D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2700_uzu.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2700_uzu.png');
|
||||
break;
|
||||
|
||||
//2600
|
||||
@ -235,13 +235,13 @@ export const injectJavascriptData = (
|
||||
case "3011D":
|
||||
case "3017D":
|
||||
case "3023D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2600.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2600.png');
|
||||
break;
|
||||
|
||||
//キハ185
|
||||
case "3009D":
|
||||
case "3032D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185tu_uzu.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185tu_uzu.png');
|
||||
break;
|
||||
|
||||
//マリンライナー
|
||||
@ -313,14 +313,14 @@ export const injectJavascriptData = (
|
||||
case "3167M":
|
||||
case "3169M":
|
||||
case "3175M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s5001.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s5001.png');
|
||||
break;
|
||||
case "3102M":
|
||||
case "3101M":
|
||||
case "3103M":
|
||||
case "3171M":
|
||||
case "3173M":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s5001k.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s5001k.png');
|
||||
break;
|
||||
|
||||
//サンライズ瀬戸
|
||||
@ -328,7 +328,7 @@ export const injectJavascriptData = (
|
||||
case "5031M":
|
||||
case "8041M": //琴平延長高松迄
|
||||
case "8031M": //琴平延長高松以降
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/w285.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/w285.png');
|
||||
break;
|
||||
|
||||
//宇和海
|
||||
@ -357,7 +357,7 @@ export const injectJavascriptData = (
|
||||
case "1075D":
|
||||
case "1077D":
|
||||
case "1079D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2000_uwa.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2000_uwa.png');
|
||||
break;
|
||||
//2000 アンパン込み
|
||||
case "1054D":
|
||||
@ -368,7 +368,7 @@ export const injectJavascriptData = (
|
||||
case "1061D":
|
||||
case "1067D":
|
||||
case "1081D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s2002a.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2002a.png');
|
||||
break;
|
||||
//しまんと
|
||||
case "2002D":
|
||||
@ -379,7 +379,7 @@ export const injectJavascriptData = (
|
||||
case "2003D":
|
||||
case "2005D":
|
||||
case "2007D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2700_smn.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2700_smn.png');
|
||||
break;
|
||||
|
||||
//あしずり 2000
|
||||
@ -393,7 +393,7 @@ export const injectJavascriptData = (
|
||||
case "2077D":
|
||||
case "2081D":
|
||||
case "2083D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2000_asi.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2000_asi.png');
|
||||
break;
|
||||
|
||||
//あしずり 2700
|
||||
@ -404,7 +404,7 @@ export const injectJavascriptData = (
|
||||
case "2079D":
|
||||
case "2085D":
|
||||
case "2072D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s2700_asi.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s2700_asi.png');
|
||||
break;
|
||||
//剣山
|
||||
case "4002D":
|
||||
@ -418,19 +418,19 @@ export const injectJavascriptData = (
|
||||
case "4007D":
|
||||
case "4009D":
|
||||
case "4011D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185tu.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185tu.png');
|
||||
break;
|
||||
//むろと
|
||||
case "5051D":
|
||||
case "5052D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185_mrt.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185_mrt.png');
|
||||
break;
|
||||
|
||||
|
||||
//よしのがわトロッコ
|
||||
case "8452D":
|
||||
case "8451D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s185to_ai.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185to_ai.png');
|
||||
break;
|
||||
|
||||
//岡山高松アントロ
|
||||
@ -439,7 +439,7 @@ export const injectJavascriptData = (
|
||||
//岡山琴平アントロ
|
||||
case "8277D":
|
||||
case "8278D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/s32to4.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s32to4.png');
|
||||
break;
|
||||
|
||||
//伊予灘ものがたり
|
||||
@ -447,14 +447,14 @@ export const injectJavascriptData = (
|
||||
case "8093D":
|
||||
case "8092D":
|
||||
case "8094D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185iyoy.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185iyoy.png');
|
||||
break;
|
||||
|
||||
|
||||
//千年ものがたり
|
||||
case "8011D":
|
||||
case "8012D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185mm1.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185mm1.png');
|
||||
break;
|
||||
|
||||
//夜明けものがたり
|
||||
@ -462,7 +462,7 @@ export const injectJavascriptData = (
|
||||
case "8054D":
|
||||
case "8062D":
|
||||
case "8063D":
|
||||
setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/b/s185ym1.png');
|
||||
setStationIcon(element.querySelector("img"),'https://storage.haruk.in/s185ym1.png');
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -472,7 +472,7 @@ export const injectJavascriptData = (
|
||||
|
||||
const JRF_icon =
|
||||
iconSetting == "true"
|
||||
? `JRF || setStationIcon(element.querySelector("img"),'http://www.trainfrontview.net/f/ef210a.png');`
|
||||
? `JRF || setStationIcon(element.querySelector("img"),'https://storage.haruk.in/ef210a.png');`
|
||||
: ``;
|
||||
const normal_train_name = `
|
||||
if(new RegExp(/^4[1-9]\\d\\d[DM]$/).test(列番データ) || new RegExp(/^5[1-7]\\d\\d[DM]$/).test(列番データ)){
|
||||
@ -667,7 +667,8 @@ const setStrings = () =>{
|
||||
document.getElementById('disp').style.overflowX = 'hidden';
|
||||
|
||||
}catch(e){
|
||||
alert("にゃーん");
|
||||
alert("本家サーバーからのデータ取得に失敗しました。");
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"LoadError"}));
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
@ -745,6 +746,23 @@ const setStationMenuDialog = new MutationObserver( (mutations) => {
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",event:s[0],id:s[1],name:s[2],pdf:s[3],map:s[4],url:s[5],chk:s[6]}));
|
||||
}
|
||||
}
|
||||
const data2 =[];
|
||||
document.querySelectorAll('#disp > div > div > div > div > font > div').forEach(d=>data2.push(d))
|
||||
|
||||
for(let d of data2 ){
|
||||
if(!d.offclick){
|
||||
d.offclick = d.onclick.toString();
|
||||
}
|
||||
const stationID = d.childNodes[0].innerText;
|
||||
const PDFAddress = d.offclick.split("'")[1];
|
||||
const Name = d.childNodes[2].innerText;
|
||||
//alert(PDFAddress);
|
||||
d.onclick = () =>{
|
||||
//const s = d.offclick.replace('(event)','').replaceAll("'", "").split('(')[1].split(')')[0].split(',');
|
||||
// これの中身抽出 PopUpMenu(event,'2','端岡','http://www.jr-shikoku.co.jp/01_trainbus/jikoku/pdf/hashioka.pdf','https://www.google.co.jp/maps/place/34.305027,133.967643','','1')
|
||||
window.ReactNativeWebView.postMessage(JSON.stringify({type:"PopUpMenu",id:stationID,name:Name,pdf:PDFAddress}));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 監視を開始
|
||||
|
154
menu.js
154
menu.js
@ -7,14 +7,12 @@ import {
|
||||
Linking,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
ToastAndroid,
|
||||
} from "react-native";
|
||||
import Constants from "expo-constants";
|
||||
import { ListItem } from "native-base";
|
||||
import Icon from "react-native-vector-icons/Entypo";
|
||||
import * as Location from "expo-location";
|
||||
import StatusbarDetect from "./StatusbarDetect";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import AutoHeightImage from "react-native-auto-height-image";
|
||||
import { widthPercentageToDP as wp } from "react-native-responsive-screen";
|
||||
import {
|
||||
@ -24,7 +22,6 @@ import {
|
||||
MaterialCommunityIcons,
|
||||
} from "@expo/vector-icons";
|
||||
import LottieView from "lottie-react-native";
|
||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||
import { parseAllTrainDiagram } from "./lib/parseAllTrainDiagram";
|
||||
import trainList from "./assets/originData/trainList";
|
||||
|
||||
@ -35,24 +32,18 @@ import { UsefulBox } from "./components/atom/UsefulBox";
|
||||
import { TicketBox } from "./components/atom/TicketBox";
|
||||
import { TextBox } from "./components/atom/TextBox";
|
||||
import { getStationList, lineList } from "./lib/getStationList";
|
||||
import { JRSTraInfo } from "./components/ActionSheetComponents/JRSTraInfo";
|
||||
import { EachTrainInfo } from "./components/ActionSheetComponents/EachTrainInfo";
|
||||
import useInterval from "./lib/useInterval";
|
||||
import { HeaderConfig } from "./lib/HeaderConfig";
|
||||
import { useFavoriteStation } from "./stateBox/useFavoriteStation";
|
||||
import { SheetManager } from "react-native-actions-sheet";
|
||||
import { useTrainDelayData } from "./stateBox/useTrainDelayData";
|
||||
|
||||
export default function Menu(props) {
|
||||
const {
|
||||
navigation: { navigate },
|
||||
favoriteStation,
|
||||
setFavoriteStation,
|
||||
busAndTrainData,
|
||||
currentTrainState,
|
||||
currentTrainLoadingState,
|
||||
getCurrentTrain,
|
||||
} = props;
|
||||
const JRSTraInfoEXAcSR = useRef(null);
|
||||
const StationBoardAcSR = useRef(null);
|
||||
const navigation = useNavigation();
|
||||
const { favoriteStation } = useFavoriteStation();
|
||||
|
||||
//位置情報
|
||||
const [locationStatus, setLocationStatus] = useState(null);
|
||||
@ -62,14 +53,6 @@ export default function Menu(props) {
|
||||
});
|
||||
}, []);
|
||||
|
||||
//列車情報表示関連
|
||||
const EachTrainInfoAsSR = useRef(null);
|
||||
const [trainInfo, setTrainInfo] = useState({
|
||||
trainNum: undefined,
|
||||
limited: undefined,
|
||||
trainData: undefined,
|
||||
});
|
||||
|
||||
const getCurrentPosition = () => {
|
||||
if (locationStatus !== "granted") return () => {};
|
||||
Location.getCurrentPositionAsync({}).then((location) =>
|
||||
@ -120,25 +103,15 @@ export default function Menu(props) {
|
||||
const [originalStationList, setOriginalStationList] = useState(); // 第一要素
|
||||
useEffect(() => getStationList().then(setOriginalStationList), []);
|
||||
|
||||
const [count, setCount] = useState(0);
|
||||
const [delayData, setDelayData] = useState(undefined);
|
||||
const [getTime, setGetTime] = useState(new Date());
|
||||
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
||||
const carouselRef = useRef();
|
||||
const [selectedCurrentStation, setSelectedCurrentStation] = useState(0);
|
||||
|
||||
const [allStationData, setAllStationData] = useState([]);
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((data) => setDelayData(data !== "" ? data.split("^") : null))
|
||||
.then(() => setGetTime(new Date()))
|
||||
.finally(() => setLoadingDelayData(false));
|
||||
}, [loadingDelayData]);
|
||||
const allStationData = [currentStation, ...favoriteStation].filter(
|
||||
(d) => d != undefined
|
||||
);
|
||||
setAllStationData(
|
||||
[currentStation, ...favoriteStation].filter((d) => d != undefined)
|
||||
);
|
||||
}, [currentStation, favoriteStation]);
|
||||
useEffect(() => {
|
||||
if (allStationData.length == 0) {
|
||||
setSelectedCurrentStation(0);
|
||||
@ -170,13 +143,13 @@ export default function Menu(props) {
|
||||
if (d.indexOf("<title>404 Not Found</title>") != -1) throw Error;
|
||||
setTrainDiagram(parseAllTrainDiagram(d));
|
||||
})
|
||||
.catch((d) => {
|
||||
.catch(() => {
|
||||
console.log("fallback");
|
||||
setTrainDiagram(trainList);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const openStationACFromEachTrainInfo = (stationName) => {
|
||||
const openStationACFromEachTrainInfo = () => {
|
||||
// EachTrainInfoAsSR.current?.hide();
|
||||
// const findStationEachLine = (selectLine) => {
|
||||
// let NearStation = selectLine.filter((d) => d.Station_JP == stationName);
|
||||
@ -224,7 +197,7 @@ export default function Menu(props) {
|
||||
onSnapToItem={(d) => {
|
||||
setSelectedCurrentStation(d);
|
||||
}}
|
||||
renderItem={({ item, index }) => {
|
||||
renderItem={({ item }) => {
|
||||
return (
|
||||
<View
|
||||
style={{ marginVertical: 10 }}
|
||||
@ -233,9 +206,27 @@ export default function Menu(props) {
|
||||
<Sign
|
||||
currentStation={item}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
oP={StationBoardAcSR.current?.setModalVisible}
|
||||
oP={() => {
|
||||
const payload = {
|
||||
currentStation:
|
||||
originalStationList &&
|
||||
allStationData.length != 0 &&
|
||||
allStationData[selectedCurrentStation],
|
||||
originalStationList: originalStationList,
|
||||
navigate: navigate,
|
||||
goTo: "menu",
|
||||
useShow: () =>
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
}),
|
||||
onExit: () => {
|
||||
SheetManager.hide("StationDetailView");
|
||||
},
|
||||
};
|
||||
SheetManager.show("StationDetailView", {
|
||||
payload,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@ -249,56 +240,16 @@ export default function Menu(props) {
|
||||
station={
|
||||
originalStationList && allStationData[selectedCurrentStation][0]
|
||||
}
|
||||
setTrainInfo={setTrainInfo}
|
||||
EachTrainInfoAsSR={EachTrainInfoAsSR}
|
||||
trainDiagram={trainDiagram}
|
||||
currentTrainState={currentTrainState}
|
||||
currentTrainLoadingState={currentTrainLoadingState}
|
||||
getCurrentTrain={getCurrentTrain}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
/>
|
||||
)}
|
||||
<JRSTraInfoBox
|
||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||
getTime={getTime}
|
||||
setLoadingDelayData={setLoadingDelayData}
|
||||
loadingDelayData={loadingDelayData}
|
||||
delayData={delayData}
|
||||
/>
|
||||
<JRSTraInfoBox />
|
||||
<FixedContentBottom navigate={navigate} />
|
||||
</ScrollView>
|
||||
|
||||
<StationDeteilView
|
||||
StationBoardAcSR={StationBoardAcSR}
|
||||
currentStation={
|
||||
originalStationList &&
|
||||
allStationData.length != 0 &&
|
||||
allStationData[selectedCurrentStation]
|
||||
}
|
||||
originalStationList={originalStationList}
|
||||
favoriteStation={favoriteStation}
|
||||
setFavoriteStation={setFavoriteStation}
|
||||
busAndTrainData={busAndTrainData}
|
||||
navigate={navigate}
|
||||
onExit={() => {
|
||||
StationBoardAcSR.current?.setModalVisible();
|
||||
navigate("menu");
|
||||
}}
|
||||
/>
|
||||
<JRSTraInfo
|
||||
JRSTraInfoEXAcSR={JRSTraInfoEXAcSR}
|
||||
getTime={getTime}
|
||||
loadingDelayData={loadingDelayData}
|
||||
setLoadingDelayData={setLoadingDelayData}
|
||||
delayData={delayData}
|
||||
/>
|
||||
<EachTrainInfo
|
||||
setRef={EachTrainInfoAsSR}
|
||||
data={trainInfo}
|
||||
navigate={navigate}
|
||||
originalStationList={originalStationList}
|
||||
openStationACFromEachTrainInfo={openStationACFromEachTrainInfo}
|
||||
from="LED"
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@ -361,14 +312,15 @@ const TopMenuButton = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const JRSTraInfoBox = (props) => {
|
||||
const JRSTraInfoBox = () => {
|
||||
const {
|
||||
JRSTraInfoEXAcSR,
|
||||
getTime,
|
||||
setLoadingDelayData,
|
||||
loadingDelayData,
|
||||
setGetTime,
|
||||
delayData,
|
||||
} = props;
|
||||
setDelayData,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
} = useTrainDelayData();
|
||||
const styles = {
|
||||
touch: {
|
||||
backgroundColor: "#0099CC",
|
||||
@ -400,7 +352,7 @@ const JRSTraInfoBox = (props) => {
|
||||
};
|
||||
return (
|
||||
<TouchableOpacity
|
||||
onPress={JRSTraInfoEXAcSR.current?.setModalVisible}
|
||||
onPress={() => SheetManager.show("JRSTraInfo")}
|
||||
style={styles.touch}
|
||||
>
|
||||
<ScrollView scrollEnabled={false} style={styles.scroll}>
|
||||
@ -439,7 +391,7 @@ const JRSTraInfoBox = (props) => {
|
||||
/>
|
||||
</View>
|
||||
) : delayData ? (
|
||||
delayData.map((d, index) => {
|
||||
delayData.map((d) => {
|
||||
let data = d.split(" ");
|
||||
return (
|
||||
<View style={{ flexDirection: "row" }} key={data[1] + "key"}>
|
||||
@ -467,7 +419,7 @@ const JRSTraInfoBox = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const FixedContentTop = (props) => {
|
||||
const FixedContentTop = () => {
|
||||
return (
|
||||
<>
|
||||
<TopMenuButton />
|
||||
@ -716,12 +668,26 @@ const FixedContentBottom = (props) => {
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>上級者向け機能</Text>
|
||||
<TextBox
|
||||
backgroundColor="#8c00d6"
|
||||
flex={1}
|
||||
onPressButton={() => props.navigate("AllTrainIDList")}
|
||||
>
|
||||
<Text style={{ color: "white", fontWeight: "bold", fontSize: 20 }}>
|
||||
列番探索
|
||||
</Text>
|
||||
<Text style={{ color: "white", fontSize: 18 }}>
|
||||
データベースに存在する全列車のダイヤを確認できる機能です。
|
||||
</Text>
|
||||
</TextBox>
|
||||
<Text style={{ fontWeight: "bold", fontSize: 20 }}>
|
||||
このアプリについて
|
||||
</Text>
|
||||
<Text>
|
||||
このアプリはXprocess(HARUKIN)が製作しているJR四国の完全非公式アシストアプリケーションです。このアプリに関することでのJR四国公式へ問合せすることはお控えください。以下のTwitterよりお願いします。
|
||||
</Text>
|
||||
|
||||
<TextBox
|
||||
backgroundColor="#CC0000"
|
||||
flex={1}
|
||||
|
54
ndView.js
54
ndView.js
@ -1,8 +1,11 @@
|
||||
import React from "react";
|
||||
import { View, Platform } from "react-native";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { View, Platform, TouchableOpacity } from "react-native";
|
||||
import { WebView } from "react-native-webview";
|
||||
import Constants from "expo-constants";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
export default function tndView() {
|
||||
const webview = useRef();
|
||||
const [LoadError, setLoadError] = useState(false);
|
||||
return (
|
||||
<View
|
||||
style={{
|
||||
@ -13,11 +16,22 @@ export default function tndView() {
|
||||
>
|
||||
<WebView
|
||||
useWebKit={true}
|
||||
ref={webview}
|
||||
source={{ uri: "https://www.jr-shikoku.co.jp/info/" }}
|
||||
originWhitelist={["https://www.jr-shikoku.co.jp"]}
|
||||
mixedContentMode={"compatibility"}
|
||||
javaScriptEnabled={true}
|
||||
injectedJavaScript={jsa}
|
||||
pullToRefreshEnabled
|
||||
onError={(syntheticEvent) => {
|
||||
//webViewの再読み込みを行う
|
||||
this.webView.reload();
|
||||
}}
|
||||
/>
|
||||
<ReloadButton
|
||||
onPress={() => webview.current.reload()}
|
||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||
LoadError={LoadError}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@ -26,3 +40,39 @@ const jsa = `
|
||||
document.querySelector('.sitettl').style.display = 'none';
|
||||
document.querySelector('.attention').style.display = 'none';
|
||||
`;
|
||||
|
||||
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||
const styles = {
|
||||
touch: {
|
||||
position: "absolute",
|
||||
top,
|
||||
right: 10,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||
borderColor: "white",
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
borderRadius: 50,
|
||||
alignContent: "center",
|
||||
alignSelf: "center",
|
||||
alignItems: "center",
|
||||
display: mapSwitch,
|
||||
},
|
||||
text: {
|
||||
textAlign: "center",
|
||||
width: "auto",
|
||||
height: "auto",
|
||||
textAlignVertical: "center",
|
||||
fontWeight: "bold",
|
||||
color: "white",
|
||||
},
|
||||
};
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress} style={styles.touch}>
|
||||
<View style={{ flex: 1 }} />
|
||||
<Ionicons name="reload" color="white" size={30} />
|
||||
<View style={{ flex: 1 }} />
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
|
38
package.json
38
package.json
@ -8,43 +8,47 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^13.0.0",
|
||||
"@react-native-async-storage/async-storage": "1.17.11",
|
||||
"@react-native-async-storage/async-storage": "1.18.2",
|
||||
"@react-native-community/masked-view": "0.1.10",
|
||||
"@react-navigation/bottom-tabs": "^5.11.11",
|
||||
"@react-navigation/native": "^5.9.4",
|
||||
"@react-navigation/stack": "^5.14.5",
|
||||
"expo": "^48.0.0",
|
||||
"expo-font": "~11.1.1",
|
||||
"expo-location": "~15.1.1",
|
||||
"expo-updates": "~0.16.3",
|
||||
"expo-web-browser": "~12.1.1",
|
||||
"dayjs": "^1.11.9",
|
||||
"eas-cli": "^5.9.1",
|
||||
"expo": "^49.0.21",
|
||||
"expo-device": "~5.4.0",
|
||||
"expo-font": "~11.4.0",
|
||||
"expo-location": "~16.1.0",
|
||||
"expo-notifications": "~0.20.1",
|
||||
"expo-updates": "~0.18.17",
|
||||
"expo-web-browser": "~12.3.2",
|
||||
"firebase": "8.2.3",
|
||||
"lottie-react-native": "5.1.4",
|
||||
"lottie-react-native": "5.1.6",
|
||||
"native-base": "^2.15.2",
|
||||
"npm": "^7.18.1",
|
||||
"pushy-react-native": "^1.0.18",
|
||||
"react": "18.2.0",
|
||||
"react-native": "0.71.3",
|
||||
"react-native-actions-sheet": "^0.4.9",
|
||||
"react-native": "0.72.6",
|
||||
"react-native-actions-sheet": "0.8.21",
|
||||
"react-native-auto-height-image": "^3.2.4",
|
||||
"react-native-elements": "^3.4.2",
|
||||
"react-native-gesture-handler": "~2.9.0",
|
||||
"react-native-maps": "1.3.2",
|
||||
"react-native-reanimated": "~2.14.4",
|
||||
"react-native-gesture-handler": "~2.12.0",
|
||||
"react-native-maps": "1.7.1",
|
||||
"react-native-reanimated": "^3.6.1",
|
||||
"react-native-remote-svg": "^2.0.6",
|
||||
"react-native-responsive-screen": "^1.4.2",
|
||||
"react-native-router-flux": "^4.3.1",
|
||||
"react-native-safe-area-context": "4.5.0",
|
||||
"react-native-screens": "~3.20.0",
|
||||
"react-native-safe-area-context": "4.6.3",
|
||||
"react-native-screens": "~3.22.0",
|
||||
"react-native-snap-carousel": "^3.9.1",
|
||||
"react-native-storage": "^1.0.1",
|
||||
"react-native-svg": "13.4.0",
|
||||
"react-native-svg": "13.9.0",
|
||||
"react-native-svg-uri": "^1.2.3",
|
||||
"react-native-vector-icons": "^8.1.0",
|
||||
"react-native-webview": "11.26.0"
|
||||
"react-native-webview": "^13.6.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-preset-expo": "^9.3.0"
|
||||
"babel-preset-expo": "^9.5.0"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
38
stateBox/useAllTrainDiagram.js
Normal file
38
stateBox/useAllTrainDiagram.js
Normal file
@ -0,0 +1,38 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
const initialState = {
|
||||
allTrainDiagram: undefined,
|
||||
setAllTrainDiagram: () => {},
|
||||
};
|
||||
|
||||
const AllTrainDiagramContext = createContext(initialState);
|
||||
|
||||
export const useAllTrainDiagram = () => {
|
||||
return useContext(AllTrainDiagramContext);
|
||||
};
|
||||
|
||||
export const AllTrainDiagramProvider = ({ children }) => {
|
||||
const [allTrainDiagram, setAllTrainDiagram] = useState();
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbx_s7RB-xTy-iAslFJg7LfplLV09-hjDXEjdi9kCP_JT45wq17Af_IPOKIOqIfaNDg/exec"
|
||||
)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
const data = {};
|
||||
res.forEach((d) => {
|
||||
const keys = Object.keys(d);
|
||||
data[keys] = d[keys];
|
||||
});
|
||||
return data;
|
||||
})
|
||||
.then((res) => setAllTrainDiagram(res));
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AllTrainDiagramContext.Provider
|
||||
value={{ allTrainDiagram, setAllTrainDiagram }}
|
||||
>
|
||||
{children}
|
||||
</AllTrainDiagramContext.Provider>
|
||||
);
|
||||
};
|
21
stateBox/useAreaInfo.js
Normal file
21
stateBox/useAreaInfo.js
Normal file
@ -0,0 +1,21 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
const initialState = {
|
||||
areaInfo: "",
|
||||
setAreainfo: () => {},
|
||||
};
|
||||
|
||||
const AreaInfoContext = createContext(initialState);
|
||||
|
||||
export const useAreaInfo = () => {
|
||||
return useContext(AreaInfoContext);
|
||||
};
|
||||
|
||||
export const AreaInfoProvider = ({ children }) => {
|
||||
const [areaInfo, setAreaInfo] = useState("");
|
||||
|
||||
return (
|
||||
<AreaInfoContext.Provider value={{ areaInfo, setAreaInfo }}>
|
||||
{children}
|
||||
</AreaInfoContext.Provider>
|
||||
);
|
||||
};
|
23
stateBox/useBusAndTrainData.js
Normal file
23
stateBox/useBusAndTrainData.js
Normal file
@ -0,0 +1,23 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
const initialState = {
|
||||
busAndTrainData: [],
|
||||
setBusAndTrainData: () => {},
|
||||
};
|
||||
|
||||
const BusAndTrainDataContext = createContext(initialState);
|
||||
|
||||
export const useBusAndTrainData = () => {
|
||||
return useContext(BusAndTrainDataContext);
|
||||
};
|
||||
|
||||
export const BusAndTrainDataProvider = ({ children }) => {
|
||||
const [busAndTrainData, setBusAndTrainData] = useState([]);
|
||||
|
||||
return (
|
||||
<BusAndTrainDataContext.Provider
|
||||
value={{ busAndTrainData, setBusAndTrainData }}
|
||||
>
|
||||
{children}
|
||||
</BusAndTrainDataContext.Provider>
|
||||
);
|
||||
};
|
31
stateBox/useCurrentTrain.js
Normal file
31
stateBox/useCurrentTrain.js
Normal file
@ -0,0 +1,31 @@
|
||||
import React, { createContext, useContext, useState } from "react";
|
||||
const initialState = {
|
||||
currentTrain: [],
|
||||
setCurrentTrain: () => {},
|
||||
currentTrainLoading: "loading",
|
||||
setCurrentTrainLoading: () => {},
|
||||
};
|
||||
|
||||
const CurrentTrainContext = createContext(initialState);
|
||||
|
||||
export const useCurrentTrain = () => {
|
||||
return useContext(CurrentTrainContext);
|
||||
};
|
||||
|
||||
export const CurrentTrainProvider = ({ children }) => {
|
||||
const [currentTrain, setCurrentTrain] = useState([]); //現在在線中の全列車 { num: 列車番号, delay: 遅延時分(状態), Pos: 位置情報 }
|
||||
const [currentTrainLoading, setCurrentTrainLoading] = useState("loading"); // success, error, loading
|
||||
|
||||
return (
|
||||
<CurrentTrainContext.Provider
|
||||
value={{
|
||||
currentTrain,
|
||||
setCurrentTrain,
|
||||
currentTrainLoading,
|
||||
setCurrentTrainLoading,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</CurrentTrainContext.Provider>
|
||||
);
|
||||
};
|
31
stateBox/useFavoriteStation.js
Normal file
31
stateBox/useFavoriteStation.js
Normal file
@ -0,0 +1,31 @@
|
||||
import React, { createContext, useContext, useState, useEffect } from "react";
|
||||
import { AS } from "../storageControl";
|
||||
const initialState = {
|
||||
favoriteStation: [],
|
||||
setFavoriteStation: () => {},
|
||||
};
|
||||
|
||||
const FavoriteStationContext = createContext(initialState);
|
||||
|
||||
export const useFavoriteStation = () => {
|
||||
return useContext(FavoriteStationContext);
|
||||
};
|
||||
|
||||
export const FavoriteStationProvider = ({ children }) => {
|
||||
const [favoriteStation, setFavoriteStation] = useState([]);
|
||||
useEffect(() => {
|
||||
AS.getItem("favoriteStation")
|
||||
.then((d) => {
|
||||
const returnData = JSON.parse(d);
|
||||
setFavoriteStation(returnData);
|
||||
})
|
||||
.catch((d) => console.log(d));
|
||||
}, []);
|
||||
return (
|
||||
<FavoriteStationContext.Provider
|
||||
value={{ favoriteStation, setFavoriteStation }}
|
||||
>
|
||||
{children}
|
||||
</FavoriteStationContext.Provider>
|
||||
);
|
||||
};
|
45
stateBox/useTrainDelayData.js
Normal file
45
stateBox/useTrainDelayData.js
Normal file
@ -0,0 +1,45 @@
|
||||
import React, { createContext, useContext, useEffect, useState } from "react";
|
||||
const initialState = {
|
||||
getTime: new Date(),
|
||||
setGetTime: () => {},
|
||||
loadingDelayData: true,
|
||||
setLoadingDelayData: () => {},
|
||||
delayData: undefined,
|
||||
setDelayData: () => {},
|
||||
};
|
||||
|
||||
const TrainDelayDataContext = createContext(initialState);
|
||||
|
||||
export const useTrainDelayData = () => {
|
||||
return useContext(TrainDelayDataContext);
|
||||
};
|
||||
|
||||
export const TrainDelayDataProvider = ({ children }) => {
|
||||
const [delayData, setDelayData] = useState(undefined);
|
||||
const [getTime, setGetTime] = useState(new Date());
|
||||
const [loadingDelayData, setLoadingDelayData] = useState(true);
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbyKxch7z7l8e07LXulRHqxjVoIiB13kcgvoToLE-rqlxLmLSKdlmqz0FI1F2EuA7Zfg/exec"
|
||||
)
|
||||
.then((response) => response.text())
|
||||
.then((data) => setDelayData(data !== "" ? data.split("^") : null))
|
||||
.then(() => setGetTime(new Date()))
|
||||
.finally(() => setLoadingDelayData(false));
|
||||
}, [loadingDelayData]);
|
||||
|
||||
return (
|
||||
<TrainDelayDataContext.Provider
|
||||
value={{
|
||||
getTime,
|
||||
setGetTime,
|
||||
loadingDelayData,
|
||||
setLoadingDelayData,
|
||||
delayData,
|
||||
setDelayData,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</TrainDelayDataContext.Provider>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user