lbry-react-native/src/page/publishes/view.js

86 lines
2.6 KiB
JavaScript
Raw Normal View History

2019-07-26 17:12:28 +01:00
import React from 'react';
import { ActivityIndicator, FlatList, Text, TouchableOpacity, View } from 'react-native';
import Button from 'component/button';
import Colors from 'styles/colors';
import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api
import FileListItem from 'component/fileListItem';
import FloatingWalletBalance from 'component/floatingWalletBalance';
import UriBar from 'component/uriBar';
import publishStyle from 'styles/publish';
import { __ } from 'utils/helper';
class PublishesPage extends React.PureComponent {
didFocusListener;
componentWillMount() {
const { navigation } = this.props;
2019-08-10 07:55:12 +01:00
// this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused);
2019-07-26 17:12:28 +01:00
}
componentWillUnmount() {
if (this.didFocusListener) {
this.didFocusListener.remove();
}
}
2019-08-10 07:55:12 +01:00
componentDidMount() {
this.onComponentFocused();
}
2019-07-26 17:12:28 +01:00
onComponentFocused = () => {
2019-08-11 00:06:10 +01:00
const { checkPendingPublishes, fetchMyClaims, pushDrawerStack, setPlayerVisible } = this.props;
2019-07-26 17:12:28 +01:00
pushDrawerStack();
setPlayerVisible();
2019-08-11 00:06:10 +01:00
fetchMyClaims();
2019-07-26 17:12:28 +01:00
checkPendingPublishes();
};
render() {
const { fetching, navigation, uris } = this.props;
return (
<View style={publishStyle.container}>
<UriBar navigation={navigation} />
{fetching && (
<View style={publishStyle.centered}>
<ActivityIndicator size={'small'} color={Colors.LbryGreen} />
</View>
)}
{!fetching && (!uris || uris.length === 0) && (
<View style={publishStyle.noPublishes}>
<Text style={publishStyle.noPublishText}>
{__('It looks like you have not published anything to LBRY yet.')}
</Text>
<Button
style={publishStyle.publishNowButton}
text={__('Publish something new')}
onPress={() => navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH })}
/>
</View>
)}
{uris && uris.length > 0 && (
<FlatList
style={publishStyle.publishesList}
contentContainerStyle={publishStyle.publishesScrollPadding}
initialNumToRender={8}
maxToRenderPerBatch={24}
removeClippedSubviews
renderItem={({ item }) => (
<FileListItem hideChannel key={item} uri={item} style={publishStyle.listItem} navigation={navigation} />
)}
data={uris}
keyExtractor={(item, index) => item}
/>
)}
<FloatingWalletBalance navigation={navigation} />
</View>
);
}
}
export default PublishesPage;