diff --git a/components/Apps.js b/components/Apps.js
index f4a7d5f..38a188b 100644
--- a/components/Apps.js
+++ b/components/Apps.js
@@ -28,6 +28,8 @@ import { AppsWebView } from "./Apps/WebView";
import StatusbarDetect from '../StatusbarDetect';
var Status = StatusbarDetect(); */
+const top = Platform.OS == "ios" ? Constants.statusBarHeight : 0;
+
export default function Apps() {
const { webview } = useCurrentTrain();
const { height, width } = useWindowDimensions();
@@ -52,9 +54,7 @@ export default function Apps() {
//駅情報画面用
const [originalStationList, setOriginalStationList] = useState();
const [trainMenu, setTrainMenu] = useState("true");
- useEffect(() => {
- getStationList().then(setOriginalStationList);
- }, []);
+ useEffect(() => getStationList().then(setOriginalStationList), []);
//地図表示テキスト
const injectJavascript = injectJavascriptData(
@@ -119,7 +119,7 @@ export default function Apps() {
)}
@@ -186,13 +185,11 @@ export default function Apps() {
trainData: undefined,
});
}}
- top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
/>
)}
{mapSwitch == "true" ? (
Updates.reloadAsync()}
- top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
right={isLandscape && trainInfo.trainNum ? (width / 100) * 40 : 0}
LoadError={LoadError}
/>
@@ -207,15 +204,14 @@ export default function Apps() {
);
}
-
const NewMenu = ({ webview, LoadError }) => {
const { width } = useWindowDimensions();
return (
{
);
};
-const MapsButton = ({ onPress, top, mapSwitch }) => {
+const MapsButton = ({ onPress, mapSwitch }) => {
const styles = {
touch: {
position: "absolute",
@@ -328,11 +324,10 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
);
};
-const LandscapeBackButton = ({ onPress, top }) => {
+const LandscapeBackButton = ({ onPress }) => {
const styles = {
touch: {
position: "absolute",
- top,
left: 10,
width: 50,
height: 50,
@@ -364,13 +359,7 @@ const LandscapeBackButton = ({ onPress, top }) => {
);
};
-const ReloadButton = ({
- onPress,
- top,
- mapSwitch,
- LoadError = false,
- right,
-}) => {
+const ReloadButton = ({ onPress, mapSwitch, LoadError = false, right }) => {
const styles = {
touch: {
position: "absolute",
diff --git a/components/Apps/WebView.jsx b/components/Apps/WebView.jsx
index f080ed1..1a5469f 100644
--- a/components/Apps/WebView.jsx
+++ b/components/Apps/WebView.jsx
@@ -27,23 +27,21 @@ export const AppsWebView = ({
var urlcache = "";
let once = false;
- const onNavigationStateChange = (event) => {
- if (event.url != urlcache) {
- //URL二重判定回避
- urlcache = event.url;
-
- if (event.url.includes("https://train.jr-shikoku.co.jp/usage.htm")) {
- if (Platform.OS === "android") navigate("howto", { info: event.url });
+ const onNavigationStateChange = ({ url }) => {
+ if (url == urlcache) return;
+ //URL二重判定回避
+ urlcache = url;
+ switch (true) {
+ case url.includes("https://train.jr-shikoku.co.jp/usage.htm"):
+ if (Platform.OS === "android") navigate("howto", { info: url });
webview?.current.goBack();
//Actions.howto();
- } else if (
- event.url.includes("https://train.jr-shikoku.co.jp/train.html")
- ) {
- //Actions.trainbase({info: event.url});
- if (Platform.OS === "android")
- navigate("trainbase", { info: event.url });
+ break;
+ case url.includes("https://train.jr-shikoku.co.jp/train.html"):
+ //Actions.trainbase({info: url});
+ if (Platform.OS === "android") navigate("trainbase", { info: url });
webview?.current.goBack();
- }
+ break;
}
};
@@ -65,11 +63,8 @@ export const AppsWebView = ({
}
case "PopUpMenu":
{
- const selectedStationPDFAddress = dataSet.pdf;
const findStationEachLine = (selectLine) =>
- selectLine.filter(
- (d) => d.StationTimeTable == selectedStationPDFAddress
- );
+ selectLine.filter((d) => d.StationTimeTable == dataSet.pdf);
let returnDataBase = lineList
.map((d) => findStationEachLine(originalStationList[d]))
.filter((d) => d.length > 0)
@@ -85,9 +80,7 @@ export const AppsWebView = ({
navigate: navigate,
goTo: "Apps",
useShow: () =>
- SheetManager.show("StationDetailView", {
- payload,
- }),
+ SheetManager.show("StationDetailView", { payload }),
onExit: () => SheetManager.hide("StationDetailView"),
};
SheetManager.show("StationDetailView", { payload });
@@ -107,17 +100,12 @@ export const AppsWebView = ({
}); //遅延情報は未実装
if (isLandscape) return;
const payload = {
- data: {
- trainNum,
- limited,
- },
+ data: { trainNum, limited },
navigate,
originalStationList,
openStationACFromEachTrainInfo,
};
- SheetManager.show("EachTrainInfo", {
- payload,
- });
+ SheetManager.show("EachTrainInfo", { payload });
return;
}
case "currentLines": {
@@ -136,22 +124,21 @@ export const AppsWebView = ({
const onLoadEnd = () => {
if (once) return () => {};
if (!stationData) return () => {};
- if (favoriteStation.length > 0) {
- const getStationLine = (now) => {
- const returnData = Object.keys(stationData).filter((d) => {
- const cache = stationData[d].findIndex(
- (data) => data.Station_JP == now.Station_JP
- );
- return cache != -1;
- });
- return returnData[0];
- };
- const lineName = getStationLine(favoriteStation[0][0]);
- webview.current?.injectJavaScript(
- `MoveDisplayStation('${lineName}_${favoriteStation[0][0].MyStation}_${favoriteStation[0][0].Station_JP}')`
- );
- once = true;
- }
+ if (favoriteStation.length < 1) return () => {};
+ const getStationLine = (now) => {
+ const returnData = Object.keys(stationData).filter((d) => {
+ const cache = stationData[d].findIndex(
+ (data) => data.Station_JP == now.Station_JP
+ );
+ return cache != -1;
+ });
+ return returnData[0];
+ };
+ const lineName = getStationLine(favoriteStation[0][0]);
+ webview.current?.injectJavaScript(
+ `MoveDisplayStation('${lineName}_${favoriteStation[0][0].MyStation}_${favoriteStation[0][0].Station_JP}')`
+ );
+ once = true;
};
return (