-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
60 lines (55 loc) · 1.39 KB
/
App.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
import { useState } from "react";
import { Button, StyleSheet, TextInput, View } from "react-native";
import { SafeAreaView } from "react-native";
import { WebView } from "react-native-webview";
export default function App() {
const [url, setUrl] = useState("https://www.sesamy.com");
const [currentUrl, setCurrentUrl] = useState(url);
const handleUrlChange = (text: string) => {
setCurrentUrl(text);
};
const handleGoPress = () => {
// Here you could add some URL validation before setting it
setUrl(currentUrl);
};
return (
<SafeAreaView style={{ flex: 1 }}>
<View style={styles.urlInputView}>
<TextInput
style={styles.urlInput}
autoCapitalize="none"
autoCorrect={false}
onChangeText={handleUrlChange}
onSubmitEditing={handleGoPress}
value={currentUrl}
placeholder="Enter URL"
/>
<Button title="Go" onPress={handleGoPress} />
</View>
<WebView source={{ uri: url }} />
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
urlInputView: {
flexDirection: "row",
padding: 10,
height: 50,
},
urlInput: {
flex: 1,
height: 40,
borderColor: "gray",
borderWidth: 1,
marginRight: 10,
},
webview: {
flex: 1,
},
});