-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.tsx
98 lines (94 loc) · 2.24 KB
/
index.tsx
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import { useState } from "react";
import {
Modal,
StyleSheet,
Text,
Pressable,
View,
SafeAreaView,
TextInput,
Image,
} from "react-native";
import WebView from "react-native-webview";
export default function Index() {
const [modalVisible, setModalVisible] = useState(false);
const [url, setUrl] = useState("");
return (
<View style={styles.centeredView}>
<Image source={require("@/assets/images/logo.png")} style={styles.logo} />
<TextInput
style={styles.input}
onChangeText={setUrl}
value={url}
placeholder="Enter URL"
keyboardType="url"
/>
<Pressable style={[styles.button]} onPress={() => setUrl("")}>
<Text style={styles.textStyle}>Clear url</Text>
</Pressable>
<Pressable style={[styles.button]} onPress={() => setModalVisible(true)}>
<Text style={styles.textStyle}>Show webview in modal</Text>
</Pressable>
<Modal
animationType="slide"
visible={modalVisible}
presentationStyle="pageSheet"
>
<SafeAreaView style={{ flex: 1 }}>
<WebView
source={{
uri: url,
}}
style={{ flex: 1 }}
allowsInlineMediaPlayback={true} // Important
mediaPlaybackRequiresUserAction={false} // Important
/>
<Pressable
style={[styles.button]}
onPress={() => setModalVisible(!modalVisible)}
>
<Text style={styles.textStyle}>Hide Modal</Text>
</Pressable>
</SafeAreaView>
</Modal>
</View>
);
}
const styles = StyleSheet.create({
input: {
height: 40,
margin: 12,
borderWidth: 1,
borderColor: "#B6B6B6",
borderRadius: 8,
padding: 8,
width: "80%",
},
centeredView: {
flex: 1,
justifyContent: "center",
alignItems: "center",
marginTop: 22,
},
button: {
borderRadius: 20,
padding: 10,
marginHorizontal: 10,
marginVertical: 5,
elevation: 2,
backgroundColor: "#fc5332",
},
textStyle: {
color: "white",
fontWeight: "bold",
textAlign: "center",
},
modalText: {
marginBottom: 15,
textAlign: "center",
},
logo: {
height: 100,
resizeMode: "center",
},
});