You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

5 months ago
  1. import React, { useEffect, useState } from 'react';
  2. import {Button, Text, View} from 'react-native';
  3. import ELogo from '@components/ELogo';
  4. import { useAuthState } from '@components/AuthProvider';
  5. import { Redirect, useRouter } from 'expo-router';
  6. import auth from '@react-native-firebase/auth';
  7. export default function LoginScreen(props:any) {
  8. const [user, _, setLoginState, init] = useAuthState();
  9. const [redirect, setRedirect] = useState(false);
  10. const router = useRouter();
  11. useEffect(() => {
  12. if (!init) {
  13. if (user === null) setRedirect(true);
  14. }
  15. }, [init])
  16. if (redirect) {
  17. return <Redirect href="auth/login" />
  18. }
  19. return (
  20. <>
  21. <View
  22. style={{
  23. flex: 1,
  24. rowGap: 24,
  25. flexDirection: 'column',
  26. paddingTop: 345,
  27. }}>
  28. <ELogo />
  29. <Text style={{color: 'white'}}>{JSON.stringify(user)} , {JSON.stringify(init)}</Text>
  30. <Button title="Signout" onPress={async ()=> {await auth().signOut(); router.replace("auth/login")}} />
  31. </View>
  32. </>
  33. );
  34. }