-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
150 lines (137 loc) · 4.13 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import { StatusBar, Linking, ScrollView } from 'react-native';
import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native';
import React, { useState } from 'react';
import Gif from 'react-native-gif';
import * as Animatable from 'react-native-animatable';
export default function App() {
const [data, setData] = useState('');
const [urlToScan, setUrlToScan] = useState('');
const handleScan = async () => {
const apiUrl = 'http://192.168.1.33:4000/api/proxy';
try {
const requestOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ url: urlToScan }),
};
const response = await fetch(apiUrl, requestOptions);
const dataObject = await response.json();
setData(dataObject);
} catch (error) {
console.error('Error en la solicitud:', error);
}
};
const openResultURL = () => {
if (data && data.result) {
Linking.openURL(data.result);
}
};
const renderResult = () => {
if (data) {
if (data.message && data.visibility) {
return (
<View style={[styles.resultContainer, { backgroundColor: 'rgba(255, 255, 255, 0.8)' }]}>
<Text style={{ fontWeight: 'bold', marginBottom: 5 }}>{data.message}!</Text>
<Text>{`Visibility: ${data.visibility}`}</Text>
<Text>Link:</Text>
<TouchableOpacity onPress={openResultURL}>
<Text style={{ color: 'blue' }}>{data.result}</Text>
</TouchableOpacity>
</View>
);
} else {
return (
<View style={[styles.resultContainer, { backgroundColor: 'rgba(255, 255, 255, 0.8)' }]}>
<Text>¡No podemos mostrar el análisis de esta página!</Text>
</View>
);
}
} else {
return null;
}
};
return (
<ScrollView contentContainerStyle={styles.container}>
<Gif
style={StyleSheet.absoluteFill}
source={{ uri: 'https://tenor.com/es/view/hackerman-hacker-apple-glitch-logo-gif-15548598.gif' }}
/>
<View style={styles.overlay}>
<Animatable.View animation="fadeIn" duration={1000} style={styles.innerContainer}>
<Text style={[styles.title, { marginBottom: 20 }]}>URL Scan</Text>
<Animatable.View animation="fadeIn" duration={1000} style={[styles.inputContainer, { marginBottom: 10 }]}>
<TextInput
style={styles.input}
placeholder="Insert URL to scan"
value={urlToScan}
onChangeText={(text) => setUrlToScan(text)}
/>
</Animatable.View>
<Animatable.View animation="fadeIn" duration={1000} style={[styles.buttonContainer, { marginBottom: 10 }]}>
<TouchableOpacity style={styles.button} onPress={handleScan}>
<Text style={styles.buttonText}>Scan</Text>
</TouchableOpacity>
</Animatable.View>
<Animatable.View animation="fadeIn" duration={1000} style={[styles.resultContainer, { marginBottom: 20 }]}>
{renderResult()}
</Animatable.View>
<StatusBar style="auto" />
</Animatable.View>
</View>
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
justifyContent: 'center',
alignItems: 'center',
},
overlay: {
...StyleSheet.absoluteFillObject,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
},
innerContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
title: {
fontWeight: 'bold',
textAlign: 'center',
fontSize: 24,
color: '#fff',
},
inputContainer: {
marginBottom: 10,
},
input: {
height: 40,
borderColor: 'gray',
borderWidth: 1,
paddingHorizontal: 10,
width: '80%',
backgroundColor: '#fff',
},
buttonContainer: {
marginBottom: 10,
},
button: {
backgroundColor: 'grey',
padding: 10,
borderRadius: 5,
},
buttonText: {
color: 'white',
textAlign: 'center',
},
resultContainer: {
marginTop: 20,
padding: 10,
borderWidth: 1,
borderRadius: 5,
},
});