mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 21:48:04 -05:00
* [INJIMOB-2381] update package.json and resolve dependencies for react 0.73.0 Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-2381] setup for 0.73.6 Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-2381] fix font & image not loading issue changes include - move common image assets to android & iOS folders - update gradle version to 8.2 - add expo-font asset for Inter regular - replace useFont with expo-font - remove flipper (reason: 0.74 react native decoupled flipper) - npm package updates - close icon changed to close text in QRScanner.tsx Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> * [INJIMOB-2381] update android:mosip script as per updated react native version Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix android build failure issue Changes include: - rename android assets folder as per convention - remove unused biometrics dependency - use env from react-native-dotenv as per module registered in babel config - revert conversion of close icon to image in QRScanner component Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix iOS build issue Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] rm unused local images linking in adnroid Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix splash screen not rendering issue in android Issue: Local assets were not loaded via React Native Image component in android, to fix this @react-native/assets-registry has been added Reference: https://github.com/expo/expo/issues/31240#issuecomment-2459049911 Other changes: - remove usage of expo-image as we dont have any explicit usecase for expo-image and its unused Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] rm unused intro slider image assets Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] revert back using local font assets in android Reason: Previously expo-font was used for fonts, to bring back the same compatiblity it is bought back Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] use GestureHandlerRootView in root level to handle gestures ref - https://docs.swmansion.com/react-native-gesture-handler/docs/1.x/#js Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove custom assets and linking for images in iOS Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] use default parameters instead of defaultProps Reason: React 18 has marked defaultProps as deprecated and it is removed in React 19 version. To avoid the issue of deprated usage, its modified. Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove unused terminal option in android build script Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove font assets in android Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] optimize import Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix failing test Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] set package.resolved version to 2 Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix setting of camera view in face scanner Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix setting of camera view in face compare Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove flipper config file Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove unused debug logs Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] refactor use component instead of type Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] refactor use GestureHandlerRootView only on root level Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] refactor remove unused config linking of font assets Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] refactor remove unused image assets Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] fix camera persmission issue in QRScanner use expo-camera to request and getstatus of camera permission instead of expo-barcode-scanner to avoid multiple re-renders of scan screen in flow of camera permission denial Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove package expo-barcode-scanner expo-barcode-scanner is deprecated and its suggested to use expo-camera to handle the scanning flows. The existing bar-code-scanner implementations have been replaced with expo-camera. Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] use extracted enums instead of legacy expo-camera Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove patch for react-native-0.71.8 Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] revert date-fs version to 2.28.0 date-fns is not supporting filipino langauge, so we are maintaining patch for that. The patch created is for version 2.28.0 and updating the version of date-fns is causing conflicts in patch application if updated as well. To avoid this issue, version is kept as 2.28.0 Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] update readme Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] remove usage of legacy expo-camera in getting image type Other changes - remove resolutions block from package.json - sync pbxproj Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> * [INJIMOB-2381] add active prop to expo-camera as per suggestions expo-camera suggests "Only one Camera preview can be active at any given time. If you have multiple screens in your app, you should unmount Camera components whenever a screen is unfocused.". To handle this active prop is used which is set to false on unMount of the component whenever rendering Camera from expo-camera Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> --------- Signed-off-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> Signed-off-by: KiruthikaJeyashankar <kiruthikavjshankar@gmail.com> Signed-off-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com> Co-authored-by: Abhishek Paul <paul.apaul.abhishek.ap@gmail.com> Co-authored-by: adityankannan-tw <109274996+adityankannan-tw@users.noreply.github.com>
321 lines
11 KiB
TypeScript
321 lines
11 KiB
TypeScript
import {useFocusEffect} from '@react-navigation/native';
|
|
import React, {useEffect, useLayoutEffect} from 'react';
|
|
import {useTranslation} from 'react-i18next';
|
|
import {BackHandler, I18nManager, View} from 'react-native';
|
|
import {Button, Column, Row, Text} from '../../components/ui';
|
|
import {Theme} from '../../components/ui/styleUtils';
|
|
import {VcItemContainer} from '../../components/VC/VcItemContainer';
|
|
import {LIVENESS_CHECK} from '../../shared/constants';
|
|
import {TelemetryConstants} from '../../shared/telemetry/TelemetryConstants';
|
|
import {
|
|
getImpressionEventData,
|
|
sendImpressionEvent,
|
|
} from '../../shared/telemetry/TelemetryUtils';
|
|
import {VCItemContainerFlowType} from '../../shared/Utils';
|
|
import {VCMetadata} from '../../shared/VCMetadata';
|
|
import {VerifyIdentityOverlay} from '../VerifyIdentityOverlay';
|
|
import {VPShareOverlay} from './VPShareOverlay';
|
|
import {FaceVerificationAlertOverlay} from './FaceVerificationAlertOverlay';
|
|
import {useSendVPScreen} from './SendVPScreenController';
|
|
import LinearGradient from 'react-native-linear-gradient';
|
|
import {Error} from '../../components/ui/Error';
|
|
import {SvgImage} from '../../components/ui/svg';
|
|
import {Loader} from '../../components/ui/Loader';
|
|
import {Icon} from 'react-native-elements';
|
|
import {ScanLayoutProps} from '../../routes/routeTypes';
|
|
|
|
export const SendVPScreen: React.FC<ScanLayoutProps> = props => {
|
|
const {t} = useTranslation('SendVPScreen');
|
|
const controller = useSendVPScreen();
|
|
|
|
const vcsMatchingAuthRequest = controller.vcsMatchingAuthRequest;
|
|
|
|
useEffect(() => {
|
|
sendImpressionEvent(
|
|
getImpressionEventData(
|
|
TelemetryConstants.FlowType.senderVcShare,
|
|
TelemetryConstants.Screens.vcList,
|
|
),
|
|
);
|
|
}, []);
|
|
|
|
useFocusEffect(
|
|
React.useCallback(() => {
|
|
const onBackPress = () => true;
|
|
|
|
const disableBackHandler = BackHandler.addEventListener(
|
|
'hardwareBackPress',
|
|
onBackPress,
|
|
);
|
|
|
|
return () => disableBackHandler.remove();
|
|
}, []),
|
|
);
|
|
|
|
useLayoutEffect(() => {
|
|
if (controller.showLoadingScreen) {
|
|
props.navigation.setOptions({
|
|
headerShown: false,
|
|
});
|
|
} else {
|
|
props.navigation.setOptions({
|
|
headerShown: true,
|
|
title: t('SendVPScreen:requester'),
|
|
headerTitleAlign: 'center',
|
|
headerTitle: props => (
|
|
<View style={Theme.Styles.sendVPHeaderContainer}>
|
|
<Text style={Theme.Styles.sendVPHeaderTitle}>{props.children}</Text>
|
|
{controller.vpVerifierName && (
|
|
<Text
|
|
numLines={1}
|
|
ellipsizeMode="tail"
|
|
style={Theme.Styles.sendVPHeaderSubTitle}>
|
|
{controller.vpVerifierName}
|
|
</Text>
|
|
)}
|
|
</View>
|
|
),
|
|
headerRight: () =>
|
|
!I18nManager.isRTL && (
|
|
<Icon
|
|
name="close"
|
|
color={Theme.Colors.blackIcon}
|
|
onPress={controller.DISMISS}
|
|
/>
|
|
),
|
|
headerLeft: () =>
|
|
I18nManager.isRTL && (
|
|
<Icon
|
|
name="close"
|
|
color={Theme.Colors.blackIcon}
|
|
onPress={controller.DISMISS}
|
|
/>
|
|
),
|
|
});
|
|
}
|
|
}, [controller.showLoadingScreen, controller.vpVerifierName]);
|
|
|
|
if (controller.showLoadingScreen) {
|
|
return (
|
|
<Loader
|
|
title={t('loaders.loading')}
|
|
subTitle={t(`loaders.subTitle.fetchingVerifiers`)}
|
|
/>
|
|
);
|
|
}
|
|
|
|
const handleTextButtonEvent = () => {
|
|
controller.GO_TO_HOME();
|
|
controller.RESET_RETRY_COUNT();
|
|
};
|
|
|
|
const getVcKey = vcData => {
|
|
return VCMetadata.fromVcMetadataString(vcData.vcMetadata).getVcKey();
|
|
};
|
|
|
|
const noOfCardsSelected = controller.areAllVCsChecked
|
|
? Object.values(controller.vcsMatchingAuthRequest).length
|
|
: Object.keys(controller.selectedVCKeys).length;
|
|
|
|
const cardsSelectedText =
|
|
noOfCardsSelected === 1
|
|
? noOfCardsSelected + ' ' + t('cardSelected')
|
|
: noOfCardsSelected + ' ' + t('cardsSelected');
|
|
|
|
const areAllVcsChecked =
|
|
noOfCardsSelected ===
|
|
Object.values(controller.vcsMatchingAuthRequest).flatMap(vc => vc).length;
|
|
|
|
return (
|
|
<React.Fragment>
|
|
{Object.keys(vcsMatchingAuthRequest).length > 0 && (
|
|
<>
|
|
{controller.purpose !== '' && (
|
|
<View style={{backgroundColor: Theme.Colors.whiteBackgroundColor}}>
|
|
<Column
|
|
padding="14 12 14 12"
|
|
margin="20 20 20 20"
|
|
style={Theme.VPSharingStyles.purposeContainer}>
|
|
<Text
|
|
color={Theme.Colors.TimeoutHintText}
|
|
style={Theme.VPSharingStyles.purposeText}>
|
|
{controller.purpose}
|
|
</Text>
|
|
</Column>
|
|
</View>
|
|
)}
|
|
<Column fill backgroundColor={Theme.Colors.lightGreyBackgroundColor}>
|
|
<LinearGradient colors={Theme.Colors.selectIDTextGradient}>
|
|
<Column>
|
|
<Text
|
|
margin="15 0 13 24"
|
|
color={Theme.Colors.textValue}
|
|
style={Theme.VPSharingStyles.selectIDText}>
|
|
{t('SendVcScreen:pleaseSelectAnId')}
|
|
</Text>
|
|
</Column>
|
|
</LinearGradient>
|
|
<Row
|
|
padding="11 24 11 24"
|
|
style={{
|
|
backgroundColor: '#FAFAFA',
|
|
justifyContent: 'space-between',
|
|
}}>
|
|
<Text style={Theme.VPSharingStyles.cardsSelectedText}>
|
|
{cardsSelectedText}
|
|
</Text>
|
|
<Text
|
|
style={{
|
|
color: Theme.Colors.Icon,
|
|
fontFamily: 'Inter_600SemiBold',
|
|
}}
|
|
onPress={
|
|
areAllVcsChecked
|
|
? controller.UNCHECK_ALL
|
|
: controller.CHECK_ALL
|
|
}>
|
|
{areAllVcsChecked ? t('unCheck') : t('checkAll')}
|
|
</Text>
|
|
</Row>
|
|
<Column scroll backgroundColor={Theme.Colors.whiteBackgroundColor}>
|
|
{Object.entries(vcsMatchingAuthRequest).map(
|
|
([inputDescriptorId, vcs]) =>
|
|
vcs.map(vcData => (
|
|
<VcItemContainer
|
|
key={getVcKey(vcData)}
|
|
vcMetadata={vcData.vcMetadata}
|
|
margin="0 2 8 2"
|
|
onPress={controller.SELECT_VC_ITEM(
|
|
getVcKey(vcData),
|
|
inputDescriptorId,
|
|
)}
|
|
selectable
|
|
selected={
|
|
controller.areAllVCsChecked ||
|
|
Object.keys(controller.selectedVCKeys).includes(
|
|
getVcKey(vcData),
|
|
)
|
|
}
|
|
flow={VCItemContainerFlowType.VP_SHARE}
|
|
isPinned={vcData.vcMetadata.isPinned}
|
|
/>
|
|
)),
|
|
)}
|
|
</Column>
|
|
<Column
|
|
style={[
|
|
Theme.SendVcScreenStyles.shareOptionButtonsContainer,
|
|
{position: 'relative'},
|
|
]}
|
|
backgroundColor={Theme.Colors.whiteBackgroundColor}>
|
|
{!controller.checkIfAllVCsHasImage(
|
|
controller.vcsMatchingAuthRequest,
|
|
) && (
|
|
<Button
|
|
type="gradient"
|
|
styles={{marginTop: 12}}
|
|
title={t('SendVcScreen:acceptRequest')}
|
|
disabled={
|
|
Object.keys(controller.getSelectedVCs()).length === 0 ||
|
|
controller.checkIfAnyVCHasImage(controller.getSelectedVCs())
|
|
}
|
|
onPress={controller.ACCEPT_REQUEST}
|
|
/>
|
|
)}
|
|
{controller.checkIfAnyVCHasImage(
|
|
controller.vcsMatchingAuthRequest,
|
|
) && (
|
|
<Button
|
|
type="gradient"
|
|
title={t('SendVcScreen:acceptRequestAndVerify')}
|
|
styles={{marginTop: 12}}
|
|
disabled={
|
|
Object.keys(controller.getSelectedVCs()).length === 0 ||
|
|
!controller.checkIfAnyVCHasImage(
|
|
controller.getSelectedVCs(),
|
|
)
|
|
}
|
|
onPress={controller.VERIFY_AND_ACCEPT_REQUEST}
|
|
/>
|
|
)}
|
|
|
|
<Button
|
|
type="clear"
|
|
loading={controller.isCancelling}
|
|
title={t('SendVcScreen:reject')}
|
|
onPress={controller.CANCEL}
|
|
/>
|
|
</Column>
|
|
</Column>
|
|
<VerifyIdentityOverlay
|
|
credential={controller.credentials}
|
|
verifiableCredentialData={controller.verifiableCredentialsData}
|
|
isVerifyingIdentity={controller.isVerifyingIdentity}
|
|
onCancel={controller.CANCEL}
|
|
onFaceValid={controller.FACE_VALID}
|
|
onFaceInvalid={controller.FACE_INVALID}
|
|
isInvalidIdentity={controller.isInvalidIdentity}
|
|
onNavigateHome={controller.GO_TO_HOME}
|
|
onRetryVerification={controller.RETRY_VERIFICATION}
|
|
isLivenessEnabled={LIVENESS_CHECK}
|
|
/>
|
|
|
|
{controller.overlayDetails !== null && (
|
|
<VPShareOverlay
|
|
isVisible={controller.overlayDetails !== null}
|
|
title={controller.overlayDetails.title}
|
|
titleTestID={controller.overlayDetails.titleTestID}
|
|
message={controller.overlayDetails.message}
|
|
messageTestID={controller.overlayDetails.messageTestID}
|
|
primaryButtonTestID={
|
|
controller.overlayDetails.primaryButtonTestID
|
|
}
|
|
primaryButtonText={controller.overlayDetails.primaryButtonText}
|
|
primaryButtonEvent={controller.overlayDetails.primaryButtonEvent}
|
|
secondaryButtonTestID={
|
|
controller.overlayDetails.secondaryButtonTestID
|
|
}
|
|
secondaryButtonText={
|
|
controller.overlayDetails.secondaryButtonText
|
|
}
|
|
secondaryButtonEvent={
|
|
controller.overlayDetails.secondaryButtonEvent
|
|
}
|
|
onCancel={controller.overlayDetails.onCancel}
|
|
/>
|
|
)}
|
|
|
|
<FaceVerificationAlertOverlay
|
|
isVisible={controller.isFaceVerificationConsent}
|
|
onConfirm={controller.FACE_VERIFICATION_CONSENT}
|
|
close={controller.DISMISS_POPUP}
|
|
/>
|
|
</>
|
|
)}
|
|
<Error
|
|
isModal
|
|
alignActionsOnEnd
|
|
showClose={false}
|
|
isVisible={controller.errorModal.show}
|
|
title={controller.errorModal.title}
|
|
message={controller.errorModal.message}
|
|
image={SvgImage.PermissionDenied()}
|
|
primaryButtonTestID={'retry'}
|
|
primaryButtonText={
|
|
controller.errorModal.showRetryButton &&
|
|
controller.openID4VPRetryCount < 3
|
|
? t('ScanScreen:status.retry')
|
|
: undefined
|
|
}
|
|
primaryButtonEvent={controller.RETRY}
|
|
textButtonTestID={'home'}
|
|
textButtonText={t('ScanScreen:status.accepted.home')}
|
|
textButtonEvent={handleTextButtonEvent}
|
|
customImageStyles={{paddingBottom: 0, marginBottom: -6}}
|
|
customStyles={{marginTop: '30%'}}
|
|
testID={'vpShareError'}
|
|
/>
|
|
</React.Fragment>
|
|
);
|
|
};
|