OPS: Expanded BlueBitcoinAmount to support sats

This commit is contained in:
Marcos Rodriguez Vélez 2019-01-06 01:39:39 -05:00
parent b6ad5fdc12
commit 7f4887d5c7
2 changed files with 18 additions and 4 deletions

View file

@ -1116,6 +1116,11 @@ export class BlueBitcoinAmount extends Component {
amount: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onChangeText: PropTypes.func,
disabled: PropTypes.bool,
unit: PropTypes.string,
};
static defaultProps = {
unit: BitcoinUnit.BTC,
};
render() {
@ -1127,7 +1132,13 @@ export class BlueBitcoinAmount extends Component {
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
<TextInput
keyboardType="numeric"
onChangeText={text => this.props.onChangeText(text.replace(',', '.'))}
onChangeText={text =>
this.props.onChangeText(
this.props.unit === BitcoinUnit.BTC
? text.replace(new RegExp('[^0-9.]'), '', '.')
: text.replace(new RegExp('[^0-9]'), ''),
)
}
placeholder="0"
maxLength={10}
ref={textInput => (this.textInput = textInput)}
@ -1150,12 +1161,15 @@ export class BlueBitcoinAmount extends Component {
alignSelf: 'flex-end',
}}
>
{' ' + BitcoinUnit.BTC}
{' ' + this.props.unit}
</Text>
</View>
<View style={{ alignItems: 'center', marginBottom: 22, marginTop: 4 }}>
<Text style={{ fontSize: 18, color: '#d4d4d4', fontWeight: '600' }}>
{loc.formatBalance(amount || 0, BitcoinUnit.LOCAL_CURRENCY)}
{loc.formatBalance(
this.props.unit === BitcoinUnit.BTC ? amount || 0 : loc.formatBalanceWithoutSuffix(amount || 0, BitcoinUnit.BTC),
BitcoinUnit.LOCAL_CURRENCY,
)}
</Text>
</View>
</View>

View file

@ -53,7 +53,7 @@ export default class RBF extends Component {
} else {
// DESTINATION address
destinationAddress = o.addresses && o.addresses[0] || '';
destinationAddress = (o.addresses && o.addresses[0]) || '';
console.log('dest = ', destinationAddress);
}
}