diff --git a/src/components/transaction/transactionView.js b/src/components/transaction/transactionView.js
index fb6ad2603..7e24fdec6 100644
--- a/src/components/transaction/transactionView.js
+++ b/src/components/transaction/transactionView.js
@@ -1,7 +1,7 @@
/* eslint-disable react/jsx-wrap-multilines */
import React from 'react';
import { useIntl } from 'react-intl';
-import { View, Text, FlatList } from 'react-native';
+import { View, Text, FlatList, RefreshControl } from 'react-native';
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
@@ -11,10 +11,11 @@ import { getTimeFromNow } from '../../utils/time';
// Components
import { WalletLineItem, ListPlaceHolder } from '../basicUIElements';
import { CollapsibleCard } from '..';
+import { ThemeContainer } from '../../containers';
import globalStyles from '../../globalStyles';
-const TransactionView = ({ transactions, type }) => {
+const TransactionView = ({ transactions, type, refreshing, setRefreshing }) => {
const intl = useIntl();
const _renderLoading = () => {
@@ -27,6 +28,21 @@ const TransactionView = ({ transactions, type }) => {
);
};
+ const refreshControl = () => (
+
+ {isDarkTheme => (
+ setRefreshing(true)}
+ progressBackgroundColor="#357CE6"
+ tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
+ titleColor="#fff"
+ colors={['#fff']}
+ />
+ )}
+
+ );
+
const _renderItem = (item, index) => {
return (
{
_renderItem(item, index)}
/>
diff --git a/src/components/upvote/view/upvoteView.js b/src/components/upvote/view/upvoteView.js
index 695aac5fc..f15ac1080 100644
--- a/src/components/upvote/view/upvoteView.js
+++ b/src/components/upvote/view/upvoteView.js
@@ -8,6 +8,7 @@ import get from 'lodash/get';
// Utils
import parseToken from '../../../utils/parseToken';
import { vestsToRshares } from '../../../utils/conversions';
+import { getEstimatedAmount } from '../../../utils/vote';
// Components
import { Icon } from '../../icon';
@@ -71,20 +72,9 @@ class UpvoteView extends Component {
if (currentAccount && Object.entries(currentAccount).length !== 0) {
const { sliderValue } = this.state;
- const { fundRecentClaims, fundRewardBalance, base, quote } = globalProps;
-
- const votingPower = currentAccount.voting_power;
- const totalVests =
- parseToken(get(currentAccount, 'vesting_shares')) +
- parseToken(get(currentAccount, 'received_vesting_shares')) -
- parseToken(get(currentAccount, 'delegated_vesting_shares'));
- const votePct = sliderValue * 10000;
-
- const rShares = vestsToRshares(totalVests, votingPower, votePct);
- const estimated = (rShares / fundRecentClaims) * fundRewardBalance * (base / quote);
this.setState({
- amount: estimated.toFixed(5),
+ amount: getEstimatedAmount(currentAccount, globalProps, sliderValue),
});
}
};
diff --git a/src/components/walletHeader/view/walletHeaderView.js b/src/components/walletHeader/view/walletHeaderView.js
index 7818eefa4..cb01afcd0 100644
--- a/src/components/walletHeader/view/walletHeaderView.js
+++ b/src/components/walletHeader/view/walletHeaderView.js
@@ -86,13 +86,11 @@ const WalletHeaderView = ({
isDisable={isClaiming}
style={styles.mainButton}
height={50}
- onPress={() =>
- unclaimedBalance > 0 ? claim() : navigation.navigate(ROUTES.SCREENS.BOOST)
- }
+ onPress={() => (unclaimedBalance ? claim() : navigation.navigate(ROUTES.SCREENS.BOOST))}
>
- {unclaimedBalance > 0
+ {unclaimedBalance
? unclaimedBalance
: intl.formatMessage({ id: `wallet.${type}.buy` })}
@@ -126,18 +124,3 @@ const WalletHeaderView = ({
};
export default withNavigation(WalletHeaderView);
-
-// const refreshControl = () => (
-//
-// {isDarkTheme => (
-//
-// )}
-//
-// );
diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json
index 0187c7120..cb4f6a374 100644
--- a/src/config/locales/en-US.json
+++ b/src/config/locales/en-US.json
@@ -45,6 +45,7 @@
"to": "To",
"estimated_value_desc": "*determined by purchase value",
"estimated_value": "Estimated value",
+ "estimated_amount": "Vote value",
"amount_information": "Drag the slider to adjust the amount",
"amount": "Amount",
"memo": "Memo",
diff --git a/src/containers/steemWalletContainer.js b/src/containers/steemWalletContainer.js
index 77e687367..d25caa77f 100644
--- a/src/containers/steemWalletContainer.js
+++ b/src/containers/steemWalletContainer.js
@@ -16,6 +16,7 @@ import { groomingWalletData, groomingTransactionData } from '../utils/wallet';
import parseToken from '../utils/parseToken';
import { vestsToSp } from '../utils/conversions';
import { navigate } from '../navigation/service';
+import { getEstimatedAmount } from '../utils/vote';
// Constants
import ROUTES from '../constants/routeNames';
@@ -48,9 +49,14 @@ const WalletContainer = ({
const [steemSavingBalance, setSteemSavingBalance] = useState(0);
const [estimatedValue, setEstimatedValue] = useState(0);
const [unclaimedBalance, setUnclaimedBalance] = useState('');
+ const [estimatedAmount, setEstimatedAmount] = useState(0);
const intl = useIntl();
const dispatch = useDispatch();
+ useEffect(() => {
+ setEstimatedAmount(getEstimatedAmount(currentAccount, globalProps));
+ }, [currentAccount, globalProps]);
+
useEffect(() => {
_getWalletData(selectedUser);
}, [_getWalletData, selectedUser]);
@@ -138,7 +144,7 @@ const WalletContainer = ({
})
.then(() => getAccount(currentAccount.name))
.then(account => {
- _getWalletData(account && account[0]);
+ _getWalletData(selectedUser);
if (isHasUnclaimedRewards) {
dispatch(
toastNotification(
@@ -150,7 +156,7 @@ const WalletContainer = ({
}
})
.then(account => {
- _getWalletData(account && account[0]);
+ _getWalletData(selectedUser);
setIsClaiming(false);
})
.catch(() => {
@@ -171,7 +177,7 @@ const WalletContainer = ({
getAccount(selectedUser.name)
.then(account => {
- _getWalletData(account && account[0]);
+ _getWalletData(selectedUser);
setRefreshing(false);
})
.catch(() => {
@@ -245,7 +251,8 @@ const WalletContainer = ({
savingSteemDropdown: SAVING_STEEM_DROPDOWN,
savingSbdDropdown: SAVING_SBD_DROPDOWN,
steemPowerDropdown: STEEM_POWER_DROPDOWN,
- unclaimedBalance: unclaimedBalance.trim(),
+ unclaimedBalance: unclaimedBalance && unclaimedBalance.trim(),
+ estimatedAmount,
})
);
};
diff --git a/src/screens/wallet/screen/estmView.js b/src/screens/wallet/screen/estmView.js
index 1da1e5d1e..3ae13a683 100644
--- a/src/screens/wallet/screen/estmView.js
+++ b/src/screens/wallet/screen/estmView.js
@@ -22,7 +22,7 @@ const EstmView = ({ handleOnSelected, index, currentIndex }) => (
dropdownOptions,
}) => (
handleOnSelected(userActivities, 'estm')}
+ componentDidUpdate={() => handleOnSelected(userActivities, 'estm', fetchUserActivity)}
index={index}
showIconList
claim={claim}
@@ -31,7 +31,9 @@ const EstmView = ({ handleOnSelected, index, currentIndex }) => (
isLoading={isLoading}
refreshing={refreshing}
userActivities={userActivities}
- unclaimedBalance={get(userPoints, 'unclaimed_points', 0)}
+ unclaimedBalance={
+ get(userPoints, 'unclaimed_points') > 0 && get(userPoints, 'unclaimed_points')
+ }
userBalance={[
{ balance: get(userPoints, 'points'), nameKey: 'estm', options: dropdownOptions },
]}
diff --git a/src/screens/wallet/screen/spView.js b/src/screens/wallet/screen/spView.js
index 16b922cf8..7b17951bc 100644
--- a/src/screens/wallet/screen/spView.js
+++ b/src/screens/wallet/screen/spView.js
@@ -19,12 +19,11 @@ const SpView = ({ handleOnSelected, index, currentIndex }) => (
userActivities,
spBalance,
isLoading,
- steemSavingBalance,
estimatedValue,
steemPowerDropdown,
- savingSteemDropdown,
unclaimedBalance,
navigate,
+ estimatedAmount,
}) => (
handleOnSelected(userActivities, 'steem_power')}
@@ -50,8 +49,8 @@ const SpView = ({ handleOnSelected, index, currentIndex }) => (
value: ,
},
{
- textKey: 'estimated_value',
- value: ,
+ textKey: 'estimated_amount',
+ value: ,
},
]}
/>
diff --git a/src/screens/wallet/screen/walletScreen.js b/src/screens/wallet/screen/walletScreen.js
index 4e962d327..db807a951 100644
--- a/src/screens/wallet/screen/walletScreen.js
+++ b/src/screens/wallet/screen/walletScreen.js
@@ -18,8 +18,9 @@ const WalletScreen = () => {
const [selectedUserActivities, setSelectedUserActivities] = useState(null);
const [selectedType, setSelectedType] = useState('points');
const [currentIndex, setCurrentIndex] = useState(0);
+ const [refreshing, setRefreshing] = useState(false);
- const _handleSwipeItemChange = (userActivities, type) => {
+ const _handleSwipeItemChange = (userActivities, type, xx) => {
setSelectedUserActivities(userActivities);
setSelectedType(type);
};
@@ -40,21 +41,29 @@ const WalletScreen = () => {
-
+
>
)}
diff --git a/src/utils/vote.js b/src/utils/vote.js
new file mode 100644
index 000000000..8f36d10f4
--- /dev/null
+++ b/src/utils/vote.js
@@ -0,0 +1,16 @@
+import parseToken from './parseToken';
+import get from 'lodash/get';
+import { vestsToRshares } from './conversions';
+
+export const getEstimatedAmount = (account, globalProps, value = 100) => {
+ const { fundRecentClaims, fundRewardBalance, base, quote } = globalProps;
+ const votingPower = account.voting_power;
+ const totalVests =
+ parseToken(get(account, 'vesting_shares')) +
+ parseToken(get(account, 'received_vesting_shares')) -
+ parseToken(get(account, 'delegated_vesting_shares'));
+ const votePct = value * 10000;
+ const rShares = vestsToRshares(totalVests, votingPower, votePct);
+
+ return ((rShares / fundRecentClaims) * fundRewardBalance * (base / quote)).toFixed(5);
+};