Skip to content

Commit

Permalink
Merge pull request #37 from whogurdevil/main
Browse files Browse the repository at this point in the history
file system and ux controls
  • Loading branch information
whogurdevil authored Apr 1, 2023
2 parents a06824c + c3ac7ee commit 3e8f9f0
Show file tree
Hide file tree
Showing 17 changed files with 164 additions and 137 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Hackathon
This repo is for algorithmics hackathon project
# Issues
1. No delete button for tasks
1. UI of settings page is overflowing
1. Responsiveness is not proper
1. My profile page is still incomplete
1. Set wallpaper has dummy values for tasks

# Rules for contributing in this repository:
1. Create your own branch named after you, commit and push code to your own branch only.
Expand All @@ -14,6 +18,7 @@ This repo is for algorithmics hackathon project
1. Android Studio
1. Github desktop
1. Visual Studio code
1. iconkitchen(for generating app icon)

## Requirements
1. node
Expand Down
38 changes: 21 additions & 17 deletions code/MyComp/AddTask.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import { View, Text, TouchableOpacity, StyleSheet, Dimensions, TextInput, Button, Alert, Modal } from 'react-native';
import { ToastAndroid, View, Text, TouchableOpacity, StyleSheet, Dimensions, TextInput, Button, Alert, Modal } from 'react-native';

import React, { useState } from 'react'
import DatePicker from 'react-native-date-picker'
Expand All @@ -8,8 +8,8 @@ import FontAwesome5 from 'react-native-vector-icons/FontAwesome';
// following line includes database functions
import { addNewTask, resetAIjson, resetHIjson, removeTaskByID, editTaskByID, TaskArray, organiseTask } from '../brain/testing';

import DurationBtn from './DurationBtn';

//responsiveness
const { scale } = Dimensions.get("window")
const { width, height } = Dimensions.get("window")

Expand All @@ -22,9 +22,11 @@ Width = width * y
let z = 804.5714285714286 / height

Height = height * z
const iconSize = Scale * 9


//colors and modes
const colors = ['#e4def2', '#e2ddd8', '#eef8ef', '#2d414e', '#E0DFE3', '#fff']
const iconSize = Scale * 9


const input = {
Expand Down Expand Up @@ -114,39 +116,36 @@ const styles = StyleSheet.create({

});

//main function starts here

function AddTask() {
//hooks for storing input values
const [date, setDate] = useState(new Date())
const [dateVisible, setDateVisible] = useState(false)
const [title, setTitle] = useState('Title')
const [desc, setDesc] = useState('Desc')
const [title, setTitle] = useState('')
const [desc, setDesc] = useState('')
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 (

<View>
<TextInput
style={styles.title}
maxLength={15}
placeholder='Enter Title for your task'
onChangeText={(e) => { setTitle(e) }}

>{title}</TextInput>

<TextInput
style={styles.desc}
placeholder='Enter Description for your task'
multiline={true}
onChangeText={(e) => { setDesc(e) }}

>{desc}</TextInput>
Expand Down Expand Up @@ -254,7 +253,12 @@ function AddTask() {
<TouchableOpacity

style={styles.inputBtns}
onPress={() => { addNewTask(title, desc, '00', priority, '0') }}
onPress={() => {
addNewTask(title, desc, date , priority, '0')
ToastAndroid.show('Task saved successfully', ToastAndroid.LONG);
setTitle('')
setDesc('')
}}
><View
style={{ flexDirection: 'row', padding: scale * 3 }}
>
Expand Down
31 changes: 23 additions & 8 deletions code/MyComp/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,47 @@ const filePath = `${RNFS.DocumentDirectoryPath}/${packageName}/hi.json`;

const Home = ({navigation}) => {

const requestCameraPermission = async () => {

//this functions asks for file permissions when app is opened for very first time
//also writes file hijson and availableidjson
const requestStoragePermission = async () => {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
{
title: 'Cool Photo App Camera Permission',
title: 'Atomic-Tasker App needs storage permission ',
message:
'Cool Photo App needs access to your camera ' +
'so you can take awesome pictures.',
'Atomic-Tasker App needs access to your storage ' +
'to save the data',
buttonNeutral: 'Ask Me Later',
buttonNegative: 'Cancel',
buttonPositive: 'OK',
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('You can use the storage');
resetAIjson()
resetHIjson()

RNFS.exists(filePath)
.then((exists) => {
if (exists) {
console.log('File exists');
} else {
resetAIjson()
resetHIjson()
}
})
.catch((error) => {
console.log(error);
});

} else {
console.log('Camera permission denied');
}
} catch (err) {
console.warn(err);
}
};
requestCameraPermission()
requestStoragePermission()
return (
<View style={{backgroundColor:colors[3], flex:1, alignItems:'center'}}>

Expand All @@ -87,7 +102,7 @@ const Home = ({navigation}) => {
>

<View style={styles.TouchableOpacityView}>
<FontAwesome5 name={'question'} size={iconSize} color={colors[3]}/>
<FontAwesome5 name={'bolt'} size={iconSize} color={colors[3]}/>
</View>

<Text style={styles.TouchableOpacityText1}
Expand Down
168 changes: 84 additions & 84 deletions code/MyComp/QuickTasker.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,114 +2,114 @@ 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 [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 checkValidation = () => {
if (task === '') {
Alert.alert('Error', 'Please Enter a valid Task');
} else {
addTask();
}
};

const addTask = () => {
setPrevTaskList(taskList);
setTaskList([...taskList, task]);
setTask('');
};
const addTask = () => {
setPrevTaskList(taskList);
setTaskList([...taskList, task]);
setTask('');
};

const deleteTask = (index) => {
setPrevTaskList(taskList);
const newTaskList = [...taskList];
newTaskList.splice(index, 1);
setTaskList(newTaskList);
};
const deleteTask = (index) => {
setPrevTaskList(taskList);
const newTaskList = [...taskList];
newTaskList.splice(index, 1);
setTaskList(newTaskList);
};

const undo = () => {
setTaskList(prevTaskList);
};
const undo = () => {
setTaskList(prevTaskList);
};

return (
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Add task"
onChangeText={text => setTask(text)}
value={task}
/>
<View style={styles.btn}>
<Button style={styles.button} buttonStyle={{ backgroundColor: 'z#e4def2' }} title="Add Task" onPress={checkValidation} />
<Button style={styles.undoButton} title="Undo" onPress={undo} />
</View>
{taskList.map((task, index) => (
<View style={styles.taskContainer} key={index}>
<Text style={styles.task}>{index + 1}. {task}</Text>
<Button
style={styles.deleteButton}
title="Delete"
onPress={() => deleteTask(index)}
/>
</View>
))}
</View>
);
return (
<View style={styles.container}>
<TextInput
style={styles.input}
placeholder="Add task"
onChangeText={text => setTask(text)}
value={task}
/>
<View style={styles.btn}>
<Button style={styles.button} buttonStyle={{ backgroundColor: 'z#e4def2' }} title="Add Task" onPress={checkValidation} />
<Button style={styles.undoButton} title="Undo" onPress={undo} />
</View>
{taskList.map((task, index) => (
<View style={styles.taskContainer} key={index}>
<Text style={styles.task}>{index + 1}. {task}</Text>
<Button
style={styles.deleteButton}
title="Delete"
onPress={() => deleteTask(index)}
/>
</View>
))}
</View>
);
}

const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
padding: 20,
flex: 1,
alignItems: 'center',
padding: 20,
},
input: {
width: '100%',
height: 40,
borderColor: 'black',
color:'black',
borderWidth: 1,
marginBottom: 20,
padding: 10,
width: '100%',
height: 40,
borderColor: 'black',
color: 'black',
borderWidth: 1,
marginBottom: 20,
padding: 10,
},
btn:{
display:'flex',
btn: {

display: 'flex',
flexDirection: 'row',
gap:80
gap: 80
, width: '75%',
},
button: {
backgroundColor:'white',
color:'white',
backgroundColor: 'white',
color: 'white',
// display:'flex',
marginBottom: 20,
padding: 10,
marginBottom: 20,
padding: 10,
},
undoButton: {
backgroundColor:'black',
background : 'yellow',
backgroundColor: 'black',
background: 'yellow',
// display:'flex',
marginBottom: 20,
padding: 107,
width: '100%'
marginBottom: 20,
padding: 107,
width: '100%'

},
taskContainer: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
marginBottom: 20,
padding: 10,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
marginBottom: 20,
padding: 10,
},
task: {
color: 'black',
fontSize: 18,
flex: 1,
color: 'black',
fontSize: 18,
flex: 1,
},
deleteButton: {
marginLeft: 10,
padding: 10,
marginLeft: 10,
padding: 10,
},
});
});
Loading

0 comments on commit 3e8f9f0

Please sign in to comment.