mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-13 19:16:52 +01:00
27 lines
941 B
TypeScript
27 lines
941 B
TypeScript
import { Platform } from 'react-native';
|
|
import { check, request, PERMISSIONS, RESULTS } from 'react-native-permissions';
|
|
import { navigationRef } from '../NavigationService.ts';
|
|
|
|
const isCameraAuthorizationStatusGranted = async () => {
|
|
const status = await check(Platform.OS === 'android' ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA);
|
|
return status === RESULTS.GRANTED;
|
|
};
|
|
|
|
const requestCameraAuthorization = () => {
|
|
return request(Platform.OS === 'android' ? PERMISSIONS.ANDROID.CAMERA : PERMISSIONS.IOS.CAMERA);
|
|
};
|
|
|
|
const scanQrHelper = async (): Promise<string> => {
|
|
await requestCameraAuthorization();
|
|
return new Promise(resolve => {
|
|
if (navigationRef.isReady()) {
|
|
navigationRef.current?.navigate('ScanQRCode', {
|
|
onBarScanned: (data: string) => {
|
|
resolve(data);
|
|
},
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
export { isCameraAuthorizationStatusGranted, requestCameraAuthorization, scanQrHelper };
|