FIX: Fix issue with typing amounts

This commit is contained in:
Marcos Rodriguez Vélez 2019-01-06 15:21:04 -05:00
parent 5876b9e9ef
commit c0a137a965
3 changed files with 49 additions and 48 deletions

View file

@ -1131,14 +1131,12 @@ export class BlueBitcoinAmount extends Component {
<View>
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
<TextInput
{...this.props}
keyboardType="numeric"
onChangeText={text =>
this.props.onChangeText(
this.props.unit === BitcoinUnit.BTC
? text.replace(new RegExp('[^0-9.]'), '', '.')
: text.replace(new RegExp('[^0-9]'), ''),
)
}
onChangeText={text => {
text = this.props.unit === BitcoinUnit.BTC ? text.replace(/[^0-9.]/g, '') : text.replace(/[^0-9]/g, '');
this.props.onChangeText(text);
}}
placeholder="0"
maxLength={10}
ref={textInput => (this.textInput = textInput)}
@ -1150,7 +1148,6 @@ export class BlueBitcoinAmount extends Component {
fontSize: 36,
fontWeight: '600',
}}
{...this.props}
/>
<Text
style={{

View file

@ -33,7 +33,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>217</string>
<string>218</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View file

@ -71,7 +71,8 @@ export default class ScanLndInvoice extends React.Component {
}
}
async processInvoice(data) {
processInvoice(data) {
this.setState({ isLoading: true }, async () => {
if (this.ignoreRead) return;
this.ignoreRead = true;
setTimeout(() => {
@ -107,10 +108,13 @@ export default class ScanLndInvoice extends React.Component {
expiresIn,
destination: data,
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
isLoading: false,
});
} catch (Err) {
this.setState({ isLoading: false });
alert(Err.message);
}
});
}
async pay() {
@ -190,7 +194,7 @@ export default class ScanLndInvoice extends React.Component {
amount={typeof this.state.decoded === 'object' ? this.state.decoded.num_satoshis : 0}
onChangeText={text => {
if (typeof this.state.decoded === 'object') {
text = parseInt(text);
text = parseInt(text || 0);
let decoded = this.state.decoded;
decoded.num_satoshis = text;
this.setState({ decoded: decoded });