Update Logo and Scanned DataBox Logic
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 66 KiB |
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { View, Text, StyleSheet, Image, TouchableOpacity, Modal, ActivityIndicator, ScrollView, Dimensions } from 'react-native';
|
import { View, Text, StyleSheet, Image, TouchableOpacity, Modal, ActivityIndicator, ScrollView, Dimensions } from 'react-native';
|
||||||
import QRCode from 'react-native-qrcode-svg';
|
import QRCode from 'react-native-qrcode-svg';
|
||||||
import { Ionicons, MaterialCommunityIcons, SimpleLineIcons } from '@expo/vector-icons';
|
import { Feather, Ionicons, MaterialCommunityIcons, SimpleLineIcons } from '@expo/vector-icons';
|
||||||
import { getQRCodeDetails } from '../api/qrCodeAPI';
|
import { getQRCodeDetails } from '../api/qrCodeAPI';
|
||||||
import SecureWebView from '../components/SecureWebView';
|
import SecureWebView from '../components/SecureWebView';
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
const [isWebViewVisible, setIsWebViewVisible] = useState(false);
|
const [isWebViewVisible, setIsWebViewVisible] = useState(false);
|
||||||
const [webViewUrl, setWebViewUrl] = useState('');
|
const [webViewUrl, setWebViewUrl] = useState('');
|
||||||
|
|
||||||
|
// Fetch QR code details on component mount or qrCodeId change
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchQRDetails = async () => {
|
const fetchQRDetails = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -50,9 +51,11 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
const contents = data.contents || 'Undefined';
|
const contents = data.contents || 'Undefined';
|
||||||
const secureConnection = details.hstsHeader?.some((header: string) => header.includes('HSTS Header'));
|
const secureConnection = details.hstsHeader?.some((header: string) => header.includes('HSTS Header'));
|
||||||
const redirects = details.redirect || 0;
|
const redirects = details.redirect || 0;
|
||||||
const securityHeaders = details.hstsHeader || ['No Headers'];
|
const securityHeaders = details.hstsHeader && details.hstsHeader.length > 0 ? details.hstsHeader : [];
|
||||||
|
|
||||||
const redirectChain = details.redirectChain || ['No Redirects'];
|
const redirectChain = details.redirectChain || ['No Redirects'];
|
||||||
|
|
||||||
|
// Determine the result text based on the security status
|
||||||
const getResultText = () => {
|
const getResultText = () => {
|
||||||
if (!secureConnection || redirects > 0) {
|
if (!secureConnection || redirects > 0) {
|
||||||
return 'DANGEROUS';
|
return 'DANGEROUS';
|
||||||
@@ -63,6 +66,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get color corresponding to the result text
|
||||||
const getResultColor = () => {
|
const getResultColor = () => {
|
||||||
const result = getResultText();
|
const result = getResultText();
|
||||||
if (result === 'DANGEROUS') {
|
if (result === 'DANGEROUS') {
|
||||||
@@ -76,6 +80,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Get icon based on the number of redirects
|
||||||
const getSheildIcon = () => {
|
const getSheildIcon = () => {
|
||||||
if (redirects === 0) {
|
if (redirects === 0) {
|
||||||
return <Ionicons name="shield-checkmark" size={screenWidth * 0.045} color="#44c167" />;
|
return <Ionicons name="shield-checkmark" size={screenWidth * 0.045} color="#44c167" />;
|
||||||
@@ -86,11 +91,13 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Open URL in a WebView
|
||||||
const openWebView = (url: string) => {
|
const openWebView = (url: string) => {
|
||||||
setWebViewUrl(url);
|
setWebViewUrl(url);
|
||||||
setIsWebViewVisible(true);
|
setIsWebViewVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Truncate content string to specified length
|
||||||
const truncateContent = (content: string, length: number) => {
|
const truncateContent = (content: string, length: number) => {
|
||||||
if (content.length > length) {
|
if (content.length > length) {
|
||||||
return `${content.substring(0, length)}...`;
|
return `${content.substring(0, length)}...`;
|
||||||
@@ -99,10 +106,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
|
||||||
<View style={styles.dataBox}>
|
<View style={styles.dataBox}>
|
||||||
|
|
||||||
<TouchableOpacity style={styles.closeButton} onPress={clearScanData}>
|
<TouchableOpacity style={styles.closeButton} onPress={clearScanData}>
|
||||||
<Ionicons name="close-circle-outline" size={screenWidth * 0.05} color="#ff69b4" />
|
<Ionicons name="close-circle-outline" size={screenWidth * 0.05} color="#ff69b4" />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
@@ -146,26 +150,33 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
<>
|
<>
|
||||||
<SimpleLineIcons name="shield" size={screenWidth * 0.045} color="#ff0000" />
|
<SimpleLineIcons name="shield" size={screenWidth * 0.045} color="#ff0000" />
|
||||||
<Text style={styles.moreInfoButtonText}>Not Secure</Text>
|
<Text style={styles.moreInfoButtonText}>Not Secure</Text>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{/* Security Headers Button */}
|
||||||
|
{securityHeaders.length > 0 ? (
|
||||||
|
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsModalVisible(true)}>
|
||||||
|
<Ionicons name="shield-checkmark" size={screenWidth * 0.045} color="#44c167" />
|
||||||
|
<Text style={styles.moreInfoButtonText}>Security Headers</Text>
|
||||||
|
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
||||||
|
</TouchableOpacity>
|
||||||
|
) : (
|
||||||
|
<View style={styles.displayCheck}>
|
||||||
|
<MaterialCommunityIcons name="shield-off" size={screenWidth * 0.045} color="#ffa500" />
|
||||||
|
<Text style={styles.moreInfoButtonText}>No Security Headers</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
|
||||||
|
{/* Redirects Button */}
|
||||||
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsRedirectModalVisible(true)}>
|
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsRedirectModalVisible(true)}>
|
||||||
{getSheildIcon()}
|
{getSheildIcon()}
|
||||||
<Text style={styles.moreInfoButtonText}>Redirects</Text>
|
<Text style={styles.moreInfoButtonText}>Redirects</Text>
|
||||||
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
||||||
|
{/* Security Headers Modal */}
|
||||||
|
|
||||||
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsModalVisible(true)}>
|
|
||||||
<Ionicons name="shield-checkmark" size={screenWidth * 0.045} color="#ff69b4" />
|
|
||||||
<Text style={styles.moreInfoButtonText}>Security Headers</Text>
|
|
||||||
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
|
||||||
</TouchableOpacity>
|
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
visible={isModalVisible}
|
visible={isModalVisible}
|
||||||
transparent={true}
|
transparent={true}
|
||||||
@@ -185,6 +196,7 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
{/* Redirect Chain Modal */}
|
||||||
<Modal
|
<Modal
|
||||||
visible={isRedirectModalVisible}
|
visible={isRedirectModalVisible}
|
||||||
transparent={true}
|
transparent={true}
|
||||||
@@ -203,11 +215,10 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
</>
|
</>
|
||||||
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* SMS Type */}
|
||||||
{type === 'SMS' && (
|
{type === 'SMS' && (
|
||||||
<>
|
<>
|
||||||
<Text style={styles.moreInfoButton}>Recipient Phone Number: {details.phone || 'Undefined'}</Text>
|
<Text style={styles.moreInfoButton}>Recipient Phone Number: {details.phone || 'Undefined'}</Text>
|
||||||
@@ -215,21 +226,15 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* TEXT Type */}
|
||||||
{type === 'TEXT' && (
|
{type === 'TEXT' && (
|
||||||
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsContentModalVisible(true)}>
|
<TouchableOpacity style={styles.moreInfoButton} onPress={() => setIsContentModalVisible(true)}>
|
||||||
<Text >
|
<Text>Content: {truncateContent(contents, 30)}</Text>
|
||||||
Content: {truncateContent(contents, 30)} {/* Truncated content further */}
|
|
||||||
</Text>
|
|
||||||
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
<Ionicons name="chevron-forward" size={screenWidth * 0.045} color="#ff69b4" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Full Content Modal */}
|
||||||
|
|
||||||
<Modal
|
<Modal
|
||||||
visible={isContentModalVisible}
|
visible={isContentModalVisible}
|
||||||
transparent={true}
|
transparent={true}
|
||||||
@@ -249,16 +254,17 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ qrCodeId, clearScanData
|
|||||||
</View>
|
</View>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
{/* URL Open Button */}
|
||||||
<View style={styles.iconContainer}>
|
|
||||||
{type === 'URL' && (
|
{type === 'URL' && (
|
||||||
|
<View style={styles.iconContainer}>
|
||||||
<TouchableOpacity style={styles.iconButton} onPress={() => openWebView(contents)}>
|
<TouchableOpacity style={styles.iconButton} onPress={() => openWebView(contents)}>
|
||||||
<Ionicons name="open" size={screenWidth * 0.045} color="#2196F3" />
|
<Ionicons name="open" size={screenWidth * 0.045} color="#2196F3" />
|
||||||
<Text style={styles.iconText}>Open</Text>
|
<Text style={styles.iconText}>Open</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)}
|
|
||||||
</View>
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* WebView Modal */}
|
||||||
<Modal
|
<Modal
|
||||||
visible={isWebViewVisible}
|
visible={isWebViewVisible}
|
||||||
transparent={true}
|
transparent={true}
|
||||||
@@ -323,8 +329,6 @@ const styles = StyleSheet.create({
|
|||||||
detailsSection: {
|
detailsSection: {
|
||||||
flex: 2,
|
flex: 2,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
timestampText: {
|
timestampText: {
|
||||||
fontSize: screenWidth * 0.03,
|
fontSize: screenWidth * 0.03,
|
||||||
color: '#000',
|
color: '#000',
|
||||||
@@ -345,12 +349,6 @@ const styles = StyleSheet.create({
|
|||||||
color: '#000',
|
color: '#000',
|
||||||
marginLeft: screenWidth * 0.01875,
|
marginLeft: screenWidth * 0.01875,
|
||||||
},
|
},
|
||||||
checksText: {
|
|
||||||
fontSize: screenWidth * 0.03,
|
|
||||||
color: '#000',
|
|
||||||
marginBottom: screenWidth * 0.009375,
|
|
||||||
marginLeft: screenWidth * 0.01875,
|
|
||||||
},
|
|
||||||
iconContainer: {
|
iconContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
@@ -367,12 +365,6 @@ const styles = StyleSheet.create({
|
|||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontSize: screenWidth * 0.03,
|
fontSize: screenWidth * 0.03,
|
||||||
},
|
},
|
||||||
moreInfoText: {
|
|
||||||
fontSize: screenWidth * 0.03375,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
color: '#000',
|
|
||||||
marginVertical: screenWidth * 0.01875,
|
|
||||||
},
|
|
||||||
moreInfoButton: {
|
moreInfoButton: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
@@ -393,19 +385,6 @@ const styles = StyleSheet.create({
|
|||||||
borderRadius: screenWidth * 0.01875,
|
borderRadius: screenWidth * 0.01875,
|
||||||
marginTop: screenWidth * 0.01875,
|
marginTop: screenWidth * 0.01875,
|
||||||
},
|
},
|
||||||
contentBox: {
|
|
||||||
marginTop: screenWidth * 0.01875,
|
|
||||||
padding: screenWidth * 0.025,
|
|
||||||
backgroundColor: '#fff',
|
|
||||||
borderRadius: screenWidth * 0.01875,
|
|
||||||
borderWidth: 1,
|
|
||||||
borderColor: '#ff69b4',
|
|
||||||
shadowColor: '#000',
|
|
||||||
shadowOffset: { width: 0, height: screenHeight * 0.001875 },
|
|
||||||
shadowOpacity: 0.15,
|
|
||||||
shadowRadius: screenWidth * 0.01875,
|
|
||||||
elevation: screenWidth * 0.0135,
|
|
||||||
},
|
|
||||||
closeButton: {
|
closeButton: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: screenWidth * 0.01875,
|
top: screenWidth * 0.01875,
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { View, Text, TouchableOpacity, FlatList, StyleSheet, ActivityIndicator, Alert, Animated } from 'react-native';
|
import { View, Text, TouchableOpacity, FlatList, StyleSheet, ActivityIndicator, Alert, Animated, Dimensions } from 'react-native';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
import { getEmails, getScannedEmails, getUserInfo } from '../api/qrCodeAPI';
|
import { getEmails, getScannedEmails, getUserInfo } from '../api/qrCodeAPI';
|
||||||
|
|
||||||
|
|
||||||
|
const { width: screenWidth, height: screenHeight } = Dimensions.get('window');
|
||||||
|
|
||||||
const EmailScreen: React.FC = () => {
|
const EmailScreen: React.FC = () => {
|
||||||
const [selectedMessage, setSelectedMessage] = useState(null);
|
const [selectedMessage, setSelectedMessage] = useState(null);
|
||||||
const [emailData, setEmailData] = useState(null);
|
const [emailData, setEmailData] = useState(null);
|
||||||
@@ -12,6 +15,7 @@ const EmailScreen: React.FC = () => {
|
|||||||
const [userEmail, setUserEmail] = useState('');
|
const [userEmail, setUserEmail] = useState('');
|
||||||
const [bannerOpacity] = useState(new Animated.Value(0));
|
const [bannerOpacity] = useState(new Animated.Value(0));
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
startPollingForScannedEmails();
|
startPollingForScannedEmails();
|
||||||
fetchUserEmail();
|
fetchUserEmail();
|
||||||
@@ -35,8 +39,8 @@ const EmailScreen: React.FC = () => {
|
|||||||
try {
|
try {
|
||||||
// Call to start email fetching process
|
// Call to start email fetching process
|
||||||
const response = await getEmails(
|
const response = await getEmails(
|
||||||
'ya29.a0AcM612zTwLojArYvmKxAKiUKL1eBIs04ZBN2dp53BShPcPAhZigjmivq-mQmT6BgF5G1ernMKb2LCHmRgX3vlSaBj2hD8JDi7kvpexduM-_x8aG7QorKfyB2z6yJzFrwVes2Y9tHhb9vWUAqbPdiL4wqNqeE5HxZNhoaCgYKAS0SARISFQHGX2MikJkWByj0FaiKBj3jU7svGg0170',
|
'Google Access Token',
|
||||||
'1//0g-hOrh4_72p3CgYIARAAGBASNwF-L9IrYVyuPL7WPbsm_ePtzFugduBLmdSr3UpQx7GMSt17KcS2Y_Z3v4N5wZiWua88RFjJ3Zk'
|
'Refresh Token'
|
||||||
);
|
);
|
||||||
setRescanLoading(false);
|
setRescanLoading(false);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -169,6 +173,7 @@ const styles = StyleSheet.create({
|
|||||||
backgroundColor: '#f8f0fc',
|
backgroundColor: '#f8f0fc',
|
||||||
padding: 10,
|
padding: 10,
|
||||||
paddingTop: 40, // Padding from the top to align content
|
paddingTop: 40, // Padding from the top to align content
|
||||||
|
paddingBottom: screenHeight * 0.1,
|
||||||
},
|
},
|
||||||
headerContainer: {
|
headerContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
@@ -265,10 +270,12 @@ const styles = StyleSheet.create({
|
|||||||
left: 0,
|
left: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
backgroundColor: '#ff69b4',
|
backgroundColor: '#ff69b4',
|
||||||
padding: 10,
|
paddingVertical: 20, // Increase this value for more height
|
||||||
|
paddingHorizontal: 10,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
|
|
||||||
bannerText: {
|
bannerText: {
|
||||||
color: '#fff',
|
color: '#fff',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ const styles = StyleSheet.create({
|
|||||||
},
|
},
|
||||||
scannedDataBoxPopup: {
|
scannedDataBoxPopup: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: '10%',
|
top: '30%',
|
||||||
left: '5%',
|
left: '5%',
|
||||||
right: '5%',
|
right: '5%',
|
||||||
zIndex: 2,
|
zIndex: 2,
|
||||||
@@ -281,7 +281,8 @@ const styles = StyleSheet.create({
|
|||||||
borderRadius: screenWidth * 0.025,
|
borderRadius: screenWidth * 0.025,
|
||||||
padding: screenWidth * 0.025,
|
padding: screenWidth * 0.025,
|
||||||
elevation: 5,
|
elevation: 5,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
settingsModal: {
|
settingsModal: {
|
||||||
backgroundColor: 'rgba(0, 0, 0, 0.5)', // Semi-transparent background
|
backgroundColor: 'rgba(0, 0, 0, 0.5)', // Semi-transparent background
|
||||||
|
|||||||
Reference in New Issue
Block a user