Front: Authentication View: Refactor to be usable with URL navigation
This commit is contained in:
committed by
Clément Le Bihan
parent
b736dbc1f0
commit
f77fa33396
@@ -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<AuthenticationViewProps>) => {
|
||||
const dispatch = useDispatch();
|
||||
const [mode, setMode] = React.useState<'signin' | 'signup'>(isSignup ? 'signup' : 'signin');
|
||||
const navigation = useNavigation();
|
||||
const mode = isSignup ? 'signup' : 'signin';
|
||||
|
||||
return (
|
||||
<Center style={{ flex: 1 }}>
|
||||
@@ -82,7 +83,7 @@ const AuthenticationView = ({ isSignup }: RouteProps<AuthenticationViewProps>) =
|
||||
variant="outline"
|
||||
marginTop={5}
|
||||
colorScheme="primary"
|
||||
onPress={() => setMode(mode === 'signin' ? 'signup' : 'signin')}
|
||||
onPress={() => navigation.navigate(mode === 'signin' ? 'Signup' : 'Login', {})}
|
||||
/>
|
||||
</Center>
|
||||
);
|
||||
|
||||
@@ -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)',
|
||||
|
||||
Reference in New Issue
Block a user