mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-07 20:53:54 -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>
128 lines
3.7 KiB
TypeScript
128 lines
3.7 KiB
TypeScript
import React, {useContext, useEffect, useState} from 'react';
|
|
import Icon from 'react-native-vector-icons/MaterialIcons';
|
|
import {Camera} from 'expo-camera';
|
|
import {BarCodeEvent, BarCodeScanner} from 'expo-barcode-scanner';
|
|
import {Linking, TouchableOpacity, View, Image, Pressable} from 'react-native';
|
|
import {Theme} from './ui/styleUtils';
|
|
import {Column, Button, Text, Centered, Row} from './ui';
|
|
import {GlobalContext} from '../shared/GlobalContext';
|
|
import {useSelector} from '@xstate/react';
|
|
import {selectIsActive} from '../machines/app';
|
|
import {useTranslation} from 'react-i18next';
|
|
import {useScanLayout} from '../screens/Scan/ScanLayoutController';
|
|
|
|
export const QrScanner: React.FC<QrScannerProps> = props => {
|
|
const {t} = useTranslation('QrScanner');
|
|
const {appService} = useContext(GlobalContext);
|
|
const [hasPermission, setHasPermission] = useState(null);
|
|
const [scanned, setScanned] = useState(false);
|
|
const [cameraType, setCameraType] = useState(Camera.Constants.Type.back);
|
|
const controller = useScanLayout();
|
|
|
|
const isActive = useSelector(appService, selectIsActive);
|
|
|
|
const openSettings = () => {
|
|
Linking.openSettings();
|
|
};
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
const response = await Camera.requestCameraPermissionsAsync();
|
|
setHasPermission(response.granted);
|
|
})();
|
|
}, []);
|
|
|
|
useEffect(() => {
|
|
if (isActive && hasPermission === false) {
|
|
(async () => {
|
|
const response = await Camera.requestCameraPermissionsAsync();
|
|
setHasPermission(response.granted);
|
|
})();
|
|
}
|
|
}, [isActive]);
|
|
|
|
if (hasPermission === null) {
|
|
return <View />;
|
|
}
|
|
|
|
const CameraDisabledPopUp: React.FC = () => {
|
|
return (
|
|
<View>
|
|
<Row style={Theme.Styles.cameraDisabledPopUp}>
|
|
<Column>
|
|
<Text color={Theme.Colors.whiteText} weight="bold">
|
|
{t('cameraAccessDisabled')}
|
|
</Text>
|
|
<Text
|
|
color={Theme.Colors.whiteText}
|
|
weight="semibold"
|
|
size="smaller">
|
|
{t('cameraPermissionGuideLabel')}
|
|
</Text>
|
|
</Column>
|
|
<Pressable>
|
|
<Icon
|
|
name="close"
|
|
onPress={controller.DISMISS}
|
|
color={Theme.Colors.whiteText}
|
|
size={19}
|
|
/>
|
|
</Pressable>
|
|
</Row>
|
|
</View>
|
|
);
|
|
};
|
|
return (
|
|
<View>
|
|
{hasPermission == false && <CameraDisabledPopUp />}
|
|
<View style={Theme.Styles.scannerContainer}>
|
|
<Camera
|
|
style={Theme.Styles.scanner}
|
|
barCodeScannerSettings={{
|
|
barcodeTypes: [BarCodeScanner.Constants.BarCodeType.qr],
|
|
}}
|
|
onBarCodeScanned={scanned ? undefined : onBarcodeScanned}
|
|
type={cameraType}
|
|
/>
|
|
</View>
|
|
{props.title && (
|
|
<Text
|
|
align="center"
|
|
weight="semibold"
|
|
style={Theme.TextStyles.base}
|
|
margin="20 57 0 57">
|
|
{props.title}
|
|
</Text>
|
|
)}
|
|
<Column margin="18 0" crossAlign="center">
|
|
<TouchableOpacity
|
|
onPress={() => {
|
|
setCameraType(
|
|
cameraType === Camera.Constants.Type.back
|
|
? Camera.Constants.Type.front
|
|
: Camera.Constants.Type.back,
|
|
);
|
|
}}>
|
|
<Image
|
|
source={Theme.CameraFlipIcon}
|
|
style={Theme.Styles.cameraFlipIcon}
|
|
/>
|
|
</TouchableOpacity>
|
|
<Text size="small" weight="semibold" margin="8">
|
|
{t('flipCamera')}
|
|
</Text>
|
|
</Column>
|
|
</View>
|
|
);
|
|
|
|
function onBarcodeScanned(event: BarCodeEvent) {
|
|
props.onQrFound(event.data);
|
|
setScanned(true);
|
|
}
|
|
};
|
|
|
|
interface QrScannerProps {
|
|
onQrFound: (data: string) => void;
|
|
title?: string;
|
|
}
|