FIX: translate message if Bitcoin address or LN invoice is in clipboard

This commit is contained in:
Ivan Vershigora 2020-11-20 21:28:34 +03:00
parent 29b960525a
commit 2730921ca3
2 changed files with 24 additions and 35 deletions

47
App.js
View file

@ -1,17 +1,6 @@
import 'react-native-gesture-handler'; // should be on top
import React, { useContext, useEffect, useRef, useState } from 'react';
import {
Linking,
DeviceEventEmitter,
AppState,
StyleSheet,
KeyboardAvoidingView,
Platform,
View,
useColorScheme,
useWindowDimensions,
} from 'react-native';
import Modal from 'react-native-modal';
import { AppState, DeviceEventEmitter, KeyboardAvoidingView, Linking, Platform, StyleSheet, useColorScheme, View } from 'react-native';
import { NavigationContainer, CommonActions } from '@react-navigation/native';
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { navigationRef } from './NavigationService';
@ -25,6 +14,7 @@ import OnAppLaunch from './class/on-app-launch';
import DeeplinkSchemaMatch from './class/deeplink-schema-match';
import loc from './loc';
import { BlueDefaultTheme, BlueDarkTheme, BlueCurrentTheme } from './components/themes';
import BottomModal from './components/BottomModal';
import InitRoot from './Navigation';
import BlueClipboard from './blue_modules/clipboard';
import { BlueStorageContext } from './blue_modules/storage-context';
@ -36,22 +26,25 @@ import Biometric from './class/biometrics';
import WidgetCommunication from './blue_modules/WidgetCommunication';
import changeNavigationBarColor from 'react-native-navigation-bar-color';
const A = require('./blue_modules/analytics');
if (process.env.NODE_ENV !== 'development') {
Sentry.init({
dsn: 'https://23377936131848ca8003448a893cb622@sentry.io/1295736',
});
}
const bitcoinModalString = 'Bitcoin address';
const lightningModalString = 'Lightning Invoice';
const ClipboardContentType = Object.freeze({
BITCOIN: 'BITCOIN',
LIGHTNING: 'LIGHTNING',
});
const App = () => {
const { walletsInitialized, wallets, addWallet, saveToDisk, fetchAndSaveWalletTransactions } = useContext(BlueStorageContext);
const appState = useRef(AppState.currentState);
const [isClipboardContentModalVisible, setIsClipboardContentModalVisible] = useState(false);
const [clipboardContentModalAddressType, setClipboardContentModalAddressType] = useState(bitcoinModalString);
const [clipboardContentType, setClipboardContentType] = useState();
const [clipboardContent, setClipboardContent] = useState('');
const colorScheme = useColorScheme();
const { height } = useWindowDimensions();
const stylesHook = StyleSheet.create({
modalContent: {
backgroundColor: colorScheme === 'dark' ? BlueDarkTheme.colors.elevated : BlueDefaultTheme.colors.elevated,
@ -228,11 +221,11 @@ const App = () => {
(isBitcoinAddress || isLightningInvoice || isLNURL || isBothBitcoinAndLightning)
) {
if (isBitcoinAddress) {
setClipboardContentModalAddressType(bitcoinModalString);
setClipboardContentType(ClipboardContentType.BITCOIN);
} else if (isLightningInvoice || isLNURL) {
setClipboardContentModalAddressType(lightningModalString);
setClipboardContentType(ClipboardContentType.LIGHTNING);
} else if (isBothBitcoinAndLightning) {
setClipboardContentModalAddressType(bitcoinModalString);
setClipboardContentType(ClipboardContentType.BITCOIN);
}
setIsClipboardContentModalVisible(true);
}
@ -254,18 +247,16 @@ const App = () => {
const renderClipboardContentModal = () => {
return (
<Modal
<BottomModal
onModalShow={() => ReactNativeHapticFeedback.trigger('impactLight', { ignoreAndroidSystemSettings: false })}
isVisible={isClipboardContentModalVisible}
style={styles.bottomModal}
deviceHeight={height}
onBackdropPress={hideClipboardContentModal}
onBackButtonPress={hideClipboardContentModal}
onClose={hideClipboardContentModal}
>
<KeyboardAvoidingView behavior={Platform.OS === 'ios' ? 'position' : null}>
<View style={[styles.modalContent, stylesHook.modalContent]}>
<BlueTextCentered>
You have a {clipboardContentModalAddressType} on your clipboard. Would you like to use it for a transaction?
{clipboardContentType === ClipboardContentType.BITCOIN && loc.wallets.clipboard_bitcoin}
{clipboardContentType === ClipboardContentType.LIGHTNING && loc.wallets.clipboard_lightning}
</BlueTextCentered>
<View style={styles.modelContentButtonLayout}>
<SecondButton noMinWidth title={loc._.cancel} onPress={hideClipboardContentModal} />
@ -282,7 +273,7 @@ const App = () => {
</View>
</View>
</KeyboardAvoidingView>
</Modal>
</BottomModal>
);
};
return (
@ -320,10 +311,6 @@ const styles = StyleSheet.create({
minHeight: 200,
height: 200,
},
bottomModal: {
justifyContent: 'flex-end',
margin: 0,
},
modelContentButtonLayout: {
flexDirection: 'row',
margin: 16,

View file

@ -326,14 +326,13 @@
"transactions_count": "transactions count"
},
"wallets": {
"add_bitcoin_explain": "Simple and powerful Bitcoin wallet",
"add_bitcoin": "Bitcoin",
"add_bitcoin_explain": "Simple and powerful Bitcoin wallet",
"add_create": "Create",
"add_entropy_generated": "{gen} bytes of generated entropy",
"add_entropy_provide": "Provide entropy via dice rolls",
"add_entropy_remain": "{gen} bytes of generated entropy. Remaining {rem} bytes will be obtained from the System random number generator.",
"add_import_wallet": "Import wallet",
"import_file": "Import File",
"add_lightning": "Lightning",
"add_lightning_explain": "For spending with instant transactions",
"add_lndhub": "Connect to your LNDHub",
@ -343,6 +342,8 @@
"add_title": "add wallet",
"add_wallet_name": "name",
"add_wallet_type": "type",
"clipboard_bitcoin": "You have a Bitcoin address on your clipboard. Would you like to use it for a transaction?",
"clipboard_lightning": "You have a Lightning Invoice on your clipboard. Would you like to use it for a transaction?",
"details_address": "Address",
"details_advanced": "Advanced",
"details_are_you_sure": "Are you sure?",
@ -364,15 +365,15 @@
"details_use_with_hardware_wallet": "Use with hardware wallet",
"details_wallet_updated": "Wallet updated",
"details_yes_delete": "Yes, delete",
"enter_bip38_password": "Enter password to decrypt",
"export_title": "wallet export",
"import_do_import": "Import",
"import_error": "Failed to import. Please, make sure that the provided data is valid.",
"import_explanation": "Write here your mnemonic, private key, WIF, or anything you've got. BlueWallet will do its best to guess the correct format and import your wallet",
"import_file": "Import File",
"import_imported": "Imported",
"import_scan_qr": "Scan or import a file",
"import_success": "Your wallet has been successfully imported.",
"looks_like_bip38": "This looks like password-protected private key (BIP38)",
"enter_bip38_password": "Enter password to decrypt",
"import_title": "import",
"list_create_a_button": "Add now",
"list_create_a_wallet": "Add a wallet",
@ -388,14 +389,15 @@
"list_long_choose": "Choose Photo",
"list_long_clipboard": "Copy from Clipboard",
"list_long_scan": "Scan QR Code",
"take_photo": "Take Photo",
"list_tap_here_to_buy": "Buy Bitcoin",
"list_title": "wallets",
"list_tryagain": "Try Again",
"looks_like_bip38": "This looks like password-protected private key (BIP38)",
"reorder_title": "Reorder Wallets",
"select_no_bitcoin": "There are currently no Bitcoin wallets available.",
"select_no_bitcoin_exp": "A Bitcoin wallet is required to refill Lightning wallets. Please, create or import one.",
"select_wallet": "Select Wallet",
"take_photo": "Take Photo",
"xpub_copiedToClipboard": "Copied to clipboard.",
"xpub_title": "wallet XPUB"
},