diff --git a/App.js b/App.js index 94bbc8a..d25b83c 100644 --- a/App.js +++ b/App.js @@ -1,59 +1,158 @@ -import React, { useEffect, useRef } from 'react'; -import { NavigationContainer } from '@react-navigation/native'; -import { createStackNavigator,TransitionPresets ,} from '@react-navigation/stack'; -import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; -import { AntDesign, Ionicons } from '@expo/vector-icons'; -import {ToastAndroid, Platform, UIManager,} from 'react-native'; -import { UpdateAsync } from './UpdateAsync.js'; -import Apps from './Apps'; -import tndView from './ndView'; -import trainbase from './trainbaseview'; -import howto from './howto'; -import menu from './menu'; -import News from './components/news.js'; -import TestArea from './TestArea.js'; -import Setting from './components/settings.js'; -import trainMenu from './components/trainMenu.js'; +import React, { useEffect, useRef } from "react"; +import { NavigationContainer } from "@react-navigation/native"; +import { + createStackNavigator, + TransitionPresets, +} from "@react-navigation/stack"; +import { createBottomTabNavigator } from "@react-navigation/bottom-tabs"; +import { AntDesign, Ionicons } from "@expo/vector-icons"; +import { ToastAndroid, Platform, UIManager } from "react-native"; +import { UpdateAsync } from "./UpdateAsync.js"; +import Apps from "./Apps"; +import tndView from "./ndView"; +import trainbase from "./trainbaseview"; +import howto from "./howto"; +import menu from "./menu"; +import News from "./components/news.js"; +import TestArea from "./TestArea.js"; +import Setting from "./components/settings.js"; +import trainMenu from "./components/trainMenu.js"; const Stack = createStackNavigator(); const Tab = createBottomTabNavigator(); -if (Platform.OS === 'android') { +if (Platform.OS === "android") { if (UIManager.setLayoutAnimationEnabledExperimental) { UIManager.setLayoutAnimationEnabledExperimental(true); } } -export default function App(){ +export default function App() { const navigationRef = useRef(); var platform = Platform.OS === "android" ? 70 : 50; - useEffect(()=>UpdateAsync(),[]) - return( - - - (),}}/> - (),}}/> - (),}}/> - - - - - ) + useEffect(() => UpdateAsync(), []); + return ( + + + ( + + ), + }} + /> + ( + + ), + }} + /> + ( + + ), + }} + /> + + + ); } -function top(){ - return( +function top() { + return ( - - - - - - + + + + + + - ) + ); } -function menuPage(){ - return( +function menuPage() { + return ( - - + + - ) -} \ No newline at end of file + ); +} diff --git a/Apps.js b/Apps.js index 539fcba..5fd182a 100644 --- a/Apps.js +++ b/Apps.js @@ -773,7 +773,30 @@ observer.observe(target, { }); `; - const injectJavascriptData = bootData + trainIconMaker + textInsert; + const modal_content = ` + +const modal_content = document.getElementById('modal_content'); // body要素を監視 +const modal_observer = new MutationObserver( (mutations) => { + // observer.disconnect(); // 監視を終了 + for(let d of modal_content.getElementsByTagName("button") ){ + const data = d.onclick.toString().split("\\"")[1]; + d.onclick = () => window.ReactNativeWebView.postMessage(data) + } +}); + +// 監視を開始 +modal_observer.observe(modal_content, { + //attributes: true, // 属性変化の監視 + //attributeOldValue: true, // 変化前の属性値を matation.oldValue に格納する + //characterData: true, // テキストノードの変化を監視 + //characterDataOldValue: true, // 変化前のテキストを matation.oldValue に格納する + childList: true, // 子ノードの変化を監視 + //subtree: true // 子孫ノードも監視対象に含める +}); +`; + + const injectJavascriptData = + bootData + modal_content + trainIconMaker + textInsert; useEffect(() => { AsyncStorage.getItem("status") @@ -862,7 +885,10 @@ observer.observe(target, { } } }} - onMessage={(event) => {}} + onMessage={(event) => { + console.log(event.nativeEvent.data); + navigate("trainbase", { info: event.nativeEvent.data }); + }} injectedJavaScript={injectJavascriptData} /> - 内部バージョン: 4.3.1 + 内部バージョン: 4.3.2 diff --git a/trainbaseview.js b/trainbaseview.js index 7198821..5528722 100644 --- a/trainbaseview.js +++ b/trainbaseview.js @@ -1,14 +1,19 @@ const WEBVIEW = "WEBVIEW"; -import React, { Component } from 'react'; -import { StatusBar,View} from 'react-native'; -import {WebView} from 'react-native-webview'; -export default function trainbase({route, navigation}) { +import React, { Component } from "react"; +import { StatusBar, View } from "react-native"; +import { WebView } from "react-native-webview"; +const jss = `document.getElementById('Footer').style.display = 'none';`; +export default function trainbase({ route, navigation }) { const { info } = route.params; + console.log(info); return ( - - + + ); } - -const jss = `document.getElementById('Footer').style.display = 'none';`;