aboutsummaryrefslogtreecommitdiffstats
path: root/components/CategoryView.js
diff options
context:
space:
mode:
authorMaksymilian Jopek <maks@jopek.eu>2023-03-28 17:18:05 +0200
committerMaksymilian Jopek <maks@jopek.eu>2023-03-28 17:36:09 +0200
commit1cb36cd073252f4a185cd9775382da4c6861a8cb (patch)
tree30d374fc87e0409364f03faa8f7c58eb2bf7b882 /components/CategoryView.js
parent67b6f338cfe4da739d39dc6764d11efa00105d81 (diff)
downloadremarques-1cb36cd073252f4a185cd9775382da4c6861a8cb.tar.gz
remarques-1cb36cd073252f4a185cd9775382da4c6861a8cb.tar.zst
remarques-1cb36cd073252f4a185cd9775382da4c6861a8cb.zip
Working app
Diffstat (limited to 'components/CategoryView.js')
-rw-r--r--components/CategoryView.js61
1 files changed, 61 insertions, 0 deletions
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 (
+ <SafeAreaView style={styles.cont}>
+ <TextInput
+ underlineColorAndroid="#FFFFFF"
+ placeholder="NAME..."
+ placeholderTextColor="#FFFFFF"
+ onChangeText={setName}
+ style={styles.input}
+ ref={ti}
+ />
+ <TouchableOpacity onPress={addCategory}><Text style={styles.txt}>Add</Text></TouchableOpacity>
+ </SafeAreaView>
+ )
+}
+
+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",
+ }
+})
+