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

Fixes for Bluetooth enable / EN enable flow #100

Merged
merged 2 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/components/InfoBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface InfoBlockProps {
text: string;
action: () => void;
};
showButton?: boolean;
}

export const InfoBlock = ({
Expand All @@ -27,6 +28,7 @@ export const InfoBlock = ({
backgroundColor,
title,
titleBolded,
showButton,
}: InfoBlockProps) => {
return (
<Box borderRadius={10} backgroundColor={backgroundColor} padding="m" alignItems="flex-start">
Expand Down Expand Up @@ -58,9 +60,15 @@ export const InfoBlock = ({
<Text variant="bodyText" fontSize={16} color={color} marginBottom="m">
{text}
</Text>
<Box marginHorizontal="none" alignSelf="stretch">
<Button text={buttonText} onPress={action} variant="bigFlat" color={color} />
</Box>
{showButton ? (
<Box marginHorizontal="none" alignSelf="stretch">
<Button text={buttonText} onPress={action} variant="bigFlat" color={color} />
</Box>
) : null}
</Box>
);
};

InfoBlock.defaultProps = {
showButton: true,
};
4 changes: 2 additions & 2 deletions src/screens/home/views/BluetoothDisabledView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ export const BluetoothDisabledView = () => {
<Box marginBottom="l">
<Icon name="icon-bluetooth-disabled" size={44} />
</Box>
<Text textAlign="center" variant="bodyTitle" color="bodyText" marginBottom="l" accessibilityRole="header">
<Text variant="bodyTitle" color="bodyText" marginBottom="l" accessibilityRole="header">
{i18n.translate('Home.BluetoothDisabled')}
</Text>
<Text variant="bodyText" color="bodyText" textAlign="center">
<Text variant="bodyText" color="bodyText" marginBottom="l">
{i18n.translate('Home.EnableBluetoothCTA')}
</Text>
</BaseHomeView>
Expand Down
22 changes: 10 additions & 12 deletions src/screens/home/views/OverlayView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,30 @@ import React, {useCallback} from 'react';
import {useNavigation} from '@react-navigation/native';
import {Box, InfoBlock, BoxProps} from 'components';
import {useI18n, I18n} from '@shopify/react-i18n';
import {SystemStatus, useStartExposureNotificationService} from 'services/ExposureNotificationService';
import {SystemStatus} from 'services/ExposureNotificationService';
import {Linking} from 'react-native';

import {InfoShareView} from './InfoShareView';
import {StatusHeaderView} from './StatusHeaderView';

const SystemStatusOff = ({i18n}: {i18n: I18n}) => {
const startExposureNotificationService = useStartExposureNotificationService();

const enableExposureNotifications = useCallback(() => {
startExposureNotificationService();
}, [startExposureNotificationService]);
const toSettings = useCallback(() => {
Linking.openSettings();
}, []);

return (
<InfoBlock
icon="icon-exposure-notifications-off"
title={i18n.translate('OverlayOpen.ExposureNotificationCardStatus')}
titleBolded={i18n.translate('OverlayOpen.ExposureNotificationCardStatusOff')}
text={i18n.translate('OverlayOpen.ExposureNotificationCardBody')}
button={{text: i18n.translate('OverlayOpen.ExposureNotificationCardAction'), action: enableExposureNotifications}}
button={{text: i18n.translate('OverlayOpen.ExposureNotificationCardAction'), action: toSettings}}
backgroundColor="errorBackground"
color="errorText"
/>
);
};

/*
const BluetoothStatusOff = ({i18n}: {i18n: I18n}) => {
const toSettings = useCallback(() => {
Linking.openSettings();
Expand All @@ -41,10 +39,10 @@ const BluetoothStatusOff = ({i18n}: {i18n: I18n}) => {
button={{text: i18n.translate('OverlayOpen.BluetoothCardAction'), action: toSettings}}
backgroundColor="errorBackground"
color="errorText"
showButton={false}
/>
);
};
*/

const NotificationStatusOff = ({action, i18n}: {action: () => void; i18n: I18n}) => {
return (
Expand Down Expand Up @@ -75,16 +73,16 @@ export const OverlayView = ({status, notificationWarning, turnNotificationsOn, m
<Box marginBottom="l">
<StatusHeaderView enabled={status === SystemStatus.Active} />
</Box>
{status !== SystemStatus.Active && (
{(status === SystemStatus.Disabled || status === SystemStatus.Restricted) && (
<Box marginBottom="m" marginHorizontal="m">
<SystemStatusOff i18n={i18n} />
</Box>
)}
{/* {status !== SystemStatus.Active && (
{status === SystemStatus.BluetoothOff && (
<Box marginBottom="m" marginHorizontal="m">
<BluetoothStatusOff i18n={i18n} />
</Box>
)}*/}
)}
{notificationWarning && (
<Box marginBottom="m" marginHorizontal="m">
<NotificationStatusOff action={turnNotificationsOn} i18n={i18n} />
Expand Down