From 10c1828cdf98cf0ad1264d39792bd14f3c48217c Mon Sep 17 00:00:00 2001 From: GabrielTrettel Date: Thu, 28 Oct 2021 19:41:36 -0300 Subject: [PATCH] Letting user uses some functionalities while not logged --- src/App.js | 2 +- src/app/components/ConfirmationModal.js | 8 +++--- src/app/components/SvgLabeledButton.js | 24 +++++++++++++---- src/app/screens/LoginScreen.js | 35 ++++++++++++++++-------- src/app/screens/SharingDataScreen.js | 36 +++++++++++++++++++------ 5 files changed, 76 insertions(+), 29 deletions(-) diff --git a/src/App.js b/src/App.js index da6bcb3..ac89ad2 100644 --- a/src/App.js +++ b/src/App.js @@ -25,7 +25,7 @@ export default function App() { const netInfo = useNetInfo(); useEffect(() => { - user && authStorage.setUser(user) + user?.username != null && authStorage.setUser(user) }, [user]) diff --git a/src/app/components/ConfirmationModal.js b/src/app/components/ConfirmationModal.js index ecec83f..de45bdf 100644 --- a/src/app/components/ConfirmationModal.js +++ b/src/app/components/ConfirmationModal.js @@ -45,7 +45,7 @@ export default function ConfirmationModal({ }} > - + @@ -57,7 +57,7 @@ export default function ConfirmationModal({ style={{ flexDirection: "row", justifyContent: "space-evenly", - marginTop: 24, + marginTop: 24, }} > {onConfirm && confirmationLabel && {}, }) { const dims = scaleDimsFromWidth(width, height, 16); return ( @@ -25,8 +33,16 @@ export default function SvgLabeledButton({ startColor="rgba(0, 0, 0, 0.15)" paintInside={true} > - - + + - { - props.navigation.navigate("ForgotPassword"); - }} - > - - - Esqueceu a senha? - - - + {/* FIXME: update this in future versions */} + {/* { */} + {/* props.navigation.navigate("ForgotPassword"); */} + {/* }} */} + {/* > */} + {/* */} + {/* */} + {/* Esqueceu a senha? */} + {/* */} + {/* */} + {/* */} @@ -159,6 +160,18 @@ export default function LoginScreen(props) { props.navigation.navigate("Register"); }} /> + + { + authContext.setUser(true); + }} + > + + + Ou continue sem uma conta + + + diff --git a/src/app/screens/SharingDataScreen.js b/src/app/screens/SharingDataScreen.js index 7dc1727..d525937 100644 --- a/src/app/screens/SharingDataScreen.js +++ b/src/app/screens/SharingDataScreen.js @@ -1,15 +1,27 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, useContext } from "react"; import { StyleSheet, View } from "react-native"; - +import ConfirmationModal from "../components/ConfirmationModal"; import { ScrollView } from "react-native"; import assets from "../config/assets"; import { dimensions } from "../config/dimensions"; import SvgLabeledButton from "../components/SvgLabeledButton"; +import { AuthContext } from "../auth/context"; function SharingDataScreen({ navigation }) { + const authContext = useContext(AuthContext); + const [showLog, setShowLog] = useState(false); + + const isRegistered = authContext.user?.username != null; return ( + authContext.setUser(false)} + onDecline={() => setShowLog(false)} + /> navigation.navigate("FloodSharingData")} + active={isRegistered} + inactiveOnPress={() => setShowLog(true)} /> - navigation.navigate("RainSharingData")} SvgImage={assets.rainLevel.Rain_1_5} + active={isRegistered} + inactiveOnPress={() => setShowLog(true)} /> @@ -42,17 +57,22 @@ function SharingDataScreen({ navigation }) { marginVertical: 24, }} > - navigation.navigate("PluviometerSharingData")} - SvgImage={assets.PluviometerIcon}/> + SvgImage={assets.PluviometerIcon} + active={isRegistered} + inactiveOnPress={() => setShowLog(true)} + /> navigation.navigate("RiverFloodData")} - SvgImage={assets.riverLevel.RiverIcon}/> + SvgImage={assets.riverLevel.RiverIcon} + active={isRegistered} + inactiveOnPress={() => setShowLog(true)} + />