From f77fa33396a72815f37c4f49b430dd2627b7320f Mon Sep 17 00:00:00 2001 From: Arthur Jamet Date: Wed, 21 Jun 2023 14:47:59 +0100 Subject: [PATCH] Front: Authentication View: Refactor to be usable with URL navigation --- front/views/AuthenticationView.tsx | 7 ++++--- front/views/StartPageView.tsx | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/front/views/AuthenticationView.tsx b/front/views/AuthenticationView.tsx index 89dd60e..a0a463c 100644 --- a/front/views/AuthenticationView.tsx +++ b/front/views/AuthenticationView.tsx @@ -7,7 +7,7 @@ import { Center, Button, Text } from 'native-base'; import SigninForm from '../components/forms/signinform'; import SignupForm from '../components/forms/signupform'; import TextButton from '../components/TextButton'; -import { RouteProps } from '../Navigation'; +import { RouteProps, useNavigation } from '../Navigation'; const hanldeSignin = async ( username: string, @@ -48,7 +48,8 @@ type AuthenticationViewProps = { const AuthenticationView = ({ isSignup }: RouteProps) => { const dispatch = useDispatch(); - const [mode, setMode] = React.useState<'signin' | 'signup'>(isSignup ? 'signup' : 'signin'); + const navigation = useNavigation(); + const mode = isSignup ? 'signup' : 'signin'; return (
@@ -82,7 +83,7 @@ const AuthenticationView = ({ isSignup }: RouteProps) = variant="outline" marginTop={5} colorScheme="primary" - onPress={() => setMode(mode === 'signin' ? 'signup' : 'signin')} + onPress={() => navigation.navigate(mode === 'signin' ? 'Signup' : 'Login', {})} />
); diff --git a/front/views/StartPageView.tsx b/front/views/StartPageView.tsx index ead1697..302ffcf 100644 --- a/front/views/StartPageView.tsx +++ b/front/views/StartPageView.tsx @@ -92,7 +92,7 @@ const StartPageView = () => { image={imgLogin} iconName="user" iconProvider={FontAwesome5} - onPress={() => navigation.navigate('Login', { isSignup: false })} + onPress={() => navigation.navigate('Login', {})} style={{ width: isSmallScreen ? '90%' : 'clamp(100px, 33.3%, 600px)', height: '300px', @@ -132,7 +132,7 @@ const StartPageView = () => { subtitle="Create an account to save your progress" iconProvider={FontAwesome5} iconName="user-plus" - onPress={() => navigation.navigate('Login', { isSignup: true })} + onPress={() => navigation.navigate('Signup', {})} style={{ height: '150px', width: isSmallScreen ? '90%' : 'clamp(150px, 50%, 600px)',