地図用駅リストを再設置
This commit is contained in:
parent
0c4a4921c6
commit
9135ad3504
31
Apps.js
31
Apps.js
@ -13,6 +13,7 @@ import { news } from "./config/newsUpdate";
|
|||||||
import { getStationList } from "./lib/getStationList";
|
import { getStationList } from "./lib/getStationList";
|
||||||
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
import { StationDeteilView } from "./components/ActionSheetComponents/StationDeteilView";
|
||||||
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
import { injectJavascriptData } from "./lib/webViewInjectjavascript";
|
||||||
|
import { getStationList2 } from "./lib/getStationList2";
|
||||||
/*
|
/*
|
||||||
import StatusbarDetect from './StatusbarDetect';
|
import StatusbarDetect from './StatusbarDetect';
|
||||||
var Status = StatusbarDetect(); */
|
var Status = StatusbarDetect(); */
|
||||||
@ -23,10 +24,19 @@ export default function Apps(props) {
|
|||||||
} = props;
|
} = props;
|
||||||
var urlcache = "";
|
var urlcache = "";
|
||||||
const webview = useRef();
|
const webview = useRef();
|
||||||
|
//画面表示関連
|
||||||
const [iconSetting, setIconSetting] = useState(undefined);
|
const [iconSetting, setIconSetting] = useState(undefined);
|
||||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||||
|
|
||||||
const [stationData, setStationData] = useState(undefined);
|
//地図用
|
||||||
|
const [mapsStationData, setMapsStationData] = useState(undefined);
|
||||||
|
useEffect(() => {
|
||||||
|
getStationList2().then((data) => {
|
||||||
|
setMapsStationData(data);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
//駅情報画面用
|
||||||
const StationBoardAcSR = useRef(null);
|
const StationBoardAcSR = useRef(null);
|
||||||
const [currentStation, setCurrentStation] = useState(undefined);
|
const [currentStation, setCurrentStation] = useState(undefined);
|
||||||
const [originalStationList, setOriginalStationList] = useState();
|
const [originalStationList, setOriginalStationList] = useState();
|
||||||
@ -37,20 +47,18 @@ export default function Apps(props) {
|
|||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
//地図表示テキスト
|
||||||
const injectJavascript = injectJavascriptData(mapSwitch, iconSetting);
|
const injectJavascript = injectJavascriptData(mapSwitch, iconSetting);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
//ニュース表示
|
||||||
AsyncStorage.getItem("status")
|
AsyncStorage.getItem("status")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d != news) {
|
if (d != news) navigate("news");
|
||||||
navigate("news");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => navigate("news"));
|
||||||
navigate("news");
|
|
||||||
});
|
//列車アイコンスイッチ
|
||||||
}, []);
|
|
||||||
useEffect(() => {
|
|
||||||
AsyncStorage.getItem("iconSwitch")
|
AsyncStorage.getItem("iconSwitch")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
@ -67,6 +75,7 @@ export default function Apps(props) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//地図スイッチ
|
||||||
AsyncStorage.getItem("mapSwitch")
|
AsyncStorage.getItem("mapSwitch")
|
||||||
.then((d) => {
|
.then((d) => {
|
||||||
if (d) {
|
if (d) {
|
||||||
@ -133,7 +142,9 @@ export default function Apps(props) {
|
|||||||
injectedJavaScript={injectJavascript}
|
injectedJavaScript={injectJavascript}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => navigate("trainMenu", { webview, stationData })}
|
onPress={() =>
|
||||||
|
navigate("trainMenu", { webview, stationData: mapsStationData })
|
||||||
|
}
|
||||||
style={{
|
style={{
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
top: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
top: Platform.OS == "ios" ? Constants.statusBarHeight : 0,
|
||||||
|
55
lib/getStationList2.js
Normal file
55
lib/getStationList2.js
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
let status = undefined;
|
||||||
|
export const getStationList2 = async (props) => {
|
||||||
|
if (status) return status;
|
||||||
|
const HeaderConfig = {
|
||||||
|
headers: { referer: "https://train.jr-shikoku.co.jp/sp.html" },
|
||||||
|
};
|
||||||
|
|
||||||
|
return await Promise.all([
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=yosan",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=uwajima2",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=dosan2",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=koutoku",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=tokushima",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
fetch(
|
||||||
|
"https://train.jr-shikoku.co.jp/g?arg1=station&arg2=naruto",
|
||||||
|
HeaderConfig
|
||||||
|
).then((response) => response.json()),
|
||||||
|
]).then((values) => {
|
||||||
|
let stationList = {};
|
||||||
|
[
|
||||||
|
stationList.yosan,
|
||||||
|
stationList.uwajima,
|
||||||
|
stationList.uwajima2,
|
||||||
|
stationList.dosan,
|
||||||
|
stationList.dosan2,
|
||||||
|
stationList.koutoku,
|
||||||
|
stationList.tokushima,
|
||||||
|
stationList.naruto,
|
||||||
|
] = values;
|
||||||
|
return stationList;
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user