From cc98da27fac18ba8060bc7fa76ce13624d452543 Mon Sep 17 00:00:00 2001 From: Justin Shillingford Date: Thu, 25 Jun 2020 17:21:04 -0400 Subject: Added base app with background color for Sign In Everything's in App.tsx for now since we haven't discussed structure --- src/routes/Routes.tsx | 2 +- src/screens/Login.tsx | 225 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 217 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/routes/Routes.tsx b/src/routes/Routes.tsx index 9c2efada..0b08cbb1 100644 --- a/src/routes/Routes.tsx +++ b/src/routes/Routes.tsx @@ -15,7 +15,7 @@ interface RoutesProps {} const Routes: React.FC = ({}) => { return ( - + ); diff --git a/src/screens/Login.tsx b/src/screens/Login.tsx index 0305b907..672fd035 100644 --- a/src/screens/Login.tsx +++ b/src/screens/Login.tsx @@ -1,9 +1,19 @@ -import React from 'react'; +import React, { useRef } from 'react'; import {RouteProp} from '@react-navigation/native'; import {StackNavigationProp} from '@react-navigation/stack'; -import {View, Text, Button} from 'react-native'; +import { + View, + Text, + Alert, + StatusBar, + Image, + TextInput, + TouchableOpacity, + StyleSheet +} from 'react-native'; import {RootStackParams} from '../routes'; +import LinearGradient from 'react-native-linear-gradient'; type LoginScreenRouteProp = RouteProp; type LoginScreenNavigationProp = StackNavigationProp; @@ -13,15 +23,212 @@ interface LoginProps { navigation: LoginScreenNavigationProp; } const Login = ({navigation}: LoginProps) => { + const passwordInput = useRef(); + const [data, setData] = React.useState({ + username: '', + password: '', + isValidUser: true, + isValidPassword: true, + }) + + /* + Updates the state of username. Also verifies the input of the Username field. + */ + const handleUsernameUpdate = (val:string) => { + var validLength:boolean = val.trim().length >= 6 + + if (validLength) { + setData({ + ...data, + username: val, + isValidUser: true + }) + } + else { + setData({ + ...data, + username: val, + isValidUser: false + }) + } + } + + /* + Updates the state of password. Also verifies the input of the Password field. + */ + const handlePasswordUpdate = (val:string) => { + var validLength:boolean = val.trim().length >= 8 + + if (validLength) { + setData({ + ...data, + password: val, + isValidPassword: true + }) + } + else { + setData({ + ...data, + password: val, + isValidPassword: false + }) + } + } + + /* + Handler for the Let's Start button or the Go button on the keyboard. + */ + const handleLogin = () => { + if (data.isValidUser && data.isValidPassword) { + Alert.alert(`My favorite Girl Scout Cookies are taggalongs! What are yours ${data.username}?`) + navigation.navigate('Registration') + } + } + return ( - - Welcome to Tagg! Login page goes here. -