FIX: require cycle errors

This commit is contained in:
Ivan Vershigora 2020-10-13 08:49:30 +03:00 committed by Overtorment
parent fc09fc72d4
commit 23ef513469
7 changed files with 45 additions and 40 deletions

View File

@ -48,7 +48,7 @@ import { useTheme } from '@react-navigation/native';
import { BlueCurrentTheme } from './components/themes';
import loc, { formatBalance, formatBalanceWithoutSuffix, formatBalancePlain, removeTrailingZeros, transactionTimeToReadable } from './loc';
import Lnurl from './class/lnurl';
import ScanQRCode from './screen/send/ScanQRCode';
import { presentCameraNotAuthorizedAlert } from './class/camera';
/** @type {AppStorage} */
const BlueApp = require('./BlueApp');
const { height, width } = Dimensions.get('window');
@ -2148,7 +2148,7 @@ export class BlueAddressInput extends Component {
}
});
} else if (response.error) {
ScanQRCode.presentCameraNotAuthorizedAlert(response.error);
presentCameraNotAuthorizedAlert(response.error);
}
},
);

33
class/camera.js Normal file
View File

@ -0,0 +1,33 @@
import { Linking, Alert } from 'react-native';
import { getSystemName } from 'react-native-device-info';
import loc from '../loc';
const isDesktop = getSystemName() === 'Mac OS X';
export const openPrivacyDesktopSettings = () => {
if (isDesktop) {
Linking.openURL('x-apple.systempreferences:com.apple.preference.security?Privacy_Camera');
} else {
Linking.openSettings();
}
};
export const presentCameraNotAuthorizedAlert = error => {
Alert.alert(
loc.errors.error,
error,
[
{
text: loc.send.open_settings,
onPress: openPrivacyDesktopSettings,
style: 'default',
},
{
text: loc._.ok,
onPress: () => {},
style: 'cancel',
},
],
{ cancelable: true },
);
};

View File

@ -1,4 +1,5 @@
import { HDSegwitBech32Wallet, SegwitBech32Wallet } from './';
import { HDSegwitBech32Wallet } from './wallets/hd-segwit-bech32-wallet';
import { SegwitBech32Wallet } from './wallets/segwit-bech32-wallet';
const bitcoin = require('bitcoinjs-lib');
const BlueElectrum = require('../blue_modules/BlueElectrum');
const reverse = require('buffer-reverse');

View File

@ -1,5 +1,5 @@
export * from './wallets/abstract-wallet';
export * from './app-storage';
export * from './wallets/abstract-wallet';
export * from './wallets/legacy-wallet';
export * from './wallets/segwit-bech32-wallet';
export * from './wallets/segwit-p2sh-wallet';
@ -10,8 +10,8 @@ export * from './wallets/watch-only-wallet';
export * from './wallets/lightning-custodian-wallet';
export * from './wallets/abstract-hd-wallet';
export * from './wallets/hd-segwit-bech32-wallet';
export * from './hd-segwit-bech32-transaction';
export * from './wallets/placeholder-wallet';
export * from './wallets/hd-legacy-electrum-seed-p2pkh-wallet';
export * from './wallets/hd-segwit-electrum-seed-p2wpkh-wallet';
export * from './wallets/multisig-hd-wallet';
export * from './hd-segwit-bech32-transaction';

View File

@ -1,4 +1,4 @@
import { HDLegacyP2PKHWallet } from '..';
import { HDLegacyP2PKHWallet } from './hd-legacy-p2pkh-wallet';
const bitcoin = require('bitcoinjs-lib');
const mn = require('electrum-mnemonic');

View File

@ -1,4 +1,4 @@
import { HDSegwitBech32Wallet } from '..';
import { HDSegwitBech32Wallet } from './hd-segwit-bech32-wallet';
const bitcoin = require('bitcoinjs-lib');
const mn = require('electrum-mnemonic');

View File

@ -1,18 +1,17 @@
/* global alert */
import React, { useState } from 'react';
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, Linking, Alert, TextInput } from 'react-native';
import { Image, View, TouchableOpacity, StatusBar, Platform, StyleSheet, TextInput } from 'react-native';
import { RNCamera } from 'react-native-camera';
import { Icon } from 'react-native-elements';
import ImagePicker from 'react-native-image-picker';
import { decodeUR, extractSingleWorkload } from 'bc-ur';
import { useNavigation, useRoute, useIsFocused, useTheme } from '@react-navigation/native';
import loc from '../../loc';
import { BlueLoadingHook, BlueTextHooks, BlueButtonHook, BlueSpacing40 } from '../../BlueComponents';
import { getSystemName } from 'react-native-device-info';
import { BlueCurrentTheme } from '../../components/themes';
import { decodeUR, extractSingleWorkload } from 'bc-ur';
import { openPrivacyDesktopSettings } from '../../class/camera';
const LocalQRCode = require('@remobile/react-native-qrcode-local-image');
const createHash = require('create-hash');
const isDesktop = getSystemName() === 'Mac OS X';
const fs = require('../../blue_modules/fs');
const Base43 = require('../../blue_modules/base43');
const bitcoin = require('bitcoinjs-lib');
@ -251,7 +250,7 @@ const ScanQRCode = () => {
<View style={[styles.openSettingsContainer, stylesHook.openSettingsContainer]}>
<BlueTextHooks>{loc.send.permission_camera_message}</BlueTextHooks>
<BlueSpacing40 />
<BlueButtonHook title={loc.send.open_settings} onPress={ScanQRCode.openPrivacyDesktopSettings} />
<BlueButtonHook title={loc.send.open_settings} onPress={openPrivacyDesktopSettings} />
</View>
)}
<TouchableOpacity style={styles.closeTouch} onPress={dismiss}>
@ -316,34 +315,6 @@ const ScanQRCode = () => {
);
};
ScanQRCode.openPrivacyDesktopSettings = () => {
if (isDesktop) {
Linking.openURL('x-apple.systempreferences:com.apple.preference.security?Privacy_Camera');
} else {
Linking.openSettings();
}
};
ScanQRCode.presentCameraNotAuthorizedAlert = error => {
Alert.alert(
loc.errors.error,
error,
[
{
text: loc.send.open_settings,
onPress: ScanQRCode.openPrivacyDesktopSettings,
style: 'default',
},
{
text: loc._.ok,
onPress: () => {},
style: 'cancel',
},
],
{ cancelable: true },
);
};
ScanQRCode.navigationOptions = {
headerShown: false,
};