diff --git a/components/Dashboard/DashboardScreen.js b/components/Dashboard/DashboardScreen.js index 97fe2a9..9bb3a50 100644 --- a/components/Dashboard/DashboardScreen.js +++ b/components/Dashboard/DashboardScreen.js @@ -1,132 +1,62 @@ import React from 'react'; import { Icon, Layout, Text, Button, Card, CardHeader, BottomNavigation, BottomNavigationTab } from '@ui-kitten/components'; import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'; - import { View, SafeAreaView, ScrollView } from 'react-native'; - import QRCode from 'react-native-qrcode-svg'; -import moment from "moment"; +import { DashboardTimeline } from './DashboardTimeline'; const Footer = createBottomTabNavigator(); export const DashboardContent = () => ( }> - - - + + + ); -const DashboardNavbar = ({navigation, state}) => { +const DashboardNavbar = ({ navigation, state }) => { const onSelect = (index) => { navigation.navigate(state.routeNames[index]); }; return ( - } /> - } /> - } /> + } /> + } /> + } /> ); }; -const DashboardTimeline = () => ( - - - } status='success'> - Tested for the virus, results are negative. - - - Tested: - Results: - - - March 12, 2020 - March 14, 2020 - - - - "Exam came back negative. It did include a warning that it might not - detect small quantities of virus if you’re asymptomatic (which is my - case). I might have been lucky, or maybe I already got it a long time - ago (I had a strong flu after EthDenver and SF Blockchain week)." - - - } status='warning'> - Self-isolated and requested testing for the virus. - - "Just tested myself for Sars-Cov-19 virus. Had mild flu symptoms but - since I’ve been in close contact with people who tested positive it - was the right thing to do. I could’ve done for free on the clinic in - Brazil but decided to get home tested for $50." - - - } status='warning'> - Attended event with 8 confirmed virus carriers. - - - Event: - Date: - Place: - - - EthCC 3 - March 3-5, 2020 - Maison de la Mutualité, Paris, France - - - - } status='danger'> - Tested for the virus, results are positive. - - - Tested: - Results: - - - March 11, 2020 - March 11, 2020 - - - - "I fell ill yesterday and have just been diagnosed with #COVID2019. - Everybody who had close contact @EthCC or @ETHLondonwith me should - take extra precautions and/or get tested" - - - - -) - const DashboardContacts = () => ( - - - + + + - } status='danger' titleStyle={{}}> - + } status='danger' titleStyle={{}}> + Contacts in this list self-reported positive virus infection. Avoid them until relevant authorities give the green light for them to rejoin society. {/* No contacts are reporting infection currently. */} - - - Zhen Yu Yong: + + + Zhen Yu Yong: March 11, 2020 - } status='warning'> - + } status='warning'> + Contacts in this list either self-reported potential virus infection, or they have been flagged automatically for participating in an event with a confirmed positive carrier. Request them to self-isolate for two @@ -135,11 +65,11 @@ const DashboardContacts = () => ( {/* No contacts are reporting suspicion currently. */} - - - Guillaume Ballet: + + + Guillaume Ballet: - + Suspicion: Expiry: @@ -149,16 +79,16 @@ const DashboardContacts = () => ( - } status='info'> - + } status='info'> + Contacts in this list *seem* to not be current carriers of the virus based on the data they self-reported. They may still be unaware, or unwilling to self report. Avoid people who you do not trust to thruthfully share their status. - - - Alex Van De Sande: + + + Alex Van De Sande: Negative at March 14, 2020 @@ -167,46 +97,46 @@ const DashboardContacts = () => ( -) +); const DashboardEvents = () => ( - - - + + + - + - } status='info'> - + } status='info'> + Maintained by Péter Szilágyi. Last sync 2 hours ago. - - + + 2 participants did not report - - + + Event open until March 30, 2020. Participants can join via: - + - } status='danger'> - + } status='danger'> + Maintained by Piper Merriam. Last sync 1 hour ago. - - + + 2 4 2 @@ -219,17 +149,17 @@ const DashboardEvents = () => ( participants did not report - + Event ended March 8, 2020; cannot be joined any more. This entry will be automatically deleted on April 8, 2020. - } status='danger' titleStyle={{}}> - + } status='danger' titleStyle={{}}> + Maintained by John Doe. Last sync 3 days ago. - - + + 9 7 4 @@ -242,7 +172,7 @@ const DashboardEvents = () => ( participants did not report - + Event ended March 5, 2020; cannot be joined any more. Will be auto-deleted on April 5, 2020. diff --git a/components/Dashboard/DashboardTimeline.js b/components/Dashboard/DashboardTimeline.js new file mode 100644 index 0000000..56e0941 --- /dev/null +++ b/components/Dashboard/DashboardTimeline.js @@ -0,0 +1,77 @@ +import React from 'react'; +import { ScrollView } from 'react-native'; +import { Layout, Text, Card, CardHeader } from '@ui-kitten/components'; + +import moment from "moment"; +import { loadProfile } from '../hooks'; +export const DashboardTimeline = () => { + const [profile, loading] = loadProfile(); + return ( + + + } status='success'> + Tested for the virus, results are negative. + + + Tested: + Results: + + + March 12, 2020 + March 14, 2020 + + + + "Exam came back negative. It did include a warning that it might not + detect small quantities of virus if you’re asymptomatic (which is my + case). I might have been lucky, or maybe I already got it a long time + ago (I had a strong flu after EthDenver and SF Blockchain week)." + + + {/* Example cards */} + } status='warning'> + Self-isolated and requested testing for the virus. + + "Just tested myself for Sars-Cov-19 virus. Had mild flu symptoms but + since I’ve been in close contact with people who tested positive it + was the right thing to do. I could’ve done for free on the clinic in + Brazil but decided to get home tested for $50." + + + } status='warning'> + Attended event with 8 confirmed virus carriers. + + + Event: + Date: + Place: + + + EthCC 3 + March 3-5, 2020 + Maison de la Mutualité, Paris, France + + + + } status='danger'> + Tested for the virus, results are positive. + + + Tested: + Results: + + + March 11, 2020 + March 11, 2020 + + + + "I fell ill yesterday and have just been diagnosed with #COVID2019. + Everybody who had close contact @EthCC or @ETHLondonwith me should + take extra precautions and/or get tested" + + + + + ); + }; \ No newline at end of file diff --git a/components/Dashboard/index.js b/components/Dashboard/index.js index f47073c..24080e8 100644 --- a/components/Dashboard/index.js +++ b/components/Dashboard/index.js @@ -3,17 +3,19 @@ import { useTheme } from '@ui-kitten/components'; import { createStackNavigator } from '@react-navigation/stack'; import { DashboardContent } from './DashboardScreen'; +import { loadProfile } from '../hooks'; const Header = createStackNavigator(); export const DashboardScreen = () => { - const theme = useTheme(); + const theme = useTheme(); + const [profile, loading] = loadProfile(); - return ( - - - - ); + return ( + + + + ); }; diff --git a/components/SignupScreen.js b/components/SignupScreen.js index 0700b1c..d21a4b9 100644 --- a/components/SignupScreen.js +++ b/components/SignupScreen.js @@ -4,21 +4,54 @@ import { Dimensions, View, Image, ScrollView } from 'react-native'; export const SignupScreen = ({ navigation }) => { const navigateDash = () => { - navigation.navigate('Dashboard'); + console.log("Creating profile"); + + // TODO + // Create new user profile and navigate to dashboard + fetch('https://corona-network/profile', { method: 'POST' }) + .then(resp => { + console.log(resp); + if(resp.status === 200) { + return true; + } else { + throw Error(resp.status); + } + }) + // .then(resp => console.log(resp)) + .then(resp => { + console.log(resp); + if(resp) { + const profileInfo = { + name: fName + } + console.log(profileInfo); + + fetch('https://corona-network/profile', { method: 'PUT', body: JSON.stringify(profileInfo) }) + .then(resp => { + if(resp.status === 200) { + console.log("Profile created successfully. Navigate to dash"); + navigation.navigate('Dashboard'); + } + }) + } + }) + .catch(e => console.error(e)); }; const [checked, setChecked] = useState(false); + const [fName, setFName] = useState(''); + const [lName, setLName] = useState(''); const onCheckedChange = (isChecked) => { setChecked(isChecked); }; return ( - + @@ -33,25 +66,25 @@ export const SignupScreen = ({ navigation }) => { To avoid wasting developer time on niceties, for the forseeable future, you will not be able to change your name once registered. - - - + + + - - + + - + - + ); }; diff --git a/components/WelcomeScreen.js b/components/WelcomeScreen.js index 98ce7bc..dc07ed0 100644 --- a/components/WelcomeScreen.js +++ b/components/WelcomeScreen.js @@ -1,36 +1,57 @@ import React from 'react'; import { Layout, Text, Button } from '@ui-kitten/components'; import { Dimensions, View, Image } from 'react-native'; +import { loadProfile } from './hooks'; export const WelcomeScreen = ({ navigation }) => { + const [profile, loading, setProfile] = loadProfile(); const navigateSignup = () => { navigation.navigate('Signup'); }; + const navigateDash = () => { + navigation.navigate('Dashboard'); + }; + const deleteProfile = () => { + fetch('https://corona-network/profile', { method: 'DELETE' }); + setProfile({}); + }; return ( - - + + Corona Network - - The Corona Network is a mobile + + The Corona Network is a mobile app to aid in social distancing during the Coronavirus pandemic. It helps keeping an account of physical contacts and tracking suspected and confirmed infections within your friend circle. The goal is to act as an early warning system to self-isolate and to omit meeting potential carriers.{'\n'}{'\n'} - Your data is stored + Your data is stored exclusively on your mobile device and shared directly, end-to-end encrypted, with your approved contacts. No cloud, no server, no tracking. - + {loading && + Loading... + } + {!(Object.keys(profile).length > 0) && + + } + { + Object.keys(profile).length > 0 && + + + + + } - ) + ); }; diff --git a/components/hooks.js b/components/hooks.js new file mode 100644 index 0000000..20fc1f8 --- /dev/null +++ b/components/hooks.js @@ -0,0 +1,20 @@ +import { useState, useEffect } from "react"; + +function loadProfile() { + const url = 'https://corona-network/profile'; + const [data, setData] = useState({}); + const [loading, setLoading] = useState(true); + async function fetchUrl() { + const response = await fetch(url, { method: 'GET' }); + setLoading(false); + if(response.status === 200) { + const json = await response.json(); + setData(json); + } + } + useEffect(() => { + fetchUrl(); + }, []); + return [data, loading, setData]; +} +export { loadProfile }; \ No newline at end of file