mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-16 09:02:24 +03:00
created wallet refresh feature
This commit is contained in:
parent
12ac038a07
commit
b1078b31e9
@ -1,4 +1,4 @@
|
||||
// import Card from './view/cardView';
|
||||
import Card from './view/card/cardView';
|
||||
import Chip from './view/chip/chipView';
|
||||
import GrayWrapper from './view/grayWrapper/grayWrapperView';
|
||||
import LineBreak from './view/lineBreak/lineBreakView';
|
||||
@ -6,29 +6,30 @@ import NoPost from './view/noPost/noPostView';
|
||||
import PostCardPlaceHolder from './view/placeHolder/postCardPlaceHolderView';
|
||||
import PostPlaceHolder from './view/placeHolder/postPlaceHolderView';
|
||||
import ProfileSummaryPlaceHolder from './view/placeHolder/profileSummaryPlaceHolder';
|
||||
import WalletDetailsPlaceHolder from './view/placeHolder/walletDetailsPlaceHolder';
|
||||
import WalletUnclaimedPlaceHolder from './view/placeHolder/walletUnclaimedPlaceHolder';
|
||||
import RefreshControl from './view/refreshControl/refreshControlView';
|
||||
import StickyBar from './view/stickyBar/stickyBarView';
|
||||
import Tag from './view/tag/tagView';
|
||||
import TextWithIcon from './view/textWithIcon/textWithIconView';
|
||||
import WalletLineItem from './view/walletLineItem/walletLineItemView';
|
||||
import StickyBar from './view/stickyBar/stickyBarView';
|
||||
import Card from './view/card/cardView';
|
||||
import UserListItem from './view/userListItem/userListItem';
|
||||
import WalletDetailsPlaceHolder from './view/placeHolder/walletDetailsPlaceHolder';
|
||||
import WalletLineItem from './view/walletLineItem/walletLineItemView';
|
||||
import WalletUnclaimedPlaceHolder from './view/placeHolder/walletUnclaimedPlaceHolder';
|
||||
|
||||
export {
|
||||
Card,
|
||||
StickyBar,
|
||||
Chip,
|
||||
GrayWrapper,
|
||||
UserListItem,
|
||||
LineBreak,
|
||||
NoPost,
|
||||
PostCardPlaceHolder,
|
||||
PostPlaceHolder,
|
||||
ProfileSummaryPlaceHolder,
|
||||
WalletDetailsPlaceHolder,
|
||||
WalletUnclaimedPlaceHolder,
|
||||
RefreshControl,
|
||||
StickyBar,
|
||||
Tag,
|
||||
TextWithIcon,
|
||||
UserListItem,
|
||||
WalletDetailsPlaceHolder,
|
||||
WalletLineItem,
|
||||
WalletUnclaimedPlaceHolder,
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ export default EStyleSheet.create({
|
||||
wrapper: {
|
||||
flexDirection: 'column',
|
||||
backgroundColor: '$primaryBackgroundColor',
|
||||
shadowOpacity: 0.8,
|
||||
shadowOpacity: 0.2,
|
||||
shadowColor: '#e7e7e7',
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 8,
|
||||
|
@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { RefreshControl } from 'react-native';
|
||||
|
||||
const RefreshControlView = ({ refreshing, onRefresh, isDarkTheme }) => (
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={onRefresh}
|
||||
progressBackgroundColor="#357CE6"
|
||||
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
||||
titleColor="#fff"
|
||||
colors={['#fff']}
|
||||
/>
|
||||
);
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
currentAccount: state.application.isDarkTheme,
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps)(RefreshControlView);
|
@ -1,7 +1,5 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import {
|
||||
FlatList, View, ActivityIndicator, RefreshControl,
|
||||
} from 'react-native';
|
||||
import { FlatList, View, ActivityIndicator } from 'react-native';
|
||||
import { injectIntl } from 'react-intl';
|
||||
import { withNavigation } from 'react-navigation';
|
||||
|
||||
@ -11,7 +9,7 @@ import { getPostsSummary } from '../../../providers/steem/dsteem';
|
||||
// COMPONENTS
|
||||
import { PostCard } from '../../postCard';
|
||||
import { FilterBar } from '../../filterBar';
|
||||
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
||||
import { PostCardPlaceHolder, NoPost, RefreshControl } from '../../basicUIElements';
|
||||
import { POPULAR_FILTERS, PROFILE_FILTERS } from '../../../constants/options/filters';
|
||||
|
||||
// Styles
|
||||
@ -260,17 +258,15 @@ class PostsView extends Component {
|
||||
/>
|
||||
)}
|
||||
<Fragment>
|
||||
{ getFor === 'feed'
|
||||
&& isLoginDone
|
||||
&& !isLoggedIn && (
|
||||
<NoPost
|
||||
imageStyle={styles.noImage}
|
||||
isButtonText
|
||||
defaultText={intl.formatMessage({
|
||||
id: 'profile.login_to_see',
|
||||
})}
|
||||
handleOnButtonPress={this._handleOnPressLogin}
|
||||
/>
|
||||
{getFor === 'feed' && isLoginDone && !isLoggedIn && (
|
||||
<NoPost
|
||||
imageStyle={styles.noImage}
|
||||
isButtonText
|
||||
defaultText={intl.formatMessage({
|
||||
id: 'profile.login_to_see',
|
||||
})}
|
||||
handleOnButtonPress={this._handleOnPressLogin}
|
||||
/>
|
||||
)}
|
||||
</Fragment>
|
||||
|
||||
@ -290,16 +286,9 @@ class PostsView extends Component {
|
||||
initialNumToRender={10}
|
||||
ListFooterComponent={this._renderFooter}
|
||||
onScrollBeginDrag={() => this._handleOnScrollStart()}
|
||||
refreshControl={(
|
||||
<RefreshControl
|
||||
refreshing={refreshing}
|
||||
onRefresh={this._handleOnRefreshPosts}
|
||||
progressBackgroundColor="#357CE6"
|
||||
tintColor={!isDarkTheme ? '#357ce6' : '#96c0ff'}
|
||||
titleColor="#fff"
|
||||
colors={['#fff']}
|
||||
/>
|
||||
)}
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={refreshing} onRefresh={this._handleOnRefreshPosts} />
|
||||
}
|
||||
ref={(ref) => {
|
||||
this.flatList = ref;
|
||||
}}
|
||||
|
@ -25,6 +25,7 @@ class WalletContainer extends Component {
|
||||
this.state = {
|
||||
walletData: null,
|
||||
claiming: false,
|
||||
isRefreshing: false,
|
||||
};
|
||||
}
|
||||
|
||||
@ -77,10 +78,10 @@ class WalletContainer extends Component {
|
||||
id: 'alert.claim_reward_balance_ok',
|
||||
}),
|
||||
);
|
||||
this._getWalletData(account);
|
||||
this._getWalletData(account[0]);
|
||||
})
|
||||
.then((account) => {
|
||||
this._getWalletData(account);
|
||||
this._getWalletData(account[0]);
|
||||
})
|
||||
.catch((err) => {
|
||||
Alert.alert(err);
|
||||
@ -90,9 +91,26 @@ class WalletContainer extends Component {
|
||||
});
|
||||
};
|
||||
|
||||
_handleOnWalletRefresh = () => {
|
||||
const { selectedUser } = this.props;
|
||||
this.setState({ isRefreshing: true });
|
||||
|
||||
|
||||
getAccount(selectedUser.name)
|
||||
.then((account) => {
|
||||
this._getWalletData(account[0]);
|
||||
})
|
||||
.catch((err) => {
|
||||
Alert.alert(err);
|
||||
})
|
||||
.finally(() => {
|
||||
this.setState({ isRefreshing: false });
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
const { currentAccount, selectedUser } = this.props;
|
||||
const { walletData, claiming } = this.state;
|
||||
const { walletData, claiming, isRefreshing } = this.state;
|
||||
|
||||
return (
|
||||
<WalletView
|
||||
@ -101,6 +119,8 @@ class WalletContainer extends Component {
|
||||
walletData={walletData}
|
||||
claimRewardBalance={this._claimRewardBalance}
|
||||
claiming={claiming}
|
||||
handleOnWalletRefresh={this._handleOnWalletRefresh}
|
||||
isRefreshing={isRefreshing}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import { MainButton } from '../../mainButton';
|
||||
import { CollapsibleCard } from '../../collapsibleCard';
|
||||
import { WalletDetails } from '../../walletDetails';
|
||||
import { Transaction } from '../../transaction';
|
||||
import { WalletDetailsPlaceHolder } from '../../basicUIElements';
|
||||
import { WalletDetailsPlaceHolder, RefreshControl } from '../../basicUIElements';
|
||||
|
||||
// Styles
|
||||
import styles from './walletStyles';
|
||||
@ -44,16 +44,23 @@ class WalletView extends PureComponent {
|
||||
|
||||
render() {
|
||||
const {
|
||||
claiming,
|
||||
claimRewardBalance,
|
||||
currentAccountUsername,
|
||||
handleOnWalletRefresh,
|
||||
intl,
|
||||
isRefreshing,
|
||||
selectedUsername,
|
||||
walletData,
|
||||
claimRewardBalance,
|
||||
claiming,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<ScrollView style={styles.scrollView}>
|
||||
<ScrollView
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={isRefreshing} onRefresh={handleOnWalletRefresh} />
|
||||
}
|
||||
style={styles.scrollView}
|
||||
>
|
||||
{!walletData ? (
|
||||
<Fragment>
|
||||
<WalletDetailsPlaceHolder />
|
||||
|
Loading…
Reference in New Issue
Block a user