feat(dev): option to render web app inside the mobile app (#1164)
* 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>
This commit is contained in:
29
packages/mobile/MobileWebAppContainer.tsx
Normal file
29
packages/mobile/MobileWebAppContainer.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
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 */
|
||||
}
|
||||
Reference in New Issue
Block a user