robosats/mobile/App.tsx

57 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-06-24 23:35:01 +00:00
import React from 'react';
import { WebView, WebViewMessageEvent } from "react-native-webview";
import {SafeAreaView, Text} from 'react-native';
// 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
const htmlPath = "file:///android_asset/Web.bundle/index.html";
const uri = 'https://robosats.onion.moe'
const onion = 'http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'
2022-06-24 23:35:01 +00:00
return (
<SafeAreaView style={{ flex: 1 }}>
<WebView
source={{
2022-06-25 18:30:53 +00:00
uri: 'uri',
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}
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;