robosats/mobile/App.tsx

66 lines
2.4 KiB
TypeScript
Raw Permalink Normal View History

2022-06-24 23:35:01 +00:00
import React from 'react';
import { WebView, WebViewMessageEvent } from "react-native-webview";
2022-06-26 10:54:48 +00:00
import {SafeAreaView, Text, Platform} from 'react-native';
2022-06-24 23:35:01 +00:00
// import Tor from "react-native-tor";
// Initialize the module
// const tor = Tor();
// const makeTorRequest = async()=>{
// // Start the daemon and socks proxy (no need for Orbot and yes iOS supported!)
// await tor.startIfNotStarted();
// try{
// // Use built in client to make REST calls to .onion urls routed through the Sock5 proxy !
// const resp = await tor.get('http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion/api/info');
// return resp
// } catch(error){
// // Catch a network or server error like you normally with any other fetch library
// }
// }
const App = () => {
2022-06-25 18:30:53 +00:00
// Webview with local html/js in a single location for andrid/iOS
// https://yelotofu.com/react-native-load-local-static-site-inside-webview-2b93eb1c4225
2022-07-11 14:47:54 +00:00
const htmlPath = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/index.html';
2022-06-25 18:30:53 +00:00
const uri = 'https://robosats.onion.moe'
const onion = 'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'
2022-07-11 14:47:54 +00:00
const runFirst = `
// document.body.style.backgroundColor = 'red';
// const currentLocation = window.location;
// setTimeout(function() { window.alert(currentLocation) }, 000);
// true; // note: this is required, or you'll sometimes get silent failures
`;
2022-06-24 23:35:01 +00:00
return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
2022-07-11 14:47:54 +00:00
source={{ uri: uri }}
// source={{ baseUrl: 'file:///android_asset/Web.bundle/' }}
2022-06-24 23:35:01 +00:00
javaScriptEnabled={true}
domStorageEnabled={true}
sharedCookiesEnabled={true}
2022-06-25 18:30:53 +00:00
originWhitelist={['*']} //originWhitelist={[uri,uri2]}
2022-06-24 23:35:01 +00:00
scalesPageToFit={true}
startInLoadingState={true}
mixedContentMode={"always"}
allowsInlineMediaPlayback={true}
allowsFullscreenVideo={false}
setBuiltInZoomControls={false}
allowingReadAccessToURL={uri}
allowFileAccess={true}
allowsBackForwardNavigationGestures={false}
mediaPlaybackRequiresUserAction={false}
allowsLinkPreview={false}
2022-07-11 14:47:54 +00:00
injectedJavaScript={runFirst}
2022-06-24 23:35:01 +00:00
renderLoading={() => <Text>Loading RoboSats</Text>}
2022-06-25 18:30:53 +00:00
onError={(syntheticEvent) => <Text>{syntheticEvent}</Text>}
2022-06-24 23:35:01 +00:00
/>
</SafeAreaView>
);
};
export default App;