Skip to content

Commit e23fb6f

Browse files
committedApr 11, 2024
Added more signup pages and messed with colors
1 parent 4ab0520 commit e23fb6f

19 files changed

+396
-58
lines changed
 

‎App.js

-22
This file was deleted.

‎App.jsx

-21
This file was deleted.

‎App.tsx

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { NavigationContainer } from '@react-navigation/native';
3+
import { StatusBar } from 'expo-status-bar';
4+
import { Provider } from 'react-redux';
5+
6+
import store from './StateManagement/store';
7+
import AuthNavigator from './Navigators/AuthNavigator';
8+
9+
const App: React.FC = () => {
10+
return (
11+
<Provider store={store}>
12+
<NavigationContainer>
13+
<StatusBar style="light"/>
14+
<AuthNavigator/>
15+
</NavigationContainer>
16+
</Provider>
17+
);
18+
};
19+
20+
export default App;

‎Components/Components.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { TextInput, Text, View, StyleSheet, TextInputProps, TouchableWithoutFeed
44
import {LinearGradient} from 'expo-linear-gradient';
55

66
import ComponentStyle from '../Styles/ComponentStyles';
7+
import { COLOR } from '../Styles/Colors';
78

89

910
/*
@@ -31,7 +32,7 @@ interface PrimaryTextInputProps extends TextInputProps
3132
/*
3233
Component that sets the background when used
3334
*/
34-
export const PrimaryBackground: React.FC<GradientBackgroundProps> = ({colors = ['#3F51B5','#03A9F4'], style, children }) => {
35+
export const PrimaryBackground: React.FC<GradientBackgroundProps> = ({colors = COLOR.gradientColors, style, children }) => {
3536
return (
3637
<LinearGradient colors={colors} style={[ComponentStyle.primaryBackground, style]}>
3738
<View style={[ComponentStyle.primaryBackgroundMask]}>

‎Navigators/AuthNavigator.jsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { createStackNavigator } from '@react-navigation/stack';
22

33
import AuthLoginView from '../Views/AuthLoginView';
4-
import EmailView from '../Views/SignUpViews/EmailView';
4+
import SignUpStack from './SignUpStack';
5+
56

67
const Stack = createStackNavigator();
78

@@ -13,7 +14,7 @@ const AuthNavigator = () =>
1314
screenOptions={{headerShown: false}}
1415
>
1516
<Stack.Screen name="Login" component={AuthLoginView}/>
16-
<Stack.Screen name="SignUp" component={EmailView}/>
17+
<Stack.Screen name="SignUpStack" component={SignUpStack}/>
1718
</Stack.Navigator>
1819
);
1920
};

‎Navigators/SignUpStack.tsx

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createStackNavigator } from '@react-navigation/stack';
2+
import { NavigationContainer } from '@react-navigation/native';
3+
import EmailView from '../Views/SignUpViews/EmailView';
4+
import UsernameView from '../Views/SignUpViews/UsernameView';
5+
import PasswordView from '../Views/SignUpViews/PasswordView';
6+
7+
const Stack = createStackNavigator();
8+
9+
const SignUpStack = () => {
10+
return (
11+
<Stack.Navigator initialRouteName="EmailView" screenOptions={{ headerShown: false }}>
12+
<Stack.Screen
13+
name="EmailView"
14+
component={EmailView}
15+
/>
16+
<Stack.Screen
17+
name="UsernameView"
18+
component={UsernameView}
19+
/>
20+
<Stack.Screen
21+
name="PasswordView"
22+
component={PasswordView}
23+
/>
24+
</Stack.Navigator>
25+
)
26+
}
27+
28+
export default SignUpStack;

‎StateManagement/actions.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export const setEmail = (email: string) => ({
2+
type: 'SET_EMAIL',
3+
payload: email,
4+
});
5+
6+
export const setUsername = (username: string) => ({
7+
type: 'SET_USERNAME',
8+
payload: username,
9+
});
10+
11+
export const setPassword = (password: string) => ({
12+
type: 'SET_PASSWORD',
13+
payload: password,
14+
});
15+

‎StateManagement/store.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { createStore } from 'redux';
2+
3+
interface AuthState {
4+
email: string;
5+
username: string;
6+
password: string;
7+
}
8+
9+
const initialState: AuthState = {
10+
email: '',
11+
username: '',
12+
password: '',
13+
};
14+
15+
// Handles state updates based on actions within code
16+
const reducer = (state = initialState, action: any): AuthState => {
17+
switch (action.type)
18+
{
19+
case 'SET_EMAIL':
20+
return {...state, email: action.payload };
21+
case 'SET_USERNAME':
22+
return {...state, username: action.payload };
23+
case 'SET_PASSWORD':
24+
return {...state, password: action.payload };
25+
default:
26+
return state;
27+
}
28+
};
29+
30+
const store = createStore(reducer);
31+
32+
export default store;

‎Styles/AuthStyles.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ const AuthStyles = StyleSheet.create({
1717
alignSelf: 'center',
1818
alignItems: 'center',
1919
alignSelf: 'center',
20-
width: '95%',
20+
width: '92%',
21+
},
22+
23+
createAccountContainer:
24+
{
25+
width: '92%',
26+
alignItems: 'center',
27+
alignSelf: 'center',
28+
marginBottom: 75,
2129
},
2230

2331
loginButton:
@@ -46,7 +54,7 @@ const AuthStyles = StyleSheet.create({
4654
createAccountButton:
4755
{
4856
height: 40,
49-
width: '95%',
57+
width: '100%',
5058
borderWidth: 1,
5159
borderRadius: 5,
5260
borderColor: COLOR.secondaryButtonBackground,

‎Styles/Colors.ts

+10
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
export interface Colors {
99
none: string;
1010

11+
gradientColorOne: string;
12+
gradientColorTwo: string;
13+
14+
gradientColors: string[];
15+
1116
primaryText: string;
1217
secondaryText: string;
1318
thirdText: string;
@@ -20,6 +25,11 @@ export const COLOR: Colors = {
2025

2126
none: 'transparent',
2227

28+
gradientColors: ['#3F51B5','#03A9F4', '#FFFFFF'],
29+
30+
gradientColorOne: '#3F51B5',
31+
gradientColorTwo: '#03A9F4',
32+
2333
primaryText: '#FFFFFF',
2434
secondaryText: '#FFC107',
2535
thirdText: '#CCCCCC',

‎Styles/ComponentStyles.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const ComponentStyle = StyleSheet.create({
2020
primaryBackgroundMask:
2121
{
2222
...StyleSheet.absoluteFillObject,
23-
backgroundColor: 'rgba(0,0,0,0.5)',
23+
backgroundColor: 'rgba(0,0,0,0.3)',
2424
},
2525

2626
primaryTextInputContainer:

‎Styles/SignUpStyle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const SignUpStyle = StyleSheet.create({
1212
justifyContent: 'flex-start',
1313
alignSelf: 'center',
1414
position: 'relative',
15-
width: '90%',
15+
width: '92%',
1616
},
1717

1818
backArrow:

‎Utils/DataVerify.ts

+30
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,34 @@ import validator from 'email-validator';
33
export function isValidEmail(email: string): boolean
44
{
55
return validator.validate(email);
6+
}
7+
8+
/*
9+
function to check if username already exists and/or is valid
10+
*/
11+
export function isValidUsername(username: string): boolean
12+
{
13+
return true;
14+
}
15+
16+
/*
17+
function to check if a password is valid or within set restraints
18+
*/
19+
export function isValidPassword(password: string): { isValid: boolean; reason?: string }
20+
{
21+
if (password.length < 8)
22+
{
23+
return { isValid: false, reason: "Password must be at least 8 characters long." };
24+
}
25+
26+
// Regex pattern for complexity requirements
27+
const pattern = /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)/;
28+
29+
// Check if the password contains at least one digit, lowercase letter, uppercase letter, and special character
30+
if (!pattern.test(password))
31+
{
32+
return { isValid: false, reason: "Password must contain at least one digit, lowercase letter, uppercase letter, and special character." };
33+
}
34+
35+
return { isValid: true };
636
}

‎Views/AuthLoginView.jsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const AuthLoginView = () =>
3333

3434
const sendToSignUp = () =>
3535
{
36-
navigation.navigate('SignUp')
36+
navigation.navigate('SignUpStack')
3737
}
3838

3939
const forgotPass = () =>
@@ -67,8 +67,10 @@ const AuthLoginView = () =>
6767
<Text style={AuthStyles.loginButtonText}>Login</Text>
6868
</TouchableOpacity>
6969
<Button title="Forgot Password?" onPress={forgotPass}/>
70+
</View>
71+
<View style={AuthStyles.createAccountContainer}>
7072
<TouchableOpacity onPress={sendToSignUp} style={AuthStyles.createAccountButton}>
71-
<Text style={AuthStyles.createAccountButtonText}>Create new account</Text>
73+
<Text style={AuthStyles.createAccountButtonText}>Create new account</Text>
7274
</TouchableOpacity>
7375
</View>
7476
</Component.PrimaryBackground>

‎Views/SignUpViews/EmailView.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import SignUpStyle from '../../Styles/SignUpStyle';
1414
const EmailView = () =>
1515
{
1616
const navigation = useNavigation();
17-
1817
const [email, setEmail] = useState('');
1918

2019
const returnLoginArrow = () => {
@@ -42,11 +41,11 @@ const EmailView = () =>
4241
{
4342
if (isValidEmail(email))
4443
{
45-
console.log('valid');
44+
navigation.navigate('UsernameView');
4645
}
4746
else
4847
{
49-
Alert.alert('Email is invalid or missing'); // insert navigation to the new page
48+
Alert.alert('Email is invalid or missing');
5049
}
5150
};
5251

‎Views/SignUpViews/PasswordView.tsx

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, { useState } from 'react';
2+
import { SafeAreaView, View, TextInput, Button, Alert, TouchableOpacity, Text } from 'react-native';
3+
import { useNavigation } from '@react-navigation/native';
4+
import Icon from 'react-native-vector-icons/MaterialIcons';
5+
6+
import * as Component from '../../Components/Components';
7+
import * as SignUpComponent from '../../Components/SignUpComponents';
8+
import AuthViewModel from '../../UserAuthentication/AuthViewModel';
9+
import { isValidPassword } from '../../Utils/DataVerify';
10+
11+
import Styles from '../../Styles/Styles';
12+
import SignUpStyle from '../../Styles/SignUpStyle';
13+
14+
const PasswordView = () =>
15+
{
16+
const navigation = useNavigation();
17+
const [password, setPassword] = useState('');
18+
19+
const backArrow = () => {
20+
navigation.navigate('UsernameView');
21+
};
22+
23+
// Checks that password is valid if not shows user why not
24+
const nextButton = () =>
25+
{
26+
let isPasswordValid = isValidPassword(password)
27+
if (isPasswordValid.isValid)
28+
{
29+
//navigation.navigate('AgeView')
30+
}
31+
else
32+
{
33+
Alert.alert(`${isPasswordValid.reason}`);
34+
}
35+
};
36+
37+
return (
38+
<Component.PrimaryBackground>
39+
<SafeAreaView style={Styles.safeZone}>
40+
<View style={SignUpStyle.container}>
41+
<TouchableOpacity onPress={backArrow}>
42+
<Icon name="arrow-back-ios" color="#FFF" style={SignUpStyle.backArrow}/>
43+
</TouchableOpacity>
44+
<SignUpComponent.SignUpInput
45+
heading="Good Password?"
46+
subheading={"Try and pick something secure...\nyour data matters."}
47+
placeholder="Password"
48+
value={password}
49+
onChangeText={setPassword}
50+
style={{
51+
container: SignUpStyle.input,
52+
heading: SignUpStyle.heading,
53+
subheading: SignUpStyle.subheading,
54+
}}
55+
/>
56+
<TouchableOpacity onPress={nextButton} style={SignUpStyle.nextButton}>
57+
<Text style={SignUpStyle.nextButtonText}>Next</Text>
58+
</TouchableOpacity>
59+
</View>
60+
</SafeAreaView>
61+
</Component.PrimaryBackground>
62+
);
63+
};
64+
65+
export default PasswordView;

0 commit comments

Comments
 (0)
Please sign in to comment.