Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions SetLife/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ npm-debug.*
*.orig.*
web-build/
web-report/
yarn-error.log

# macOS
.DS_Store

# PHPStorm
.idea/*
45 changes: 13 additions & 32 deletions SetLife/Components/CustomCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,49 +329,30 @@ class CustomCalendar extends React.Component {
* @returns {{hasTask: boolean, work: boolean}}
*/
constructDayObject(dateString){
let settings = this.props.settings;
let workday = settings.workday;
const days = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'];

let startTime;
let endTime;
let durationDay;

let work = false;
let date = new Date(dateString);
switch(date.getDay()){
case 0 :
work = this.props.settings.workday.sunday;
break;
case 1 :
work = this.props.settings.workday.monday;
break;
case 2 :
work = this.props.settings.workday.tuesday;
break;
case 3 :
work = this.props.settings.workday.wednesday;
break;
case 4 :
work = this.props.settings.workday.thursday;
break;
case 5 :
work = this.props.settings.workday.friday;
break;
case 6 :
work = this.props.settings.workday.saturday;
break;
default :
console.log("unknown day : " + date.getDay());
}

// Boolean who get if current date is a work date or not.
let work = settings.workday[days[date.getDay()]];

if (work === true){
startTime = this.props.settings.wakeupWeek;
endTime = this.props.settings.bedtimeWeek;
startTime = this.props.settings.wakeupWeek?.getHours();
endTime = this.props.settings.bedtimeWeek?.getHours();
}else {
startTime = this.props.settings.wakeupWeekend;
endTime = this.props.settings.bedtimeWeekend;
startTime = this.props.settings.wakeupWeekend.getHours();
endTime = this.props.settings.bedtimeWeekend.getHours();
}

durationDay = Number(endTime.substr(0, 2)) - Number(startTime.substr(0, 2));
durationDay = endTime - startTime;
let finalObject = {work : work, hasTask : false};
for(let i = Number(startTime.substr(0, 2)); i <= Number(endTime.substr(0, 2)); i++){
for(let i = startTime; i <= endTime; i++){
finalObject[i.toString().padStart(2,'0')] = {
quarter0 : [],
quarter1 : [],
Expand Down
83 changes: 48 additions & 35 deletions SetLife/Components/Login.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Components/Login.js

import React from 'react';
import {Text, View, Image, TextInput, TouchableOpacity} from "react-native";
import {Keyboard, Text, View, Image, TextInput, TouchableOpacity, TouchableWithoutFeedback} from "react-native";
import logoGreen from '../assets/images/logo_green_500.png';
import Icon from 'react-native-vector-icons/Ionicons';
import {connect} from 'react-redux';
Expand Down Expand Up @@ -111,50 +111,63 @@ class Login extends React.Component {
})
}

/**
* Redirect user to Opening view.
*/
returnOpening() {
this.props.navigation.navigate('Opening')
}

/**
* Returns the view of the login form.
* @returns {View}
*/
render() {
return(
<View style={stylesLogin.viewContainer}>
<View style={stylesLogin.logoContainer}>
<Image source={logoGreen} style={stylesLogin.logo} />
<Text style={stylesLogin.logoText}>Sign in</Text>
</View>
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<View style={stylesLogin.viewContainer}>
<View style={stylesLogin.logoContainer}>
<TouchableOpacity onPress={() => this.returnOpening()}>
<Image source={logoGreen} style={stylesLogin.logo}/>
</TouchableOpacity>
<Text style={stylesLogin.logoText}>Sign in</Text>
</View>

<View style={stylesLogin.formContainer}>
<Icon name={'ios-person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesLogin.inputIcon} />
<TextInput
placeholder={'Username'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesLogin.input}
onChangeText={(login) => this.onChangeLogin(login)}
/>
</View>
<View style={stylesLogin.formContainer}>
<Icon name={'person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesLogin.inputIcon}/>
<TextInput
placeholder={'Username'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesLogin.input}
onChangeText={(login) => this.onChangeLogin(login)}
/>
</View>

<View style={stylesLogin.formContainer}>
<Icon name={'ios-lock'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesLogin.inputIcon} />
<TextInput
placeholder={'Password'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesLogin.input}
onChangeText={(password) => this.onChangePassword(password)}
/>
<TouchableOpacity style={stylesLogin.ctaTogglePassword} onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'ios-eye' : 'ios-eye-off'} color={'rgba(0, 0, 0, 0.7)'} size={26} />
<View style={stylesLogin.formContainer}>
<Icon name={'lock-closed-outline'} size={28} color={'rgba(0, 0, 0, 0.7)'}
style={stylesLogin.inputIcon}/>
<TextInput
placeholder={'Password'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesLogin.input}
onChangeText={(password) => this.onChangePassword(password)}
/>
<TouchableOpacity style={stylesLogin.ctaTogglePassword} onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'eye' : 'eye-off'} color={'rgba(0, 0, 0, 0.7)'}
size={26}/>
</TouchableOpacity>
</View>

<TouchableOpacity style={stylesLogin.ctaLogin} onPress={() => this.signIn()}>
<Text style={stylesLogin.textLogin}>Sign in</Text>
</TouchableOpacity>
{this.errorConnection()}
{this.validConnection()}
</View>

<TouchableOpacity style={stylesLogin.ctaLogin} onPress={() => this.signIn()}>
<Text style={stylesLogin.textLogin}>Sign in</Text>
</TouchableOpacity>
{this.errorConnection()}
{this.validConnection()}
</View>
</TouchableWithoutFeedback>
)
}
}
Expand Down
149 changes: 81 additions & 68 deletions SetLife/Components/Register.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Components/Register.js

import React from 'react';
import {Text, View, Image, TextInput, TouchableOpacity} from "react-native";
import {Keyboard, Text, View, Image, TextInput, TouchableOpacity, TouchableWithoutFeedback} from "react-native";
import logoGreen from '../assets/images/logo_green_500.png';
import Icon from 'react-native-vector-icons/Ionicons';
import {connect} from 'react-redux';

import { stylesRegister } from '../assets/style/stylesheet';
import {stylesRegister} from '../assets/style/stylesheet';

/**
* Component for user registration.
Expand Down Expand Up @@ -57,12 +57,8 @@ class Register extends React.Component {
password: this.state.password,
confirmPassword: this.state.confirmPassword
};
let action = {type: "SIGN_UP", value: newUser};
let action = {type: "SIGN_UP", value: newUser, props: this.props};
this.props.dispatch(action);

if(this.props.loginReducer.signUpSuccess) {
this.props.navigation.navigate('Login');
}
}

/**
Expand Down Expand Up @@ -126,75 +122,92 @@ class Register extends React.Component {
}
}

/**
* Redirect user to Opening view.
*/
returnOpening() {
this.props.navigation.navigate('Opening')
}

/**
* Returns the view of the register form.
* @returns {View}
*/
render() {
return(
<View style={stylesRegister.viewContainer}>
<View style={stylesRegister.logoContainer}>
<Image source={logoGreen} style={stylesRegister.logo} />
<Text style={stylesRegister.logoText}>Sign up</Text>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'ios-person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon} />
<TextInput
placeholder={'Name'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesRegister.input}
onChangeText={(username) => this.onChangeUsername(username)}
/>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'ios-person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon} />
<TextInput
placeholder={'Login'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesRegister.input}
onChangeText={(login) => this.onChangeLogin(login)}
/>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'ios-lock'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon} />
<TextInput
placeholder={'Password'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesRegister.input}
onChangeText={(password) => this.onChangePassword(password)}
/>
<TouchableOpacity style={stylesRegister.ctaTogglePassword} onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'ios-eye' : 'ios-eye-off'} color={'rgba(0, 0, 0, 0.7)'} size={26} />
<TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
<View style={stylesRegister.viewContainer}>
<View style={stylesRegister.logoContainer}>
<TouchableOpacity onPress={() => this.returnOpening()}>
<Image source={logoGreen} style={stylesRegister.logo}/>
</TouchableOpacity>
<Text style={stylesRegister.logoText}>Sign up</Text>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon}/>
<TextInput
placeholder={'Name'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesRegister.input}
onChangeText={(username) => this.onChangeUsername(username)}
/>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'person'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon}/>
<TextInput
placeholder={'Login'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
style={stylesRegister.input}
onChangeText={(login) => this.onChangeLogin(login)}
/>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'lock-closed-outline'} size={28} color={'rgba(0, 0, 0, 0.7)'}
style={stylesRegister.inputIcon}/>
<TextInput
placeholder={'Password'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesRegister.input}
onChangeText={(password) => this.onChangePassword(password)}
/>
<TouchableOpacity style={stylesRegister.ctaTogglePassword}
onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'eye' : 'eye-off'} color={'rgba(0, 0, 0, 0.7)'}
size={26}/>
</TouchableOpacity>
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'lock-closed-outline'} size={28} color={'rgba(0, 0, 0, 0.7)'}
style={stylesRegister.inputIcon}/>
<TextInput
placeholder={'Password confirmation'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesRegister.input}
onChangeText={(confirmPassword) => this.onChangeConfirmPassword(confirmPassword)}
/>
<TouchableOpacity style={stylesRegister.ctaTogglePassword}
onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'eye' : 'eye-off'} color={'rgba(0, 0, 0, 0.7)'}
size={26}/>
</TouchableOpacity>
</View>

<TouchableOpacity style={stylesRegister.ctaLogin}>
<Text style={stylesRegister.textLogin} onPress={() => this.signUp()}>Sign up</Text>
</TouchableOpacity>
{this.errorSignUp()}
</View>

<View style={stylesRegister.formContainer}>
<Icon name={'ios-lock'} size={28} color={'rgba(0, 0, 0, 0.7)'} style={stylesRegister.inputIcon} />
<TextInput
placeholder={'Password confirmation'}
placeholderTextColor={'#344644'}
underlineColorAndroid='transparent'
secureTextEntry={this.state.showPassword}
style={stylesRegister.input}
onChangeText={(confirmPassword) => this.onChangeConfirmPassword(confirmPassword)}
/>
<TouchableOpacity style={stylesRegister.ctaTogglePassword} onPress={this.showPassword.bind(this)}>
<Icon name={this.state.press === false ? 'ios-eye' : 'ios-eye-off'} color={'rgba(0, 0, 0, 0.7)'} size={26} />
</TouchableOpacity>
</View>

<TouchableOpacity style={stylesRegister.ctaLogin}>
<Text style={stylesRegister.textLogin} onPress={() => this.signUp()}>Sign up</Text>
</TouchableOpacity>
{this.errorSignUp()}
</View>
</TouchableWithoutFeedback>
)
}
}
Expand Down
Loading