Merge remote-tracking branch 'idpass/develop' into develop-idpass-sync

This commit is contained in:
pmigueld
2022-10-17 17:39:17 +08:00
91 changed files with 3017 additions and 941 deletions

View File

@@ -3,7 +3,7 @@ import QRCode from 'react-native-qrcode-svg';
import { Centered, Button, Row, Column, Text } from '../../components/ui';
import { Theme } from '../../components/ui/styleUtils';
import { useRequestScreen } from './RequestScreenController';
import { useTranslation } from 'react-i18next';
import { TFunction, useTranslation } from 'react-i18next';
import { Switch } from 'react-native-elements';
import { Platform } from 'react-native';
@@ -16,24 +16,66 @@ export const RequestScreen: React.FC = () => {
fill
padding="24"
backgroundColor={Theme.Colors.lightGreyBackgroundColor}>
<Column>
{controller.isBluetoothDenied ? (
<React.Fragment>
<Text color={Theme.Colors.errorMessage} align="center">
{t('bluetoothDenied', { vcLabel: controller.vcLabel.singular })}
</Text>
<Button
margin={[32, 0, 0, 0]}
title={t('gotoSettings')}
onPress={controller.GOTO_SETTINGS}
/>
</React.Fragment>
) : (
<Text align="center">
{t('showQrCode', { vcLabel: controller.vcLabel.singular })}
{controller.isBluetoothDenied && (
<BluetoothPrompt t={t} controller={controller} />
)}
{!controller.isCheckingBluetoothService &&
!controller.isBluetoothDenied ? (
<Column align="flex-end" fill>
{controller.isWaitingForConnection && (
<SharingCode t={t} controller={controller} />
)}
<StatusMessage t={t} controller={controller} />
</Column>
) : null}
</Column>
);
};
const BluetoothPrompt: React.FC<RequestScreenProps> = ({ t, controller }) => {
return (
<Centered fill>
<Text color={Theme.Colors.errorMessage} align="center">
{t('bluetoothDenied', { vcLabel: controller.vcLabel.singular })}
</Text>
<Button
margin={[32, 0, 0, 0]}
title={t('gotoSettings')}
onPress={controller.GOTO_SETTINGS}
/>
</Centered>
);
};
const StatusMessage: React.FC<RequestScreenProps> = ({ t, controller }) => {
return (
controller.statusMessage !== '' && (
<Column elevation={1} padding="16 24">
<Text>{controller.statusMessage}</Text>
{controller.statusHint !== '' && (
<Text size="small" color={Theme.Colors.textLabel}>
{controller.statusHint}
</Text>
)}
{controller.isStatusCancellable && (
<Button
margin={[8, 0, 0, 0]}
title={t('cancel', { ns: 'common' })}
onPress={controller.CANCEL}
/>
)}
</Column>
)
);
};
const SharingCode: React.FC<RequestScreenProps> = ({ t, controller }) => {
return (
<React.Fragment>
<Text align="center">
{t('showQrCode', { vcLabel: controller.vcLabel.singular })}
</Text>
<Centered fill>
{controller.connectionParams !== '' ? (
@@ -54,12 +96,11 @@ export const RequestScreen: React.FC = () => {
/>
<Text margin={[0, 0, 0, 16]}>Online</Text>
</Row>
{controller.statusMessage !== '' && (
<Column elevation={1} padding="16 24">
<Text>{controller.statusMessage}</Text>
</Column>
)}
</Column>
</React.Fragment>
);
};
interface RequestScreenProps {
t: TFunction;
controller: ReturnType<typeof useRequestScreen>;
}