* feat (WIP): render web app inside the mobile app * fix: web app loading * chore: build scripts related to mobile web bundle * feat: show WebView header, which lets to close the WebView * refactor: remove extra component * chore: correct type * chore: remove TODO Co-authored-by: Mo <mo@standardnotes.com>
30 lines
985 B
TypeScript
30 lines
985 B
TypeScript
import React from 'react'
|
|
import { Platform } from 'react-native'
|
|
import { WebView } from 'react-native-webview'
|
|
|
|
export const MobileWebAppContainer = () => {
|
|
const sourceUri = (Platform.OS === 'android' ? 'file:///android_asset/' : '') + 'Web.bundle/loader.html'
|
|
const params = 'platform=' + Platform.OS
|
|
const injectedJS = `
|
|
if (!window.location.search) {
|
|
var link = document.getElementById('web-bundle-progress-bar');
|
|
link.href = './src/index.html?${params}';
|
|
link.click();
|
|
}`
|
|
|
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
return (
|
|
<WebView
|
|
source={{ uri: sourceUri }}
|
|
originWhitelist={['*']}
|
|
onLoad={() => {}}
|
|
onError={(err) => console.error('An error has occurred', err)}
|
|
onHttpError={() => console.error('An HTTP error occurred')}
|
|
onMessage={() => {}}
|
|
allowFileAccess={true}
|
|
injectedJavaScript={injectedJS}
|
|
/>
|
|
)
|
|
/* eslint-enable @typescript-eslint/no-empty-function */
|
|
}
|