2021-02-07 16:14:45 +00:00
|
|
|
import {useApi} from '@skolplattformen/api-hooks'
|
|
|
|
import {Icon, Text} from '@ui-kitten/components'
|
2021-01-26 11:02:24 +00:00
|
|
|
import React from 'react'
|
2021-02-07 16:14:45 +00:00
|
|
|
import {Modal, StyleSheet, View} from 'react-native'
|
|
|
|
import {TouchableOpacity} from 'react-native-gesture-handler'
|
|
|
|
import {SafeAreaView} from 'react-native-safe-area-context'
|
|
|
|
import {WebView} from 'react-native-webview'
|
2021-01-26 11:02:24 +00:00
|
|
|
import URI from 'jsuri'
|
|
|
|
|
2021-02-07 16:14:45 +00:00
|
|
|
export const ModalWebView = ({url, onClose}) => {
|
|
|
|
const {api} = useApi()
|
|
|
|
const cookie = api.getSessionCookie()
|
2021-01-26 11:02:24 +00:00
|
|
|
const uri = new URI(url)
|
|
|
|
return (
|
|
|
|
<Modal>
|
|
|
|
<SafeAreaView style={styles.container}>
|
|
|
|
<View style={styles.headerWrapper}>
|
|
|
|
<View style={styles.header}>
|
|
|
|
<Text category="s1">{uri.host()}</Text>
|
|
|
|
<TouchableOpacity onPress={onClose}>
|
2021-02-07 16:14:45 +00:00
|
|
|
<Icon name="close-circle" style={styles.icon} fill="#333333" />
|
2021-01-26 11:02:24 +00:00
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<WebView
|
|
|
|
style={styles.webview}
|
2021-02-07 16:14:45 +00:00
|
|
|
source={{uri: url, headers: {cookie}}}
|
|
|
|
/>
|
2021-01-26 11:02:24 +00:00
|
|
|
</SafeAreaView>
|
|
|
|
</Modal>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
container: {
|
2021-02-07 16:14:45 +00:00
|
|
|
flex: 1,
|
2021-01-26 11:02:24 +00:00
|
|
|
},
|
|
|
|
headerWrapper: {
|
|
|
|
backgroundColor: '#333333',
|
|
|
|
padding: 5,
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
paddingHorizontal: 10,
|
|
|
|
paddingVertical: 4,
|
|
|
|
backgroundColor: '#ffffff',
|
|
|
|
borderRadius: 5,
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
},
|
2021-02-07 16:14:45 +00:00
|
|
|
webview: {},
|
2021-01-26 11:02:24 +00:00
|
|
|
})
|