|
|
|
@ -1,4 +1,6 @@
@@ -1,4 +1,6 @@
|
|
|
|
|
import React, { FC } from 'react' |
|
|
|
|
import { useTheme } from '@/shared/hooks' |
|
|
|
|
import React, { FC, useState } from 'react' |
|
|
|
|
import { ActivityIndicator, View, StyleSheet } from 'react-native' |
|
|
|
|
import { WebView } from 'react-native-webview' |
|
|
|
|
|
|
|
|
|
interface IProps { |
|
|
|
@ -6,12 +8,43 @@ interface IProps {
@@ -6,12 +8,43 @@ interface IProps {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export const WebviewPlugin: FC<IProps> = ({ url }) => { |
|
|
|
|
const [loading, setLoading] = useState(true) |
|
|
|
|
const { styles, theme } = useTheme(createStyles) |
|
|
|
|
return ( |
|
|
|
|
<WebView |
|
|
|
|
source={{ uri: url }} |
|
|
|
|
style={{ flex: 1 }} |
|
|
|
|
originWhitelist={['file://*', '*']} |
|
|
|
|
mixedContentMode="always" |
|
|
|
|
/> |
|
|
|
|
<View style={styles.container}> |
|
|
|
|
{loading && ( |
|
|
|
|
<ActivityIndicator |
|
|
|
|
style={styles.activityIndicator} |
|
|
|
|
size="large" |
|
|
|
|
color={theme.$loaderPrimary} |
|
|
|
|
/> |
|
|
|
|
)} |
|
|
|
|
<WebView |
|
|
|
|
source={{ uri: url }} |
|
|
|
|
style={styles.webview} |
|
|
|
|
mixedContentMode="always" |
|
|
|
|
onLoadEnd={() => setLoading(false)} |
|
|
|
|
/> |
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const createStyles = () => |
|
|
|
|
StyleSheet.create({ |
|
|
|
|
container: { |
|
|
|
|
flex: 1, |
|
|
|
|
}, |
|
|
|
|
activityIndicator: { |
|
|
|
|
position: 'absolute', |
|
|
|
|
top: 0, |
|
|
|
|
left: 0, |
|
|
|
|
right: 0, |
|
|
|
|
bottom: 0, |
|
|
|
|
justifyContent: 'center', |
|
|
|
|
alignItems: 'center', |
|
|
|
|
zIndex: 999, |
|
|
|
|
}, |
|
|
|
|
webview: { |
|
|
|
|
flex: 1, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|