Files
jrshikoku/components/trainbaseview.js
harukin-expo-dev-env 06ba5fe1de LEDの処理大整理
2024-09-09 13:50:20 +00:00

50 lines
1.7 KiB
JavaScript

import React, { useRef } from "react";
import { StatusBar, Platform, View } from "react-native";
import { WebView } from "react-native-webview";
import { MaterialCommunityIcons } from "@expo/vector-icons";
import { useNavigation } from "@react-navigation/native";
import { BigButton } from "./atom/BigButton";
export default function TrainBase({ route }) {
const { info, from } = route.params;
const { navigate } = useNavigation();
const webview = useRef();
const jss = `document.getElementById('Footer').style.display = 'none';
${
Platform.OS == "ios" &&
`document.getElementsByTagName("html")[0].style['font-size'] = '11px';`
}`;
//const jss = `alert("ほげ")`;
return (
<View style={{ height: "100%" }}>
{Platform.OS == "ios" && <StatusBar barStyle="dark-content" />}
<WebView
//useWebKit={true}
ref={webview}
source={{ uri: "https://train.jr-shikoku.co.jp/" + info }}
originWhitelist={[
"https://train.jr-shikoku.co.jp",
"https://train.jr-shikoku.co.jp/sp.html",
]}
mixedContentMode={"compatibility"}
javaScriptEnabled={true}
injectedJavaScript={jss}
setSupportMultipleWindows={false}
onMessage={(event) => {}}
/>
{(from == "LED" || from == "LED2" || from == "AllTrainIDList") && (
<BigButton
style={{ borderColor: "black" }}
tS={{ color: "black" }}
string="閉じる"
onPress={() =>
navigate(from == "AllTrainIDList" ? "AllTrainIDList" : "menu")
}
>
<MaterialCommunityIcons name="close" color="black" size={30} />
</BigButton>
)}
</View>
);
}