Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Commit

Permalink
Add the proximity exposure screen to the exposure history flow (#1558)
Browse files Browse the repository at this point in the history
* created an enum for ExposureType

* renamed ExposureView -> ProximityExposureView, linked this to the exposure history page

* rm back button from expousure history screen at phils suggestion, change close route to be Menu for consistency w/ data sharing screens
  • Loading branch information
smcmurtry authored May 3, 2021
1 parent ab242fb commit fbed613
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 23 deletions.
7 changes: 3 additions & 4 deletions src/navigation/MainNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import {QRCodeIntroScreen} from 'screens/qr/QRCodeIntroScreen';
import {MenuScreen} from 'screens/menu/MenuScreen';
import {ClearOutbreakExposureScreen} from 'screens/home/views/ClearOutbreakExposureView';
import {RecentExposureScreen} from 'screens/exposureHistory/RecentExposureView';

import {FormContext, FormContextDefaults} from '../shared/FormContext';
import {FormContext, FormContextDefaults} from 'shared/FormContext';
import {ExposureType} from 'shared/qr';

const MainStack = createStackNavigator<MainStackParamList>();

Expand Down Expand Up @@ -80,8 +80,7 @@ export interface MainStackParamList extends Record<string, object | undefined> {
Tutorial: undefined;
QROnboard: undefined;
RegionSelectExposedNoPT: {drawerMenu: boolean} | undefined;
// @todo add proper type for exposureType i.e. outbreak or proximity
RecentExposureScreen: {id: string; exposureType: string};
RecentExposureScreen: {id: string; exposureType: ExposureType};
}
const LandingScreenWithNavBar = withDarkNav(LandingScreen);
const HomeScreenWithNavBar = withDarkNav(HomeScreen);
Expand Down
16 changes: 11 additions & 5 deletions src/screens/exposureHistory/ExposureHistoryScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import React, {useCallback} from 'react';
import {StyleSheet, Alert} from 'react-native';
import {useI18n, I18n} from 'locale';
import {CombinedExposureHistoryData, getCurrentOutbreakHistory, OutbreakHistoryItem, OutbreakSeverity} from 'shared/qr';
import {
CombinedExposureHistoryData,
ExposureType,
getCurrentOutbreakHistory,
OutbreakHistoryItem,
OutbreakSeverity,
} from 'shared/qr';
import {useNavigation} from '@react-navigation/native';
import {Box, Text, ToolbarWithClose, Button} from 'components';
import {SafeAreaView} from 'react-native-safe-area-context';
Expand Down Expand Up @@ -33,7 +39,7 @@ const toOutbreakExposureHistoryData = ({
return history.map(outbreak => {
return {
id: outbreak.locationId,
type: 'exposure',
type: ExposureType.Outbreak,
subtitle: severityText({severity: Number(outbreak.severity), i18n}),
timestamp: outbreak.checkInTimestamp,
};
Expand All @@ -50,7 +56,7 @@ const toProximityExposureHistoryData = ({
return history.map(outbreak => {
return {
id: outbreak,
type: 'proximity',
type: ExposureType.Proximity,
subtitle: i18n.translate('QRCode.ProximityExposure'),
timestamp: outbreak,
};
Expand All @@ -72,7 +78,7 @@ export const ExposureHistoryScreen = () => {
}, [clearExposedStatus]);

const navigation = useNavigation();
const close = useCallback(() => navigation.navigate('Home'), [navigation]);
const close = useCallback(() => navigation.navigate('Menu'), [navigation]);

const deleteAllPlaces = () => {
Alert.alert(i18n.translate('PlacesLog.Alert.TitleDeleteAll'), i18n.translate('PlacesLog.Alert.Subtitle'), [
Expand All @@ -94,7 +100,7 @@ export const ExposureHistoryScreen = () => {
return (
<Box flex={1} backgroundColor="overlayBackground">
<SafeAreaView style={styles.flex}>
<ToolbarWithClose closeText={i18n.translate('DataUpload.Close')} showBackButton onClose={close} />
<ToolbarWithClose closeText={i18n.translate('DataUpload.Close')} showBackButton={false} onClose={close} />
<ScrollView style={styles.flex}>
<Box paddingHorizontal="m" paddingBottom="m">
<Text variant="bodyTitle" marginBottom="l" accessibilityRole="header" accessibilityAutoFocus>
Expand Down
18 changes: 12 additions & 6 deletions src/screens/exposureHistory/RecentExposureView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,34 @@ import {useNavigation, useRoute, RouteProp} from '@react-navigation/native';
import {SafeAreaView} from 'react-native-safe-area-context';
import {ScrollView} from 'react-native-gesture-handler';
import {StyleSheet} from 'react-native';
import {ExposureType} from 'shared/qr';
import {OutbreakExposedView} from 'screens/home/views/OutbreakExposedView';
import {ProximityExposureView} from 'screens/home/views/ProximityExposureView';

import {OutbreakExposedView} from '../home/views/OutbreakExposedView';
import {MainStackParamList} from '../../navigation/MainNavigator';

type RecentExposureScreenProps = RouteProp<MainStackParamList, 'RecentExposureScreen'>;

const ExposureView = () => {
const route = useRoute<RecentExposureScreenProps>();
// @todo add proper type checking here -> exposureType
if (route.params?.id && route.params?.exposureType === 'exposure') {
const id = route.params.id;
if (!route.params?.id || !route.params?.exposureType) {
return null;
}
const id = route.params.id;
if (route.params.exposureType === ExposureType.Outbreak) {
return <OutbreakExposedView id={id} />;
}
// @todo return proximity Exposure
if (route.params.exposureType === ExposureType.Proximity) {
return <ProximityExposureView />;
}
return null;
};

export const RecentExposureScreen = () => {
const i18n = useI18n();

const navigation = useNavigation();
const close = useCallback(() => navigation.navigate('Home'), [navigation]);
const close = useCallback(() => navigation.navigate('Menu'), [navigation]);
return (
<SafeAreaView style={styles.flex}>
<ToolbarWithClose closeText={i18n.translate('DataUpload.Close')} showBackButton onClose={close} />
Expand Down
7 changes: 5 additions & 2 deletions src/screens/exposureHistory/views/ExposureList.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {useCallback} from 'react';
import {StyleSheet, TouchableOpacity} from 'react-native';
import {useI18n} from 'locale';
import {CombinedExposureHistoryData} from 'shared/qr';
import {CombinedExposureHistoryData, ExposureType} from 'shared/qr';
import {useNavigation} from '@react-navigation/native';
import {Box, Text, Icon} from 'components';
import {formatExposedDate} from 'shared/date-fns';
Expand Down Expand Up @@ -33,7 +33,10 @@ export const ExposureList = ({exposureHistoryData}: {exposureHistoryData: Combin
>
<Box paddingVertical="m" style={styles.exposureList}>
<Box style={styles.typeIconBox}>
<Icon size={20} name={item.type === 'proximity' ? 'exposure-proximity' : 'exposure-outbreak'} />
<Icon
size={20}
name={item.type === ExposureType.Proximity ? 'exposure-proximity' : 'exposure-outbreak'}
/>
</Box>
<Box style={styles.boxFlex}>
<Text fontWeight="bold">{formatExposedDate(new Date(item.timestamp), dateLocale)}</Text>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/home/HomeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {DiagnosedView} from './views/DiagnosedView';
import {DiagnosedShareUploadView} from './views/DiagnosedShareUploadView';
import {ExposureNotificationsDisabledView} from './views/ExposureNotificationsDisabledView';
import {ExposureNotificationsUnauthorizedView} from './views/ExposureNotificationsUnauthorizedView';
import {ExposureView} from './views/ExposureView';
import {ProximityExposureView} from './views/ProximityExposureView';
import {NoExposureUncoveredRegionView} from './views/NoExposureUncoveredRegionView';
import {NoExposureCoveredRegionView} from './views/NoExposureCoveredRegionView';
import {NoExposureNoRegionView} from './views/NoExposureNoRegionView';
Expand Down Expand Up @@ -79,7 +79,7 @@ const Content = () => {
case ForceScreen.NoExposureView:
return getNoExposureView(regionCase);
case ForceScreen.ExposureView:
return <ExposureView />;
return <ProximityExposureView />;
case ForceScreen.DiagnosedShareView:
return <DiagnosedShareView />;
case ForceScreen.DiagnosedView:
Expand Down Expand Up @@ -125,7 +125,7 @@ const Content = () => {

switch (exposureStatus.type) {
case ExposureStatusType.Exposed:
return <ExposureView />;
return <ProximityExposureView />;
case ExposureStatusType.Diagnosed:
if (!network.isConnected) {
return <NetworkDisabledView />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const ExposureText = () => {
);
};

export const ExposureView = () => {
export const ProximityExposureView = () => {
return (
<BaseHomeView iconName="hand-caution" testID="exposure">
<ExposureText />
Expand Down
8 changes: 6 additions & 2 deletions src/shared/qr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ export enum OutbreakSeverity {
GetTested = 3,
}

export enum ExposureType {
Proximity = 'proximity',
Outbreak = 'outbreak',
}

export interface CheckInData {
id: string;
name: string;
Expand Down Expand Up @@ -58,8 +63,7 @@ export interface OutbreakHistoryItem {
export interface CombinedExposureHistoryData {
id?: string | number;
timestamp: number;
// proximity or outbreak
type: string;
type: ExposureType;
subtitle: string;
}

Expand Down

0 comments on commit fbed613

Please sign in to comment.