diff --git a/GeneralWebView.tsx b/GeneralWebView.tsx new file mode 100644 index 0000000..dbc47ea --- /dev/null +++ b/GeneralWebView.tsx @@ -0,0 +1,30 @@ +import React, { CSSProperties } from "react"; +import { View, ViewProps } from "react-native"; +import { WebView } from "react-native-webview"; +import { BigButton } from "./components/atom/BigButton"; +import { useNavigation } from "@react-navigation/native"; +export default ({ route }) => { + if (!route.params) { + return null; + } + const { uri, useExitButton = true } = route.params; + const { goBack } = useNavigation(); + return ( + + { + const { data } = event.nativeEvent; + const {type} = JSON.parse(data); + if (type === "windowClose") return goBack(); + }} + /> + {useExitButton && } + + ); +}; +const styles: ViewProps["style"] = { + height: "100%", + backgroundColor: "#0099CC", +}; diff --git a/MenuPage.js b/MenuPage.js index de4f199..6f00ec3 100644 --- a/MenuPage.js +++ b/MenuPage.js @@ -18,6 +18,7 @@ import AllTrainDiagramView from "./components/AllTrainDiagramView"; import { useNavigation } from "@react-navigation/native"; import { news } from "./config/newsUpdate"; import { useBottomTabBarHeight } from "@react-navigation/bottom-tabs"; +import GeneralWebView from "./GeneralWebView"; const Stack = createStackNavigator(); export function MenuPage() { @@ -128,6 +129,7 @@ export function MenuPage() { component={AllTrainDiagramView} /> + ); } diff --git a/Top.js b/Top.js index 4e547b8..5f25b74 100644 --- a/Top.js +++ b/Top.js @@ -13,6 +13,7 @@ import { useTrainMenu } from "./stateBox/useTrainMenu"; import { AS } from "./storageControl"; import { news } from "./config/newsUpdate"; import { Linking, Platform } from "react-native"; +import GeneralWebView from "./GeneralWebView"; const Stack = createStackNavigator(); export const Top = () => { const { webview } = useCurrentTrain(); @@ -64,6 +65,7 @@ export const Top = () => { component={TrainBase} /> + = ({ return ( scrollHandlers.ref.current?.scrollTo({ y: 0, animated: true })}> - { + navigate("generalWebView", { + uri: "https://jr-shikoku-data-post-system.pages.dev?trainNum=" + trainNum, + useExitButton: false + }); + SheetManager.hide("EachTrainInfo"); + }} > = ({ {isOneMan && } {trainName} - +