added a close button for ScannedDataBox that will work on both HisoryScreen and QRScannerScreen

This commit is contained in:
2024-06-20 16:21:45 +08:00
parent a0705807fd
commit ec9e0a21af
4 changed files with 88 additions and 60 deletions

View File

@@ -6,6 +6,7 @@ import { Ionicons } from '@expo/vector-icons';
interface ScannedDataBoxProps {
data: string;
dataType: string;
clearScanData: () => void;
}
interface ScanResult {
@@ -14,7 +15,7 @@ interface ScanResult {
redirects: number;
}
const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ data, dataType }) => {
const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ data, dataType, clearScanData }) => {
const [scanResult, setScanResult] = useState<ScanResult | null>(null);
useEffect(() => {
@@ -71,6 +72,9 @@ const ScannedDataBox: React.FC<ScannedDataBoxProps> = ({ data, dataType }) => {
return (
<View style={styles.dataBox}>
<TouchableOpacity style={styles.closeButton} onPress={clearScanData}>
<Ionicons name="close-circle-outline" size={24} color="#ff69b4" />
</TouchableOpacity>
<View style={styles.row}>
<Image source={require('../assets/ScanIcon3.png')} style={styles.scan_icon} />
<Text style={styles.payload}>{extractedData}</Text>
@@ -176,6 +180,11 @@ const styles = StyleSheet.create({
color: '#2196F3',
marginTop: 5,
},
closeButton: {
position: 'absolute',
top: 10,
right: 10,
},
});
export default ScannedDataBox;