Merge pull request #504 from esteemapp/bugfix/#478

Bugfix/#478
This commit is contained in:
uğur erdal 2019-01-25 10:38:01 +03:00 committed by GitHub
commit 31a659e839
12 changed files with 82 additions and 26 deletions

View File

@ -21,9 +21,10 @@ const WalletLineItem = ({
text,
textColor,
index,
style,
}) => (
<GrayWrapper isGray={index % 2 === 0}>
<View style={[styles.container, fitContent && styles.fitContent]}>
<GrayWrapper isGray={index && index % 2 !== 0}>
<View style={[styles.container, fitContent && styles.fitContent, style]}>
<View style={styles.iconTextWrapper}>
{iconName && (
<View

View File

@ -5,7 +5,6 @@ export default EStyleSheet.create({
flexDirection: 'column',
backgroundColor: '$primaryBackgroundColor',
marginTop: 8,
marginBottom: 8,
overflow: 'hidden',
},
containerWithBorder: {

View File

@ -17,6 +17,5 @@ export default EStyleSheet.create({
text: {
fontSize: 16,
fontFamily: '$primaryFont',
marginBottom: 12,
},
});

View File

@ -0,0 +1,7 @@
import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({
container: {
marginTop: 8,
},
});

View File

@ -1,5 +1,6 @@
import React, { PureComponent, Fragment } from 'react';
import React, { PureComponent } from 'react';
import { injectIntl } from 'react-intl';
import { View } from 'react-native';
// Utilities
import { groomingTransactionData } from '../../../utils/wallet';
@ -12,6 +13,8 @@ import { getTimeFromNow } from '../../../utils/time';
import { WalletLineItem, Card } from '../../basicUIElements';
import { CollapsibleCard } from '../../collapsibleCard';
import styles from './transactionStyles';
class TransactionView extends PureComponent {
/* Props
* ------------------------------------------------
@ -37,7 +40,7 @@ class TransactionView extends PureComponent {
} = this.props;
return (
<Fragment>
<View style={styles.container}>
{/* this feature not implemented yet */}
{/* <FilterBar
dropdownIconName="arrow-drop-down"
@ -46,7 +49,6 @@ class TransactionView extends PureComponent {
onDropdownSelect={() => this._handleOnDropdownSelect()}
rightIconName="ios-lock"
iconSize={16}
if (index % 2 === 0) {
/> */}
<Card>
{transactions
@ -90,7 +92,7 @@ class TransactionView extends PureComponent {
);
})}
</Card>
</Fragment>
</View>
);
}
}

View File

@ -47,9 +47,11 @@ class WalletContainer extends Component {
// Components functions
_getWalletData = async (selectedUser) => {
const { setEstimatedWalletValue } = this.props;
const walletData = await groomingWalletData(selectedUser);
this.setState({ walletData });
setEstimatedWalletValue(walletData.estimatedValue);
};
_claimRewardBalance = async () => {

View File

@ -35,4 +35,7 @@ export default EStyleSheet.create({
width: 24,
height: 24,
},
scrollView: {
backgroundColor: '$primaryLightBackground',
},
});

View File

@ -7,4 +7,8 @@ export default EStyleSheet.create({
blackText: {
color: '$primaryBlack',
},
walletLineDetail: {
marginBottom: 15,
marginTop: 0,
},
});

View File

@ -39,7 +39,7 @@ class WalletDetailsView extends PureComponent {
rightText={`${Math.round(walletData.balance * 1000) / 1000} STEEM`}
isBoldText
/>
<GrayWrapper>
<GrayWrapper isGray>
<WalletLineItem
text={intl.formatMessage({
id: 'profile.steem_power',
@ -57,6 +57,7 @@ class WalletDetailsView extends PureComponent {
rightText={`- ${Math.round(
vestsToSp(walletData.vestingSharesDelegated, walletData.steemPerMVests) * 1000,
) / 1000} SP`}
style={styles.walletLineDetail}
/>
)}
{walletData.vestingSharesReceived > 0 && (
@ -64,6 +65,7 @@ class WalletDetailsView extends PureComponent {
rightText={`+ ${Math.round(
vestsToSp(walletData.vestingSharesReceived, walletData.steemPerMVests) * 1000,
) / 1000} SP`}
style={styles.walletLineDetail}
/>
)}
{(walletData.vestingSharesDelegated > 0 || walletData.vestingSharesReceived > 0) && (
@ -72,6 +74,7 @@ class WalletDetailsView extends PureComponent {
vestsToSp(walletData.vestingSharesTotal, walletData.steemPerMVests) * 1000,
) / 1000} SP`}
rightTextColor="#357ce6"
style={styles.walletLineDetail}
/>
)}
</GrayWrapper>
@ -85,7 +88,7 @@ class WalletDetailsView extends PureComponent {
rightText={`$${Math.round(walletData.sbdBalance * 1000) / 1000}`}
isBoldText
/>
<GrayWrapper>
<GrayWrapper isGray>
<WalletLineItem
text={intl.formatMessage({
id: 'profile.savings',
@ -95,7 +98,10 @@ class WalletDetailsView extends PureComponent {
rightText={`${Math.round(walletData.savingBalance * 1000) / 1000} STEEM`}
isBoldText
/>
<WalletLineItem rightText={`$${Math.round(walletData.savingBalanceSbd * 1000) / 1000}`} />
<WalletLineItem
rightText={`$${Math.round(walletData.savingBalanceSbd * 1000) / 1000}`}
style={styles.walletLineDetail}
/>
</GrayWrapper>
{walletData.showPowerDown && (
<WalletLineItem

View File

@ -32,6 +32,8 @@ class ProfileScreen extends PureComponent {
this.state = {
isSummaryOpen: true,
collapsibleMoreHeight: 0,
estimatedWalletValue: 0,
oldEstimatedWalletValue: 0,
};
}
@ -51,6 +53,10 @@ class ProfileScreen extends PureComponent {
this.setState({ collapsibleMoreHeight: height });
};
_setEstimatedWalletValue = (value) => {
if (value) this.setState({ estimatedWalletValue: value });
}
render() {
const {
about,
@ -76,7 +82,9 @@ class ProfileScreen extends PureComponent {
getReplies,
} = this.props;
const { isSummaryOpen, collapsibleMoreHeight } = this.state;
const {
isSummaryOpen, collapsibleMoreHeight, estimatedWalletValue, oldEstimatedWalletValue,
} = this.state;
let _about;
let coverImage;
@ -154,10 +162,18 @@ class ProfileScreen extends PureComponent {
)}
<ScrollableTabView
style={globalStyles.tabView}
style={[globalStyles.tabView, styles.tabView]}
renderTabBar={() => (
<TabBar style={styles.tabbar} tabUnderlineDefaultWidth={80} tabUnderlineScaleX={2} />
)}
onChangeTab={({ i }) => {
if (i !== 2) {
this.setState({
estimatedWalletValue: 0,
oldEstimatedWalletValue: estimatedWalletValue,
});
} else this.setState({ estimatedWalletValue: oldEstimatedWalletValue });
}}
>
<View
tabLabel={intl.formatMessage({
@ -198,11 +214,20 @@ class ProfileScreen extends PureComponent {
)}
</View>
<View
tabLabel={intl.formatMessage({
tabLabel={estimatedWalletValue
? `$${Math.round(estimatedWalletValue * 1000) / 1000}`
: intl.formatMessage({
id: 'profile.wallet',
})}
>
{selectedUser ? <Wallet selectedUser={selectedUser} /> : <WalletDetailsPlaceHolder />}
{selectedUser
? (
<Wallet
setEstimatedWalletValue={this._setEstimatedWalletValue}
selectedUser={selectedUser}
/>
)
: <WalletDetailsPlaceHolder />}
</View>
</ScrollableTabView>
</View>

View File

@ -3,7 +3,7 @@ import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({
container: {
flex: 1,
backgroundColor: '$primaryLightBackground',
backgroundColor: '$primaryGrayBackground',
},
content: {
backgroundColor: '$primaryGrayBackground',
@ -40,6 +40,10 @@ export default EStyleSheet.create({
height: 45,
backgroundColor: '$primaryBackgroundColor',
borderBottomColor: '#f1f1f1',
marginTop: 8,
},
tabView: {
backgroundColor: '$primaryGrayBackground',
},
tabbarItem: {
flex: 1,

View File

@ -1,7 +1,7 @@
import parseDate from './parseDate';
import parseToken from './parseToken';
import { vestsToSp } from './conversions';
import { globalProps, getState } from '../providers/steem/dsteem';
import { globalProps, getState, getFeedHistory } from '../providers/steem/dsteem';
export const groomingTransactionData = (transaction, walletData, formatNumber) => {
if (!transaction || !walletData) {
@ -129,15 +129,19 @@ export const groomingWalletData = async (user) => {
walletData.savingBalance = parseToken(user.savings_balance);
walletData.savingBalanceSbd = parseToken(user.savings_sbd_balance);
// const feedHistory = await getFeedHistory();
// const base = parseToken(feedHistory.current_median_history.base);
// const quote = parseToken(feedHistory.current_median_history.quote);
const feedHistory = await getFeedHistory();
const base = parseToken(feedHistory.current_median_history.base);
const quote = parseToken(feedHistory.current_median_history.quote);
walletData.steemPerMVests = (parseToken(global.total_vesting_fund_steem) / parseToken(global.total_vesting_shares)) * 1e6;
walletData.steemPerMVests = (
parseToken(global.total_vesting_fund_steem) / parseToken(global.total_vesting_shares)
) * 1e6;
// walletData.estimatedValue = vestsToSp(walletData.vestingShares, walletData.steemPerMVests) * (base / quote)
// + walletData.balance * (base / quote)
// + walletData.sbdBalance;
walletData.estimatedValue = (
vestsToSp(walletData.vestingShares, walletData.steemPerMVests) * (base / quote)
)
+ (walletData.balance * (base / quote))
+ walletData.sbdBalance;
walletData.showPowerDown = user.next_vesting_withdrawal !== '1969-12-31T23:59:59';
const timeDiff = Math.abs(parseDate(user.next_vesting_withdrawal) - new Date());