From cc6c30a64b7583ba592b2dee0c89ea2f80478a48 Mon Sep 17 00:00:00 2001
From: Raghav Jit <98019979+RaghavJit@users.noreply.github.com>
Date: Sun, 12 Feb 2023 09:11:07 +0530
Subject: [PATCH] added new components
---
code/App.js | 12 ++
code/MyComp/AddTask.js | 230 +++++++++++++++++++-----------------
code/MyComp/Home.js | 15 ++-
code/MyComp/MyProfile.js | 56 +++++++++
code/MyComp/QuickTasker.js | 115 ++++++++++++++++++
code/MyComp/SetWallpaper.js | 6 +-
code/brain/testing.js | 13 +-
7 files changed, 325 insertions(+), 122 deletions(-)
create mode 100644 code/MyComp/MyProfile.js
create mode 100644 code/MyComp/QuickTasker.js
diff --git a/code/App.js b/code/App.js
index 3901f75f..1753b360 100644
--- a/code/App.js
+++ b/code/App.js
@@ -6,6 +6,8 @@ import AddTask from "./MyComp/AddTask";
import ViewTask from "./MyComp/ViewTask";
import Settings from "./MyComp/Settings";
import SetWallpaper from "./MyComp/SetWallpaper"
+import MyProfile from "./MyComp/MyProfile";
+import QuickTasker from "./MyComp/QuickTasker";
const colors = ['#e4def2', '#e2ddd8','#eef8ef','#2d414e','#E0DFE3']
function App() {
@@ -35,6 +37,16 @@ function App() {
name="SetWallpaper"
component={SetWallpaper}
/>
+
+
);
diff --git a/code/MyComp/AddTask.js b/code/MyComp/AddTask.js
index d20bd18b..ab8842ca 100644
--- a/code/MyComp/AddTask.js
+++ b/code/MyComp/AddTask.js
@@ -63,12 +63,12 @@ const styles = StyleSheet.create({
borderRadius: input.borderRadius,
fontSize: input.fontSize,
},
- inputBtns:{
- backgroundColor:colors[3],
- width: Width*0.97,
- height:Height*0.07,
- borderRadius: Scale*6,
- margin:Scale*2
+ inputBtns: {
+ backgroundColor: colors[3],
+ width: Width * 0.97,
+ height: Height * 0.07,
+ borderRadius: Scale * 6,
+ margin: Scale * 2
},
ModalOuter: {
@@ -121,149 +121,157 @@ function AddTask() {
const [desc, setDesc] = useState('Desc')
const [priorVisible, setPriorVisible] = useState(false);
const [priority, setPrior] = useState("");
-
+
const RNFS = require('react-native-fs')
// const filePath = `${RNFS.DocumentDirectoryPath}/Avalible_ID.json`;
+ function testing() {
+ const date1 = new Date('2023-02-11');
+ const date2 = new Date('2023-02-01');
+
+ const diffInMs = date1.getTime() - date2.getTime();
+ console.log(diffInMs)
+ }
+
return (
{setTitle(e)}}
+ onChangeText={(e) => { setTitle(e) }}
>{title}
{setDesc(e)}}
+ onChangeText={(e) => { setDesc(e) }}
>{desc}
-
+
- {/* datebtn */}
- setDateVisible(true)}
- >
-
-
-
-
-
- Choose Date and Time
-
-
- {
- setDateVisible(false)
- setDate(date)
- console.log(date)
- }}
- onCancel={() => {
- setDateVisible(false)
- }}
- />
-{/* priorityBtn */}
+ {/* datebtn */}
{setPriorVisible(true)}}
- >
- setDateVisible(true)}
>
-
-
-
-
+
+
+
+
+ Choose Date and Time
+
+
+ {
+ setDateVisible(false)
+ setDate(date)
+ console.log(date)
}}
- >Choose Priority
-
- {/* priority modal */}
- {
+ setDateVisible(false)
+ }}
+ />
+ {/* priorityBtn */}
+ { setPriorVisible(true) }}
>
+
+
+
+ Choose Priority
+
+ {/* priority modal */}
+
- {
- setPrior("High");
- setPriorVisible(false);
- }}
- >High
- {
- setPrior("Moderate");
- setPriorVisible(false);
- }}
- >Moderate
- {
- setPrior("Low");
- setPriorVisible(false);
- }}
- >Low
+
+ {
+ setPrior("High");
+ setPriorVisible(false);
+ }}
+ >High
+ {
+ setPrior("Moderate");
+ setPriorVisible(false);
+ }}
+ >Moderate
+ {
+ setPrior("Low");
+ setPriorVisible(false);
+ }}
+ >Low
+
-
-
+
-{/* save task btn */}
+ {/* save task btn */}
{addNewTask(title, desc, date, priority, 0)}}
+ onPress={() => { addNewTask(title, desc, '00', priority, '0') }}
>
-
-
-
- Save
-
-
-
+
+
+
+ Save
+
+
+
diff --git a/code/MyComp/Home.js b/code/MyComp/Home.js
index 057ff32f..b9a6dfc2 100644
--- a/code/MyComp/Home.js
+++ b/code/MyComp/Home.js
@@ -6,6 +6,8 @@ import ViewTask from './ViewTask';
import {Appearance} from 'react-native';
import Settings from './Settings';
import SetWallpaper from './SetWallpaper';
+import QuickTasker from './QuickTasker';
+import MyProfile from './MyProfile';
const {scale} = Dimensions.get("window")
const {width, height} = Dimensions.get("screen")
@@ -48,19 +50,24 @@ const Home = ({navigation}) => {
-
+ {navigation.navigate(QuickTasker)}}
+ >
-
- How To Use
+
+ Zap Tasker
-
+ {navigation.navigate(MyProfile)}}
+ >
diff --git a/code/MyComp/MyProfile.js b/code/MyComp/MyProfile.js
new file mode 100644
index 00000000..f5934497
--- /dev/null
+++ b/code/MyComp/MyProfile.js
@@ -0,0 +1,56 @@
+import React from 'react';
+import { StyleSheet, View, Text, Image } from 'react-native';
+
+const MyProfile = () => {
+ return (
+
+
+
+
+ Username
+ Achievements
+ Sign in
+
+
+ );
+};
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+
+ alignItems: 'center',
+ },
+ image: {
+ marginTop:12,
+ width: 150,
+ height: 150,
+ borderRadius: 75,
+ marginBottom: 20,
+ color:'black',
+ },
+ info: {
+ alignItems: 'center',
+ color:'black',
+ },
+ name: {
+ fontSize: 24,
+ fontWeight: 'bold',
+ marginBottom: 5,
+ color:'black',
+ },
+ achievements: {
+ fontSize: 18,
+ marginBottom: 5,
+ color:'black',
+ },
+ phone: {
+ fontSize: 18,color:'black',
+ },
+});
+
+export default MyProfile;
\ No newline at end of file
diff --git a/code/MyComp/QuickTasker.js b/code/MyComp/QuickTasker.js
new file mode 100644
index 00000000..cd8c2969
--- /dev/null
+++ b/code/MyComp/QuickTasker.js
@@ -0,0 +1,115 @@
+import React, { useState } from 'react';
+import { StyleSheet, Text, View, TextInput, Button, TouchableOpacity, Alert } from 'react-native';
+
+export default function QuickTasker() {
+const [task, setTask] = useState('');
+const [taskList, setTaskList] = useState([]);
+const [prevTaskList, setPrevTaskList] = useState([]);
+
+const checkValidation = () => {
+if (task === '') {
+Alert.alert('Error', 'Please Enter a valid Task');
+} else {
+addTask();
+}
+};
+
+const addTask = () => {
+setPrevTaskList(taskList);
+setTaskList([...taskList, task]);
+setTask('');
+};
+
+const deleteTask = (index) => {
+setPrevTaskList(taskList);
+const newTaskList = [...taskList];
+newTaskList.splice(index, 1);
+setTaskList(newTaskList);
+};
+
+const undo = () => {
+setTaskList(prevTaskList);
+};
+
+return (
+
+ setTask(text)}
+value={task}
+/>
+
+
+
+
+{taskList.map((task, index) => (
+
+{index + 1}. {task}
+
+))}
+
+);
+}
+
+const styles = StyleSheet.create({
+ container: {
+ flex: 1,
+ alignItems: 'center',
+ padding: 20,
+ },
+ input: {
+ width: '100%',
+ height: 40,
+ borderColor: 'black',
+ color:'black',
+ borderWidth: 1,
+ marginBottom: 20,
+ padding: 10,
+ },
+ btn:{
+
+ display:'flex',
+ flexDirection: 'row',
+ gap:80
+ , width: '75%',
+ },
+ button: {
+ backgroundColor:'white',
+ color:'white',
+ // display:'flex',
+ marginBottom: 20,
+ padding: 10,
+ },
+ undoButton: {
+ backgroundColor:'black',
+ background : 'yellow',
+ // display:'flex',
+ marginBottom: 20,
+ padding: 107,
+ width: '100%'
+
+ },
+ taskContainer: {
+ flexDirection: 'row',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ width: '100%',
+ marginBottom: 20,
+ padding: 10,
+ },
+ task: {
+ color: 'black',
+ fontSize: 18,
+ flex: 1,
+ },
+ deleteButton: {
+ marginLeft: 10,
+ padding: 10,
+ },
+ });
\ No newline at end of file
diff --git a/code/MyComp/SetWallpaper.js b/code/MyComp/SetWallpaper.js
index ef934c9f..c7bbc33a 100644
--- a/code/MyComp/SetWallpaper.js
+++ b/code/MyComp/SetWallpaper.js
@@ -3,6 +3,9 @@ import WallPaperManager from "react-native-set-wallpaper";
const windowWidth = Math.round(Dimensions.get('window').width);
const windowHeight = Math.round(Dimensions.get('window').height);
+// following line includes database functions
+import { addNewTask, resetAIjson, resetHIjson, removeTaskByID, editTaskByID, TaskArray, organiseTask } from '../brain/testing';
+
function setWall(URL){
WallPaperManager.setWallpaper({ uri: URL }, (res) => {
console.log(res);
@@ -10,7 +13,8 @@ function setWall(URL){
}
function SetWallpaper() {
const FontSize = '56'
-const plainText = "Hello \n How \n Are \n You"
+organiseTask()
+const plainText = "Read \n Study \n Play \n Work"
const Background = '000000,128'
const TextColour = 'fff,255'
const url = "https://fakeimg.pl/"+windowWidth+'x'+windowHeight+'/'+Background+'/'+TextColour+'/?font_size='+FontSize+'&text='+encodeURIComponent(plainText);
diff --git a/code/brain/testing.js b/code/brain/testing.js
index 6efdd6c6..d3c1a538 100644
--- a/code/brain/testing.js
+++ b/code/brain/testing.js
@@ -27,7 +27,8 @@ exports.resetHIjson = () => {
deadline: 'sample',
priority: 'sample',
duration: 'sample',
- curDate: 'sample'
+ curDate: 'sample',
+ weight: 'sample'
}
]
}
@@ -54,7 +55,8 @@ exports.addNewTask = (taskTitle, taskDesp, taskDead, taskPrio, taskDurtn) => {
deadline: taskDead,
priority: taskPrio,
duration: taskDurtn,
- curDate: new Date()
+ curDate: new Date(),
+ weight: parseInt(taskPrio) * parseInt(taskDurtn)
}
RNFS.readFile(path)
@@ -141,6 +143,7 @@ exports.editTaskByID = (TaskID, attrib, newValue) => {
task.duration = newValue
}
+ task.weight = parseInt(task.priority) * parseInt(task.duration)
RNFS.writeFile(path, JSON.stringify(jsonData));
}
@@ -157,11 +160,9 @@ exports.organiseTask = () => {
const jsonData = JSON.parse(value);
// Use the JSON data as needed
- jsonData.Task_List[1]
+ jsonData.Task_List.sort((a, b) => b.weight - a.weight);
- RNFS.writeFile(path, JSON.stringify(jsonData));
-
- console.log(jsonData.Task_List[0])
+ console.log(jsonData.Task_List)
})
.catch(error => {
console.error(error);