From bc7d546dd980ca151b6b864d7ed9bc932f8eb7a4 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Fri, 26 Jul 2019 17:12:28 +0100 Subject: [PATCH] add publishes page --- src/component/AppNavigator.js | 7 +++ src/component/fileListItem/view.js | 3 +- src/constants.js | 3 ++ src/page/publish/view.js | 22 ++++---- src/page/publishes/index.js | 21 ++++++++ src/page/publishes/view.js | 80 ++++++++++++++++++++++++++++++ src/styles/publish.js | 43 ++++++++++++++++ 7 files changed, 167 insertions(+), 12 deletions(-) create mode 100644 src/page/publishes/index.js create mode 100644 src/page/publishes/view.js diff --git a/src/component/AppNavigator.js b/src/component/AppNavigator.js index 71cf69a..4db09a6 100644 --- a/src/component/AppNavigator.js +++ b/src/component/AppNavigator.js @@ -6,6 +6,7 @@ import DrawerContent from 'component/drawerContent'; import FilePage from 'page/file'; import FirstRunScreen from 'page/firstRun'; import PublishPage from 'page/publish'; +import PublishesPage from 'page/publishes'; import RewardsPage from 'page/rewards'; import TagPage from 'page/tag'; import TrendingPage from 'page/trending'; @@ -162,6 +163,12 @@ const drawer = createDrawerNavigator( drawerIcon: ({ tintColor }) => , }, }, + Publishes: { + screen: PublishesPage, + navigationOptions: { + drawerIcon: ({ tintColor }) => , + }, + }, Rewards: { screen: RewardsPage, navigationOptions: { diff --git a/src/component/fileListItem/view.js b/src/component/fileListItem/view.js index fa24157..8301581 100644 --- a/src/component/fileListItem/view.js +++ b/src/component/fileListItem/view.js @@ -58,6 +58,7 @@ class FileListItem extends React.PureComponent { onPress, navigation, thumbnail, + hideChannel, title, } = this.props; @@ -115,7 +116,7 @@ class FileListItem extends React.PureComponent { {this.formatTitle(title) || this.formatTitle(name)} )} - {channel && ( + {channel && !hideChannel && ( { + const { pushDrawerStack, setPlayerVisible } = this.props; + + pushDrawerStack(); + setPlayerVisible(); + + NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera })); + NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath })); + NativeModules.Gallery.getVideos().then(videos => this.setState({ videos })); + }; + getNewUri(name, channel) { const { resolveUri } = this.props; // If they are midway through a channel creation, treat it as anonymous until it completes @@ -212,17 +223,6 @@ class PublishPage extends React.PureComponent { this.setState({ publishStarted: true }, () => publish(publishParams)); }; - onComponentFocused = () => { - const { pushDrawerStack, setPlayerVisible } = this.props; - - pushDrawerStack(); - setPlayerVisible(); - - NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera })); - NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath })); - NativeModules.Gallery.getVideos().then(videos => this.setState({ videos })); - }; - componentDidMount() { this.onComponentFocused(); } diff --git a/src/page/publishes/index.js b/src/page/publishes/index.js new file mode 100644 index 0000000..3989253 --- /dev/null +++ b/src/page/publishes/index.js @@ -0,0 +1,21 @@ +import { connect } from 'react-redux'; +import { doCheckPendingPublishes, selectMyClaimUrisWithoutChannels, selectIsFetchingClaimListMine } from 'lbry-redux'; +import { doPushDrawerStack, doSetPlayerVisible } from 'redux/actions/drawer'; +import Constants from 'constants'; // eslint-disable-line node/no-deprecated-api +import PublishesPage from './view'; + +const select = state => ({ + uris: selectMyClaimUrisWithoutChannels(state), + fetching: selectIsFetchingClaimListMine(state), +}); + +const perform = dispatch => ({ + checkPendingPublishes: () => dispatch(doCheckPendingPublishes()), + pushDrawerStack: () => dispatch(doPushDrawerStack(Constants.DRAWER_ROUTE_PUBLISHES)), + setPlayerVisible: () => dispatch(doSetPlayerVisible(false)), +}); + +export default connect( + select, + perform +)(PublishesPage); diff --git a/src/page/publishes/view.js b/src/page/publishes/view.js new file mode 100644 index 0000000..3a09d06 --- /dev/null +++ b/src/page/publishes/view.js @@ -0,0 +1,80 @@ +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; + this.didFocusListener = navigation.addListener('didFocus', this.onComponentFocused); + } + + componentWillUnmount() { + if (this.didFocusListener) { + this.didFocusListener.remove(); + } + } + + onComponentFocused = () => { + const { checkPendingPublishes, pushDrawerStack, setPlayerVisible } = this.props; + + pushDrawerStack(); + setPlayerVisible(); + checkPendingPublishes(); + }; + + render() { + const { fetching, navigation, uris } = this.props; + + return ( + + + {fetching && ( + + + + )} + + {!fetching && (!uris || uris.length === 0) && ( + + + {__('It looks like you have not published anything to LBRY yet.')} + +