Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #111 from rsksmart/imstar15-add_refresh_control_in…
Browse files Browse the repository at this point in the history
…_transaction_page

Add refresh control in transaction page. fix #40
  • Loading branch information
imstar15 authored May 7, 2020
2 parents 1a49bbe + 4bf55e5 commit 11602e7
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions src/pages/wallet/transaction.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import React, { Component } from 'react';
import {
View, StyleSheet, Text, Linking, Image,
View, StyleSheet, Text, Linking, Image, ScrollView, RefreshControl,
} from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
Expand Down Expand Up @@ -109,6 +109,7 @@ class Transaction extends Component {
confirmations,
memo: rawTransaction.memo || strings('page.wallet.transaction.noMemo'),
title: `${transation.state} Funds`,
isRefreshing: false,
};
}

Expand All @@ -126,6 +127,14 @@ class Transaction extends Component {
this.setState(Transaction.processViewData(transation, latestBlockHeights));
}

onRefresh = () => {
this.setState({ isRefreshing: true });
// simulate 1s network delay
setTimeout(() => {
this.setState({ isRefreshing: false });
}, 1000);
}

onLinkPress() {
const { navigation } = this.props;
const transation = navigation.state.params;
Expand All @@ -137,16 +146,28 @@ class Transaction extends Component {
render() {
const { navigation } = this.props;
const {
transactionState, transactionId, amount, datetime, memo, confirmations, title, stateIcon,
transactionState, transactionId, amount, datetime, memo, confirmations, title, stateIcon, isRefreshing,
} = this.state;

const refreshControl = (
<RefreshControl
refreshing={isRefreshing}
onRefresh={this.onRefresh}
/>
);

return (
<BasePageGereral
isSafeView
hasBottomBtn={false}
hasLoader={false}
headerComponent={<Header title={`page.wallet.transaction.${title}`} onBackButtonPress={() => navigation.goBack()} />}
>
<View style={styles.body}>
<ScrollView
style={styles.body}
showsVerticalScrollIndicator={false}
refreshControl={refreshControl}
>
<View style={styles.sectionContainer}>
<Loc style={[styles.sectionTitle, styles.state]} text={transactionState} />
<View style={styles.amountView}>
Expand Down Expand Up @@ -175,7 +196,7 @@ class Transaction extends Component {
<Loc style={styles.link} text="page.wallet.transaction.viewOnChain" />
</TouchableOpacity>
</View>
</View>
</ScrollView>
</BasePageGereral>
);
}
Expand Down

0 comments on commit 11602e7

Please sign in to comment.