diff --git a/App.js b/App.js
index 4c282a2..5524ef9 100644
--- a/App.js
+++ b/App.js
@@ -1,21 +1,131 @@
-import { SafeAreaView, Text } from 'react-native';
-import tw, { useDeviceContext } from 'twrnc';
+import { NavigationContainer } from '@react-navigation/native';
+import { createNativeStackNavigator } from '@react-navigation/native-stack';
+import * as React from 'react';
+import { useState } from 'react';
+import { ActivityIndicator, FlatList, Image, SafeAreaView, ScrollView, Text, TextInput, TouchableOpacity, View } from 'react-native';
+import 'react-native-reanimated';
import { Provider } from 'react-redux';
+import tw, { useDeviceContext } from 'twrnc';
+import { useAddNoteMutation, useDeleteNoteMutation, useFetchNotesQuery, useSearchNotesQuery, useUpdateNoteMutation } from './db';
import { store } from './store';
-import 'react-native-reanimated';
+
+//Daniel Flemming
+
+//const generateData = (count) => Array.from({length : count}, (_, i) => ({id : (i + 1).toString(), note : "Note number " + (i+1).toString()}));
+//const data = generateData(0);
+
+const Stack = createNativeStackNavigator();
+
+
+
+//This is the note object. Can be added dynamically
+const Note = ({item, nav}) => {
+ return (
+ {nav.navigate('Details', {note : item});}} style = {[tw`w-1/3 aspect-square mb-1 mr-1 p-2 rounded-lg bg-[#2F0082]`]}>
+
+ {item.content}
+
+
+ );
+}
+
+function HomeScreen({route, navigation}){
+
+ const [addNote] = useAddNoteMutation();
+ const [deleteNote] = useDeleteNoteMutation();
+ const {data, error, isLoading} = useFetchNotesQuery();
+ const [text, setText] = useState("");
+ const {data : filteredData, isLoading : searchNotesLoading} = useSearchNotesQuery(""+text);
+
+ const deleteAllNotes = async () => {
+ for(const note of data){
+ for(const item of note){
+ await deleteNote({id : item.id});
+ }
+ }
+ }
+
+ if(isLoading || searchNotesLoading){
+ return(
+
+
+
+ );
+ }
+
+ if(error){
+ return(
+
+ Failed to load notes
+
+ );
+ }
+
+ return(
+
+
+ Search/Quick add
+ {setText(text)}}>
+
+ item.id}
+ renderItem = {({item}) => }
+ numColumns = {3}
+ contentContainerStyle={tw`p-4`}
+ />
+ {await addNote({title : " ", content: ""+text}); console.log(data)}}>
+
+
+ {await deleteAllNotes(); console.log(data)}}>
+
+
+
+ );
+}
+
+function DetailsScreen({route, navigation}){
+
+ const [updateNote] = useUpdateNoteMutation();
+ const {note} = route.params;
+ const [text, setText] = useState(note.content);
+ saveNote = () => {
+ console.log(text);
+ updateNote({id : note.id, content : text, title : " "});
+ }
+
+
+ return(
+
+ setText(text)} placeholder='Type here'>{note.content}
+
+ SAVE NOTE
+
+
+ );
+}
function App() {
useDeviceContext(tw);
-
return (
-
-
- Your app code goes here.
-
+
+
+
+
+
+
+
- )
+ );
}
export default App;
diff --git a/assets/add.png b/assets/add.png
new file mode 100644
index 0000000..f20ec50
Binary files /dev/null and b/assets/add.png differ