-
-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
cd0859e
commit 4f5d092
Showing
13 changed files
with
94 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a id="web-bundle-progress-bar" href="#"/></a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta content="IE=edge" http-equiv="X-UA-Compatible" /> | ||
<meta content="width=device-width, initial-scale=1" name="viewport" /> | ||
<link rel="stylesheet" href="web-src/app.css" /> | ||
</head> | ||
|
||
<body> | ||
<script> | ||
window.defaultSyncServer = "https://api.standardnotes.com"; | ||
window.defaultFilesHost = "https://files.standardnotes.com"; | ||
window.enabledUnfinishedFeatures = "" === 'true'; | ||
window.websocketUrl = ""; | ||
window.purchaseUrl = "https://standardnotes.com/purchase"; | ||
window.plansUrl = "https://standardnotes.com/plans"; | ||
window.dashboardUrl = "https://standardnotes.com/dashboard"; | ||
</script> | ||
|
||
<script src="web-src/app.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import { IsDev } from '@Lib/Utils' | ||
|
||
export enum ErrorMessage { | ||
GeneralText = 'An error occurred. Please try again later.', | ||
} | ||
|
||
export const WebAppOptionEnabled = IsDev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters