Skip to content

Commit

Permalink
Merge branch 'develop' into inji-366-v2-api-link-transaction
Browse files Browse the repository at this point in the history
Signed-off-by: Swati Goel <[email protected]>
  • Loading branch information
swatigoel authored Oct 13, 2023
2 parents 877024f + 27e2f07 commit c1e4a22
Show file tree
Hide file tree
Showing 46 changed files with 506 additions and 364 deletions.
12 changes: 1 addition & 11 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ import {
import {DualMessageOverlay} from './components/DualMessageOverlay';
import {useApp} from './screens/AppController';
import {Alert} from 'react-native';
import {
getAppInfoData,
getTelemetryConfigData,
initializeTelemetry,
sendAppInfoEvent,
} from './shared/telemetry/TelemetryUtils';
import {configureTelemetry} from './shared/telemetry/TelemetryUtils';
import {MessageOverlay} from './components/MessageOverlay';
import SecureKeystore from 'react-native-secure-keystore';
import {isCustomSecureKeystore} from './shared/cryptoutil/cryptoUtil';
Expand All @@ -42,11 +37,6 @@ const DecryptErrorAlert = (controller, t) => {
},
]);
};
function configureTelemetry() {
const config = getTelemetryConfigData();
initializeTelemetry(config);
sendAppInfoEvent(getAppInfoData());
}

const AppLayoutWrapper: React.FC = () => {
const {appService} = useContext(GlobalContext);
Expand Down
2 changes: 0 additions & 2 deletions components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Storage from '../shared/storage';
import {useTranslation} from 'react-i18next';
import i18next from 'i18next';
import RNRestart from 'react-native-restart';
import {__SelectedLanguage} from '../shared/GlobalVariables';

export const LanguageSelector: React.FC<LanguageSelectorProps> = props => {
const {i18n} = useTranslation();
Expand All @@ -17,7 +16,6 @@ export const LanguageSelector: React.FC<LanguageSelectorProps> = props => {
const changeLanguage = async (language: string) => {
if (language !== i18n.language) {
await i18n.changeLanguage(language).then(async () => {
__SelectedLanguage.setValue(language);
await Storage.setItem('language', i18n.language);
const isRTL = i18next.dir(language) === 'rtl' ? true : false;
if (isRTL !== I18nManager.isRTL) {
Expand Down
103 changes: 30 additions & 73 deletions components/VC/MosipVCItem/MosipVCItem.tsx
Original file line number Diff line number Diff line change
@@ -1,88 +1,47 @@
import React, {useContext, useEffect, useMemo, useRef} from 'react';
import {useInterpret, useSelector} from '@xstate/react';
import {View, Pressable} from 'react-native';
import React, {useEffect} from 'react';
import {Pressable, View} from 'react-native';
import {ActorRefFrom} from 'xstate';
import {
createExistingMosipVCItemMachine,
selectVerifiableCredential,
selectGeneratedOn,
ExistingMosipVCItemEvents,
ExistingMosipVCItemMachine,
selectContext,
selectEmptyWalletBindingId,
selectIsSavingFailedInIdle,
selectKebabPopUp,
} from '../../../machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine';
import {ExistingMosipVCItemEvents} from '../../../machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine';
import {ErrorMessageOverlay} from '../../MessageOverlay';
import {Theme} from '../../ui/styleUtils';
import {GlobalContext} from '../../../shared/GlobalContext';
import {MosipVCItemContent} from './MosipVCItemContent';
import {MosipVCItemActivationStatus} from './MosipVCItemActivationStatus';
import {Row} from '../../ui';
import {KebabPopUp} from '../../KebabPopUp';
import {VCMetadata} from '../../../shared/VCMetadata';
import {format} from 'date-fns';
import {
createEsignetMosipVCItemMachine,
EsignetMosipVCItemEvents,
EsignetMosipVCItemMachine,
selectContext as esignetSelectContext,
selectEmptyWalletBindingId as esignetSelectEmptyWalletBindingId,
selectGeneratedOn as esignetSelectGeneratedOn,
selectKebabPopUp as esignetSelectKebabPopUp,
selectVerifiableCredentials as esignetSelectVerifiableCredentials,
} from '../../../machines/VCItemMachine/EsignetMosipVCItem/EsignetMosipVCItemMachine';
import {EsignetMosipVCItemMachine} from '../../../machines/VCItemMachine/EsignetMosipVCItem/EsignetMosipVCItemMachine';
import {useVcItemController} from './VcItemController';

export const MosipVCItem: React.FC<
ExistingMosipVCItemProps | EsignetMosipVCItemProps
> = props => {
const {appService} = useContext(GlobalContext);
const machine = useRef(
!props.vcMetadata.isFromOpenId4VCI()
? createExistingMosipVCItemMachine(
appService.getSnapshot().context.serviceRefs,
props.vcMetadata,
)
: createEsignetMosipVCItemMachine(
appService.getSnapshot().context.serviceRefs,
props.vcMetadata,
),
);
let {
service,
context,
verifiableCredential,
emptyWalletBindingId,
isKebabPopUp,
isSavingFailedInIdle,
storeErrorTranslationPath,
generatedOn,

DISMISS,
KEBAB_POPUP,
} = useVcItemController(props);

const service = useInterpret(machine.current, {devTools: __DEV__});
let formattedDate =
generatedOn && format(new Date(generatedOn), 'MM/dd/yyyy');

useEffect(() => {
service.send(
ExistingMosipVCItemEvents.UPDATE_VC_METADATA(props.vcMetadata),
);
}, [props.vcMetadata]);

let context = useSelector(service, selectContext);
let verifiableCredential = useSelector(service, selectVerifiableCredential);
let emptyWalletBindingId = useSelector(service, selectEmptyWalletBindingId);
let isKebabPopUp = useSelector(service, selectKebabPopUp);
let DISMISS = () => service.send(ExistingMosipVCItemEvents.DISMISS());
let KEBAB_POPUP = () => service.send(ExistingMosipVCItemEvents.KEBAB_POPUP());
const isSavingFailedInIdle = useSelector(service, selectIsSavingFailedInIdle);
const storeErrorTranslationPath = 'errors.savingFailed';
let generatedOn = useSelector(service, selectGeneratedOn);
if (props.vcMetadata.isFromOpenId4VCI()) {
context = useSelector(service, esignetSelectContext);
isKebabPopUp = useSelector(service, esignetSelectKebabPopUp);
generatedOn = useSelector(service, esignetSelectGeneratedOn);
emptyWalletBindingId = useSelector(
service,
esignetSelectEmptyWalletBindingId,
);
DISMISS = () => service.send(EsignetMosipVCItemEvents.DISMISS());
KEBAB_POPUP = () => service.send(EsignetMosipVCItemEvents.KEBAB_POPUP());
verifiableCredential = useSelector(
service,
esignetSelectVerifiableCredentials,
);
}
let formattedDate =
generatedOn && format(new Date(generatedOn), 'MM/dd/yyyy');
return (
<React.Fragment>
<Pressable
Expand All @@ -105,20 +64,18 @@ export const MosipVCItem: React.FC<
iconName={props.iconName}
iconType={props.iconType}
onPress={() => props.onPress(service)}
isDownloading={props.isDownloading}
/>
<View style={Theme.Styles.horizontalLine} />
{props.isSharingVc ? null : (
<Row style={Theme.Styles.activationTab}>
{props.activeTab !== 'receivedVcsTab' &&
props.activeTab != 'sharingVcScreen' && (
<MosipVCItemActivationStatus
vcMetadata={props.vcMetadata}
verifiableCredential={verifiableCredential}
emptyWalletBindingId={emptyWalletBindingId}
onPress={() => props.onPress(service)}
showOnlyBindedVc={props.showOnlyBindedVc}
/>
)}
<MosipVCItemActivationStatus
vcMetadata={props.vcMetadata}
verifiableCredential={verifiableCredential}
emptyWalletBindingId={emptyWalletBindingId}
onPress={() => props.onPress(service)}
showOnlyBindedVc={props.showOnlyBindedVc}
/>
<View style={Theme.Styles.verticalLine} />
<Row style={Theme.Styles.kebabIcon}>
<Pressable onPress={KEBAB_POPUP} accessible={false}>
Expand Down Expand Up @@ -153,10 +110,10 @@ export interface ExistingMosipVCItemProps {
showOnlyBindedVc?: boolean;
onPress?: (vcRef?: ActorRefFrom<typeof ExistingMosipVCItemMachine>) => void;
onShow?: (vcRef?: ActorRefFrom<typeof ExistingMosipVCItemMachine>) => void;
activeTab?: string;
iconName?: string;
iconType?: string;
isSharingVc?: boolean;
isDownloading?: boolean;
}

export interface EsignetMosipVCItemProps {
Expand All @@ -167,8 +124,8 @@ export interface EsignetMosipVCItemProps {
showOnlyBindedVc?: boolean;
onPress?: (vcRef?: ActorRefFrom<typeof EsignetMosipVCItemMachine>) => void;
onShow?: (vcRef?: ActorRefFrom<typeof EsignetMosipVCItemMachine>) => void;
activeTab?: string;
iconName?: string;
iconType?: string;
isSharingVc?: boolean;
isDownloading?: boolean;
}
5 changes: 3 additions & 2 deletions components/VC/MosipVCItem/MosipVCItemActivationStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const WalletUnverifiedIcon: React.FC = () => {
size={Theme.ICON_MID_SIZE}
type="material-community"
containerStyle={{
marginStart: 10,
marginStart: 1,
marginEnd: 1,
bottom: 1,
marginLeft: 10,
marginRight: -2,
}}
/>
);
Expand Down
6 changes: 5 additions & 1 deletion components/VC/MosipVCItem/MosipVCItemContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ const getIssuerLogo = (isOpenId4VCI: boolean, issuerLogo: string) => {
export const MosipVCItemContent: React.FC<
ExistingMosipVCItemContentProps | EsignetMosipVCItemContentProps
> = props => {
const verifiableCredential = props.vcMetadata.isFromOpenId4VCI()
const verifiableCredential = props.isDownloading
? null
: props.vcMetadata.isFromOpenId4VCI()
? props.verifiableCredential?.credential
: props.verifiableCredential;

Expand Down Expand Up @@ -338,6 +340,7 @@ interface ExistingMosipVCItemContentProps {
iconType?: string;
service: any;
onPress?: () => void;
isDownloading?: boolean;
}

export interface EsignetMosipVCItemContentProps {
Expand All @@ -350,4 +353,5 @@ export interface EsignetMosipVCItemContentProps {
iconType?: string;
service: any;
onPress?: () => void;
isDownloading?: boolean;
}
6 changes: 3 additions & 3 deletions components/VC/MosipVCItem/MosipVCItemDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ export const MosipVCItemDetails: React.FC<
}

return (
<Column margin="10">
<Column margin="10 0 10 0">
<ImageBackground
imageStyle={{width: '100%'}}
resizeMethod="scale"
resizeMode="stretch"
style={Theme.Styles.openCardBgContainer}
source={Theme.OpenCard}>
<Row align="space-between" padding="10" margin="0 10 0 10">
<Row align="space-between" padding="10" margin="0 10 0 8">
<Column align="space-evenly" crossAlign="center">
<Image
source={getProfileImage(
Expand Down Expand Up @@ -198,7 +198,7 @@ export const MosipVCItemDetails: React.FC<
</Text>
</Column>
</Column>
<Column margin="0 0 0 40">
<Column margin="0 0 0 38">
<Column margin="20 0 0 0">
<Text
testID="dateOfBirth"
Expand Down
79 changes: 79 additions & 0 deletions components/VC/MosipVCItem/VcItemController.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import {useContext, useRef} from 'react';
import {GlobalContext} from '../../../shared/GlobalContext';
import {
createExistingMosipVCItemMachine,
ExistingMosipVCItemEvents,
selectContext,
selectEmptyWalletBindingId,
selectGeneratedOn,
selectIsSavingFailedInIdle,
selectKebabPopUp,
selectVerifiableCredential,
} from '../../../machines/VCItemMachine/ExistingMosipVCItem/ExistingMosipVCItemMachine';
import {
createEsignetMosipVCItemMachine,
EsignetMosipVCItemEvents,
selectContext as esignetSelectContext,
selectEmptyWalletBindingId as esignetSelectEmptyWalletBindingId,
selectGeneratedOn as esignetSelectGeneratedOn,
selectKebabPopUp as esignetSelectKebabPopUp,
selectVerifiableCredentials as esignetSelectVerifiableCredentials,
} from '../../../machines/VCItemMachine/EsignetMosipVCItem/EsignetMosipVCItemMachine';
import {useInterpret, useSelector} from '@xstate/react';
import {EsignetMosipVCItemProps, ExistingMosipVCItemProps} from './MosipVCItem';

export function useVcItemController(
props: ExistingMosipVCItemProps | EsignetMosipVCItemProps,
) {
const {appService} = useContext(GlobalContext);
const machine = useRef(
!props.vcMetadata.isFromOpenId4VCI()
? createExistingMosipVCItemMachine(
appService.getSnapshot().context.serviceRefs,
props.vcMetadata,
)
: createEsignetMosipVCItemMachine(
appService.getSnapshot().context.serviceRefs,
props.vcMetadata,
),
);

const service = useInterpret(machine.current, {devTools: __DEV__});

let context = useSelector(service, selectContext);
let verifiableCredential = useSelector(service, selectVerifiableCredential);
let emptyWalletBindingId = useSelector(service, selectEmptyWalletBindingId);
let isKebabPopUp = useSelector(service, selectKebabPopUp);
let DISMISS = () => service.send(ExistingMosipVCItemEvents.DISMISS());
let KEBAB_POPUP = () => service.send(ExistingMosipVCItemEvents.KEBAB_POPUP());
const isSavingFailedInIdle = useSelector(service, selectIsSavingFailedInIdle);
const storeErrorTranslationPath = 'errors.savingFailed';
let generatedOn = useSelector(service, selectGeneratedOn);
if (props.vcMetadata.isFromOpenId4VCI()) {
context = useSelector(service, esignetSelectContext);
isKebabPopUp = useSelector(service, esignetSelectKebabPopUp);
generatedOn = useSelector(service, esignetSelectGeneratedOn);
emptyWalletBindingId = useSelector(
service,
esignetSelectEmptyWalletBindingId,
);
DISMISS = () => service.send(EsignetMosipVCItemEvents.DISMISS());
KEBAB_POPUP = () => service.send(EsignetMosipVCItemEvents.KEBAB_POPUP());
verifiableCredential = useSelector(
service,
esignetSelectVerifiableCredentials,
);
}
return {
service,
context,
verifiableCredential,
emptyWalletBindingId,
isKebabPopUp,
DISMISS,
KEBAB_POPUP,
isSavingFailedInIdle,
storeErrorTranslationPath,
generatedOn,
};
}
25 changes: 20 additions & 5 deletions components/ui/themes/DefaultTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ export const DefaultTheme = {
VerifiedIcon: Colors.Green,
whiteText: Colors.White,
flipCameraIcon: Colors.Black,
IdInputModalBorder: Colors.Grey,
RetrieveIdLabel: Colors.ShadeOfGrey,
inputSelection: Colors.Orange,
checkCircleIcon: Colors.White,
Expand Down Expand Up @@ -177,8 +176,8 @@ export const DefaultTheme = {
cardDetailsContainer: {},
bottomTabIconStyle: {
padding: 4,
width: 36,
height: 36,
width: Dimensions.get('window').width * 0.12,
height: Dimensions.get('window').height * 0.045,
borderRadius: 6,
backgroundColor: Colors.LightOrange,
},
Expand Down Expand Up @@ -226,8 +225,8 @@ export const DefaultTheme = {
height: 30,
backgroundColor: Colors.Grey,
marginVertical: 8,
marginLeft: -45,
marginRight: 22,
marginLeft: -35,
marginRight: 15,
},
closeCardBgContainer: {
borderRadius: 10,
Expand Down Expand Up @@ -492,6 +491,22 @@ export const DefaultTheme = {
fontSize: 15,
fontFamily: 'Inter_700Bold',
},
idInputContainer: {
marginTop: 20,
marginRight: Dimensions.get('window').width * 0.26,
},
idInputPicker: {
width: Dimensions.get('window').width * 0.32,
borderBottomWidth: 1,
marginBottom: 2,
borderColor: Platform.OS === 'ios' ? 'transparent' : Colors.Grey,
bottom: Platform.OS === 'ios' ? 50 : 24,
height: Platform.OS === 'ios' ? 100 : 'auto',
},
idInputBottom: {
borderBottomColor: Colors.Orange,
borderBottomWidth: 1,
},
getId: {
justifyContent: 'center',
alignItems: 'center',
Expand Down
Loading

0 comments on commit c1e4a22

Please sign in to comment.