Cleared error messages and updated types.tsx to handle bookmarks, Hardcoded testdata for Demo
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import React, { useState, ReactNode } from 'react';
|
||||
import { QRCodeContext } from '../types';
|
||||
|
||||
interface QRCodeProviderProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
const testData = [
|
||||
{
|
||||
data: 'Type: URL\nData: https://Safe_website.com',
|
||||
bookmarked: false,
|
||||
scanResult: {
|
||||
secureConnection: true,
|
||||
virusTotalCheck: true,
|
||||
redirects: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'Type: URL\nData: https://unknown_website.com',
|
||||
bookmarked: false,
|
||||
scanResult: {
|
||||
secureConnection: true,
|
||||
virusTotalCheck: true,
|
||||
redirects: 2,
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'Type: URL\nData: http://danger_website.com',
|
||||
bookmarked: false,
|
||||
scanResult: {
|
||||
secureConnection: false,
|
||||
virusTotalCheck: false,
|
||||
redirects: 3,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const QRCodeProvider: React.FC<QRCodeProviderProps> = ({ children }) => {
|
||||
const [qrCodes, setQrCodes] = useState(testData);
|
||||
const [currentScannedData, setCurrentScannedData] = useState<string>('');
|
||||
|
||||
const toggleBookmark = (index: number) => {
|
||||
setQrCodes((prev) => {
|
||||
const newQrCodes = [...prev];
|
||||
newQrCodes[index].bookmarked = !newQrCodes[index].bookmarked;
|
||||
return newQrCodes;
|
||||
});
|
||||
};
|
||||
|
||||
const deleteQRCode = (index: number) => {
|
||||
setQrCodes((prev) => prev.filter((_, i) => i !== index));
|
||||
};
|
||||
|
||||
return (
|
||||
<QRCodeContext.Provider value={{ qrCodes, setQrCodes, setCurrentScannedData, toggleBookmark, deleteQRCode }}>
|
||||
{children}
|
||||
</QRCodeContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -244,7 +244,6 @@ const QRScannerScreen: React.FC<QRScannerScreenProps> = ({ clearScanData }) => {
|
||||
<TouchableOpacity onPress={handleImagePicker} style={styles.galleryButton}>
|
||||
<Ionicons name="image" size={24} color="#fff" />
|
||||
</TouchableOpacity>
|
||||
|
||||
{/* The CONTENT , the popup for the scanned data */}
|
||||
{/* This is called from ../components/ScannedDataBox*/}
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user