Skip to content

Commit

Permalink
Merge pull request #235 from mosip/idpass/0.4.0-rc8
Browse files Browse the repository at this point in the history
Merge idpass/0.4.0-rc8
  • Loading branch information
MonobikashDas authored Nov 9, 2022
2 parents a8ef170 + d326d6a commit e825d5d
Show file tree
Hide file tree
Showing 53 changed files with 1,484 additions and 804 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

name: Bug report
about: Create a report to help us improve
title: ''
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/android-custom-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

# Cache stuff for faster build
- name: Cache local npm repository
uses: actions/cache@v2
uses: actions/cache@v3.0.11
with:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ~/.npm

- name: Cache local gradle repository
uses: actions/cache@v2
uses: actions/cache@v3.0.11
with:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
path: |
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
MIMOTO_HOST: ${{ github.event.inputs.backendServiceUrl }}
FIREBASE_SECRET: ${{ secrets.GPG_SECRET }}
- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: apk-output
path: android/app/build/outputs/apk/newlogic/release/
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ jobs:
build-android:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0

# Cache stuff for faster build
- name: Cache local npm repository
uses: actions/cache@v2
uses: actions/cache@v3.0.11
with:
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
path: ~/.npm

- name: Cache local gradle repository
uses: actions/cache@v2
uses: actions/cache@v3.0.11
with:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
path: |
Expand Down Expand Up @@ -63,7 +63,7 @@ jobs:
FIREBASE_SECRET: ${{ secrets.GPG_SECRET }}

- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3.1.1
with:
name: output
path: android/app/build/outputs/apk/newlogic/release/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3.1.0
with:
fetch-depth: 0
- name: Install npm dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3.1.0
- name: Create Release
id: create_release
uses: actions/create-release@v1
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ npm install
export RELEASE_KEYSTORE=release.keystore
export RELEASE_KEYSTORE_ALIAS=androidreleasekey
export RELEASE_KEYSTORE_PASSWORD=android
# https://hostname/residentmobileapp is the Mimoto service url
export BACKEND_SERVICE_URL=https://hostname/residentmobileapp

# Use DEBUG_KEYSTORE, DEBUG_KEYSTORE_ALIAS, DEBUG_KEYSTORE_PASSWORD for debug build

Expand Down
4 changes: 3 additions & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ buildscript {
}
repositories {
google()
gradlePluginPortal()
mavenCentral()
jcenter()
}
Expand All @@ -35,9 +36,10 @@ allprojects {
}

google()
gradlePluginPortal()
mavenCentral()
jcenter()
maven { url 'https://www.jitpack.io' }
jcenter()
}
}

Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ android.useAndroidX=true
android.enableJetifier=true

# Version of flipper SDK to use with React Native
FLIPPER_VERSION=0.54.0
FLIPPER_VERSION=0.99.0

# The hosted JavaScript engine
# Supported values: expo.jsEngine = "hermes" | "jsc"
Expand Down
1 change: 1 addition & 0 deletions components/FaceScanner.strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
140 changes: 140 additions & 0 deletions components/FaceScanner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import React, { useCallback, useContext, useEffect, useRef } from 'react';
import Icon from 'react-native-vector-icons/MaterialIcons';
import { Camera } from 'expo-camera';
import { StyleSheet } from 'react-native';
import { Button, Centered, Column, Row, Text } from './ui';
import { useInterpret, useSelector } from '@xstate/react';
import { useTranslation } from 'react-i18next';
import {
FaceScannerEvents,
selectIsCheckingPermission,
selectIsValid,
selectIsPermissionDenied,
selectIsScanning,
selectWhichCamera,
createFaceScannerMachine,
selectIsInvalid,
selectIsCapturing,
selectIsVerifying,
} from '../machines/faceScanner';
import { GlobalContext } from '../shared/GlobalContext';
import { selectIsActive } from '../machines/app';
import { RotatingIcon } from './RotatingIcon';
import { Theme } from './ui/styleUtils';

export const FaceScanner: React.FC<FaceScannerProps> = (props) => {
const { t } = useTranslation('FaceScanner');
const { appService } = useContext(GlobalContext);
const isActive = useSelector(appService, selectIsActive);

const machine = useRef(createFaceScannerMachine(props.vcImage));
const service = useInterpret(machine.current);

const whichCamera = useSelector(service, selectWhichCamera);

const isPermissionDenied = useSelector(service, selectIsPermissionDenied);
const isValid = useSelector(service, selectIsValid);
const isInvalid = useSelector(service, selectIsInvalid);
const isCheckingPermission = useSelector(service, selectIsCheckingPermission);
const isScanning = useSelector(service, selectIsScanning);
const isCapturing = useSelector(service, selectIsCapturing);
const isVerifying = useSelector(service, selectIsVerifying);

const setCameraRef = useCallback(
(node: Camera) => {
if (node != null && !isScanning) {
service.send(FaceScannerEvents.READY(node));
}
},
[isScanning]
);

useEffect(() => {
if (isValid) {
props.onValid();
} else if (isInvalid) {
props.onInvalid();
}
}, [isValid, isInvalid]);

useEffect(() => {
if (isActive) {
service.send(FaceScannerEvents.APP_FOCUSED());
}
}, [isActive]);

if (isCheckingPermission) {
return <Column></Column>;
} else if (isPermissionDenied) {
return (
<Column padding="24" fill align="space-between">
<Text align="center" color={Theme.Colors.errorMessage}>
{t('missingPermissionText')}
</Text>
<Button
title={t('allowCameraButton')}
onPress={() => service.send(FaceScannerEvents.OPEN_SETTINGS())}
/>
</Column>
);
}

return (
<Column crossAlign="center">
<Column style={[styles.scannerContainer]}>
<Camera
ratio="4:3"
style={styles.scanner}
type={whichCamera}
ref={setCameraRef}
/>
</Column>
<Centered margin="24 0">
{isCapturing || isVerifying ? (
<RotatingIcon name="sync" size={64} />
) : (
<Row crossAlign="center">
<Icon
name="flip-camera-ios"
color={Theme.Colors.flipCameraIcon}
size={64}
onPress={() => service.send(FaceScannerEvents.FLIP_CAMERA())}
style={{ margin: 8, marginEnd: 32 }}
/>
<Icon
name="photo-camera"
color={Theme.Colors.flipCameraIcon}
size={64}
onPress={() => service.send(FaceScannerEvents.CAPTURE())}
style={{ margin: 8, marginTop: 12, marginStart: 32 }}
/>
</Row>
)}
</Centered>
</Column>
);
};

interface FaceScannerProps {
vcImage: string;
onValid: () => void;
onInvalid: () => void;
}

const styles = StyleSheet.create({
scannerContainer: {
borderWidth: 4,
borderColor: Theme.Colors.textValue,
borderRadius: 32,
justifyContent: 'center',
height: 400,
width: 300,
overflow: 'hidden',
},

scanner: {
height: '100%',
width: '100%',
margin: 'auto',
},
});
24 changes: 20 additions & 4 deletions components/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
import React from 'react';
import { SUPPORTED_LANGUAGES } from '../i18n';
import { View } from 'react-native';
import { I18nManager, View } from 'react-native';
import { Picker } from './ui/Picker';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { useTranslation } from 'react-i18next';
import i18next from 'i18next';
import RNRestart from 'react-native-restart';

export const LanguageSelector: React.FC<LanguageSelectorProps> = (props) => {
const { i18n } = useTranslation();
const languages = Object.entries(SUPPORTED_LANGUAGES).map(
([value, label]) => ({ label, value })
);

const changeLanguage = async (value: string) => {
await i18n.changeLanguage(value);
await AsyncStorage.setItem('language', i18n.language);
const changeLanguage = async (language: string) => {
if (language !== i18n.language) {
await i18n.changeLanguage(language).then(async () => {
await AsyncStorage.setItem('language', i18n.language);
const isRTL = i18next.dir(language) === 'rtl' ? true : false;
if (isRTL !== I18nManager.isRTL) {
try {
I18nManager.forceRTL(isRTL);
setTimeout(() => {
RNRestart.Restart();
}, 150);
} catch (e) {
console.log('error', e);
}
}
});
}
};

return (
Expand Down
12 changes: 11 additions & 1 deletion components/VcDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
const uin = props.vc?.verifiableCredential.credentialSubject.UIN;
const vid = props.vc?.verifiableCredential.credentialSubject.VID;

if (props.vc?.verifiableCredential == null) {
return <Text align="center">Loading details...</Text>;
}

return (
<Column>
<ImageBackground
Expand Down Expand Up @@ -70,7 +74,8 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
<Text
weight="semibold"
size="smaller"
color={Theme.Colors.Details}>
color={Theme.Colors.Details}
align="left">
{uin}
</Text>
</Column>
Expand All @@ -87,6 +92,7 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
<Text
weight="semibold"
size="smaller"
align="left"
color={Theme.Colors.Details}>
{vid}
</Text>
Expand All @@ -97,12 +103,14 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
<Text
weight="bold"
size="smaller"
align="left"
color={Theme.Colors.DetailsLabel}>
{t('generatedOn')}
</Text>
<Text
weight="semibold"
size="smaller"
align="left"
color={Theme.Colors.Details}>
{new Date(props.vc?.generatedOn).toLocaleDateString()}
</Text>
Expand All @@ -112,13 +120,15 @@ export const VcDetails: React.FC<VcDetailsProps> = (props) => {
<Text
weight="bold"
size="smaller"
align="left"
color={Theme.Colors.DetailsLabel}>
{t('status')}
</Text>
<Row>
<Text
weight="semibold"
size="smaller"
align="left"
color={Theme.Colors.Details}>
{t('valid')}
</Text>
Expand Down
Loading

0 comments on commit e825d5d

Please sign in to comment.