にゃーんをエラー文にし、再読み込みボタンの色が変化するように
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秒毎に全在線列車取得
|
||||
|
||||
const { areaInfo, setAreaInfo } = useAreaInfo();
|
||||
const getAreaInfo = () => {
|
||||
useEffect(() => {
|
||||
fetch(
|
||||
"https://script.google.com/macros/s/AKfycbz80LcaEUrhnlEsLkJy0LG2IRO3DBVQhfNmN1d_0f_HvtsujNQpxM90SrV9yKWH_JG1Ww/exec"
|
||||
)
|
||||
.then((d) => d.text())
|
||||
.then((d) => setAreaInfo(d));
|
||||
};
|
||||
useEffect(getAreaInfo, []);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<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 [mapSwitch, setMapSwitch] = useState(undefined);
|
||||
const [stationMenu, setStationMenu] = useState(undefined);
|
||||
const [LoadError, setLoadError] = useState(false);
|
||||
|
||||
//列車情報表示関連
|
||||
const EachTrainInfoAsSR = useRef(null);
|
||||
@ -127,6 +128,10 @@ export default function Apps({ navigation, webview, stationData }) {
|
||||
}
|
||||
const dataSet = JSON.parse(event.nativeEvent.data);
|
||||
switch (dataSet.type) {
|
||||
case "LoadError": {
|
||||
setLoadError(true);
|
||||
return;
|
||||
}
|
||||
case "PopUpMenu": {
|
||||
const selectedStationPDFAddress = dataSet.pdf;
|
||||
const findStationEachLine = (selectLine) => {
|
||||
@ -285,6 +290,7 @@ export default function Apps({ navigation, webview, stationData }) {
|
||||
<ReloadButton
|
||||
onPress={() => webview.current.reload()}
|
||||
top={Platform.OS == "ios" ? Constants.statusBarHeight : 0}
|
||||
LoadError={LoadError}
|
||||
/>
|
||||
|
||||
<StationDeteilView
|
||||
@ -344,7 +350,7 @@ const MapsButton = ({ onPress, top, mapSwitch }) => {
|
||||
);
|
||||
};
|
||||
|
||||
const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
const ReloadButton = ({ onPress, top, mapSwitch, LoadError = false }) => {
|
||||
const styles = {
|
||||
touch: {
|
||||
position: "absolute",
|
||||
@ -352,7 +358,7 @@ const ReloadButton = ({ onPress, top, mapSwitch }) => {
|
||||
right: 10,
|
||||
width: 50,
|
||||
height: 50,
|
||||
backgroundColor: "#0099CC",
|
||||
backgroundColor: LoadError ? "red" : "#0099CC",
|
||||
borderColor: "white",
|
||||
borderStyle: "solid",
|
||||
borderWidth: 1,
|
||||
|
@ -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) {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user