import React, { useState } from 'react';
import { View, Text, TextInput, Button, StyleSheet } from 'react-native';
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function KeyValueStorage() {
const [key, setKey] = useState('');
const [value, setValue] = useState('');
const [storedValue, setStoredValue] = useState('');
// TODO: Add saveValue function
// TODO: Add loadValue function
return (
<View style={styles.container}>
<Text style={styles.title}>Simple Key-Value Storage</Text>
<Text>Key:</Text>
<TextInput
style={styles.input}
value={key}
onChangeText={setKey}
placeholder="Enter key"
accessibilityLabel="Key input"
/>
<Text>Value:</Text>
<TextInput
style={styles.input}
value={value}
onChangeText={setValue}
placeholder="Enter value"
accessibilityLabel="Value input"
/>
<View style={styles.buttonRow}>
<Button title="Save" onPress={() => {}} accessibilityLabel="Save button" />
<Button title="Load" onPress={() => {}} accessibilityLabel="Load button" />
</View>
<Text style={styles.storedValueLabel}>Stored Value:</Text>
<Text style={styles.storedValue}>{storedValue}</Text>
</View>
);
}
const styles = StyleSheet.create({
container: {
padding: 20,
flex: 1,
backgroundColor: '#fff'
},
title: {
fontSize: 20,
marginBottom: 10
},
input: {
borderWidth: 1,
borderColor: '#999',
padding: 8,
marginBottom: 10,
borderRadius: 4
},
buttonRow: {
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 20
},
storedValueLabel: {
fontWeight: 'bold',
marginBottom: 4
},
storedValue: {
fontSize: 16,
color: '#333'
}
});