にゃーんをエラー文にし、再読み込みボタンの色が変化するように
This commit is contained in:
parent
91fb41dab0
commit
8f23faacd7
5
App.js
5
App.js
@ -105,14 +105,13 @@ export function AppContainer() {
|
|||||||
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
useInterval(getCurrentTrain, 15000); //15秒毎に全在線列車取得
|
||||||
|
|
||||||
const { areaInfo, setAreaInfo } = useAreaInfo();
|
const { areaInfo, setAreaInfo } = useAreaInfo();
|
||||||
const getAreaInfo = () => {
|
useEffect(() => {
|
||||||
fetch(
|
fetch(
|
||||||
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
||||||
)
|
)
|
||||||
.then((d) => d.text())
|
.then((d) => d.text())
|
||||||
.then((d) => setAreaInfo(d));
|
.then((d) => setAreaInfo(d));
|
||||||
};
|
}, []);
|
||||||
useEffect(getAreaInfo, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<NavigationContainer name="Root" style={{ flex: 1 }}>
|
<NavigationContainer name="Root" style={{ flex: 1 }}>
|
||||||
|
10
Apps.js
10
Apps.js
@ -26,6 +26,7 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
const [iconSetting, setIconSetting] = useState(undefined);
|
const [iconSetting, setIconSetting] = useState(undefined);
|
||||||
const [mapSwitch, setMapSwitch] = useState(undefined);
|
const [mapSwitch, setMapSwitch] = useState(undefined);
|
||||||
const [stationMenu, setStationMenu] = useState(undefined);
|
const [stationMenu, setStationMenu] = useState(undefined);
|
||||||
|
const [LoadError, setLoadError] = useState(false);
|
||||||
|
|
||||||
//列車情報表示関連
|
//列車情報表示関連
|
||||||
const EachTrainInfoAsSR = useRef(null);
|
const EachTrainInfoAsSR = useRef(null);
|
||||||
@ -127,6 +128,10 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
}
|
}
|
||||||
const dataSet = JSON.parse(event.nativeEvent.data);
|
const dataSet = JSON.parse(event.nativeEvent.data);
|
||||||
switch (dataSet.type) {
|
switch (dataSet.type) {
|
||||||
|
case "LoadError": {
|
||||||
|
setLoadError(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
case "PopUpMenu": {
|
case "PopUpMenu": {
|
||||||
const selectedStationPDFAddress = dataSet.pdf;
|
const selectedStationPDFAddress = dataSet.pdf;
|
||||||
const findStationEachLine = (selectLine) => {
|
const findStationEachLine = (selectLine) => {
|
||||||
@ -285,6 +290,7 @@ export default function Apps({ navigation, webview, stationData }) {
|
|||||||
<ReloadButton
|
<ReloadButton
|
||||||
onPress={() => webview.current.reload()}
|
onPress={() => webview.current.reload()}
|
||||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||||
|
LoadError={LoadError}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<StationDeteilView
|
<StationDeteilView
|
||||||
@ -344,7 +350,7 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||||
const styles = {
|
const styles = {
|
||||||
touch: {
|
touch: {
|
||||||
position: "absolute",
|
position: "absolute",
|
||||||
@ -352,7 +358,7 @@ const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
|||||||
right: 10,
|
right: 10,
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
backgroundColor: "#0099CC",
|
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||||
borderColor: "white",
|
borderColor: "white",
|
||||||
borderStyle: "solid",
|
borderStyle: "solid",
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
@ -667,7 +667,8 @@ const setStrings = () =>{
|
|||||||
document.getElementById('disp').style.overflowX = 'hidden';
|
document.getElementById('disp').style.overflowX = 'hidden';
|
||||||
|
|
||||||
}catch(e){
|
}catch(e){
|
||||||
alert("にゃーん");
|
alert("本家サーバーからのデータ取得に失敗しました。");
|
||||||
|
window.ReactNativeWebView.postMessage(JSON.stringify({type:"LoadError"}));
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user