From c7f06404dae3f462fbe58ab90a0f6edd3650a0fd Mon Sep 17 00:00:00 2001 From: u-e Date: Sun, 21 Apr 2019 21:34:10 +0300 Subject: [PATCH] updateed a bit --- .../points/container/pointsContainer.js | 28 +++++++++++++++++-- src/components/points/view/pointsStyles.js | 24 ++++++++++++++++ src/components/points/view/pointsView.js | 23 ++++++++++++++- 3 files changed, 72 insertions(+), 3 deletions(-) diff --git a/src/components/points/container/pointsContainer.js b/src/components/points/container/pointsContainer.js index 636b9358f..993578649 100644 --- a/src/components/points/container/pointsContainer.js +++ b/src/components/points/container/pointsContainer.js @@ -2,7 +2,7 @@ import React, { Component, Alert } from 'react'; import { connect } from 'react-redux'; // Services and Actions -import { getUser, getUserPoints } from '../../../providers/esteem/ePoint'; +import { getUser, getUserPoints, claim } from '../../../providers/esteem/ePoint'; // Constant import POINTS from '../../../constants/options/points'; @@ -22,12 +22,19 @@ class PointsContainer extends Component { userPoints: {}, userActivities: {}, refreshing: false, + isClaiming: false, }; } // Component Life Cycle Functions componentDidMount() { this._fetchuserPointActivities(); + + this.fetchInterval = setInterval(this._fetchuserPointActivities, 360000); + } + + componentWillUnmount() { + clearInterval(this.fetchInterval); } // Component Functions @@ -65,9 +72,24 @@ class PointsContainer extends Component { this.setState({ refreshing: false }); }; + _claimPoints = async () => { + const { username } = this.props; + this.setState({ isClaiming: true }); + + await claim(username) + .then(() => { + this._fetchuserPointActivities(); + }) + .catch((err) => { + Alert.alert(err); + }); + + this.setState({ isClaiming: false }); + } + render() { const { - userPoints, userActivities, isDarkTheme, refreshing, + userPoints, userActivities, isDarkTheme, refreshing, isClaiming, } = this.state; return ( @@ -77,6 +99,8 @@ class PointsContainer extends Component { isDarkTheme={isDarkTheme} fetchUserActivity={this._fetchuserPointActivities} refreshing={refreshing} + isClaiming={isClaiming} + claimPoints={this._claimPoints} /> ); } diff --git a/src/components/points/view/pointsStyles.js b/src/components/points/view/pointsStyles.js index c2a71de8e..e9e476cb6 100644 --- a/src/components/points/view/pointsStyles.js +++ b/src/components/points/view/pointsStyles.js @@ -66,4 +66,28 @@ export default EStyleSheet.create({ listWrapper: { marginHorizontal: 8, }, + mainButton: { + marginVertical: 8, + alignSelf: 'center', + paddingHorizontal: 24, + }, + mainButtonWrapper: { + flexDirection: 'row', + }, + unclaimedText: { + color: '$primaryBackgroundColor', + fontSize: 14, + fontWeight: 'bold', + alignSelf: 'center', + }, + mainIconWrapper: { + backgroundColor: '$primaryBackgroundColor', + justifyContent: 'center', + alignSelf: 'center', + alignItems: 'center', + borderRadius: 20, + marginLeft: 20, + width: 24, + height: 24, + }, }); diff --git a/src/components/points/view/pointsView.js b/src/components/points/view/pointsView.js index ce54cd66f..4a121e382 100644 --- a/src/components/points/view/pointsView.js +++ b/src/components/points/view/pointsView.js @@ -7,6 +7,8 @@ import { injectIntl } from 'react-intl'; // Components import { LineBreak, WalletLineItem } from '../../basicUIElements'; import { IconButton } from '../../iconButton'; +import { Icon } from '../../icon'; +import { MainButton } from '../../mainButton'; // Utils import { getTimeFromNow } from '../../../utils/time'; @@ -46,7 +48,7 @@ class PointsView extends Component { render() { const { - userActivities, userPoints, intl, + userActivities, userPoints, intl, isClaiming, claimPoints, } = this.props; const isActiveIcon = true; @@ -59,6 +61,25 @@ class PointsView extends Component { {userPoints.points} eSteem Points + {userPoints.unclaimed_points > 0 + && ( + claimPoints()} + > + + {userPoints.unclaimed_points} + + + + + + ) + } +