refactor: window background color on mobile, hide webview until ready (#2618) [skip e2e]
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="background">#2E2E2E</color>
|
<color name="background">#000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
@@ -26,6 +26,7 @@
|
|||||||
</script>
|
</script>
|
||||||
<script src="web-src/app.js"></script>
|
<script src="web-src/app.js"></script>
|
||||||
<style>
|
<style>
|
||||||
|
html,
|
||||||
body {
|
body {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -242,6 +242,10 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
|||||||
setShowAndroidWebviewUpdatePrompt(true)
|
setShowAndroidWebviewUpdatePrompt(true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (message === 'appLoaded') {
|
||||||
|
setDidLoadEnd(true)
|
||||||
|
return
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const functionData = JSON.parse(message)
|
const functionData = JSON.parse(message)
|
||||||
void onFunctionMessage(functionData.functionName, functionData.messageId, functionData.args)
|
void onFunctionMessage(functionData.functionName, functionData.messageId, functionData.args)
|
||||||
@@ -308,6 +312,8 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
|||||||
})
|
})
|
||||||
}, [device])
|
}, [device])
|
||||||
|
|
||||||
|
const [didLoadEnd, setDidLoadEnd] = useState(false)
|
||||||
|
|
||||||
if (showAndroidWebviewUpdatePrompt) {
|
if (showAndroidWebviewUpdatePrompt) {
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
@@ -353,7 +359,10 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
|||||||
<WebView
|
<WebView
|
||||||
ref={webViewRef}
|
ref={webViewRef}
|
||||||
source={{ uri: sourceUri }}
|
source={{ uri: sourceUri }}
|
||||||
style={{ backgroundColor: 'black' }}
|
style={{
|
||||||
|
backgroundColor: '#000000',
|
||||||
|
opacity: didLoadEnd ? 1 : 0,
|
||||||
|
}}
|
||||||
originWhitelist={['*']}
|
originWhitelist={['*']}
|
||||||
onError={(err) => console.error('An error has occurred', err)}
|
onError={(err) => console.error('An error has occurred', err)}
|
||||||
onHttpError={() => console.error('An HTTP error occurred')}
|
onHttpError={() => console.error('An HTTP error occurred')}
|
||||||
@@ -385,6 +394,7 @@ const MobileWebAppContents = ({ destroyAndReload }: { destroyAndReload: () => vo
|
|||||||
component: CustomAndroidWebView,
|
component: CustomAndroidWebView,
|
||||||
} as WebViewNativeConfig,
|
} as WebViewNativeConfig,
|
||||||
})}
|
})}
|
||||||
|
webviewDebuggingEnabled
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ declare global {
|
|||||||
webClient?: DesktopManagerInterface
|
webClient?: DesktopManagerInterface
|
||||||
electronRemoteBridge?: unknown
|
electronRemoteBridge?: unknown
|
||||||
reactNativeDevice?: WebDevice
|
reactNativeDevice?: WebDevice
|
||||||
|
ReactNativeWebView?: {
|
||||||
|
postMessage: (message: string) => void
|
||||||
|
}
|
||||||
platform?: Platform
|
platform?: Platform
|
||||||
isClipper?: boolean
|
isClipper?: boolean
|
||||||
|
|
||||||
@@ -91,6 +94,10 @@ const startApplication: StartApplication = async function startApplication(
|
|||||||
onDestroy={onDestroy}
|
onDestroy={onDestroy}
|
||||||
/>,
|
/>,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (window.ReactNativeWebView) {
|
||||||
|
window.ReactNativeWebView.postMessage('appLoaded')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const domReady = document.readyState === 'complete' || document.readyState === 'interactive'
|
const domReady = document.readyState === 'complete' || document.readyState === 'interactive'
|
||||||
|
|||||||
Reference in New Issue
Block a user