From 3662834fbae588f4c000a2d95eb89891f7c81c3f Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 13 Dec 2019 17:02:53 +0100 Subject: [PATCH] display balance when LBC input text is focused --- src/component/channelSelector/view.js | 12 ++++++++++-- src/component/walletSend/view.js | 10 +++++++++- src/page/channelCreator/view.js | 10 +++++++++- src/page/file/view.js | 17 +++++++++++++---- src/page/publish/view.js | 9 +++++++++ src/styles/channelCreator.js | 5 +++++ src/styles/channelSelector.js | 5 +++++ src/styles/filePage.js | 8 ++++++-- src/styles/publish.js | 5 +++++ src/styles/wallet.js | 5 +++++ 10 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/component/channelSelector/view.js b/src/component/channelSelector/view.js index 2652307..1f109ac 100644 --- a/src/component/channelSelector/view.js +++ b/src/component/channelSelector/view.js @@ -1,5 +1,5 @@ import React from 'react'; -import { CLAIM_VALUES, isNameValid } from 'lbry-redux'; +import { CLAIM_VALUES, formatCredits, isNameValid } from 'lbry-redux'; import { ActivityIndicator, NativeModules, Picker, Text, TextInput, TouchableOpacity, View } from 'react-native'; import { logPublish } from 'utils/helper'; import Button from 'component/button'; @@ -14,6 +14,7 @@ export default class ChannelSelector extends React.PureComponent { super(props); this.state = { + creditsInputFocused: false, currentSelectedValue: Constants.ITEM_ANONYMOUS, newChannelName: '', newChannelBid: 0.1, @@ -188,7 +189,7 @@ export default class ChannelSelector extends React.PureComponent { render() { const channel = this.state.addingChannel ? 'new' : this.props.channel; - const { enabled, fetchingChannels, channels = [] } = this.props; + const { balance, enabled, fetchingChannels, channels = [] } = this.props; const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat( channels ? channels.map(ch => ch.name) : [] ); @@ -244,11 +245,18 @@ export default class ChannelSelector extends React.PureComponent { style={channelSelectorStyle.bidAmountInput} value={String(newChannelBid)} onChangeText={this.handleNewChannelBidChange} + onFocus={() => this.setState({ creditsInputFocused: true })} + onBlur={() => this.setState({ creditsInputFocused: false })} placeholder={'0.00'} keyboardType={'number-pad'} underlineColorAndroid={Colors.NextLbryGreen} /> LBC + + {this.state.creditsInputFocused + ? __('Bal: %balance%', { balance: formatCredits(parseFloat(balance), 1, true) }) + : ''} + {__('This LBC remains yours. It is a deposit to reserve the name and can be undone at any time.')} diff --git a/src/component/walletSend/view.js b/src/component/walletSend/view.js index 6b9f914..17aae7d 100644 --- a/src/component/walletSend/view.js +++ b/src/component/walletSend/view.js @@ -1,6 +1,6 @@ // @flow import React from 'react'; -import { regexAddress } from 'lbry-redux'; +import { formatCredits, regexAddress } from 'lbry-redux'; import { Alert, Clipboard, TextInput, Text, View } from 'react-native'; import Button from 'component/button'; import Colors from 'styles/colors'; @@ -24,6 +24,7 @@ class WalletSend extends React.PureComponent { address: null, addressChanged: false, addressValid: false, + creditsInputFocused: false, }; componentWillUpdate(nextProps) { @@ -118,6 +119,8 @@ class WalletSend extends React.PureComponent { (this.amountInput = ref)} onChangeText={value => this.setState({ amount: value })} + onFocus={() => this.setState({ creditsInputFocused: true })} + onBlur={() => this.setState({ creditsInputFocused: false })} keyboardType={'numeric'} placeholder={'0'} underlineColorAndroid={Colors.NextLbryGreen} @@ -125,6 +128,11 @@ class WalletSend extends React.PureComponent { style={[walletStyle.input, walletStyle.amountInput]} /> LBC + + {this.state.creditsInputFocused + ? __('Bal: %balance%', { balance: formatCredits(parseFloat(balance), 1, true) }) + : ''} +