import React, { useState } from "react"; import { View, Text, TextInput, Button, Image, TouchableOpacity } from "react-native"; import * as DocumentPicker from "expo-document-picker"; import * as SecureStore from "expo-secure-store";
export default function App() { const [auth, setAuth] = useState(false); const [pin, setPin] = useState(""); const [inputPin, setInputPin] = useState(""); const [files, setFiles] = useState([]);
const savePin = async () => { await SecureStore.setItemAsync("user_pin", pin); setAuth(true); };
const checkPin = async () => { const storedPin = await SecureStore.getItemAsync("user_pin"); if (storedPin === inputPin) setAuth(true); };
const pickFile = async () => { const result = await DocumentPicker.getDocumentAsync({ multiple: true }); if (result.type === "success") { setFiles([...files, result]); } };
if (!auth) { return ( <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}> <Image source={require("./assets/logo.png")} style={{ width: 100, height: 100 }} /> <Text style={{ fontSize: 20, fontWeight: "bold", marginBottom: 10 }}>Enter PIN <TextInput secureTextEntry keyboardType="numeric" style={{ borderBottomWidth: 1, width: 200, marginBottom: 20 }} onChangeText={setInputPin} /> <Text style={{ marginTop: 20, fontSize: 12 }}>First Time? Set your PIN below <TextInput secureTextEntry keyboardType="numeric" placeholder="Set PIN" style={{ borderBottomWidth: 1, width: 200, marginBottom: 10 }} onChangeText={setPin} /> ); } return ( <View style={{ flex: 1, padding: 20 }}> <Text style={{ fontSize: 24, fontWeight: "bold" }}>Secure Vault {files.map((file, index) => ( {file.name} ))} ); }