Open viniciussantos1998 opened 5 months ago
import { StatusBar } from 'expo-status-bar'; import React, {useState} from 'react'; import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'
export default function AppForm( {navigation}) { const [descricao, setDescricao] = useState(''); const [quantidade, setQuantidade] = useState('');
function handleDescriptionChange(descricao){ setDescricao(descricao); } function handleQuantityChange(quantidade){ setQuantidade(quantidade) }
async function handleButtonPress(){ const Listitem={id: new Date().getTime(), descricao, quantidade}; let saveitens = [] const reponse= await AsyncStorage.getItem('items');;
if (Response) saveItems = JSON.parse(response); saveItems.push(listItem) navigation.navigate('AppList') await AsyncStorage.setItem('items', JSON.stringify(saveItems)); navigation.navigate('AppList')
} return (
); }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', alignItems: 'center', }, title:{ color: '#fff', fontSize: 20, fontWeight: 'bold', marginTop: 50, }, inputContainer:{ flex:1, marginTop: 30, width: '90%', padding: 20, borderTopLeftRadius: 10, borderTopRightRadius: 10, alignItems: 'stretch', backgroundColor: 'black', }, input:{ marginTop: 10, height: 60, backgroundColor: 'black', borderRadius: 10, paddingHorizontal: 24, fontSize: 16, alignItems: 'stretch' }, button:{ marginTop:10, height: 60, backgroundColor: 'green', borderRadius: 10, paddingHorizontal: 24, fontSize: 16, alignItems: 'center', justifyContent: 'center', elevation: 20, shadowOpacity:20, shadowColor: '#ccc' }, buttonText: { color: '#fff', fontWeight: 'bold', } });
import { StatusBar } from 'expo-status-bar'; import React, {useState} from 'react'; import { StyleSheet, Text, View, TextInput, TouchableOpacity } from 'react-native'; import AsyncStorage from '@react-native-async-storage/async-storage'
export default function AppForm( {navigation}) { const [descricao, setDescricao] = useState(''); const [quantidade, setQuantidade] = useState('');
function handleDescriptionChange(descricao){ setDescricao(descricao); } function handleQuantityChange(quantidade){ setQuantidade(quantidade) }
async function handleButtonPress(){ const Listitem={id: new Date().getTime(), descricao, quantidade}; let saveitens = [] const reponse= await AsyncStorage.getItem('items');;
} return (
); }
const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: 'white', alignItems: 'center', }, title:{ color: '#fff', fontSize: 20, fontWeight: 'bold', marginTop: 50, }, inputContainer:{ flex:1, marginTop: 30, width: '90%', padding: 20, borderTopLeftRadius: 10, borderTopRightRadius: 10, alignItems: 'stretch', backgroundColor: 'black', }, input:{ marginTop: 10, height: 60, backgroundColor: 'black', borderRadius: 10, paddingHorizontal: 24, fontSize: 16, alignItems: 'stretch' }, button:{ marginTop:10, height: 60, backgroundColor: 'green', borderRadius: 10, paddingHorizontal: 24, fontSize: 16, alignItems: 'center', justifyContent: 'center', elevation: 20, shadowOpacity:20, shadowColor: '#ccc' }, buttonText: { color: '#fff', fontWeight: 'bold', } });