diff --git a/components/ScannedDataBox.tsx b/components/ScannedDataBox.tsx index 28955ff..a40687c 100644 --- a/components/ScannedDataBox.tsx +++ b/components/ScannedDataBox.tsx @@ -78,7 +78,7 @@ const { text: securityText, icon: securityIcon } = getSecurityStatus(); // Function to get result text and color based on the security status const getResultStatus = () => { if (result === 'UNSAFE') { - return { text: 'DANGEROUS', color: '#ff0000' }; // Red + return { text: 'UNSAFE', color: '#ff0000' }; // Red } else if (result === 'SAFE') { return { text: 'SAFE', color: '#44c167' }; // Green } else if (result === 'WARNING') { @@ -120,6 +120,41 @@ const securityHeaderStatus = getSecurityHeaderStatus(details.hstsHeader || []); return content; }; + +// Function to get encryption status and icon +const getEncryptionStatus = (encryption) => { + if (encryption === 'NO') { + return { + text: 'No Encryption', + icon: // Red + }; + } else if (encryption === 'WEP') { + return { + text: 'WEP Encryption', + icon: // Orange + }; + } else if (encryption === 'WPA' || encryption === 'WPA2') { + return { + text: 'WPA Encryption', + icon: // Green + }; + } else { + return { + text: 'Unknown Encryption', + icon: // Black for unknown + }; + } +}; + +const { text: encryptionText, icon: encryptionIcon } = getEncryptionStatus(encryption); + + +// Function to handle the connect to WiFi action +const handleConnectToWifi = (wifiContent) => { + Linking.openURL(wifiContent).catch(err => console.error('Error connecting to WiFi:', err)); +}; + + // Function to open the Wi-Fi configuration in the OS const handleOpenUrl = (url: string) => { Linking.openURL(url).catch(err => console.error('Error opening URL:', err)); @@ -179,27 +214,27 @@ const securityHeaderStatus = getSecurityHeaderStatus(details.hstsHeader || []); <> {securityIcon} - {securityText} + {securityText} {/* Security Headers Button */} {securityHeaderStatus.hasHeaders ? ( - setIsModalVisible(true)}> + setIsModalVisible(true)}> - {securityHeaderStatus.text} + {securityHeaderStatus.text} ) : ( - {securityHeaderStatus.text} + {securityHeaderStatus.text} )} {/* Redirects Button */} - setIsRedirectModalVisible(true)}> + setIsRedirectModalVisible(true)}> 1 ? "#ff0000" : "#44c167"} /> - Redirects + Redirects @@ -233,13 +268,40 @@ const securityHeaderStatus = getSecurityHeaderStatus(details.hstsHeader || []); {/* WIFI Type */} + {type === 'WIFI' && ( - <> - SSID: {ssid} - Encryption: {encryption} - Visibility: {hidden === 'Hidden' ? '✔️' : '❌'} - - )} + <> + {/* SSID */} + + SSID: {ssid} + + + {/* Encryption */} + + {encryptionIcon} + {encryptionText} + + + {/* Visibility */} + + + Visibility: {hidden === 'Hidden' ? 'Hidden' : 'Visible'} + + + {/* Divider */} + + + {/* Connect to WiFi Button */} + handleConnectToWifi(contents)}> + + Connect to WiFi + + +)} + + + + {/* TEXT Type */} {type === 'TEXT' && ( @@ -417,7 +479,7 @@ const styles = StyleSheet.create({ color: '#000', marginBottom: screenWidth * 0.01875, }, - moreInfoButtonText: { + DetailsInfo: { fontSize: screenWidth * 0.03, color: '#000', marginLeft: screenWidth * 0.01875, @@ -448,7 +510,7 @@ const styles = StyleSheet.create({ }, - moreInfoButton: { + DetailsInfoButton: { flexDirection: 'row', alignItems: 'center', paddingVertical: screenWidth * 0.01875, @@ -534,6 +596,23 @@ const styles = StyleSheet.create({ shadowRadius: screenWidth * 0.01875, elevation: screenWidth * 0.0135, }, + connectButton: { + flexDirection: 'row', + alignItems: 'center', + justifyContent: 'center', + paddingVertical: screenWidth * 0.0375, + paddingHorizontal: screenWidth * 0.0375, + backgroundColor: '#44c167', // Green background for the button + borderRadius: screenWidth * 0.01875, + marginTop: screenWidth * 0.025, + }, + + connectButtonText: { + color: '#fff', + marginLeft: screenWidth * 0.01875, + fontSize: screenWidth * 0.0375, + }, + });