mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-08 21:18:14 -05:00
* chore(INJI-195): upgrade react native version and dependencies * chore(INJI-195): upgrade expo version and dependencies * chore(INJI-195): modify associated files on version upgrade * chore(INJI-295): fixed react native flipper and patch packages * chore(INJI-195): fix for expo prebuild * chore(INJI-195): expo linked to android/ios projects * chore(INJI-195): update metro config * chore(INJI-195): fix ios build with mmkv storage patch * chore(INJI-195): gradle version modified * chore(INJI-195): fixed rn version 0.71.8 due to mmkv library issue * chore(INJI-195): removed files in android * chore(INJI-195): fix 0.71.8 for iOS project through pods with expo linking * chore(INJI-195): fix for custom fonts added through pods due to rn linkage * chore(INJI-195): fix for removing assets.car generated from pods * Modify Node version in pipeline (#806) * chore(INJI-195): fix for android splash screen not shown up * chore(INJI-195): upgraded to node 18 in pipeline * chore(INJI-195): add the pod install twice to remove duplicates via script workaround (#807) Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * INJI-195 Set the signing team for iOS (#810) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * Modify github runner to self hosted runner (#811) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build * chore(INJI-195): set the self hosted runner for ios build --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * Modify self hosted runner to github hosted runner (#813) * chore(INJI-195): add the pod install twice to remove duplicates via script workaround * chore(INJI-195): set the signing team for ios build * chore(INJI-195): set the self hosted runner for ios build * chore(INJI-195): modify the self hosted to github hosted runner --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> * chore(INJI-195): modify the self hosted to github hosted runner * chore(INJI-195): set the code signing identity for ios build * chore(INJI-195): assigned app icon files to asset --------- Signed-off-by: dhivya0413 <120356578+dhivya0413@users.noreply.github.com> Signed-off-by: Swati Goel <meet2swati@gmail.com> Co-authored-by: Swati Goel <meet2swati@gmail.com>
165 lines
4.6 KiB
TypeScript
165 lines
4.6 KiB
TypeScript
import React, {useEffect, useState} from 'react';
|
|
import {TFunction, useTranslation} from 'react-i18next';
|
|
import QRCode from 'react-native-qrcode-svg';
|
|
|
|
import {Centered, Button, Column, Text} from '../../components/ui';
|
|
import {Theme} from '../../components/ui/styleUtils';
|
|
import {useRequestScreen} from './RequestScreenController';
|
|
import BluetoothStateManager from 'react-native-bluetooth-state-manager';
|
|
import {Platform} from 'react-native';
|
|
import Storage from '../../shared/storage';
|
|
import {ErrorMessageOverlay} from '../../components/MessageOverlay';
|
|
import {
|
|
NavigationProp,
|
|
useFocusEffect,
|
|
useNavigation,
|
|
} from '@react-navigation/native';
|
|
import {MainBottomTabParamList} from '../../routes/main';
|
|
import {BOTTOM_TAB_ROUTES} from '../../routes/routesConstants';
|
|
|
|
type RequestStackParamList = {
|
|
RequestScreen: undefined;
|
|
ReceiveVcScreen: undefined;
|
|
};
|
|
|
|
type RequestLayoutNavigation = NavigationProp<
|
|
RequestStackParamList & MainBottomTabParamList
|
|
>;
|
|
|
|
export const RequestScreen: React.FC = () => {
|
|
const {t} = useTranslation('RequestScreen');
|
|
const controller = useRequestScreen();
|
|
const props: RequestScreenProps = {t, controller};
|
|
const [isBluetoothOn, setIsBluetoothOn] = useState(false);
|
|
const navigation = useNavigation<RequestLayoutNavigation>();
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
await BluetoothStateManager.onStateChange(state => {
|
|
if (state === 'PoweredOff') {
|
|
setIsBluetoothOn(false);
|
|
} else {
|
|
setIsBluetoothOn(true);
|
|
}
|
|
}, true);
|
|
})();
|
|
}, [isBluetoothOn]);
|
|
|
|
return (
|
|
<Column
|
|
fill
|
|
padding="24"
|
|
align="space-between"
|
|
backgroundColor={Theme.Colors.lightGreyBackgroundColor}>
|
|
{loadQRCode()}
|
|
{controller.isMinimumStorageLimitReached && (
|
|
<ErrorMessageOverlay
|
|
isVisible={controller.isMinimumStorageLimitReached}
|
|
error="errors.storageLimitReached"
|
|
onDismiss={() => {
|
|
navigation.navigate(BOTTOM_TAB_ROUTES.home);
|
|
}}
|
|
translationPath="RequestScreen"
|
|
/>
|
|
)}
|
|
</Column>
|
|
);
|
|
|
|
function loadQRCode() {
|
|
if (controller.isNearByDevicesPermissionDenied) {
|
|
return <NearByPrompt {...props} />;
|
|
}
|
|
if (
|
|
(controller.isBluetoothDenied || !isBluetoothOn) &&
|
|
controller.isReadyForBluetoothStateCheck
|
|
) {
|
|
return <BluetoothPrompt {...props} />;
|
|
}
|
|
if (
|
|
!controller.isCheckingBluetoothService &&
|
|
!controller.isBluetoothDenied
|
|
) {
|
|
return (
|
|
<Column align="flex-end" fill>
|
|
{controller.isWaitingForConnection && <SharingQR {...props} />}
|
|
<StatusMessage {...props} />
|
|
</Column>
|
|
);
|
|
}
|
|
}
|
|
};
|
|
|
|
const BluetoothPrompt: React.FC<RequestScreenProps> = ({t}) => {
|
|
return (
|
|
<Centered fill>
|
|
<Text color={Theme.Colors.errorMessage} align="center" margin="0 10">
|
|
{t(
|
|
Platform.OS === 'ios' ? 'bluetoothStateIos' : 'bluetoothStateAndroid',
|
|
)}
|
|
</Text>
|
|
</Centered>
|
|
);
|
|
};
|
|
|
|
const NearByPrompt: React.FC<RequestScreenProps> = ({t, controller}) => {
|
|
return (
|
|
<Column fill align="space-between">
|
|
<Centered fill>
|
|
<Text color={Theme.Colors.errorMessage} align="center">
|
|
{t('errors.nearbyDevicesPermissionDenied.message')}
|
|
</Text>
|
|
</Centered>
|
|
<Button
|
|
title={t('errors.nearbyDevicesPermissionDenied.button')}
|
|
onPress={controller.GOTO_SETTINGS}
|
|
/>
|
|
</Column>
|
|
);
|
|
};
|
|
|
|
const SharingQR: React.FC<RequestScreenProps> = ({t, controller}) => {
|
|
return (
|
|
<React.Fragment>
|
|
<Text align="center">{t('showQrCode')}</Text>
|
|
|
|
<Centered fill>
|
|
{controller.openId4VpUri !== '' ? (
|
|
<QRCode
|
|
size={200}
|
|
value={controller.openId4VpUri}
|
|
backgroundColor={Theme.Colors.QRCodeBackgroundColor}
|
|
/>
|
|
) : null}
|
|
</Centered>
|
|
</React.Fragment>
|
|
);
|
|
};
|
|
|
|
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'})}
|
|
loading={controller.isCancelling}
|
|
onPress={controller.CANCEL}
|
|
/>
|
|
)}
|
|
</Column>
|
|
)
|
|
);
|
|
};
|
|
|
|
interface RequestScreenProps {
|
|
t: TFunction;
|
|
controller: ReturnType<typeof useRequestScreen>;
|
|
}
|