Skip to content

Commit

Permalink
Resolve w Bryan
Browse files Browse the repository at this point in the history
  • Loading branch information
ChaseTeichmann committed Nov 12, 2019
2 parents 202b7a1 + f1b2a47 commit 4c65376
Show file tree
Hide file tree
Showing 13 changed files with 360 additions and 83 deletions.
Binary file modified Routinely/app/components/img/RoutinelyR.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 3 additions & 5 deletions Routinely/app/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import CalendarScreen from './screens/calendar';
import AlarmScreen from './screens/alarm';
import AlarmRingingScreen from './screens/alarmRinging';
import EventScreen from './screens/event';
import TaskScreen from './screens/tasks';
import TasksScreen from './screens/tasks';
import TaskScreen from './screens/task';
import MenuScreen from './screens/menu';
import EditEventScreen from './screens/editEvent';
import EditTaskScreen from './screens/editTask';
Expand All @@ -28,16 +29,13 @@ const AppStack = createStackNavigator(
Calendar: CalendarScreen,
Event: EventScreen,
Task: TaskScreen,
Tasks: TasksScreen,
Menu: MenuScreen,
EditEvent: EditEventScreen,
EditTask: EditTaskScreen,
Notes: NotesScreen,
},
{
initialRouteName: 'Alarm',
initialRouteName: 'AlarmRinging',
initialRouteName: 'Menu',
initialRouteName: 'Notes',
initialRouteName: 'Calendar',
},
);
Expand Down
148 changes: 116 additions & 32 deletions Routinely/app/screens/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import firebase from '@react-native-firebase/app';
import firestore from '@react-native-firebase/firestore';
import '@react-native-firebase/auth';
import {Divider} from 'react-native-elements';
import Swipeout from 'react-native-swipeout';

const today = new Date().toISOString().split('T')[0];
const fastDate = getPastDate(3);
Expand All @@ -35,7 +36,11 @@ const utcDateToString = (momentInUTC: moment): string => {
return moment.utc(momentInUTC).format('YYYY-MM-DDTHH:mm:ss.SSS[Z]');
};

const user = firebase.auth().currentUser;
const user = [{email: ''}];
if (firebase.auth().currentUser !== null) {
const currentUser = firebase.auth().currentUser;
user.email = currentUser.email;
}

const eventsRef = firestore()
.collection('users')
Expand Down Expand Up @@ -91,6 +96,7 @@ class CalendarScreen extends Component {
getEvents = async eventRetrieved => {
try {
eventsRef.onSnapshot(querySnapshot => {
this.setState({eventList: []});
querySnapshot.forEach(event => {
this.state.eventList.push(event.data());
//console.log("this is the event " +event.get('chosenDate').toDate());
Expand All @@ -105,6 +111,7 @@ class CalendarScreen extends Component {
getTasks = async taskRetrieved => {
try {
tasksRef.onSnapshot(querySnapshot => {
this.setState({taskList: []});
querySnapshot.forEach(tasks => {
this.state.taskList.push(tasks.data());
//console.log("this is the event " +event.get('chosenDate').toDate());
Expand Down Expand Up @@ -231,6 +238,106 @@ class CalendarScreen extends Component {
this.props.navigation.navigate('EditTask', {task: item});
};

listTasks = item => {
const swipeBtns = [
{
onPress: item => {
this.editTask(item);
},
text: 'Edit',
backgroundColor: '#166EE5',
},
{
onPress: () => {
Alert.alert('Delete?', 'Are you sure you want to delete this item?', [
{
text: 'No',
onPress: () => console.log('cancelled'),
},
{
text: 'Yes',
onPress: () => this.deleteTask(item),
},
]);
},
text: 'Delete',
backgroundColor: '#F0050F',
},
];

return (
<Swipeout
right={swipeBtns}
autoClose="true"
backgroundColor="transparent"
sensitivity={100}
buttonWidth={50}>
<View style={styles.item}>
<Text style={styles.itemTitleText}>{item.title}</Text>
<Text>{item.note}</Text>
</View>
</Swipeout>
);
};

listEvents = item => {
const swipeBtns = [
{
onPress: item => {
this.editTask(item);
},
text: 'Edit',
backgroundColor: '#166EE5',
},
{
onPress: () => {
Alert.alert('Delete?', 'Are you sure you want to delete this item?', [
{
text: 'No',
onPress: () => console.log('cancelled'),
},
{
text: 'Yes',
onPress: () => this.deleteEvent(item),
},
]);
},
text: 'Delete',
backgroundColor: '#F0050F',
},
];

return (
<Swipeout
right={swipeBtns}
autoClose="true"
backgroundColor="transparent"
sensitivity={100}
buttonWidth={50}>
<View style={styles.item}>
<Text style={styles.itemHourText}>{item.hour}</Text>
<Text style={styles.itemDurationText}>{item.duration}</Text>
<Text style={styles.itemTitleText}> {item.title} </Text>
<Text style={styles.itemHourText}>
{' '}
{item.notes}
{item.chosenDate.toDate().getUTCMonth() + 1} -{' '}
{item.chosenDate.toDate().getUTCDate()} -{' '}
{item.chosenDate.toDate().getUTCFullYear()}{' '}
{item.chosenDate.toDate().getHours() > 12
? item.chosenDate.toDate().getHours() - 12
: item.chosenDate.toDate().getHours()}
:
{item.chosenDate.toDate().getMinutes() < 10
? '0' + item.chosenDate.toDate().getMinutes()
: item.chosenDate.toDate().getMinutes()}{' '}
{item.chosenDate.toDate().getHours() > 12 ? 'pm' : 'am'}
</Text>
</View>
</Swipeout>
);
};

deleteEvent = item => {
const index = this.state.eventList.indexOf(item);
//console.log(index);
Expand Down Expand Up @@ -378,37 +485,14 @@ class CalendarScreen extends Component {
data={this.state.eventList}
keyExtractor={item => item.id}
renderItem={({item}) => {
return (
<TouchableOpacity
onPress={() =>
this.itemPressed(item.title + ' ' + item.notes)
}
style={styles.item}>
<View>
<Text style={styles.itemHourText}>{item.hour}</Text>
<Text style={styles.itemDurationText}>
{item.duration}
</Text>
</View>
<Text style={styles.itemTitleText}>{item.title} </Text>
<Text style={styles.itemHourText}>{item.notes} </Text>
<Text style={styles.itemHourText}>
{item.chosenDate.toDate().getUTCMonth() + 1} -{' '}
{item.chosenDate.toDate().getUTCDate()} -{' '}
{item.chosenDate.toDate().getUTCFullYear()}{' '}
</Text>
<Text style={styles.itemHourText}>
{item.chosenDate.toDate().getHours() > 12
? item.chosenDate.toDate().getHours() - 12
: item.chosenDate.toDate().getHours()}
:
{item.chosenDate.toDate().getMinutes() < 10
? '0' + item.chosenDate.toDate().getMinutes()
: item.chosenDate.toDate().getMinutes()}{' '}
{item.chosenDate.toDate().getHours() > 12 ? 'pm' : 'am'}
</Text>
</TouchableOpacity>
);
return this.listEvents(item);
}}
/>
<FlatList
data={this.state.taskList}
keyExtractor={item => item.id}
renderItem={({item}) => {
return this.listTasks(item);
}}
/>
</View>
Expand Down
6 changes: 5 additions & 1 deletion Routinely/app/screens/editEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import AwesomeButtonBlue from 'react-native-really-awesome-button/src/themes/blu
import RepeatDiv from '../components/alarm_components/RepeatDiv';
import {Divider} from 'react-native-elements';

const user = firebase.auth().currentUser;
const user = [{"email": ''}];
if(firebase.auth().currentUser !== null){
const currentUser = firebase.auth().currentUser;
user.email= currentUser.email;
}

class EditEventScreen extends Component {

Expand Down
7 changes: 6 additions & 1 deletion Routinely/app/screens/editTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import {
ListRenderItem,
} from 'react-native';
import {Hoshi} from 'react-native-textinput-effects';
const user = firebase.auth().currentUser;
const user = [{"email": ''}];
if(firebase.auth().currentUser !== null){
const currentUser = firebase.auth().currentUser;
user.email= currentUser.email;
}

const ref = firestore()
.collection('users')
.doc(user.email)
Expand Down
6 changes: 5 additions & 1 deletion Routinely/app/screens/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ const utcDateToString = (momentInUTC: moment): string => {
return time;
};

const user = firebase.auth().currentUser;
const user = [{"email": ''}];
if(firebase.auth().currentUser !== null){
const currentUser = firebase.auth().currentUser;
user.email= currentUser.email;
}

class EventScreen extends Component {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion Routinely/app/screens/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MenuScreen extends Component {
<View style={styles.row}>
<View>
<TouchableHighlight
onPress={() => this.props.navigation.navigate('Task')}>
onPress={() => this.props.navigation.navigate('Tasks')}>
<Image
style={styles.icon}
source={require('../components/img/DailyToDoButton.png')}
Expand Down
111 changes: 111 additions & 0 deletions Routinely/app/screens/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

import React from 'react';
import firebase from '@react-native-firebase/app';
import firestore from '@react-native-firebase/firestore';
import '@react-native-firebase/auth';
import AwesomeButtonBlue from 'react-native-really-awesome-button/src/themes/blue';
import {
TextInput,
RefreshControl,
Text,
FlatList,
View,
StyleSheet,
ListRenderItem,
} from 'react-native';
import {Hoshi} from 'react-native-textinput-effects';

const user = [{"email": ''}];
if(firebase.auth().currentUser !== null){
const currentUser = firebase.auth().currentUser;
user.email= currentUser.email;
}

const ref = firestore()
.collection('users')
.doc(user.email)
.collection('tasks');

class task extends React.Component {
state = {
list:[],
taskList: [],
setTask: '',
task: '',
title: '',
note: '',
};
addTask = async (title, note) => {
try {
const date = new Date(Date.now());
await ref.add({
title: title,
note: note,
date: date,
complete: false,
});
} catch (error) {
console.log('addTask failed');
}
this.setState({title: ''});
this.setState( {note: ''});
this.props.navigation.navigate('Tasks');

};

render() {
return (
<View style={styles.container}>
<Hoshi
style={styles.card1}
placeholder={task.title}
label={'Enter Title'}
onChangeText={title => this.setState({title})}
value={this.state.title}
borderColor={'#2E68FF'}
maskColor={'#blue'}
/>
<Hoshi
style={styles.card1}
placeholder={task.title}
label={'Enter Task Name'}
onChangeText={note => this.setState({note})}
value={this.state.note}
borderColor={'#2E68FF'}
maskColor={'#blue'}
/>
<AwesomeButtonBlue
width={75}
title="addTitle"
onPress={() => this.addTask(this.state.title, this.state.note)}>
Add
</AwesomeButtonBlue>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
paddingLeft: 10,
paddingRight: 10,
},
inputRow: {
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 10,
marginTop: 25,
},
card1: {
paddingVertical: 16,
width: 275,
},
tasks: {
fontSize: 25,
marginTop: 15,
},
});

export default task;


Loading

0 comments on commit 4c65376

Please sign in to comment.