From 1cb36cd073252f4a185cd9775382da4c6861a8cb Mon Sep 17 00:00:00 2001 From: Maksymilian Jopek Date: Tue, 28 Mar 2023 17:18:05 +0200 Subject: Working app --- components/CategoryView.js | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 components/CategoryView.js (limited to 'components/CategoryView.js') diff --git a/components/CategoryView.js b/components/CategoryView.js new file mode 100644 index 0000000..a9c6222 --- /dev/null +++ b/components/CategoryView.js @@ -0,0 +1,61 @@ +import * as React from 'react'; +import { SafeAreaView, TextInput, StyleSheet, Text, TouchableOpacity } from 'react-native'; +import * as SecureStore from 'expo-secure-store'; + +export default function CategoryView() { + let [name, setName] = React.useState("") + const ti = React.createRef() + + async function addCategory() { + let nk = await SecureStore.getItemAsync('categories') + let categories = [] + if (!nk) categories = ["default"]; else categories = JSON.parse(nk); + if (!categories.find(c => c === name)) + categories.push(name) + await SecureStore.setItemAsync('categories', JSON.stringify(categories)) + + ti.current.clear() + + // props.navigation.navigate('s1') + } + return ( + + + Add + + ) +} + +const styles = StyleSheet.create({ + cont: { + flex: 1, + backgroundColor: "black", + padding: 20, + alignItems: "center" + }, + ico: { + width: 200, + height: 200, + }, + txt: { + fontSize: 30, + fontWeight: "bold", + color: "#FFFFFF" + }, + input: { + height: 40, + width: "100%", + margin: 12, + borderWidth: 1, + padding: 10, + color: "#FFFFFF", + } +}) + -- cgit v1.3.1