Browse Source

Initial

localNotifications
Marcos Rodriguez Vélez 6 years ago
parent
commit
9d514ce656
  1. 2
      BlueComponents.js
  2. 15
      class/abstract-hd-wallet.js
  3. 16
      class/abstract-wallet.js
  4. 4
      ios/BlueWallet/Info.plist
  5. 1
      loc/en.js
  6. 3
      loc/index.js
  7. 21
      screen/wallets/details.js
  8. 2
      screen/wallets/transactions.js

2
BlueComponents.js

@ -935,7 +935,7 @@ export class WalletsCarousel extends Component {
let scaleValue = new Animated.Value(1.0);
this.onPressedIn = () => {
Animated.spring(scaleValue, { toValue: 0.90, duration: 100, useNativeDriver: Platform.OS === 'android' }).start();
Animated.spring(scaleValue, { toValue: 0.9, duration: 100, useNativeDriver: Platform.OS === 'android' }).start();
};
this.onPressedOut = () => {
Animated.spring(scaleValue, { toValue: 1.0, duration: 100, useNativeDriver: Platform.OS === 'android' }).start();

15
class/abstract-hd-wallet.js

@ -1,6 +1,7 @@
import { LegacyWallet } from './legacy-wallet';
import Frisbee from 'frisbee';
import { WatchOnlyWallet } from './watch-only-wallet';
import { BitcoinUnit } from '../models/bitcoinUnits';
const bip39 = require('bip39');
export class AbstractHDWallet extends LegacyWallet {
@ -14,6 +15,7 @@ export class AbstractHDWallet extends LegacyWallet {
this._xpub = ''; // cache
this.usedAddresses = [];
this._address_to_wif_cache = {};
this.preferredBalanceUnit = BitcoinUnit.BTC;
}
generate() {
@ -80,6 +82,19 @@ export class AbstractHDWallet extends LegacyWallet {
return this;
}
getPreferredBalanceUnit() {
return this.preferredBalanceUnit;
}
getPreferredBalanceUnitIndex = () => {
return BitcoinUnit.ARRAY.indexOf(this.getPreferredBalanceUnit);
};
setPreferredBalanceUnit(unit) {
this.preferredBalanceUnit = unit;
return this;
}
/**
* @return {Boolean} is mnemonic in `this.secret` valid
*/

16
class/abstract-wallet.js

@ -1,3 +1,5 @@
import { BitcoinUnit } from '../models/bitcoinUnits';
export class AbstractWallet {
constructor() {
this.type = 'abstract';
@ -10,6 +12,7 @@ export class AbstractWallet {
this.utxo = [];
this._lastTxFetch = 0;
this._lastBalanceFetch = 0;
this.preferredBalanceUnit = BitcoinUnit.BTC;
}
getTransactions() {
@ -32,6 +35,19 @@ export class AbstractWallet {
return this.balance;
}
getPreferredBalanceUnit() {
return this.preferredBalanceUnit;
}
getPreferredBalanceUnitIndex = () => {
return BitcoinUnit.ARRAY.indexOf(this.getPreferredBalanceUnit);
};
setPreferredBalanceUnit(unit) {
this.preferredBalanceUnit = unit;
return this;
}
allowReceive() {
return true;
}

4
ios/BlueWallet/Info.plist

@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.2.0</string>
<string>3.2.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>146</string>
<string>147</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>

1
loc/en.js

@ -55,6 +55,7 @@ module.exports = {
no_cancel: 'No, cancel',
delete: 'Delete',
save: 'Save',
displayBalanceUsing: 'Display balance using',
delete_this_wallet: 'Delete this wallet',
export_backup: 'Export / backup',
buy_bitcoin: 'Buy Bitcoin',

3
loc/index.js

@ -71,7 +71,6 @@ strings.formatBalance = (balance, unit) => {
}
return balance + ' ' + BitcoinUnit.BTC;
} else {
if (balance !== 0) {
let b = new BigNumber(balance);
if (unit === BitcoinUnit.MBTC) {
return b.multipliedBy(1000).toString() + ' ' + BitcoinUnit.MBTC;
@ -83,8 +82,6 @@ strings.formatBalance = (balance, unit) => {
return (b.times(conversion).toString() + ' ' + BitcoinUnit.SATS).replace(/\./g, '');
}
}
return balance + ' ' + BitcoinUnit.BTC;
}
};
strings.formatBalanceWithoutSuffix = (balance, unit) => {

21
screen/wallets/details.js

@ -3,8 +3,10 @@ import React, { Component } from 'react';
import { ActivityIndicator, View, Text, TextInput, Alert, TouchableOpacity, Keyboard, TouchableWithoutFeedback } from 'react-native';
import { BlueButton, SafeBlueArea, BlueCard, BlueSpacing20, BlueNavigationStyle } from '../../BlueComponents';
import PropTypes from 'prop-types';
import { ButtonGroup } from 'react-native-elements';
import { LightningCustodianWallet } from '../../class/lightning-custodian-wallet';
import ReactNativeHapticFeedback from 'react-native-haptic-feedback';
import { BitcoinUnit } from '../../models/bitcoinUnits';
let EV = require('../../events');
/** @type {AppStorage} */
let BlueApp = require('../../BlueApp');
@ -65,6 +67,10 @@ export default class WalletDetails extends Component {
this.props.navigation.goBack(null);
}
updatePreferredBalanceUnit = selectedIndex => {
this.state.wallet.setPreferredBalanceUnit(Object.keys(BitcoinUnit)[selectedIndex]);
};
render() {
if (this.state.isLoading) {
return (
@ -73,7 +79,6 @@ export default class WalletDetails extends Component {
</View>
);
}
return (
<SafeBlueArea style={{ flex: 1 }}>
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
@ -124,15 +129,19 @@ export default class WalletDetails extends Component {
{loc.wallets.details.type.toLowerCase()}
</Text>
<Text style={{ color: '#81868e', fontWeight: '500', fontSize: 14 }}>{this.state.wallet.getTypeReadable()}</Text>
<Text style={{ color: '#0c2550', fontWeight: '500', fontSize: 14, marginVertical: 12 }}>
{loc.wallets.details.displayBalanceUsing.toLowerCase()}
</Text>
<ButtonGroup
onPress={this.updatePreferredBalanceUnit}
selectedIndex={Number(this.state.wallet.getPreferredBalanceUnitIndex)}
buttons={[BitcoinUnit.BTC, BitcoinUnit.MBTC, BitcoinUnit.BITS, BitcoinUnit.SATOSHIS]}
/>
</BlueCard>
<View>
<BlueSpacing20 />
<BlueButton
icon={{
name: 'cloud-upload',
type: 'octicon',
color: BlueApp.settings.buttonTextColor,
}}
onPress={() =>
this.props.navigation.navigate('WalletExport', {
address: this.state.wallet.getAddress(),

2
screen/wallets/transactions.js

@ -64,7 +64,7 @@ export default class WalletTransactions extends Component {
isTransactionsLoading: false,
wallet: wallet,
dataSource: wallet.getTransactions(),
walletBalanceUnit: BitcoinUnit.MBTC,
walletBalanceUnit: Object.keys(BitcoinUnit)[wallet.getPreferredBalanceUnit],
};
}

Loading…
Cancel
Save