From de0e8bcb79193d92e99c4154c08f110efc771c86 Mon Sep 17 00:00:00 2001 From: Krisztu Date: Wed, 25 Feb 2026 09:16:09 +0100 Subject: [PATCH] Initial commit --- .gitignore | 41 + App.tsx | 88 + app.json | 28 + assets/adaptive-icon.png | Bin 0 -> 17547 bytes assets/favicon.png | Bin 0 -> 1466 bytes assets/icon.png | Bin 0 -> 22380 bytes assets/splash-icon.png | Bin 0 -> 17547 bytes index.ts | 8 + package-lock.json | 9659 ++++++++++++++++++++++++++++++++++++++ package.json | 24 + tsconfig.json | 6 + 11 files changed, 9854 insertions(+) create mode 100644 .gitignore create mode 100644 App.tsx create mode 100644 app.json create mode 100644 assets/adaptive-icon.png create mode 100644 assets/favicon.png create mode 100644 assets/icon.png create mode 100644 assets/splash-icon.png create mode 100644 index.ts create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d914c32 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files + +# dependencies +node_modules/ + +# Expo +.expo/ +dist/ +web-build/ +expo-env.d.ts + +# Native +.kotlin/ +*.orig.* +*.jks +*.p8 +*.p12 +*.key +*.mobileprovision + +# Metro +.metro-health-check* + +# debug +npm-debug.* +yarn-debug.* +yarn-error.* + +# macOS +.DS_Store +*.pem + +# local env files +.env*.local + +# typescript +*.tsbuildinfo + +# generated native folders +/ios +/android diff --git a/App.tsx b/App.tsx new file mode 100644 index 0000000..ee8213d --- /dev/null +++ b/App.tsx @@ -0,0 +1,88 @@ +import React, { useState, useEffect } from 'react'; +import { View, Text, TextInput, Button, FlatList, TouchableOpacity, StyleSheet } from 'react-native'; +import AsyncStorage from '@react-native-async-storage/async-storage'; + +interface Product { + id: string; + name: string; + price: number; +} + +export default function App() { + const [products, setProducts] = useState([]); + const [name, setName] = useState(''); + const [price, setPrice] = useState(''); + const [editId, setEditId] = useState(null); + + useEffect(() => { + loadProducts(); + }, []); + + const loadProducts = async () => { + const data = await AsyncStorage.getItem('products'); + if (data) setProducts(JSON.parse(data)); + }; + + const saveProducts = async (newProducts: Product[]) => { + await AsyncStorage.setItem('products', JSON.stringify(newProducts)); + setProducts(newProducts); + }; + + const addProduct = () => { + const newProduct = { id: Date.now().toString(), name, price: parseFloat(price) }; + saveProducts([...products, newProduct]); + setName(''); + setPrice(''); + }; + + const updateProduct = () => { + const updated = products.map(p => p.id === editId ? { ...p, name, price: parseFloat(price) } : p); + saveProducts(updated); + setEditId(null); + setName(''); + setPrice(''); + }; + + const deleteProduct = (id: string) => { + saveProducts(products.filter(p => p.id !== id)); + }; + + const sortByPrice = () => { + saveProducts([...products].sort((a, b) => a.price - b.price)); + }; + + return ( + + + +