2020-06-01 14:54:23 +02:00
|
|
|
/* eslint react/prop-types: "off", react-native/no-inline-styles: "off" */
|
2021-02-27 17:46:09 +01:00
|
|
|
import React, { Component, useState, useMemo, useCallback, useContext, useRef, useEffect, forwardRef } from 'react';
|
2018-12-25 15:16:23 +01:00
|
|
|
import PropTypes from 'prop-types';
|
2020-09-22 03:53:28 +02:00
|
|
|
import { Icon, Input, Text, Header, ListItem, Avatar } from 'react-native-elements';
|
2018-12-12 04:33:28 +01:00
|
|
|
import {
|
|
|
|
ActivityIndicator,
|
2020-09-09 19:55:13 +02:00
|
|
|
Alert,
|
|
|
|
Animated,
|
2018-12-12 04:33:28 +01:00
|
|
|
Dimensions,
|
|
|
|
Image,
|
2019-01-31 07:52:21 +01:00
|
|
|
InputAccessoryView,
|
2020-09-09 19:55:13 +02:00
|
|
|
Keyboard,
|
|
|
|
KeyboardAvoidingView,
|
2021-02-25 07:51:25 +01:00
|
|
|
Linking,
|
2020-09-09 19:55:13 +02:00
|
|
|
PixelRatio,
|
2018-12-12 04:33:28 +01:00
|
|
|
Platform,
|
2020-10-08 09:55:17 +02:00
|
|
|
PlatformColor,
|
2020-09-09 19:55:13 +02:00
|
|
|
SafeAreaView,
|
|
|
|
StyleSheet,
|
2020-09-22 03:53:28 +02:00
|
|
|
Switch,
|
2018-12-23 05:13:58 +01:00
|
|
|
TextInput,
|
2020-09-09 19:55:13 +02:00
|
|
|
TouchableOpacity,
|
|
|
|
TouchableWithoutFeedback,
|
|
|
|
View,
|
2021-03-14 04:23:16 +01:00
|
|
|
InteractionManager,
|
2021-03-19 03:30:01 +01:00
|
|
|
I18nManager,
|
2018-12-12 04:33:28 +01:00
|
|
|
} from 'react-native';
|
2021-02-28 06:13:37 +01:00
|
|
|
import Clipboard from '@react-native-clipboard/clipboard';
|
2018-12-11 23:52:46 +01:00
|
|
|
import LinearGradient from 'react-native-linear-gradient';
|
2020-10-15 18:25:24 +02:00
|
|
|
import { LightningCustodianWallet, MultisigHDWallet } from './class';
|
2018-12-25 15:16:23 +01:00
|
|
|
import { BitcoinUnit } from './models/bitcoinUnits';
|
2020-06-19 02:24:26 +02:00
|
|
|
import * as NavigationService from './NavigationService';
|
2020-05-24 12:27:08 +02:00
|
|
|
import WalletGradient from './class/wallet-gradient';
|
2019-08-03 23:29:15 +02:00
|
|
|
import { BlurView } from '@react-native-community/blur';
|
2020-09-14 12:49:08 +02:00
|
|
|
import NetworkTransactionFees, { NetworkTransactionFee, NetworkTransactionFeeType } from './models/networkTransactionFees';
|
2019-09-25 05:42:21 +02:00
|
|
|
import Biometric from './class/biometrics';
|
2021-07-09 12:52:09 +02:00
|
|
|
import { encodeUR } from './blue_modules/ur';
|
2020-06-24 13:56:35 +02:00
|
|
|
import QRCode from 'react-native-qrcode-svg';
|
2020-12-16 04:15:57 +01:00
|
|
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
2020-11-28 04:06:37 +01:00
|
|
|
import { useNavigation, useTheme } from '@react-navigation/native';
|
2020-07-15 19:32:59 +02:00
|
|
|
import { BlueCurrentTheme } from './components/themes';
|
2021-02-25 17:13:34 +01:00
|
|
|
import loc, { formatBalance, formatBalanceWithoutSuffix, transactionTimeToReadable } from './loc';
|
2020-07-23 20:06:13 +02:00
|
|
|
import Lnurl from './class/lnurl';
|
2020-10-24 19:20:59 +02:00
|
|
|
import { BlueStorageContext } from './blue_modules/storage-context';
|
2021-02-10 06:18:40 +01:00
|
|
|
import ToolTipMenu from './components/TooltipMenu';
|
2021-02-25 04:09:41 +01:00
|
|
|
|
2018-05-12 22:27:34 +02:00
|
|
|
const { height, width } = Dimensions.get('window');
|
|
|
|
const aspectRatio = height / width;
|
|
|
|
let isIpad;
|
|
|
|
if (aspectRatio > 1.6) {
|
|
|
|
isIpad = false;
|
|
|
|
} else {
|
|
|
|
isIpad = true;
|
|
|
|
}
|
2020-10-07 14:24:36 +02:00
|
|
|
// eslint-disable-next-line no-unused-expressions
|
|
|
|
Platform.OS === 'android' ? (ActivityIndicator.defaultProps.color = PlatformColor('?attr/colorControlActivated')) : null;
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-10-06 19:54:35 +02:00
|
|
|
export const BlueButton = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
2020-10-10 21:19:42 +02:00
|
|
|
let backgroundColor = props.backgroundColor ? props.backgroundColor : colors.mainColor || BlueCurrentTheme.colors.mainColor;
|
2020-10-29 22:13:54 +01:00
|
|
|
let fontColor = props.buttonTextColor || colors.buttonTextColor;
|
2020-10-06 19:54:35 +02:00
|
|
|
if (props.disabled === true) {
|
|
|
|
backgroundColor = colors.buttonDisabledBackgroundColor;
|
|
|
|
fontColor = colors.buttonDisabledTextColor;
|
|
|
|
}
|
2020-10-06 12:28:06 +02:00
|
|
|
|
2020-10-06 19:54:35 +02:00
|
|
|
return (
|
|
|
|
<TouchableOpacity
|
|
|
|
style={{
|
|
|
|
flex: 1,
|
|
|
|
borderWidth: 0.7,
|
|
|
|
borderColor: 'transparent',
|
|
|
|
backgroundColor: backgroundColor,
|
|
|
|
minHeight: 45,
|
|
|
|
height: 45,
|
|
|
|
maxHeight: 45,
|
|
|
|
borderRadius: 25,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
2020-11-22 09:48:16 +01:00
|
|
|
paddingHorizontal: 16,
|
2020-10-06 19:54:35 +02:00
|
|
|
}}
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-10-06 19:54:35 +02:00
|
|
|
{...props}
|
|
|
|
>
|
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
|
|
|
|
{props.icon && <Icon name={props.icon.name} type={props.icon.type} color={props.icon.color} />}
|
2020-10-29 22:13:54 +01:00
|
|
|
{props.title && <Text style={{ marginHorizontal: 8, fontSize: 16, color: fontColor, fontWeight: '500' }}>{props.title}</Text>}
|
2020-10-06 19:54:35 +02:00
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2020-07-15 19:32:59 +02:00
|
|
|
|
2021-02-27 01:23:59 +01:00
|
|
|
export const SecondButton = forwardRef((props, ref) => {
|
2020-11-20 02:16:11 +01:00
|
|
|
const { colors } = useTheme();
|
|
|
|
let backgroundColor = props.backgroundColor ? props.backgroundColor : colors.buttonBlueBackgroundColor;
|
|
|
|
let fontColor = colors.buttonTextColor;
|
|
|
|
if (props.disabled === true) {
|
|
|
|
backgroundColor = colors.buttonDisabledBackgroundColor;
|
|
|
|
fontColor = colors.buttonDisabledTextColor;
|
2018-07-14 20:54:27 +02:00
|
|
|
}
|
2020-11-22 09:48:16 +01:00
|
|
|
|
2020-11-20 02:16:11 +01:00
|
|
|
return (
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-11-20 02:16:11 +01:00
|
|
|
style={{
|
|
|
|
flex: 1,
|
|
|
|
borderWidth: 0.7,
|
|
|
|
borderColor: 'transparent',
|
|
|
|
backgroundColor: backgroundColor,
|
|
|
|
minHeight: 45,
|
|
|
|
height: 45,
|
|
|
|
maxHeight: 45,
|
|
|
|
borderRadius: 25,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
{...props}
|
2021-02-27 01:23:59 +01:00
|
|
|
ref={ref}
|
2020-11-20 02:16:11 +01:00
|
|
|
>
|
|
|
|
<View style={{ flexDirection: 'row', justifyContent: 'center', alignItems: 'center' }}>
|
|
|
|
{props.icon && <Icon name={props.icon.name} type={props.icon.type} color={props.icon.color} />}
|
|
|
|
{props.title && <Text style={{ marginHorizontal: 8, fontSize: 16, color: fontColor }}>{props.title}</Text>}
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
2021-02-27 01:23:59 +01:00
|
|
|
});
|
2018-07-14 20:54:27 +02:00
|
|
|
|
2020-08-11 00:38:07 +02:00
|
|
|
export const BitcoinButton = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" testID={props.testID} onPress={props.onPress}>
|
2020-08-11 00:38:07 +02:00
|
|
|
<View
|
|
|
|
style={{
|
2020-10-29 22:13:54 +01:00
|
|
|
borderColor: (props.active && colors.newBlue) || colors.buttonDisabledBackgroundColor,
|
|
|
|
borderWidth: 1.5,
|
|
|
|
borderRadius: 8,
|
|
|
|
backgroundColor: colors.buttonDisabledBackgroundColor,
|
2020-08-11 00:38:07 +02:00
|
|
|
minWidth: props.style.width,
|
|
|
|
minHeight: props.style.height,
|
|
|
|
height: props.style.height,
|
|
|
|
flex: 1,
|
2020-10-29 22:13:54 +01:00
|
|
|
marginBottom: 8,
|
2018-07-14 20:54:27 +02:00
|
|
|
}}
|
|
|
|
>
|
2020-10-29 22:13:54 +01:00
|
|
|
<View style={{ marginHorizontal: 16, marginVertical: 10, flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<View>
|
|
|
|
<Image style={{ width: 34, height: 34, marginRight: 8 }} source={require('./img/addWallet/bitcoin.png')} />
|
|
|
|
</View>
|
|
|
|
<View>
|
2021-05-22 05:36:34 +02:00
|
|
|
<Text style={{ color: colors.newBlue, fontWeight: 'bold', fontSize: 18, writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr' }}>
|
|
|
|
{loc.wallets.add_bitcoin}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
color: colors.alternativeTextColor,
|
|
|
|
fontSize: 13,
|
|
|
|
fontWeight: '500',
|
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.wallets.add_bitcoin_explain}
|
|
|
|
</Text>
|
2020-10-29 22:13:54 +01:00
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const VaultButton = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" testID={props.testID} onPress={props.onPress}>
|
2020-10-29 22:13:54 +01:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
borderColor: (props.active && colors.foregroundColor) || colors.buttonDisabledBackgroundColor,
|
|
|
|
borderWidth: 1.5,
|
|
|
|
borderRadius: 8,
|
|
|
|
backgroundColor: colors.buttonDisabledBackgroundColor,
|
|
|
|
minWidth: props.style.width,
|
|
|
|
minHeight: props.style.height,
|
|
|
|
height: props.style.height,
|
|
|
|
flex: 1,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<View style={{ marginHorizontal: 16, marginVertical: 10, flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<View>
|
|
|
|
<Image style={{ width: 34, height: 34, marginRight: 8 }} source={require('./img/addWallet/vault.png')} />
|
|
|
|
</View>
|
|
|
|
<View>
|
2021-05-22 05:36:34 +02:00
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 18,
|
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.multisig.multisig_vault}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
color: colors.alternativeTextColor,
|
|
|
|
fontSize: 13,
|
|
|
|
fontWeight: '500',
|
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
|
|
}}
|
|
|
|
>
|
2020-10-29 22:13:54 +01:00
|
|
|
{loc.multisig.multisig_vault_explain}
|
|
|
|
</Text>
|
|
|
|
</View>
|
2018-07-14 20:54:27 +02:00
|
|
|
</View>
|
2020-08-11 00:38:07 +02:00
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2018-07-14 20:54:27 +02:00
|
|
|
|
2020-08-11 00:38:07 +02:00
|
|
|
export const LightningButton = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" onPress={props.onPress}>
|
2020-08-11 00:38:07 +02:00
|
|
|
<View
|
|
|
|
style={{
|
2020-10-29 22:13:54 +01:00
|
|
|
borderColor: (props.active && colors.lnborderColor) || colors.buttonDisabledBackgroundColor,
|
|
|
|
borderWidth: 1.5,
|
|
|
|
borderRadius: 8,
|
|
|
|
backgroundColor: colors.buttonDisabledBackgroundColor,
|
2020-08-11 00:38:07 +02:00
|
|
|
minWidth: props.style.width,
|
|
|
|
minHeight: props.style.height,
|
|
|
|
height: props.style.height,
|
|
|
|
flex: 1,
|
2020-10-29 22:13:54 +01:00
|
|
|
marginBottom: 8,
|
2018-07-14 20:54:27 +02:00
|
|
|
}}
|
|
|
|
>
|
2020-10-29 22:13:54 +01:00
|
|
|
<View style={{ marginHorizontal: 16, marginVertical: 10, flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<View>
|
|
|
|
<Image style={{ width: 34, height: 34, marginRight: 8 }} source={require('./img/addWallet/lightning.png')} />
|
|
|
|
</View>
|
|
|
|
<View>
|
2021-05-22 05:36:34 +02:00
|
|
|
<Text
|
|
|
|
style={{ color: colors.lnborderColor, fontWeight: 'bold', fontSize: 18, writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr' }}
|
|
|
|
>
|
|
|
|
{loc.wallets.add_lightning}
|
|
|
|
</Text>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
color: colors.alternativeTextColor,
|
|
|
|
fontSize: 13,
|
|
|
|
fontWeight: '500',
|
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.wallets.add_lightning_explain}
|
|
|
|
</Text>
|
2020-10-29 22:13:54 +01:00
|
|
|
</View>
|
2018-07-14 20:54:27 +02:00
|
|
|
</View>
|
2020-08-11 00:38:07 +02:00
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2018-07-14 20:54:27 +02:00
|
|
|
|
2019-08-04 07:01:29 +02:00
|
|
|
export class BlueWalletNavigationHeader extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
wallet: PropTypes.shape().isRequired,
|
2019-08-04 08:42:05 +02:00
|
|
|
onWalletUnitChange: PropTypes.func,
|
2019-08-04 07:01:29 +02:00
|
|
|
};
|
|
|
|
|
2021-03-14 04:23:16 +01:00
|
|
|
static getDerivedStateFromProps(props) {
|
|
|
|
return { wallet: props.wallet, onWalletUnitChange: props.onWalletUnitChange };
|
2019-08-04 07:01:29 +02:00
|
|
|
}
|
|
|
|
|
2020-10-24 19:20:59 +02:00
|
|
|
static contextType = BlueStorageContext;
|
2020-11-23 03:36:43 +01:00
|
|
|
walletBalanceText = React.createRef();
|
2021-02-10 06:18:40 +01:00
|
|
|
tooltip = React.createRef();
|
2019-08-04 07:01:29 +02:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2019-12-14 07:52:14 +01:00
|
|
|
this.state = {
|
|
|
|
wallet: props.wallet,
|
|
|
|
walletPreviousPreferredUnit: props.wallet.getPreferredBalanceUnit(),
|
2021-03-14 04:23:16 +01:00
|
|
|
allowOnchainAddress: false,
|
2019-12-14 07:52:14 +01:00
|
|
|
};
|
2019-08-04 07:01:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
handleCopyPress = _item => {
|
2020-07-20 15:38:46 +02:00
|
|
|
Clipboard.setString(formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit()).toString());
|
2019-08-04 07:01:29 +02:00
|
|
|
};
|
|
|
|
|
2021-03-14 04:23:16 +01:00
|
|
|
componentDidUpdate(prevState) {
|
|
|
|
InteractionManager.runAfterInteractions(() => {
|
|
|
|
if (prevState.wallet.getID() !== this.state.wallet.getID() && this.state.wallet.type === LightningCustodianWallet.type) {
|
|
|
|
this.verifyIfWalletAllowsOnchainAddress();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
verifyIfWalletAllowsOnchainAddress = () => {
|
2019-12-14 07:52:14 +01:00
|
|
|
if (this.state.wallet.type === LightningCustodianWallet.type) {
|
|
|
|
this.state.wallet
|
|
|
|
.allowOnchainAddress()
|
|
|
|
.then(value => this.setState({ allowOnchainAddress: value }))
|
2021-03-14 04:23:16 +01:00
|
|
|
.catch(e => {
|
|
|
|
console.log('This Lndhub wallet does not have an onchain address API.');
|
|
|
|
this.setState({ allowOnchainAddress: false });
|
|
|
|
});
|
2019-12-14 07:52:14 +01:00
|
|
|
}
|
2021-03-14 04:23:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
this.verifyIfWalletAllowsOnchainAddress();
|
2019-12-14 07:52:14 +01:00
|
|
|
}
|
|
|
|
|
2019-08-04 07:01:29 +02:00
|
|
|
handleBalanceVisibility = async _item => {
|
|
|
|
const wallet = this.state.wallet;
|
2019-09-25 05:42:21 +02:00
|
|
|
|
|
|
|
const isBiometricsEnabled = await Biometric.isBiometricUseCapableAndEnabled();
|
|
|
|
|
|
|
|
if (isBiometricsEnabled && wallet.hideBalance) {
|
|
|
|
if (!(await Biometric.unlockWithBiometrics())) {
|
|
|
|
return this.props.navigation.goBack();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-04 07:01:29 +02:00
|
|
|
wallet.hideBalance = !wallet.hideBalance;
|
|
|
|
this.setState({ wallet });
|
2020-10-24 19:20:59 +02:00
|
|
|
await this.context.saveToDisk();
|
2019-08-04 07:01:29 +02:00
|
|
|
};
|
|
|
|
|
2020-11-23 03:36:43 +01:00
|
|
|
changeWalletBalanceUnit = () => {
|
2019-08-04 07:01:29 +02:00
|
|
|
let walletPreviousPreferredUnit = this.state.wallet.getPreferredBalanceUnit();
|
|
|
|
const wallet = this.state.wallet;
|
|
|
|
if (walletPreviousPreferredUnit === BitcoinUnit.BTC) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.SATS;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.SATS) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.LOCAL_CURRENCY;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.SATS;
|
|
|
|
} else if (walletPreviousPreferredUnit === BitcoinUnit.LOCAL_CURRENCY) {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
|
|
|
} else {
|
|
|
|
wallet.preferredBalanceUnit = BitcoinUnit.BTC;
|
|
|
|
walletPreviousPreferredUnit = BitcoinUnit.BTC;
|
|
|
|
}
|
|
|
|
|
2019-08-31 08:54:11 +02:00
|
|
|
this.setState({ wallet, walletPreviousPreferredUnit: walletPreviousPreferredUnit }, () => {
|
|
|
|
this.props.onWalletUnitChange(wallet);
|
2019-08-04 08:42:05 +02:00
|
|
|
});
|
2020-11-23 03:36:43 +01:00
|
|
|
};
|
2019-08-04 07:01:29 +02:00
|
|
|
|
2019-09-29 22:01:27 +02:00
|
|
|
manageFundsPressed = () => {
|
|
|
|
this.props.onManageFundsPressed();
|
|
|
|
};
|
|
|
|
|
2021-02-10 06:18:40 +01:00
|
|
|
showToolTipMenu = () => {
|
|
|
|
this.tooltip.current.showMenu();
|
|
|
|
};
|
|
|
|
|
2019-08-04 07:01:29 +02:00
|
|
|
render() {
|
2021-02-10 07:28:40 +01:00
|
|
|
const balance =
|
|
|
|
!this.state.wallet.hideBalance &&
|
|
|
|
formatBalance(this.state.wallet.getBalance(), this.state.wallet.getPreferredBalanceUnit(), true).toString();
|
|
|
|
|
2019-08-04 07:01:29 +02:00
|
|
|
return (
|
|
|
|
<LinearGradient
|
|
|
|
colors={WalletGradient.gradientsFor(this.state.wallet.type)}
|
|
|
|
style={{ padding: 15, minHeight: 140, justifyContent: 'center' }}
|
2020-12-11 18:35:47 +01:00
|
|
|
{...WalletGradient.linearGradientProps(this.state.wallet.type)}
|
2019-08-04 07:01:29 +02:00
|
|
|
>
|
|
|
|
<Image
|
2020-10-05 23:25:14 +02:00
|
|
|
source={(() => {
|
|
|
|
switch (this.state.wallet.type) {
|
|
|
|
case LightningCustodianWallet.type:
|
2021-03-23 23:39:19 +01:00
|
|
|
return I18nManager.isRTL ? require('./img/lnd-shape-rtl.png') : require('./img/lnd-shape.png');
|
2020-10-05 23:25:14 +02:00
|
|
|
case MultisigHDWallet.type:
|
2021-03-23 23:39:19 +01:00
|
|
|
return I18nManager.isRTL ? require('./img/vault-shape-rtl.png') : require('./img/vault-shape.png');
|
2020-10-05 23:25:14 +02:00
|
|
|
default:
|
2021-03-23 23:39:19 +01:00
|
|
|
return I18nManager.isRTL ? require('./img/btc-shape-rtl.png') : require('./img/btc-shape.png');
|
2020-10-05 23:25:14 +02:00
|
|
|
}
|
|
|
|
})()}
|
2019-08-04 07:01:29 +02:00
|
|
|
style={{
|
|
|
|
width: 99,
|
|
|
|
height: 94,
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
right: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<Text
|
2021-03-02 14:38:02 +01:00
|
|
|
testID="WalletLabel"
|
2019-08-04 07:01:29 +02:00
|
|
|
numberOfLines={1}
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontSize: 19,
|
|
|
|
color: '#fff',
|
2021-03-27 11:27:36 +01:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2019-08-04 07:01:29 +02:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
{this.state.wallet.getLabel()}
|
|
|
|
</Text>
|
2021-02-10 06:18:40 +01:00
|
|
|
<ToolTipMenu
|
|
|
|
ref={this.tooltip}
|
|
|
|
anchorRef={this.walletBalanceText}
|
|
|
|
actions={
|
|
|
|
this.state.wallet.hideBalance
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
id: 'walletBalanceVisibility',
|
2021-02-10 06:23:48 +01:00
|
|
|
text: loc.transactions.details_balance_show,
|
2021-02-10 06:18:40 +01:00
|
|
|
onPress: this.handleBalanceVisibility,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: [
|
|
|
|
{
|
|
|
|
id: 'walletBalanceVisibility',
|
2021-02-10 06:23:48 +01:00
|
|
|
text: loc.transactions.details_balance_hide,
|
2021-02-10 06:18:40 +01:00
|
|
|
onPress: this.handleBalanceVisibility,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'copyToClipboard',
|
|
|
|
text: loc.transactions.details_copy,
|
2021-02-10 06:23:48 +01:00
|
|
|
onPress: this.handleCopyPress,
|
2021-02-10 06:18:40 +01:00
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
/>
|
2019-08-04 07:01:29 +02:00
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2019-08-04 07:01:29 +02:00
|
|
|
style={styles.balance}
|
2020-11-23 03:36:43 +01:00
|
|
|
onPress={this.changeWalletBalanceUnit}
|
|
|
|
ref={this.walletBalanceText}
|
2021-02-10 06:18:40 +01:00
|
|
|
onLongPress={this.showToolTipMenu}
|
2019-08-04 07:01:29 +02:00
|
|
|
>
|
|
|
|
{this.state.wallet.hideBalance ? (
|
|
|
|
<BluePrivateBalance />
|
|
|
|
) : (
|
|
|
|
<Text
|
2020-06-01 14:54:23 +02:00
|
|
|
testID="WalletBalance"
|
2021-02-10 07:28:40 +01:00
|
|
|
key={balance} // force component recreation on balance change. To fix right-to-left languages, like Farsi
|
2019-08-04 07:01:29 +02:00
|
|
|
numberOfLines={1}
|
|
|
|
adjustsFontSizeToFit
|
|
|
|
style={{
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 36,
|
|
|
|
color: '#fff',
|
2021-03-27 11:27:36 +01:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2019-08-04 07:01:29 +02:00
|
|
|
}}
|
|
|
|
>
|
2021-02-10 07:28:40 +01:00
|
|
|
{balance}
|
2019-08-04 07:01:29 +02:00
|
|
|
</Text>
|
|
|
|
)}
|
|
|
|
</TouchableOpacity>
|
2019-12-14 07:52:14 +01:00
|
|
|
{this.state.wallet.type === LightningCustodianWallet.type && this.state.allowOnchainAddress && (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" onPress={this.manageFundsPressed}>
|
2019-08-04 07:01:29 +02:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
marginTop: 14,
|
|
|
|
marginBottom: 10,
|
|
|
|
backgroundColor: 'rgba(255,255,255,0.2)',
|
|
|
|
borderRadius: 9,
|
|
|
|
minHeight: 39,
|
2020-09-28 15:13:20 +02:00
|
|
|
alignSelf: 'flex-start',
|
|
|
|
paddingHorizontal: 12,
|
2019-08-04 07:01:29 +02:00
|
|
|
height: 39,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
color: '#FFFFFF',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.lnd.title}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
)}
|
2020-12-11 18:18:10 +01:00
|
|
|
{this.state.wallet.type === MultisigHDWallet.type && (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" onPress={this.manageFundsPressed}>
|
2020-12-11 18:18:10 +01:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
marginTop: 14,
|
|
|
|
marginBottom: 10,
|
|
|
|
backgroundColor: 'rgba(255,255,255,0.2)',
|
|
|
|
borderRadius: 9,
|
|
|
|
minHeight: 39,
|
|
|
|
alignSelf: 'flex-start',
|
|
|
|
paddingHorizontal: 12,
|
|
|
|
height: 39,
|
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: 14,
|
|
|
|
color: '#FFFFFF',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.multisig.manage_keys}
|
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
)}
|
2019-08-04 07:01:29 +02:00
|
|
|
</LinearGradient>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-27 01:23:59 +01:00
|
|
|
export const BlueButtonLink = forwardRef((props, ref) => {
|
2020-07-15 19:32:59 +02:00
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-07-15 19:32:59 +02:00
|
|
|
style={{
|
|
|
|
minHeight: 60,
|
|
|
|
minWidth: 100,
|
|
|
|
justifyContent: 'center',
|
|
|
|
}}
|
2020-08-11 00:38:07 +02:00
|
|
|
{...props}
|
2021-02-27 01:23:59 +01:00
|
|
|
ref={ref}
|
2020-07-15 19:32:59 +02:00
|
|
|
>
|
2020-08-11 00:38:07 +02:00
|
|
|
<Text style={{ color: colors.foregroundColor, textAlign: 'center', fontSize: 16 }}>{props.title}</Text>
|
2020-07-15 19:32:59 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
2021-02-27 01:23:59 +01:00
|
|
|
});
|
2020-07-15 19:32:59 +02:00
|
|
|
|
2019-12-25 04:35:47 +01:00
|
|
|
export const BlueAlertWalletExportReminder = ({ onSuccess = () => {}, onFailure }) => {
|
|
|
|
Alert.alert(
|
2020-07-23 15:09:48 +02:00
|
|
|
loc.wallets.details_title,
|
|
|
|
loc.pleasebackup.ask,
|
2019-12-25 04:35:47 +01:00
|
|
|
[
|
2020-07-23 15:09:48 +02:00
|
|
|
{ text: loc.pleasebackup.ask_yes, onPress: onSuccess, style: 'cancel' },
|
|
|
|
{ text: loc.pleasebackup.ask_no, onPress: onFailure },
|
2019-12-25 04:35:47 +01:00
|
|
|
],
|
|
|
|
{ cancelable: false },
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-08-03 23:29:15 +02:00
|
|
|
export const BluePrivateBalance = () => {
|
|
|
|
return Platform.select({
|
|
|
|
ios: (
|
2020-11-23 03:36:43 +01:00
|
|
|
<View style={{ flexDirection: 'row', marginTop: 13 }}>
|
2019-08-03 23:29:15 +02:00
|
|
|
<BlurView style={styles.balanceBlur} blurType="light" blurAmount={25} />
|
|
|
|
<Icon name="eye-slash" type="font-awesome" color="#FFFFFF" />
|
|
|
|
</View>
|
|
|
|
),
|
|
|
|
android: (
|
2020-11-23 03:36:43 +01:00
|
|
|
<View style={{ flexDirection: 'row', marginTop: 13 }}>
|
2019-08-03 23:29:15 +02:00
|
|
|
<View style={{ backgroundColor: '#FFFFFF', opacity: 0.5, height: 30, width: 100, marginRight: 8 }} />
|
|
|
|
<Icon name="eye-slash" type="font-awesome" color="#FFFFFF" />
|
|
|
|
</View>
|
|
|
|
),
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-09-27 16:49:56 +02:00
|
|
|
export const BlueCopyToClipboardButton = ({ stringToCopy, displayText = false }) => {
|
2018-09-29 06:58:09 +02:00
|
|
|
return (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" onPress={() => Clipboard.setString(stringToCopy)}>
|
2020-07-20 15:38:46 +02:00
|
|
|
<Text style={{ fontSize: 13, fontWeight: '400', color: '#68bbe1' }}>{displayText || loc.transactions.details_copy}</Text>
|
2018-09-29 06:58:09 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2019-01-21 14:55:39 +01:00
|
|
|
export class BlueCopyTextToClipboard extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
text: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
text: '',
|
|
|
|
};
|
|
|
|
|
2019-02-02 04:45:18 +01:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = { hasTappedText: false, address: props.text };
|
2019-01-21 16:57:02 +01:00
|
|
|
}
|
|
|
|
|
2019-05-02 22:33:03 +02:00
|
|
|
static getDerivedStateFromProps(props, state) {
|
|
|
|
if (state.hasTappedText) {
|
|
|
|
return { hasTappedText: state.hasTappedText, address: state.address };
|
|
|
|
} else {
|
|
|
|
return { hasTappedText: state.hasTappedText, address: props.text };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-21 14:55:39 +01:00
|
|
|
copyToClipboard = () => {
|
2019-02-02 04:45:18 +01:00
|
|
|
this.setState({ hasTappedText: true }, () => {
|
2019-01-21 14:55:39 +01:00
|
|
|
Clipboard.setString(this.props.text);
|
2020-07-20 15:38:46 +02:00
|
|
|
this.setState({ address: loc.wallets.xpub_copiedToClipboard }, () => {
|
2019-02-02 04:45:18 +01:00
|
|
|
setTimeout(() => {
|
|
|
|
this.setState({ hasTappedText: false, address: this.props.text });
|
|
|
|
}, 1000);
|
|
|
|
});
|
2019-01-21 14:55:39 +01:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<View style={{ justifyContent: 'center', alignItems: 'center', paddingHorizontal: 16 }}>
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity
|
|
|
|
accessibilityRole="button"
|
|
|
|
onPress={this.copyToClipboard}
|
|
|
|
disabled={this.state.hasTappedText}
|
|
|
|
testID="BlueCopyTextToClipboard"
|
|
|
|
>
|
2019-02-02 04:45:18 +01:00
|
|
|
<Animated.Text style={styleCopyTextToClipboard.address} numberOfLines={0}>
|
|
|
|
{this.state.address}
|
|
|
|
</Animated.Text>
|
2019-01-21 14:55:39 +01:00
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const styleCopyTextToClipboard = StyleSheet.create({
|
|
|
|
address: {
|
|
|
|
marginVertical: 32,
|
|
|
|
fontSize: 15,
|
2019-04-01 10:21:53 +02:00
|
|
|
color: '#9aa0aa',
|
2019-01-21 14:55:39 +01:00
|
|
|
textAlign: 'center',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-11-25 04:03:11 +01:00
|
|
|
export const SafeBlueArea = props => {
|
2021-03-22 12:54:17 +01:00
|
|
|
const { style, ...nonStyleProps } = props;
|
2020-11-25 04:03:11 +01:00
|
|
|
const { colors } = useTheme();
|
2021-03-23 23:39:19 +01:00
|
|
|
const baseStyle = { flex: 1, backgroundColor: colors.background };
|
2021-03-22 12:54:17 +01:00
|
|
|
return <SafeAreaView forceInset={{ horizontal: 'always' }} style={[baseStyle, style]} {...nonStyleProps} />;
|
2020-11-25 04:03:11 +01:00
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueCard = props => {
|
|
|
|
return <View {...props} style={{ padding: 20 }} />;
|
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-11-22 09:04:04 +01:00
|
|
|
export const BlueText = props => {
|
2020-07-15 19:32:59 +02:00
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
|
|
|
<Text
|
2021-04-05 01:50:36 +02:00
|
|
|
{...props}
|
2020-07-15 19:32:59 +02:00
|
|
|
style={{
|
2021-04-05 01:50:36 +02:00
|
|
|
color: colors.foregroundColor,
|
2021-05-22 05:36:34 +02:00
|
|
|
|
2021-04-06 01:33:55 +02:00
|
|
|
...props.style,
|
2021-05-22 05:36:34 +02:00
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
2020-07-15 19:32:59 +02:00
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-11-25 04:01:51 +01:00
|
|
|
export const BlueTextCentered = props => {
|
2020-08-11 00:38:07 +02:00
|
|
|
const { colors } = useTheme();
|
|
|
|
return <Text {...props} style={{ color: colors.foregroundColor, textAlign: 'center' }} />;
|
|
|
|
};
|
|
|
|
|
2020-09-22 03:53:28 +02:00
|
|
|
export const BlueListItem = React.memo(props => {
|
2020-07-15 19:32:59 +02:00
|
|
|
const { colors } = useTheme();
|
2021-03-16 03:07:52 +01:00
|
|
|
|
2020-07-15 19:32:59 +02:00
|
|
|
return (
|
|
|
|
<ListItem
|
2020-09-22 03:53:28 +02:00
|
|
|
containerStyle={props.containerStyle ?? { backgroundColor: 'transparent' }}
|
|
|
|
Component={props.Component ?? TouchableOpacity}
|
2020-10-29 22:13:54 +01:00
|
|
|
bottomDivider={props.bottomDivider !== undefined ? props.bottomDivider : true}
|
|
|
|
topDivider={props.topDivider !== undefined ? props.topDivider : false}
|
2020-09-22 03:53:28 +02:00
|
|
|
testID={props.testID}
|
|
|
|
onPress={props.onPress}
|
2021-02-25 04:09:41 +01:00
|
|
|
onLongPress={props.onLongPress}
|
2020-11-10 01:51:27 +01:00
|
|
|
disabled={props.disabled}
|
2021-03-16 03:07:52 +01:00
|
|
|
accessible={props.switch === undefined}
|
2020-09-22 03:53:28 +02:00
|
|
|
>
|
|
|
|
{props.leftAvatar && <Avatar>{props.leftAvatar}</Avatar>}
|
|
|
|
{props.leftIcon && <Avatar icon={props.leftIcon} />}
|
|
|
|
<ListItem.Content>
|
|
|
|
<ListItem.Title
|
|
|
|
style={{
|
|
|
|
color: props.disabled ? colors.buttonDisabledTextColor : colors.foregroundColor,
|
|
|
|
fontSize: 16,
|
|
|
|
fontWeight: '500',
|
|
|
|
}}
|
|
|
|
numberOfLines={0}
|
2021-03-16 03:07:52 +01:00
|
|
|
accessible={props.switch === undefined}
|
2020-09-22 03:53:28 +02:00
|
|
|
>
|
|
|
|
{props.title}
|
|
|
|
</ListItem.Title>
|
|
|
|
{props.subtitle && (
|
|
|
|
<ListItem.Subtitle
|
2021-02-27 00:26:18 +01:00
|
|
|
numberOfLines={props.subtitleNumberOfLines ?? 1}
|
2021-03-16 03:07:52 +01:00
|
|
|
accessible={props.switch === undefined}
|
2020-09-22 03:53:28 +02:00
|
|
|
style={{ flexWrap: 'wrap', color: colors.alternativeTextColor, fontWeight: '400', fontSize: 14 }}
|
|
|
|
>
|
|
|
|
{props.subtitle}
|
|
|
|
</ListItem.Subtitle>
|
|
|
|
)}
|
|
|
|
</ListItem.Content>
|
|
|
|
<ListItem.Content right>
|
|
|
|
{props.rightTitle && (
|
|
|
|
<ListItem.Title style={props.rightTitleStyle} numberOfLines={0} right>
|
|
|
|
{props.rightTitle}
|
|
|
|
</ListItem.Title>
|
|
|
|
)}
|
|
|
|
</ListItem.Content>
|
2020-10-10 21:19:42 +02:00
|
|
|
{props.isLoading ? (
|
|
|
|
<ActivityIndicator />
|
|
|
|
) : (
|
|
|
|
<>
|
2021-03-19 03:30:01 +01:00
|
|
|
{props.chevron && <ListItem.Chevron iconStyle={{ transform: [{ scaleX: I18nManager.isRTL ? -1 : 1 }] }} />}
|
2020-10-10 21:19:42 +02:00
|
|
|
{props.rightIcon && <Avatar icon={props.rightIcon} />}
|
2021-03-16 03:07:52 +01:00
|
|
|
{props.switch && <Switch {...props.switch} accessibilityLabel={props.title} accessible accessibilityRole="switch" />}
|
2020-10-29 22:13:54 +01:00
|
|
|
{props.checkmark && <ListItem.CheckBox iconType="octaicon" checkedColor="#0070FF" checkedIcon="check" checked />}
|
2020-10-10 21:19:42 +02:00
|
|
|
</>
|
|
|
|
)}
|
2020-09-22 03:53:28 +02:00
|
|
|
</ListItem>
|
2020-07-15 19:32:59 +02:00
|
|
|
);
|
2020-09-22 03:53:28 +02:00
|
|
|
});
|
2020-07-15 19:32:59 +02:00
|
|
|
|
2020-08-11 00:38:07 +02:00
|
|
|
export const BlueFormLabel = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
2021-05-22 05:36:34 +02:00
|
|
|
return (
|
|
|
|
<Text
|
|
|
|
{...props}
|
|
|
|
style={{
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
fontWeight: '400',
|
|
|
|
marginHorizontal: 20,
|
|
|
|
writingDirection: I18nManager.isRTL ? 'rtl' : 'ltr',
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
2020-08-11 00:38:07 +02:00
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueFormInput = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
return (
|
|
|
|
<Input
|
|
|
|
{...props}
|
|
|
|
inputStyle={{ color: colors.foregroundColor, maxWidth: width - 105 }}
|
|
|
|
containerStyle={{
|
|
|
|
marginTop: 5,
|
|
|
|
borderColor: colors.inputBorderColor,
|
|
|
|
borderBottomColor: colors.inputBorderColor,
|
|
|
|
borderWidth: 0.5,
|
|
|
|
borderBottomWidth: 0.5,
|
|
|
|
backgroundColor: colors.inputBackgroundColor,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-07-22 16:49:59 +02:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueFormMultiInput = props => {
|
|
|
|
const { colors } = useTheme();
|
2019-02-28 01:45:44 +01:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
return (
|
|
|
|
<TextInput
|
|
|
|
multiline
|
|
|
|
underlineColorAndroid="transparent"
|
|
|
|
numberOfLines={4}
|
|
|
|
style={{
|
|
|
|
paddingHorizontal: 8,
|
|
|
|
paddingVertical: 16,
|
|
|
|
flex: 1,
|
|
|
|
marginTop: 5,
|
|
|
|
marginHorizontal: 20,
|
|
|
|
borderColor: colors.formBorder,
|
|
|
|
borderBottomColor: colors.formBorder,
|
|
|
|
borderWidth: 1,
|
|
|
|
borderBottomWidth: 0.5,
|
|
|
|
borderRadius: 4,
|
|
|
|
backgroundColor: colors.inputBackgroundColor,
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
textAlignVertical: 'top',
|
|
|
|
}}
|
|
|
|
autoCorrect={false}
|
|
|
|
autoCapitalize="none"
|
|
|
|
spellCheck={false}
|
|
|
|
{...props}
|
|
|
|
selectTextOnFocus={false}
|
|
|
|
keyboardType={Platform.OS === 'android' ? 'visible-password' : 'default'}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-05-06 19:12:14 +02:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueHeader = props => {
|
|
|
|
return (
|
|
|
|
<Header
|
|
|
|
{...props}
|
|
|
|
backgroundColor="transparent"
|
|
|
|
outerContainerStyles={{
|
|
|
|
borderBottomColor: 'transparent',
|
|
|
|
borderBottomWidth: 0,
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export const BlueHeaderDefaultSub = props => {
|
|
|
|
const { colors } = useTheme();
|
2020-07-15 19:32:59 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<SafeAreaView>
|
|
|
|
<Header
|
|
|
|
backgroundColor={colors.background}
|
|
|
|
leftContainerStyle={{ minWidth: '100%' }}
|
|
|
|
outerContainerStyles={{
|
|
|
|
borderBottomColor: 'transparent',
|
|
|
|
borderBottomWidth: 0,
|
|
|
|
}}
|
|
|
|
leftComponent={
|
|
|
|
<Text
|
|
|
|
adjustsFontSizeToFit
|
|
|
|
style={{
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 30,
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{props.leftText}
|
|
|
|
</Text>
|
|
|
|
}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
</SafeAreaView>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2020-09-25 15:17:09 +02:00
|
|
|
export const BlueHeaderDefaultMain = props => {
|
|
|
|
const { colors } = useTheme();
|
2020-10-07 22:53:50 +02:00
|
|
|
const { isDrawerList } = props;
|
2021-07-18 17:54:43 +02:00
|
|
|
const { isImportingWallet } = useContext(BlueStorageContext);
|
2020-09-25 15:17:09 +02:00
|
|
|
return (
|
|
|
|
<Header
|
|
|
|
leftComponent={{
|
|
|
|
text: props.leftText,
|
|
|
|
style: {
|
|
|
|
fontWeight: 'bold',
|
|
|
|
fontSize: 34,
|
|
|
|
color: colors.foregroundColor,
|
|
|
|
paddingHorizontal: 4,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
placement="left"
|
|
|
|
containerStyle={{
|
2020-10-07 22:53:50 +02:00
|
|
|
borderTopColor: isDrawerList ? colors.elevated : colors.background,
|
|
|
|
borderBottomColor: isDrawerList ? colors.elevated : colors.background,
|
2020-09-25 15:17:09 +02:00
|
|
|
maxHeight: 44,
|
|
|
|
height: 44,
|
|
|
|
paddingTop: 0,
|
|
|
|
marginBottom: 8,
|
|
|
|
}}
|
|
|
|
bottomDivider={false}
|
|
|
|
topDivider={false}
|
2020-10-07 22:53:50 +02:00
|
|
|
backgroundColor={isDrawerList ? colors.elevated : colors.background}
|
2021-07-18 17:54:43 +02:00
|
|
|
rightComponent={isImportingWallet ? undefined : <BluePlusIcon onPress={props.onNewWalletPress} Component={TouchableOpacity} />}
|
2020-09-25 15:17:09 +02:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueSpacing = props => {
|
|
|
|
return <View {...props} style={{ height: 60 }} />;
|
|
|
|
};
|
2018-06-29 00:17:14 +02:00
|
|
|
|
2020-11-28 04:24:20 +01:00
|
|
|
export const BlueSpacing40 = props => {
|
|
|
|
return <View {...props} style={{ height: 50 }} />;
|
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-12-11 05:17:55 +01:00
|
|
|
export const BlueSpacingVariable = props => {
|
|
|
|
if (isIpad) {
|
|
|
|
return <BlueSpacing40 {...props} />;
|
|
|
|
} else {
|
|
|
|
return <BlueSpacing {...props} />;
|
2018-06-29 00:17:14 +02:00
|
|
|
}
|
2020-12-11 05:17:55 +01:00
|
|
|
};
|
2018-06-29 00:17:14 +02:00
|
|
|
|
|
|
|
export class is {
|
|
|
|
static ipad() {
|
|
|
|
return isIpad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 04:24:20 +01:00
|
|
|
export const BlueSpacing20 = props => {
|
|
|
|
return <View {...props} style={{ height: 20, opacity: 0 }} />;
|
|
|
|
};
|
2018-06-25 00:22:46 +02:00
|
|
|
|
2020-11-28 04:24:20 +01:00
|
|
|
export const BlueSpacing10 = props => {
|
|
|
|
return <View {...props} style={{ height: 10, opacity: 0 }} />;
|
|
|
|
};
|
2019-05-22 14:08:31 +02:00
|
|
|
|
2020-12-11 05:17:55 +01:00
|
|
|
export const BlueDismissKeyboardInputAccessory = () => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
BlueDismissKeyboardInputAccessory.InputAccessoryViewID = 'BlueDismissKeyboardInputAccessory';
|
2019-08-29 06:18:32 +02:00
|
|
|
|
2020-12-11 05:17:55 +01:00
|
|
|
return Platform.OS !== 'ios' ? null : (
|
|
|
|
<InputAccessoryView nativeID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}>
|
2019-08-29 06:18:32 +02:00
|
|
|
<View
|
|
|
|
style={{
|
2020-12-11 05:17:55 +01:00
|
|
|
backgroundColor: colors.inputBackgroundColor,
|
|
|
|
height: 44,
|
|
|
|
flex: 1,
|
2019-08-29 06:18:32 +02:00
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
alignItems: 'center',
|
|
|
|
}}
|
|
|
|
>
|
2020-12-11 05:17:55 +01:00
|
|
|
<BlueButtonLink title={loc.send.input_done} onPress={Keyboard.dismiss} />
|
2019-08-29 06:18:32 +02:00
|
|
|
</View>
|
2020-12-11 05:17:55 +01:00
|
|
|
</InputAccessoryView>
|
|
|
|
);
|
|
|
|
};
|
2019-08-29 06:18:32 +02:00
|
|
|
|
2020-12-11 05:17:55 +01:00
|
|
|
export const BlueDoneAndDismissKeyboardInputAccessory = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID = 'BlueDoneAndDismissKeyboardInputAccessory';
|
|
|
|
|
|
|
|
const onPasteTapped = async () => {
|
|
|
|
const clipboard = await Clipboard.getString();
|
|
|
|
props.onPasteTapped(clipboard);
|
|
|
|
};
|
|
|
|
|
|
|
|
const inputView = (
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
backgroundColor: colors.inputBackgroundColor,
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'flex-end',
|
|
|
|
alignItems: 'center',
|
|
|
|
maxHeight: 44,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<BlueButtonLink title={loc.send.input_clear} onPress={props.onClearTapped} />
|
|
|
|
<BlueButtonLink title={loc.send.input_paste} onPress={onPasteTapped} />
|
|
|
|
<BlueButtonLink title={loc.send.input_done} onPress={Keyboard.dismiss} />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return <InputAccessoryView nativeID={BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID}>{inputView}</InputAccessoryView>;
|
|
|
|
} else {
|
|
|
|
return <KeyboardAvoidingView>{inputView}</KeyboardAvoidingView>;
|
2019-08-29 06:18:32 +02:00
|
|
|
}
|
2020-12-11 05:17:55 +01:00
|
|
|
};
|
2019-08-29 06:18:32 +02:00
|
|
|
|
2020-11-30 05:18:54 +01:00
|
|
|
export const BlueLoading = props => {
|
2020-07-15 19:32:59 +02:00
|
|
|
return (
|
2021-04-29 16:32:48 +02:00
|
|
|
<View style={{ flex: 1, justifyContent: 'center' }} {...props}>
|
2020-07-15 19:32:59 +02:00
|
|
|
<ActivityIndicator />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2018-06-25 00:22:46 +02:00
|
|
|
const stylesBlueIcon = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
},
|
|
|
|
box1: {
|
|
|
|
position: 'relative',
|
|
|
|
top: 15,
|
|
|
|
},
|
2018-06-28 03:43:28 +02:00
|
|
|
box: {
|
2018-09-19 03:59:16 +02:00
|
|
|
alignSelf: 'flex-end',
|
|
|
|
paddingHorizontal: 14,
|
|
|
|
paddingTop: 8,
|
2018-06-28 03:43:28 +02:00
|
|
|
},
|
2019-01-31 07:52:21 +01:00
|
|
|
boxIncoming: {
|
2018-06-25 00:22:46 +02:00
|
|
|
position: 'relative',
|
|
|
|
},
|
|
|
|
ball: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
|
|
|
},
|
2019-01-31 07:52:21 +01:00
|
|
|
ballIncoming: {
|
2018-06-25 00:22:46 +02:00
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
2018-12-31 23:29:36 +01:00
|
|
|
transform: [{ rotate: '-45deg' }],
|
2020-05-03 20:17:49 +02:00
|
|
|
justifyContent: 'center',
|
2018-12-31 23:29:36 +01:00
|
|
|
},
|
2019-01-31 07:52:21 +01:00
|
|
|
ballIncomingWithoutRotate: {
|
2018-12-31 23:29:36 +01:00
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
2018-06-25 00:22:46 +02:00
|
|
|
},
|
|
|
|
ballReceive: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderBottomLeftRadius: 15,
|
|
|
|
transform: [{ rotate: '-45deg' }],
|
|
|
|
},
|
|
|
|
ballOutgoing: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
2018-12-31 23:29:36 +01:00
|
|
|
transform: [{ rotate: '225deg' }],
|
2020-05-03 20:17:49 +02:00
|
|
|
justifyContent: 'center',
|
2018-06-25 00:22:46 +02:00
|
|
|
},
|
2018-12-28 22:43:38 +01:00
|
|
|
ballOutgoingWithoutRotate: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
|
|
|
},
|
2020-03-29 17:33:37 +02:00
|
|
|
ballOutgoingExpired: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
2020-05-03 20:17:49 +02:00
|
|
|
justifyContent: 'center',
|
2020-03-29 17:33:37 +02:00
|
|
|
},
|
2018-06-25 00:22:46 +02:00
|
|
|
ballTransparrent: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
},
|
|
|
|
ballDimmed: {
|
|
|
|
width: 30,
|
|
|
|
height: 30,
|
|
|
|
borderRadius: 15,
|
|
|
|
backgroundColor: 'gray',
|
|
|
|
},
|
|
|
|
});
|
2020-09-09 01:36:35 +02:00
|
|
|
|
|
|
|
export const BluePlusIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ball: {
|
|
|
|
backgroundColor: colors.buttonBackgroundColor,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
2020-09-25 15:17:09 +02:00
|
|
|
<Avatar
|
|
|
|
rounded
|
|
|
|
containerStyle={[stylesBlueIcon.ball, stylesBlueIconHooks.ball]}
|
|
|
|
icon={{ name: 'add', size: 22, type: 'ionicons', color: colors.foregroundColor }}
|
|
|
|
{...props}
|
|
|
|
/>
|
2020-09-09 01:36:35 +02:00
|
|
|
);
|
|
|
|
};
|
2018-01-30 23:42:38 +01:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionIncomingIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballIncoming: {
|
|
|
|
backgroundColor: colors.ballReceive,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballIncoming, stylesBlueIconHooks.ballIncoming]}>
|
|
|
|
<Icon {...props} name="arrow-down" size={16} type="font-awesome" color={colors.incomingForegroundColor} />
|
2018-01-30 23:42:38 +01:00
|
|
|
</View>
|
2018-06-25 00:22:46 +02:00
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-06-25 00:22:46 +02:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionPendingIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ball: {
|
|
|
|
backgroundColor: colors.buttonBackgroundColor,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ball, stylesBlueIconHooks.ball]}>
|
|
|
|
<Icon
|
|
|
|
{...props}
|
|
|
|
name="kebab-horizontal"
|
|
|
|
size={16}
|
|
|
|
type="octicon"
|
|
|
|
color={colors.foregroundColor}
|
|
|
|
iconStyle={{ left: 0, top: 7 }}
|
|
|
|
/>
|
2018-06-25 00:22:46 +02:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-06-25 00:22:46 +02:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionExpiredIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballOutgoingExpired: {
|
|
|
|
backgroundColor: colors.ballOutgoingExpired,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballOutgoingExpired, stylesBlueIconHooks.ballOutgoingExpired]}>
|
|
|
|
<Icon {...props} name="clock" size={16} type="octicon" color="#9AA0AA" iconStyle={{ left: 0, top: 0 }} />
|
2018-12-28 22:43:38 +01:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-12-28 22:43:38 +01:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionOnchainIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballIncoming: {
|
|
|
|
backgroundColor: colors.ballReceive,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballIncoming, stylesBlueIconHooks.ballIncoming]}>
|
|
|
|
<Icon
|
|
|
|
{...props}
|
|
|
|
name="link"
|
|
|
|
size={16}
|
|
|
|
type="font-awesome"
|
|
|
|
color={colors.incomingForegroundColor}
|
|
|
|
iconStyle={{ left: 0, top: 0, transform: [{ rotate: '-45deg' }] }}
|
|
|
|
/>
|
2018-09-01 01:28:19 +02:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-09-01 01:28:19 +02:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionOffchainIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballOutgoingWithoutRotate: {
|
|
|
|
backgroundColor: colors.ballOutgoing,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballOutgoingWithoutRotate, stylesBlueIconHooks.ballOutgoingWithoutRotate]}>
|
|
|
|
<Icon
|
|
|
|
{...props}
|
|
|
|
name="bolt"
|
|
|
|
size={16}
|
|
|
|
type="font-awesome"
|
|
|
|
color={colors.outgoingForegroundColor}
|
|
|
|
iconStyle={{ left: 0, marginTop: 6 }}
|
|
|
|
/>
|
2018-09-05 00:18:24 +02:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-09-05 00:18:24 +02:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionOffchainIncomingIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballIncomingWithoutRotate: {
|
|
|
|
backgroundColor: colors.ballReceive,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballIncomingWithoutRotate, stylesBlueIconHooks.ballIncomingWithoutRotate]}>
|
|
|
|
<Icon
|
|
|
|
{...props}
|
|
|
|
name="bolt"
|
|
|
|
size={16}
|
|
|
|
type="font-awesome"
|
|
|
|
color={colors.incomingForegroundColor}
|
|
|
|
iconStyle={{ left: 0, marginTop: 6 }}
|
|
|
|
/>
|
2018-09-05 00:18:24 +02:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-09-05 00:18:24 +02:00
|
|
|
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueTransactionOutgoingIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
const stylesBlueIconHooks = StyleSheet.create({
|
|
|
|
ballOutgoing: {
|
|
|
|
backgroundColor: colors.ballOutgoing,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return (
|
|
|
|
<View {...props}>
|
|
|
|
<View style={stylesBlueIcon.boxIncoming}>
|
|
|
|
<View style={[stylesBlueIcon.ballOutgoing, stylesBlueIconHooks.ballOutgoing]}>
|
|
|
|
<Icon {...props} name="arrow-down" size={16} type="font-awesome" color={colors.outgoingForegroundColor} />
|
2018-06-25 00:22:46 +02:00
|
|
|
</View>
|
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
};
|
2018-06-25 00:22:46 +02:00
|
|
|
|
2020-08-21 00:50:38 +02:00
|
|
|
const sendReceiveScanButtonFontSize =
|
|
|
|
PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26) > 22
|
|
|
|
? 22
|
|
|
|
: PixelRatio.roundToNearestPixel(Dimensions.get('window').width / 26);
|
2020-09-09 01:36:35 +02:00
|
|
|
export const BlueReceiveButtonIcon = props => {
|
|
|
|
const { colors } = useTheme();
|
|
|
|
|
|
|
|
return (
|
2021-06-24 14:50:57 +02:00
|
|
|
<TouchableOpacity accessibilityRole="button" {...props} style={{ flex: 1 }}>
|
2020-09-09 01:36:35 +02:00
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
flex: 1,
|
|
|
|
backgroundColor: colors.buttonBackgroundColor,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<View style={{ flex: 1, flexDirection: 'row', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
left: 5,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
transform: [{ rotate: '-45deg' }],
|
|
|
|
alignItems: 'center',
|
|
|
|
marginRight: 8,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Icon
|
|
|
|
{...props}
|
|
|
|
name="arrow-down"
|
|
|
|
size={sendReceiveScanButtonFontSize}
|
|
|
|
type="font-awesome"
|
|
|
|
color={colors.buttonAlternativeTextColor}
|
|
|
|
/>
|
2018-06-25 00:22:46 +02:00
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
<Text
|
|
|
|
style={{
|
|
|
|
color: colors.buttonAlternativeTextColor,
|
|
|
|
fontWeight: '500',
|
|
|
|
fontSize: sendReceiveScanButtonFontSize,
|
|
|
|
left: 5,
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{loc.receive.header}
|
|
|
|
</Text>
|
2018-06-25 00:22:46 +02:00
|
|
|
</View>
|
2020-09-09 01:36:35 +02:00
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
);
|
|
|
|
};
|
2018-06-25 00:22:46 +02:00
|
|
|
|
2021-02-10 18:41:51 +01:00
|
|
|
export const BlueTransactionListItem = React.memo(({ item, itemPriceUnit = BitcoinUnit.BTC, timeElapsed }) => {
|
2019-12-28 17:22:43 +01:00
|
|
|
const [subtitleNumberOfLines, setSubtitleNumberOfLines] = useState(1);
|
2020-09-09 01:36:35 +02:00
|
|
|
const { colors } = useTheme();
|
2020-11-28 04:06:37 +01:00
|
|
|
const { navigate } = useNavigation();
|
2020-12-13 11:00:34 +01:00
|
|
|
const { txMetadata, wallets, preferredFiatCurrency, language } = useContext(BlueStorageContext);
|
2020-09-23 08:30:14 +02:00
|
|
|
const containerStyle = useMemo(
|
|
|
|
() => ({
|
|
|
|
backgroundColor: 'transparent',
|
|
|
|
borderBottomColor: colors.lightBorder,
|
|
|
|
paddingTop: 16,
|
|
|
|
paddingBottom: 16,
|
2020-10-14 10:22:51 +02:00
|
|
|
paddingRight: 0,
|
2020-09-23 08:30:14 +02:00
|
|
|
}),
|
|
|
|
[colors.lightBorder],
|
|
|
|
);
|
2021-02-25 04:09:41 +01:00
|
|
|
const toolTip = useRef();
|
2021-02-26 03:37:28 +01:00
|
|
|
const copyToolTip = useRef();
|
2021-02-25 04:09:41 +01:00
|
|
|
const listItemRef = useRef();
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2020-11-11 04:27:37 +01:00
|
|
|
const title = useMemo(() => {
|
|
|
|
if (item.confirmations === 0) {
|
|
|
|
return loc.transactions.pending;
|
|
|
|
} else {
|
|
|
|
return transactionTimeToReadable(item.received);
|
|
|
|
}
|
2020-12-13 11:00:34 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [item.confirmations, item.received, language]);
|
2020-10-24 19:20:59 +02:00
|
|
|
const txMemo = txMetadata[item.hash]?.memo ?? '';
|
2020-09-23 08:30:14 +02:00
|
|
|
const subtitle = useMemo(() => {
|
|
|
|
let sub = item.confirmations < 7 ? loc.formatString(loc.transactions.list_conf, { number: item.confirmations }) : '';
|
|
|
|
if (sub !== '') sub += ' ';
|
|
|
|
sub += txMemo;
|
|
|
|
if (item.memo) sub += item.memo;
|
|
|
|
return sub || null;
|
|
|
|
}, [txMemo, item.confirmations, item.memo]);
|
|
|
|
|
|
|
|
const rowTitle = useMemo(() => {
|
2019-01-30 03:13:45 +01:00
|
|
|
if (item.type === 'user_invoice' || item.type === 'payment_request') {
|
|
|
|
if (isNaN(item.value)) {
|
|
|
|
item.value = '0';
|
|
|
|
}
|
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
|
|
|
const invoiceExpiration = item.timestamp + item.expire_time;
|
|
|
|
|
|
|
|
if (invoiceExpiration > now) {
|
2020-07-20 15:38:46 +02:00
|
|
|
return formatBalanceWithoutSuffix(item.value && item.value, itemPriceUnit, true).toString();
|
2019-01-30 03:13:45 +01:00
|
|
|
} else if (invoiceExpiration < now) {
|
|
|
|
if (item.ispaid) {
|
2020-07-20 15:38:46 +02:00
|
|
|
return formatBalanceWithoutSuffix(item.value && item.value, itemPriceUnit, true).toString();
|
2019-01-30 03:13:45 +01:00
|
|
|
} else {
|
|
|
|
return loc.lnd.expired;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2020-07-20 15:38:46 +02:00
|
|
|
return formatBalanceWithoutSuffix(item.value && item.value, itemPriceUnit, true).toString();
|
2019-01-30 03:13:45 +01:00
|
|
|
}
|
2020-12-13 02:33:42 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [item, itemPriceUnit, preferredFiatCurrency]);
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2020-09-23 08:30:14 +02:00
|
|
|
const rowTitleStyle = useMemo(() => {
|
2020-09-09 01:36:35 +02:00
|
|
|
let color = colors.successColor;
|
2019-01-30 03:13:45 +01:00
|
|
|
|
|
|
|
if (item.type === 'user_invoice' || item.type === 'payment_request') {
|
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
|
|
|
const invoiceExpiration = item.timestamp + item.expire_time;
|
|
|
|
|
|
|
|
if (invoiceExpiration > now) {
|
2020-09-09 01:36:35 +02:00
|
|
|
color = colors.successColor;
|
2019-01-30 03:13:45 +01:00
|
|
|
} else if (invoiceExpiration < now) {
|
|
|
|
if (item.ispaid) {
|
2020-09-09 01:36:35 +02:00
|
|
|
color = colors.successColor;
|
2019-01-30 03:13:45 +01:00
|
|
|
} else {
|
2020-03-29 17:33:37 +02:00
|
|
|
color = '#9AA0AA';
|
2019-01-30 03:13:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (item.value / 100000000 < 0) {
|
2020-09-09 01:36:35 +02:00
|
|
|
color = colors.foregroundColor;
|
2019-01-30 03:13:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2020-09-23 08:30:14 +02:00
|
|
|
color,
|
2020-05-14 20:44:23 +02:00
|
|
|
fontSize: 14,
|
2020-09-23 08:30:14 +02:00
|
|
|
fontWeight: '600',
|
2020-05-14 20:44:23 +02:00
|
|
|
textAlign: 'right',
|
|
|
|
width: 96,
|
2019-01-30 03:13:45 +01:00
|
|
|
};
|
2020-09-23 08:30:14 +02:00
|
|
|
}, [item, colors.foregroundColor, colors.successColor]);
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2020-09-23 08:30:14 +02:00
|
|
|
const avatar = useMemo(() => {
|
2019-01-30 03:13:45 +01:00
|
|
|
// is it lightning refill tx?
|
2019-10-10 02:22:10 +02:00
|
|
|
if (item.category === 'receive' && item.confirmations < 3) {
|
2019-01-30 03:13:45 +01:00
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionPendingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-10 02:22:10 +02:00
|
|
|
if (item.type && item.type === 'bitcoind_tx') {
|
2019-01-30 03:13:45 +01:00
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOnchainIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2019-10-10 02:22:10 +02:00
|
|
|
if (item.type === 'paid_invoice') {
|
2019-01-30 03:13:45 +01:00
|
|
|
// is it lightning offchain payment?
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOffchainIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-10-10 02:22:10 +02:00
|
|
|
if (item.type === 'user_invoice' || item.type === 'payment_request') {
|
|
|
|
if (!item.ispaid) {
|
2019-01-30 03:13:45 +01:00
|
|
|
const currentDate = new Date();
|
|
|
|
const now = (currentDate.getTime() / 1000) | 0;
|
2019-10-10 02:22:10 +02:00
|
|
|
const invoiceExpiration = item.timestamp + item.expire_time;
|
2019-01-30 03:13:45 +01:00
|
|
|
if (invoiceExpiration < now) {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionExpiredIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOffchainIncomingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-10 02:22:10 +02:00
|
|
|
if (!item.confirmations) {
|
2019-01-30 03:13:45 +01:00
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionPendingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
2019-10-10 02:22:10 +02:00
|
|
|
} else if (item.value < 0) {
|
2019-01-30 03:13:45 +01:00
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
|
|
|
<BlueTransactionOutgoingIcon />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<View style={{ width: 25 }}>
|
2019-01-31 07:52:21 +01:00
|
|
|
<BlueTransactionIncomingIcon />
|
2019-01-30 03:13:45 +01:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2020-09-23 08:30:14 +02:00
|
|
|
}, [item]);
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2021-02-27 00:26:18 +01:00
|
|
|
useEffect(() => {
|
|
|
|
setSubtitleNumberOfLines(1);
|
|
|
|
}, [subtitle]);
|
|
|
|
|
2020-09-23 08:30:14 +02:00
|
|
|
const onPress = useCallback(async () => {
|
2019-10-10 02:22:10 +02:00
|
|
|
if (item.hash) {
|
2021-02-10 18:41:51 +01:00
|
|
|
navigate('TransactionStatus', { hash: item.hash });
|
2019-10-10 02:22:10 +02:00
|
|
|
} else if (item.type === 'user_invoice' || item.type === 'payment_request' || item.type === 'paid_invoice') {
|
2021-06-17 23:24:00 +02:00
|
|
|
const lightningWallet = wallets.filter(wallet => wallet?.getID() === item.walletID);
|
2021-02-10 18:41:51 +01:00
|
|
|
if (lightningWallet.length === 1) {
|
|
|
|
try {
|
|
|
|
// is it a successful lnurl-pay?
|
|
|
|
const LN = new Lnurl(false, AsyncStorage);
|
|
|
|
let paymentHash = item.payment_hash;
|
|
|
|
if (typeof paymentHash === 'object') {
|
|
|
|
paymentHash = Buffer.from(paymentHash.data).toString('hex');
|
|
|
|
}
|
|
|
|
const loaded = await LN.loadSuccessfulPayment(paymentHash);
|
|
|
|
if (loaded) {
|
|
|
|
NavigationService.navigate('ScanLndInvoiceRoot', {
|
|
|
|
screen: 'LnurlPaySuccess',
|
|
|
|
params: {
|
|
|
|
paymentHash,
|
|
|
|
justPaid: false,
|
|
|
|
fromWalletID: lightningWallet[0].getID(),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e);
|
2020-07-23 20:06:13 +02:00
|
|
|
}
|
2021-02-08 04:15:37 +01:00
|
|
|
|
2021-02-10 18:41:51 +01:00
|
|
|
navigate('LNDViewInvoice', {
|
|
|
|
invoice: item,
|
|
|
|
walletID: lightningWallet[0].getID(),
|
|
|
|
isModal: false,
|
|
|
|
});
|
|
|
|
}
|
2019-01-30 03:13:45 +01:00
|
|
|
}
|
2020-11-28 04:06:37 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2020-10-24 19:20:59 +02:00
|
|
|
}, [item, wallets]);
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2020-09-23 08:30:14 +02:00
|
|
|
const onLongPress = useCallback(() => {
|
2021-02-25 04:09:41 +01:00
|
|
|
toolTip.current.showMenu();
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const handleOnExpandNote = useCallback(() => {
|
2021-02-27 00:26:18 +01:00
|
|
|
setSubtitleNumberOfLines(0);
|
2021-02-25 07:46:04 +01:00
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2021-02-27 00:26:18 +01:00
|
|
|
}, [subtitle]);
|
2020-09-23 08:30:14 +02:00
|
|
|
|
|
|
|
const subtitleProps = useMemo(() => ({ numberOfLines: subtitleNumberOfLines }), [subtitleNumberOfLines]);
|
2021-02-26 03:37:28 +01:00
|
|
|
const handleOnCopyTap = useCallback(() => {
|
|
|
|
toolTip.current.hideMenu();
|
2021-02-26 19:09:12 +01:00
|
|
|
setTimeout(copyToolTip.current.showMenu, 205);
|
2021-02-26 03:37:28 +01:00
|
|
|
}, []);
|
2021-02-27 00:16:08 +01:00
|
|
|
const handleOnCopyAmountTap = useCallback(() => Clipboard.setString(rowTitle.replace(/[\s\\-]/g, '')), [rowTitle]);
|
2021-02-25 04:09:41 +01:00
|
|
|
const handleOnCopyTransactionID = useCallback(() => Clipboard.setString(item.hash), [item.hash]);
|
|
|
|
const handleOnCopyNote = useCallback(() => Clipboard.setString(subtitle), [subtitle]);
|
2021-02-25 07:51:25 +01:00
|
|
|
const handleOnViewOnBlockExplorer = useCallback(() => {
|
2021-04-09 17:05:08 +02:00
|
|
|
const url = `https://mempool.space/tx/${item.hash}`;
|
2021-02-25 07:51:25 +01:00
|
|
|
Linking.canOpenURL(url).then(supported => {
|
|
|
|
if (supported) {
|
|
|
|
Linking.openURL(url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, [item.hash]);
|
2021-02-26 03:37:28 +01:00
|
|
|
const handleCopyOpenInBlockExplorerPress = useCallback(() => {
|
2021-04-09 17:05:08 +02:00
|
|
|
Clipboard.setString(`https://mempool.space/tx/${item.hash}`);
|
2021-02-26 03:37:28 +01:00
|
|
|
}, [item.hash]);
|
2021-02-25 04:09:41 +01:00
|
|
|
const toolTipActions = useMemo(() => {
|
|
|
|
const actions = [
|
|
|
|
{
|
2021-02-26 03:37:28 +01:00
|
|
|
id: 'copy',
|
|
|
|
text: loc.transactions.details_copy,
|
|
|
|
onPress: handleOnCopyTap,
|
2021-02-25 04:09:41 +01:00
|
|
|
},
|
|
|
|
];
|
2021-02-26 03:37:28 +01:00
|
|
|
if (item.hash) {
|
|
|
|
actions.push({
|
|
|
|
id: 'open_in_blockExplorer',
|
|
|
|
text: loc.transactions.details_show_in_block_explorer,
|
|
|
|
onPress: handleOnViewOnBlockExplorer,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if (subtitle && subtitleNumberOfLines === 1) {
|
|
|
|
actions.push({
|
|
|
|
id: 'expandNote',
|
|
|
|
text: loc.transactions.expand_note,
|
|
|
|
onPress: handleOnExpandNote,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return actions;
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [item.hash, subtitle, rowTitle, subtitleNumberOfLines, txMetadata]);
|
|
|
|
|
|
|
|
const copyToolTipActions = useMemo(() => {
|
|
|
|
const actions = [];
|
|
|
|
if (rowTitle !== loc.lnd.expired) {
|
|
|
|
actions.push({
|
|
|
|
id: 'copyAmount',
|
|
|
|
text: loc.send.create_amount,
|
|
|
|
onPress: handleOnCopyAmountTap,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-25 04:09:41 +01:00
|
|
|
if (item.hash) {
|
2021-02-25 07:51:25 +01:00
|
|
|
actions.push(
|
|
|
|
{
|
|
|
|
id: 'copyTX_ID',
|
2021-03-11 04:27:51 +01:00
|
|
|
text: loc.transactions.txid,
|
2021-02-25 07:51:25 +01:00
|
|
|
onPress: handleOnCopyTransactionID,
|
|
|
|
},
|
|
|
|
{
|
2021-02-26 03:37:28 +01:00
|
|
|
id: 'copy_blockExplorer',
|
|
|
|
text: loc.transactions.block_explorer_link,
|
|
|
|
onPress: handleCopyOpenInBlockExplorerPress,
|
2021-02-25 07:51:25 +01:00
|
|
|
},
|
|
|
|
);
|
2021-02-25 04:09:41 +01:00
|
|
|
}
|
|
|
|
if (subtitle) {
|
2021-02-25 07:46:04 +01:00
|
|
|
actions.push({
|
|
|
|
id: 'copyNote',
|
2021-02-26 03:37:28 +01:00
|
|
|
text: loc.transactions.note,
|
2021-02-25 07:46:04 +01:00
|
|
|
onPress: handleOnCopyNote,
|
|
|
|
});
|
2021-02-25 04:09:41 +01:00
|
|
|
}
|
|
|
|
return actions;
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2021-02-26 03:37:28 +01:00
|
|
|
}, [toolTipActions]);
|
2021-02-25 04:09:41 +01:00
|
|
|
|
2019-10-10 02:22:10 +02:00
|
|
|
return (
|
2021-02-25 04:09:41 +01:00
|
|
|
<TouchableWithoutFeedback ref={listItemRef}>
|
|
|
|
<View style={{ marginHorizontal: 4 }}>
|
2021-02-25 07:46:04 +01:00
|
|
|
<ToolTipMenu ref={toolTip} anchorRef={listItemRef} actions={toolTipActions} />
|
2021-02-26 03:37:28 +01:00
|
|
|
<ToolTipMenu ref={copyToolTip} anchorRef={listItemRef} actions={copyToolTipActions} />
|
2021-02-25 04:09:41 +01:00
|
|
|
<BlueListItem
|
|
|
|
leftAvatar={avatar}
|
|
|
|
title={title}
|
2021-02-27 00:26:18 +01:00
|
|
|
subtitleNumberOfLines={subtitleNumberOfLines}
|
2021-02-25 04:09:41 +01:00
|
|
|
subtitle={subtitle}
|
|
|
|
subtitleProps={subtitleProps}
|
|
|
|
onPress={onPress}
|
|
|
|
chevron={false}
|
|
|
|
Component={TouchableOpacity}
|
|
|
|
rightTitle={rowTitle}
|
|
|
|
rightTitleStyle={rowTitleStyle}
|
|
|
|
containerStyle={containerStyle}
|
|
|
|
onLongPress={onLongPress}
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
</TouchableWithoutFeedback>
|
2019-10-10 02:22:10 +02:00
|
|
|
);
|
2020-06-19 18:31:59 +02:00
|
|
|
});
|
2019-01-30 03:13:45 +01:00
|
|
|
|
2019-08-27 06:05:27 +02:00
|
|
|
export class BlueReplaceFeeSuggestions extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
onFeeSelected: PropTypes.func.isRequired,
|
|
|
|
transactionMinimum: PropTypes.number.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
static defaultProps = {
|
|
|
|
transactionMinimum: 1,
|
|
|
|
};
|
|
|
|
|
2020-09-14 12:49:08 +02:00
|
|
|
state = {
|
|
|
|
customFeeValue: '1',
|
|
|
|
};
|
2019-08-27 06:05:27 +02:00
|
|
|
|
|
|
|
async componentDidMount() {
|
2020-09-14 12:49:08 +02:00
|
|
|
try {
|
|
|
|
const cachedNetworkTransactionFees = JSON.parse(await AsyncStorage.getItem(NetworkTransactionFee.StorageKey));
|
|
|
|
|
|
|
|
if (cachedNetworkTransactionFees && 'fastestFee' in cachedNetworkTransactionFees) {
|
2020-09-15 15:17:01 +02:00
|
|
|
this.setState({ networkFees: cachedNetworkTransactionFees }, () => this.onFeeSelected(NetworkTransactionFeeType.FAST));
|
2020-09-14 12:49:08 +02:00
|
|
|
}
|
|
|
|
} catch (_) {}
|
2019-08-27 06:05:27 +02:00
|
|
|
const networkFees = await NetworkTransactionFees.recommendedFees();
|
2020-09-15 15:17:01 +02:00
|
|
|
this.setState({ networkFees }, () => this.onFeeSelected(NetworkTransactionFeeType.FAST));
|
2019-08-27 06:05:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onFeeSelected = selectedFeeType => {
|
|
|
|
if (selectedFeeType !== NetworkTransactionFeeType.CUSTOM) {
|
|
|
|
Keyboard.dismiss();
|
|
|
|
}
|
|
|
|
if (selectedFeeType === NetworkTransactionFeeType.FAST) {
|
|
|
|
this.props.onFeeSelected(this.state.networkFees.fastestFee);
|
|
|
|
this.setState({ selectedFeeType }, () => this.props.onFeeSelected(this.state.networkFees.fastestFee));
|
|
|
|
} else if (selectedFeeType === NetworkTransactionFeeType.MEDIUM) {
|
2020-05-18 16:45:31 +02:00
|
|
|
this.setState({ selectedFeeType }, () => this.props.onFeeSelected(this.state.networkFees.mediumFee));
|
2019-08-27 06:05:27 +02:00
|
|
|
} else if (selectedFeeType === NetworkTransactionFeeType.SLOW) {
|
2020-05-18 16:45:31 +02:00
|
|
|
this.setState({ selectedFeeType }, () => this.props.onFeeSelected(this.state.networkFees.slowFee));
|
2019-08-27 06:05:27 +02:00
|
|
|
} else if (selectedFeeType === NetworkTransactionFeeType.CUSTOM) {
|
2020-09-14 12:49:08 +02:00
|
|
|
this.props.onFeeSelected(Number(this.state.customFeeValue));
|
2019-08-27 06:05:27 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
onCustomFeeTextChange = customFee => {
|
2020-09-14 12:49:08 +02:00
|
|
|
const customFeeValue = customFee.replace(/[^0-9]/g, '');
|
|
|
|
this.setState({ customFeeValue, selectedFeeType: NetworkTransactionFeeType.CUSTOM }, () => {
|
2019-08-27 06:05:27 +02:00
|
|
|
this.onFeeSelected(NetworkTransactionFeeType.CUSTOM);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-09-14 12:49:08 +02:00
|
|
|
const { networkFees, selectedFeeType } = this.state;
|
|
|
|
|
2019-08-27 06:05:27 +02:00
|
|
|
return (
|
2020-05-15 11:26:37 +02:00
|
|
|
<View>
|
2020-09-14 12:49:08 +02:00
|
|
|
{networkFees &&
|
|
|
|
[
|
|
|
|
{
|
|
|
|
label: loc.send.fee_fast,
|
|
|
|
time: loc.send.fee_10m,
|
|
|
|
type: NetworkTransactionFeeType.FAST,
|
|
|
|
rate: networkFees.fastestFee,
|
|
|
|
active: selectedFeeType === NetworkTransactionFeeType.FAST,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: loc.send.fee_medium,
|
|
|
|
time: loc.send.fee_3h,
|
|
|
|
type: NetworkTransactionFeeType.MEDIUM,
|
|
|
|
rate: networkFees.mediumFee,
|
|
|
|
active: selectedFeeType === NetworkTransactionFeeType.MEDIUM,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: loc.send.fee_slow,
|
|
|
|
time: loc.send.fee_1d,
|
|
|
|
type: NetworkTransactionFeeType.SLOW,
|
|
|
|
rate: networkFees.slowFee,
|
|
|
|
active: selectedFeeType === NetworkTransactionFeeType.SLOW,
|
|
|
|
},
|
|
|
|
].map(({ label, type, time, rate, active }, index) => (
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-09-14 12:49:08 +02:00
|
|
|
key={label}
|
|
|
|
onPress={() => this.onFeeSelected(type)}
|
|
|
|
style={[
|
|
|
|
{ paddingHorizontal: 16, paddingVertical: 8, marginBottom: 10 },
|
|
|
|
active && { borderRadius: 8, backgroundColor: BlueCurrentTheme.colors.incomingBackgroundColor },
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<View style={{ justifyContent: 'space-between', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<Text style={{ fontSize: 22, color: BlueCurrentTheme.colors.successColor, fontWeight: '600' }}>{label}</Text>
|
|
|
|
<View
|
|
|
|
style={{
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.successColor,
|
|
|
|
borderRadius: 5,
|
|
|
|
paddingHorizontal: 6,
|
|
|
|
paddingVertical: 3,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Text style={{ color: BlueCurrentTheme.colors.background }}>~{time}</Text>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
<View style={{ justifyContent: 'flex-end', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<Text style={{ color: BlueCurrentTheme.colors.successColor }}>{rate} sat/byte</Text>
|
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
|
|
|
))}
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-09-14 12:49:08 +02:00
|
|
|
onPress={() => this.customTextInput.focus()}
|
|
|
|
style={[
|
|
|
|
{ paddingHorizontal: 16, paddingVertical: 8, marginBottom: 10 },
|
|
|
|
selectedFeeType === NetworkTransactionFeeType.CUSTOM && {
|
|
|
|
borderRadius: 8,
|
|
|
|
backgroundColor: BlueCurrentTheme.colors.incomingBackgroundColor,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<View style={{ justifyContent: 'space-between', flexDirection: 'row', alignItems: 'center' }}>
|
|
|
|
<Text style={{ fontSize: 22, color: BlueCurrentTheme.colors.successColor, fontWeight: '600' }}>{loc.send.fee_custom}</Text>
|
|
|
|
</View>
|
|
|
|
<View style={{ justifyContent: 'space-between', flexDirection: 'row', alignItems: 'center', marginTop: 5 }}>
|
|
|
|
<TextInput
|
|
|
|
onChangeText={this.onCustomFeeTextChange}
|
|
|
|
keyboardType="numeric"
|
|
|
|
value={this.state.customFeeValue}
|
|
|
|
ref={ref => (this.customTextInput = ref)}
|
|
|
|
maxLength={9}
|
2020-05-15 11:26:37 +02:00
|
|
|
style={{
|
2020-09-14 12:49:08 +02:00
|
|
|
backgroundColor: BlueCurrentTheme.colors.inputBackgroundColor,
|
|
|
|
borderBottomColor: BlueCurrentTheme.colors.formBorder,
|
|
|
|
borderBottomWidth: 0.5,
|
|
|
|
borderColor: BlueCurrentTheme.colors.formBorder,
|
|
|
|
borderRadius: 4,
|
|
|
|
borderWidth: 1.0,
|
|
|
|
color: '#81868e',
|
|
|
|
flex: 1,
|
|
|
|
marginRight: 10,
|
|
|
|
minHeight: 33,
|
|
|
|
paddingRight: 5,
|
2020-09-15 16:05:25 +02:00
|
|
|
paddingLeft: 5,
|
2020-05-15 11:26:37 +02:00
|
|
|
}}
|
2020-09-14 12:49:08 +02:00
|
|
|
onFocus={() => this.onCustomFeeTextChange(this.state.customFeeValue)}
|
|
|
|
defaultValue={`${this.props.transactionMinimum}`}
|
|
|
|
placeholder={loc.send.fee_satbyte}
|
|
|
|
placeholderTextColor="#81868e"
|
|
|
|
inputAccessoryViewID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}
|
|
|
|
/>
|
|
|
|
<Text style={{ color: BlueCurrentTheme.colors.successColor }}>sat/byte</Text>
|
2020-05-15 11:26:37 +02:00
|
|
|
</View>
|
|
|
|
</TouchableOpacity>
|
2020-07-15 19:32:59 +02:00
|
|
|
<BlueText style={{ color: BlueCurrentTheme.colors.alternativeTextColor }}>
|
2020-09-14 12:49:08 +02:00
|
|
|
{loc.formatString(loc.send.fee_replace_min, { min: this.props.transactionMinimum })}
|
2020-05-15 11:26:37 +02:00
|
|
|
</BlueText>
|
|
|
|
</View>
|
2019-08-27 06:05:27 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-03 23:29:15 +02:00
|
|
|
const styles = StyleSheet.create({
|
|
|
|
balanceBlur: {
|
|
|
|
height: 30,
|
|
|
|
width: 100,
|
|
|
|
marginRight: 16,
|
|
|
|
},
|
|
|
|
});
|
2020-04-28 18:27:35 +02:00
|
|
|
|
|
|
|
export function BlueBigCheckmark({ style }) {
|
|
|
|
const defaultStyles = {
|
|
|
|
backgroundColor: '#ccddf9',
|
|
|
|
width: 120,
|
|
|
|
height: 120,
|
|
|
|
borderRadius: 60,
|
|
|
|
alignSelf: 'center',
|
|
|
|
justifyContent: 'center',
|
|
|
|
marginTop: 0,
|
|
|
|
marginBottom: 0,
|
|
|
|
};
|
|
|
|
const mergedStyles = { ...defaultStyles, ...style };
|
|
|
|
return (
|
|
|
|
<View style={mergedStyles}>
|
|
|
|
<Icon name="check" size={50} type="font-awesome" color="#0f5cc0" />
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2020-06-24 13:56:35 +02:00
|
|
|
|
2020-06-29 14:58:43 +02:00
|
|
|
const tabsStyles = StyleSheet.create({
|
|
|
|
root: {
|
|
|
|
flexDirection: 'row',
|
|
|
|
height: 50,
|
|
|
|
borderColor: '#e3e3e3',
|
|
|
|
borderBottomWidth: 1,
|
|
|
|
},
|
|
|
|
tabRoot: {
|
2020-09-20 10:23:28 +02:00
|
|
|
flex: 1,
|
2020-06-29 14:58:43 +02:00
|
|
|
justifyContent: 'center',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderColor: 'white',
|
|
|
|
borderBottomWidth: 2,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const BlueTabs = ({ active, onSwitch, tabs }) => (
|
2020-09-20 10:23:28 +02:00
|
|
|
<View style={[tabsStyles.root, isIpad && { marginBottom: 30 }]}>
|
2020-06-29 14:58:43 +02:00
|
|
|
{tabs.map((Tab, i) => (
|
|
|
|
<TouchableOpacity
|
|
|
|
key={i}
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-06-29 14:58:43 +02:00
|
|
|
onPress={() => onSwitch(i)}
|
|
|
|
style={[
|
|
|
|
tabsStyles.tabRoot,
|
|
|
|
active === i && {
|
2020-07-15 19:32:59 +02:00
|
|
|
borderColor: BlueCurrentTheme.colors.buttonAlternativeTextColor,
|
2020-06-29 14:58:43 +02:00
|
|
|
borderBottomWidth: 2,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<Tab active={active === i} />
|
|
|
|
</TouchableOpacity>
|
|
|
|
))}
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
|
2020-06-24 13:56:35 +02:00
|
|
|
export class DynamicQRCode extends Component {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
const qrCodeHeight = height > width ? width - 40 : width / 3;
|
|
|
|
const qrCodeMaxHeight = 370;
|
|
|
|
this.state = {
|
|
|
|
index: 0,
|
|
|
|
total: 0,
|
|
|
|
qrCodeHeight: Math.min(qrCodeHeight, qrCodeMaxHeight),
|
|
|
|
intervalHandler: null,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fragments = [];
|
|
|
|
|
|
|
|
componentDidMount() {
|
2021-03-16 19:03:01 +01:00
|
|
|
const { value, capacity = 200 } = this.props;
|
2020-06-24 13:56:35 +02:00
|
|
|
this.fragments = encodeUR(value, capacity);
|
|
|
|
this.setState(
|
|
|
|
{
|
|
|
|
total: this.fragments.length,
|
|
|
|
},
|
|
|
|
() => {
|
|
|
|
this.startAutoMove();
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
moveToNextFragment = () => {
|
|
|
|
const { index, total } = this.state;
|
|
|
|
if (index === total - 1) {
|
|
|
|
this.setState({
|
|
|
|
index: 0,
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.setState(state => ({
|
|
|
|
index: state.index + 1,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
startAutoMove = () => {
|
|
|
|
if (!this.state.intervalHandler)
|
|
|
|
this.setState(() => ({
|
|
|
|
intervalHandler: setInterval(this.moveToNextFragment, 500),
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
stopAutoMove = () => {
|
|
|
|
clearInterval(this.state.intervalHandler);
|
|
|
|
this.setState(() => ({
|
|
|
|
intervalHandler: null,
|
|
|
|
}));
|
|
|
|
};
|
|
|
|
|
|
|
|
moveToPreviousFragment = () => {
|
|
|
|
const { index, total } = this.state;
|
|
|
|
if (index > 0) {
|
|
|
|
this.setState(state => ({
|
|
|
|
index: state.index - 1,
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
this.setState(state => ({
|
|
|
|
index: total - 1,
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const currentFragment = this.fragments[this.state.index];
|
|
|
|
return currentFragment ? (
|
|
|
|
<View style={animatedQRCodeStyle.container}>
|
|
|
|
<BlueSpacing20 />
|
2020-08-16 04:43:17 +02:00
|
|
|
<View style={animatedQRCodeStyle.qrcodeContainer}>
|
2020-06-24 13:56:35 +02:00
|
|
|
<QRCode
|
|
|
|
value={currentFragment.toUpperCase()}
|
|
|
|
size={this.state.qrCodeHeight}
|
2020-08-03 19:26:16 +02:00
|
|
|
color="#000000"
|
2020-07-15 19:32:59 +02:00
|
|
|
logoBackgroundColor={BlueCurrentTheme.colors.brandingColor}
|
2020-08-03 19:26:16 +02:00
|
|
|
backgroundColor="#FFFFFF"
|
2020-06-24 13:56:35 +02:00
|
|
|
ecl="L"
|
|
|
|
/>
|
|
|
|
</View>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<View>
|
|
|
|
<Text style={animatedQRCodeStyle.text}>
|
2020-07-23 15:09:48 +02:00
|
|
|
{loc.formatString(loc._.of, { number: this.state.index + 1, total: this.state.total })}
|
2020-06-24 13:56:35 +02:00
|
|
|
</Text>
|
|
|
|
</View>
|
|
|
|
<BlueSpacing20 />
|
|
|
|
<View style={animatedQRCodeStyle.controller}>
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-06-24 13:56:35 +02:00
|
|
|
style={[animatedQRCodeStyle.button, { width: '25%', alignItems: 'flex-start' }]}
|
|
|
|
onPress={this.moveToPreviousFragment}
|
|
|
|
>
|
2020-07-23 15:09:48 +02:00
|
|
|
<Text style={animatedQRCodeStyle.text}>{loc.send.dynamic_prev}</Text>
|
2020-06-24 13:56:35 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-06-24 13:56:35 +02:00
|
|
|
style={[animatedQRCodeStyle.button, { width: '50%' }]}
|
|
|
|
onPress={this.state.intervalHandler ? this.stopAutoMove : this.startAutoMove}
|
|
|
|
>
|
2020-07-23 15:09:48 +02:00
|
|
|
<Text style={animatedQRCodeStyle.text}>{this.state.intervalHandler ? loc.send.dynamic_stop : loc.send.dynamic_start}</Text>
|
2020-06-24 13:56:35 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
<TouchableOpacity
|
2021-06-24 14:50:57 +02:00
|
|
|
accessibilityRole="button"
|
2020-06-24 13:56:35 +02:00
|
|
|
style={[animatedQRCodeStyle.button, { width: '25%', alignItems: 'flex-end' }]}
|
|
|
|
onPress={this.moveToNextFragment}
|
|
|
|
>
|
2020-07-23 15:09:48 +02:00
|
|
|
<Text style={animatedQRCodeStyle.text}>{loc.send.dynamic_next}</Text>
|
2020-06-24 13:56:35 +02:00
|
|
|
</TouchableOpacity>
|
|
|
|
</View>
|
|
|
|
</View>
|
|
|
|
) : (
|
|
|
|
<View>
|
2020-07-23 15:09:48 +02:00
|
|
|
<Text>{loc.send.dynamic_init}</Text>
|
2020-06-24 13:56:35 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const animatedQRCodeStyle = StyleSheet.create({
|
|
|
|
container: {
|
|
|
|
flex: 1,
|
|
|
|
flexDirection: 'column',
|
|
|
|
alignItems: 'center',
|
|
|
|
},
|
|
|
|
qrcodeContainer: {
|
|
|
|
alignItems: 'center',
|
|
|
|
justifyContent: 'center',
|
2020-08-03 19:26:16 +02:00
|
|
|
borderWidth: 6,
|
|
|
|
borderRadius: 8,
|
|
|
|
borderColor: '#FFFFFF',
|
2020-08-16 04:43:17 +02:00
|
|
|
margin: 6,
|
2020-06-24 13:56:35 +02:00
|
|
|
},
|
|
|
|
controller: {
|
|
|
|
width: '90%',
|
|
|
|
flexDirection: 'row',
|
|
|
|
justifyContent: 'space-between',
|
|
|
|
alignItems: 'center',
|
|
|
|
borderRadius: 25,
|
|
|
|
height: 45,
|
|
|
|
paddingHorizontal: 18,
|
|
|
|
},
|
|
|
|
button: {
|
|
|
|
alignItems: 'center',
|
|
|
|
height: 45,
|
|
|
|
justifyContent: 'center',
|
|
|
|
},
|
|
|
|
text: {
|
2020-07-15 19:32:59 +02:00
|
|
|
fontSize: 14,
|
|
|
|
color: BlueCurrentTheme.colors.foregroundColor,
|
|
|
|
fontWeight: 'bold',
|
2020-06-24 13:56:35 +02:00
|
|
|
},
|
|
|
|
});
|