mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-20 10:12:01 +01:00
REF: Use fs module for screens that show action sheet
This commit is contained in:
parent
f29b28b150
commit
92ab26a04c
@ -52,9 +52,11 @@ const PsbtMultisigQRCode = () => {
|
||||
|
||||
ActionSheet.showActionSheetWithOptions({ options, cancelButtonIndex: 0 }, async buttonIndex => {
|
||||
if (buttonIndex === 1) {
|
||||
fs.takePhotoWithImagePickerAndReadPhoto.then(onBarScanned);
|
||||
fs.takePhotoWithImagePickerAndReadPhoto.then(data => onBarScanned({ data }));
|
||||
} else if (buttonIndex === 2) {
|
||||
fs.showImagePickerAndReadImage(onBarScanned).catch(error => alert(error.message));
|
||||
fs.showImagePickerAndReadImage(onBarScanned)
|
||||
.then(data => onBarScanned({ data }))
|
||||
.catch(error => alert(error.message));
|
||||
} else if (buttonIndex === 3) {
|
||||
const { data } = await fs.showFilePickerAndReadFile();
|
||||
if (data) {
|
||||
|
@ -408,9 +408,15 @@ const WalletsAddMultisigStep2 = () => {
|
||||
|
||||
ActionSheet.showActionSheetWithOptions({ options, cancelButtonIndex: 0 }, async buttonIndex => {
|
||||
if (buttonIndex === 1) {
|
||||
fs.takePhotoWithImagePickerAndReadPhoto.then(onBarScanned);
|
||||
fs.takePhotoWithImagePickerAndReadPhoto.then(data => {
|
||||
onBarScanned({ data });
|
||||
});
|
||||
} else if (buttonIndex === 2) {
|
||||
fs.showImagePickerAndReadImage(onBarScanned).catch(error => alert(error.message));
|
||||
fs.showImagePickerAndReadImage()
|
||||
.then(data => {
|
||||
onBarScanned({ data });
|
||||
})
|
||||
.catch(error => alert(error.message));
|
||||
} else if (buttonIndex === 3) {
|
||||
const { data } = await fs.showFilePickerAndReadFile();
|
||||
if (data) {
|
||||
|
@ -18,7 +18,7 @@ import { Icon } from 'react-native-elements';
|
||||
import { useFocusEffect, useNavigation, useRoute, useTheme } from '@react-navigation/native';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import { getSystemName } from 'react-native-device-info';
|
||||
import { launchCamera } from 'react-native-image-picker';
|
||||
import ActionSheet from '../ActionSheet';
|
||||
|
||||
import {
|
||||
BlueButton,
|
||||
@ -40,11 +40,9 @@ import MultipleStepsListItem, {
|
||||
MultipleStepsListItemButtohType,
|
||||
MultipleStepsListItemDashType,
|
||||
} from '../../components/MultipleStepsListItem';
|
||||
import ScanQRCode from '../send/ScanQRCode';
|
||||
import Privacy from '../../Privacy';
|
||||
import Biometric from '../../class/biometrics';
|
||||
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
|
||||
|
||||
const fs = require('../../blue_modules/fs');
|
||||
const isDesktop = getSystemName() === 'Mac OS X';
|
||||
|
||||
const ViewEditMultisigCosigners = () => {
|
||||
@ -402,30 +400,32 @@ const ViewEditMultisigCosigners = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const showActionSheet = () => {
|
||||
const options = [loc._.cancel, loc.wallets.take_photo, loc.wallets.list_long_choose, loc.wallets.import_file];
|
||||
|
||||
ActionSheet.showActionSheetWithOptions({ options, cancelButtonIndex: 0 }, async buttonIndex => {
|
||||
if (buttonIndex === 1) {
|
||||
fs.takePhotoWithImagePickerAndReadPhoto.then(data => {
|
||||
_handleUseMnemonicPhrase(data);
|
||||
});
|
||||
} else if (buttonIndex === 2) {
|
||||
fs.showImagePickerAndReadImage()
|
||||
.then(data => {
|
||||
_handleUseMnemonicPhrase(data);
|
||||
})
|
||||
.catch(error => alert(error.message));
|
||||
} else if (buttonIndex === 3) {
|
||||
const { data } = await fs.showFilePickerAndReadFile();
|
||||
if (data) {
|
||||
_handleUseMnemonicPhrase(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const scanOrOpenFile = () => {
|
||||
setIsProvideMnemonicsModalVisible(false);
|
||||
if (isDesktop) {
|
||||
launchCamera(
|
||||
{
|
||||
title: null,
|
||||
mediaType: 'photo',
|
||||
takePhotoButtonTitle: null,
|
||||
},
|
||||
response => {
|
||||
if (response.uri) {
|
||||
const uri = Platform.OS === 'ios' ? response.uri.toString().replace('file://', '') : response.uri;
|
||||
LocalQRCode.decode(uri, (error, result) => {
|
||||
if (!error) {
|
||||
_handleUseMnemonicPhrase(result);
|
||||
} else {
|
||||
alert(loc.send.qr_error_no_qrcode);
|
||||
}
|
||||
});
|
||||
} else if (response.error) {
|
||||
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
|
||||
}
|
||||
},
|
||||
);
|
||||
showActionSheet();
|
||||
} else {
|
||||
navigate('ScanQRCodeRoot', {
|
||||
screen: 'ScanQRCode',
|
||||
|
Loading…
Reference in New Issue
Block a user