Browse Source

disabling events reports when disconected from internet

master
analuizaff 3 years ago
parent
commit
5348b2dc0b
  1. 16
      src/app/screens/SharingDataScreen.js

16
src/app/screens/SharingDataScreen.js

@ -6,12 +6,14 @@ import assets from "../config/assets";
import { dimensions } from "../config/dimensions"; import { dimensions } from "../config/dimensions";
import SvgLabeledButton from "../components/SvgLabeledButton"; import SvgLabeledButton from "../components/SvgLabeledButton";
import { AuthContext } from "../auth/context"; import { AuthContext } from "../auth/context";
import colors from "../config/colors";
import { useNetInfo } from "@react-native-community/netinfo";
function SharingDataScreen({ navigation }) { function SharingDataScreen({ navigation }) {
const authContext = useContext(AuthContext); const authContext = useContext(AuthContext);
const [showLog, setShowLog] = useState(false); const [showLog, setShowLog] = useState(false);
const [showLogPluv, setShowLogPluv] = useState(false); const [showLogPluv, setShowLogPluv] = useState(false);
const connection = useNetInfo().isConnected;
console.log(connection)
const isRegistered = authContext.user?.username != null; const isRegistered = authContext.user?.username != null;
const pluviometer = authContext.user?.pluviometer ? true : false; const pluviometer = authContext.user?.pluviometer ? true : false;
@ -40,7 +42,9 @@ function SharingDataScreen({ navigation }) {
<ConfirmationModal <ConfirmationModal
show={showLog} show={showLog}
icon={"md-warning-outline"} icon={"md-warning-outline"}
description={"Para enviar uma informação,"+"\n"+"faça o login ou cadastre-se"}
description={
"Para enviar uma informação," + "\n" + "faça o login ou cadastre-se"
}
confirmationLabel="LOGIN" confirmationLabel="LOGIN"
onConfirm={() => authContext.setUser(false)} onConfirm={() => authContext.setUser(false)}
onDecline={() => setShowLog(false)} onDecline={() => setShowLog(false)}
@ -61,7 +65,7 @@ function SharingDataScreen({ navigation }) {
onPress={() => onPress={() =>
navigation.navigate("FloodSharingData", { user: currentUser }) navigation.navigate("FloodSharingData", { user: currentUser })
} }
active={isRegistered}
active={isRegistered && connection}
inactiveOnPress={() => setShowLog(true)} inactiveOnPress={() => setShowLog(true)}
/> />
@ -71,7 +75,7 @@ function SharingDataScreen({ navigation }) {
navigation.navigate("RainSharingData", { user: currentUser }) navigation.navigate("RainSharingData", { user: currentUser })
} }
SvgImage={assets.rainLevel.RainIcon} SvgImage={assets.rainLevel.RainIcon}
active={isRegistered}
active={isRegistered && connection}
inactiveOnPress={() => setShowLog(true)} inactiveOnPress={() => setShowLog(true)}
/> />
</View> </View>
@ -93,7 +97,7 @@ function SharingDataScreen({ navigation }) {
}) })
} }
SvgImage={assets.PluviometricDataIcon} SvgImage={assets.PluviometricDataIcon}
active={isRegistered && pluviometer}
active={isRegistered && pluviometer && connection}
inactiveOnPress={() => { inactiveOnPress={() => {
setShowLog(!isRegistered), setShowLog(!isRegistered),
setShowLogPluv(!pluviometer && isRegistered); setShowLogPluv(!pluviometer && isRegistered);
@ -106,7 +110,7 @@ function SharingDataScreen({ navigation }) {
navigation.navigate("RiverFloodData", { user: currentUser }) navigation.navigate("RiverFloodData", { user: currentUser })
} }
SvgImage={assets.riverLevel.RiverIcon} SvgImage={assets.riverLevel.RiverIcon}
active={isRegistered}
active={isRegistered && connection}
inactiveOnPress={() => setShowLog(true)} inactiveOnPress={() => setShowLog(true)}
/> />
</View> </View>

Loading…
Cancel
Save