diff --git a/src/App.js b/src/App.js index a4ecf62..f636e3b 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,6 @@ import React from 'react'; import './css/App.css'; +import './css/PopUp.css'; import { BrowserRouter as Router, Route, Switch, Redirect, Link } from 'react-router-dom'; import Home from "./Home"; import LoggedInHome from "./LoggedInHome"; @@ -18,11 +19,14 @@ import TermsOfService from "./TermsOfService"; import PrivacyPolicy from "./PrivacyPolicy"; import Button from "./Button"; import { CheckRounded as CheckRoundedIcon } from "@material-ui/icons"; +import Loader from "./puff-loader.svg"; import RouteChangeTracker from './RouteChangeTracker'; import Cookies from 'universal-cookie'; +import styled, { keyframes } from "styled-components"; + import firebase from "firebase/app"; import "firebase/auth"; import "firebase/functions"; @@ -48,10 +52,37 @@ appCheck.activate( true ); -// firebase.functions().useEmulator("localhost", 5001); -// firebase.auth().useEmulator("http://localhost:9099"); -// firebase.firestore().useEmulator("localhost", 8080); -const functions = firebase.app().functions("europe-west2");//firebase.functions(); +firebase.functions().useEmulator("localhost", 5001); +firebase.auth().useEmulator("http://localhost:9099"); +firebase.firestore().useEmulator("localhost", 8080); +const functions = firebase.functions();//firebase.app().functions("europe-west2"); + +const fadeIn = keyframes` + from { + opacity: 0; + } + + to { + opacity: 0.65; + } +`; + +const fadeOut = keyframes` + from { + opacity: 0.65; + } + + to { + opacity: 0; + } +`; + +const Fade = styled.div` + display: inline-block; + visibility: ${props => props.out ? 'hidden' : 'visible'}; + animation: ${props => props.out ? fadeOut : fadeIn} 0.1s linear; + transition: visibility 0.1s linear; +`; firebase.firestore().enablePersistence() .catch((err) => { @@ -85,10 +116,27 @@ const analytics = firebase.analytics(); class App extends React.Component { constructor(props) { super(props); + this.state = { user: null, + userDataPresent: false, sound: true, theme: "default", + pageLoading: true, + }; + + this.page = { + loaded: !this.state.pageLoading, + load: () => { + this.setState({ + pageLoading: false, + }); + }, + unload: () => { + this.setState({ + pageLoading: true, + }); + }, }; } @@ -96,6 +144,7 @@ class App extends React.Component { firebase.auth().onAuthStateChanged(async (userData) => { let newState = { user: userData, + userDataPresent: true, }; if (userData) { @@ -107,16 +156,16 @@ class App extends React.Component { await firebase.firestore() - .collection("users") - .doc(userData.uid) - .get() - .then((userDoc) => { - newState.sound = userDoc.data().sound; - newState.theme = userDoc.data().theme; - }).catch((error) => { - newState.sound = true; - newState.theme = "default"; - }); + .collection("users") + .doc(userData.uid) + .get() + .then((userDoc) => { + newState.sound = userDoc.data().sound; + newState.theme = userDoc.data().theme; + }).catch((error) => { + newState.sound = true; + newState.theme = "default"; + }); } this.setState(newState); @@ -217,73 +266,76 @@ class App extends React.Component {