-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
52 lines (46 loc) · 1.39 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React, { useState, useEffect } from 'react';
import { StyleSheet, View, Platform } from 'react-native';
import { WebView as MobileWebView } from 'react-native-webview';
import WebWebView from 'react-native-web-webview';
import * as SplashScreen from 'expo-splash-screen';
import { SafeAreaView } from 'react-native-safe-area-context';
import { StatusBar as ExpoStatusBar } from 'expo-status-bar';
SplashScreen.preventAutoHideAsync();
const WebView = Platform.select({
web: WebWebView,
default: MobileWebView,
});
export default function App() {
const [isWebViewLoaded, setIsWebViewLoaded] = useState(false);
useEffect(() => {
if (isWebViewLoaded) {
SplashScreen.hideAsync();
}
}, [isWebViewLoaded]);
return (
<SafeAreaView style={styles.container}>
<ExpoStatusBar style="dark" translucent={true} backgroundColor="transparent" />
<WebView
source={{ uri: 'https://www.clasome.com' }}
mixedContentMode="always"
style={styles.webview}
onLoadEnd={() => setIsWebViewLoaded(true)}
javaScriptEnabled={true}
injectedJavaScript={`
document.body.style.backgroundColor = 'transparent';
true;
`}
/>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'transparent',
},
webview: {
flex: 1,
backgroundColor: 'transparent',
},
});