From dcd3399689d4827a3b6a70bdc7dc883cfef0385c Mon Sep 17 00:00:00 2001 From: Isky Date: Thu, 15 Aug 2024 01:44:48 +0800 Subject: [PATCH] Fixed Security header not clickable --- components/ScannedDataBox.tsx | 120 +++++++++++++++++++--------------- screens/EmailScreen.tsx | 2 +- 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/components/ScannedDataBox.tsx b/components/ScannedDataBox.tsx index 249f6e5..495de9c 100644 --- a/components/ScannedDataBox.tsx +++ b/components/ScannedDataBox.tsx @@ -28,7 +28,6 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData - useEffect(() => { const fetchQRDetails = async () => { try { @@ -85,6 +84,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData const hidden = details.hidden ? 'Hidden' : 'Visible'; const isShorteningService = details.shorteningService === 'Yes'; + const classification = details.classifications || 'Unknown'; // Function to get security text and icon based on the URL description @@ -97,7 +97,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData } else { return { text: 'Not Secure', - icon: + icon: }; } }; @@ -109,7 +109,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData // Function to get result text and color based on the security status const getResultStatus = () => { if (result === 'UNSAFE') { - return { text: 'UNSAFE', color: '#ff0000' }; // Red + return { text: 'UNSAFE', color: '#ff5942' }; // Red } else if (result === 'SAFE') { return { text: 'SAFE', color: '#44c167' }; // Green } else if (result === 'WARNING') { @@ -143,7 +143,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData if (redirectCount === 0) { return { text: 'No Redirects', color: '#44c167', hasRedirects: false }; // Green with no redirects } else { - return { text: 'Redirects', color: '#ff0000', hasRedirects: true }; // Red with redirects + return { text: 'Redirects', color: '#ff5942', hasRedirects: true }; // Red with redirects } }; const redirectStatus = getRedirectStatus(details.redirect || 0); @@ -164,7 +164,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData if (encryption === 'NO') { return { text: 'No Encryption', - icon: // Red + icon: // Red }; } else if (encryption === 'WEP') { return { @@ -224,7 +224,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData text: details.sslStripping?.some(status => status === true) ? "SSL Stripping Detected" : "No SSL Stripping", - color: details.sslStripping?.some(status => status === true) ? "#FF0000" : "#44c167", // Green for No SSL Stripping + color: details.sslStripping?.some(status => status === true) ? "#ff5942" : "#44c167", // Green for No SSL Stripping }; // Log to check what's happening @@ -234,7 +234,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData const hasExecutableStatus = { hasExecutable: details.hasExecutable ?? false, text: details.hasExecutable ? "Executable Detected" : "No Executable", - color: details.hasExecutable ? "#FF0000" : "#44c167", // Green for No Executable + color: details.hasExecutable ? "#ff5942" : "#44c167", // Green for No Executable }; // Log to check what's happening @@ -244,7 +244,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData const trackingStatus = { hasTracking: details.tracking ?? false, text: details.tracking ? "Tracking Detected" : "No Tracking", - color: details.tracking ? "#FF0000" : "#44c167", // Green for No Tracking + color: details.tracking ? "#ff5942" : "#44c167", // Green for No Tracking }; // Log to check what's happening @@ -293,59 +293,69 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData Result: {resultText} - + + Classification: {classification} + {/* URL Type */} {type === 'URL' && ( <> - {/* Left Container */} - - - {securityIcon} - {securityText} - + {/* Left Container */} + + + {securityIcon} + {securityText} + - - - {securityHeaderStatus.text} - + {securityHeaderStatus.hasHeaders ? ( + setIsModalVisible(true)}> + + {securityHeaderStatus.text} + + + ) : ( + + + {securityHeaderStatus.text} + + )} - {/* Redirects Button */} - {redirectCount > 0 ? ( - setIsRedirectModalVisible(true)}> - - {`Redirects: ${redirectCount}`} - - - ) : ( - - - {`Redirects: ${redirectCount}`} - - )} - + {/* Redirects Button */} + {redirectCount > 0 ? ( + setIsRedirectModalVisible(true)}> + + {`Redirects: ${redirectCount}`} + + + ) : ( + + + {`Redirects: ${redirectCount}`} + + )} + - {/* Vertical Divider */} - + {/* Vertical Divider */} + - {/* Right Container */} - - - - {sslStrippingStatus.text} - + {/* Right Container */} + + + + {sslStrippingStatus.text} + - - - {hasExecutableStatus.text} - + + + {hasExecutableStatus.text} + - - - {trackingStatus.text} - - + + + {trackingStatus.text} + + {/* Divider */} @@ -425,7 +435,7 @@ const ScannedDataBox: React.FC = ({ qrCodeId, clearScanData {/* Visibility */} - + Visibility: {hidden === 'Hidden' ? 'Hidden' : 'Visible'} @@ -845,5 +855,13 @@ const styles = StyleSheet.create({ chevronIcon: { marginLeft: 'auto', }, + + classificationText: { + fontSize: screenWidth * 0.0375, // Adjust size to be consistent with other text + color: '#000', // Black color for contrast + textAlign: 'center', + marginTop: screenWidth * 0.01875, // Add some spacing above + }, + }); export default ScannedDataBox; \ No newline at end of file diff --git a/screens/EmailScreen.tsx b/screens/EmailScreen.tsx index fdeba7f..02eb8eb 100644 --- a/screens/EmailScreen.tsx +++ b/screens/EmailScreen.tsx @@ -416,7 +416,7 @@ const styles = StyleSheet.create({ }, banner: { position: 'absolute', - top: screenHeight * 0.4, // Adjusts the banner to appear in the middle of the screen + top: screenHeight * 0.45, // Adjusts the banner to appear in the middle of the screen left: screenWidth * 0.1, // Adjust these values to center the banner as needed right: screenWidth * 0.1, backgroundColor: '#ff69b4',