FIX: Disable editing amount if num_satoshis is specified

This commit is contained in:
Marcos Rodriguez Vélez 2019-01-06 04:30:32 -05:00
parent fa9d9b9d69
commit b62a5f5eea
4 changed files with 7 additions and 7 deletions

View file

@ -1127,7 +1127,7 @@ export class BlueBitcoinAmount extends Component {
const amount = typeof this.props.amount === 'number' ? this.props.amount.toString() : this.props.amount;
return (
<TouchableWithoutFeedback onPress={() => this.textInput.focus()}>
<TouchableWithoutFeedback disabled={this.props.pointerEvents === 'none'} onPress={() => this.textInput.focus()}>
<View>
<View style={{ flexDirection: 'row', justifyContent: 'center', paddingTop: 16, paddingBottom: 16 }}>
<TextInput
@ -1150,6 +1150,7 @@ 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>213</string>
<string>215</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSRequiresIPhoneOS</key>

View file

@ -78,10 +78,6 @@ export default class LNDCreateInvoice extends Component {
isLoading={this.state.isLoading}
amount={this.state.amount}
onChangeText={text => {
if (text.length === 0) {
text = '0';
}
text = parseInt(text);
this.setState({ amount: text });
}}
disabled={this.state.isLoading}

View file

@ -21,6 +21,7 @@ export default class ScanLndInvoice extends React.Component {
state = {
isLoading: false,
isAmountInitiallyEmpty: false,
};
constructor(props) {
@ -105,6 +106,7 @@ export default class ScanLndInvoice extends React.Component {
decoded,
expiresIn,
destination: data,
isAmountInitiallyEmpty: decoded.num_satoshis === '0',
});
} catch (Err) {
this.setState({ destination: '' });
@ -176,7 +178,7 @@ export default class ScanLndInvoice extends React.Component {
return true;
}
}
return this.state.decoded.num_satoshis <= 0 || this.state.isLoading;
return this.state.decoded.num_satoshis <= 0 || this.state.isLoading || isNaN(this.state.decoded.num_satoshis);
};
render() {
@ -184,6 +186,7 @@ export default class ScanLndInvoice extends React.Component {
<TouchableWithoutFeedback onPress={Keyboard.dismiss} accessible={false}>
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
<BlueBitcoinAmount
pointerEvents={this.state.isAmountInitiallyEmpty ? 'auto' : 'none'}
isLoading={this.state.isLoading}
amount={typeof this.state.decoded === 'object' ? this.state.decoded.num_satoshis : 0}
onChangeText={text => {